Skip to content

Commit

Permalink
Wait for image load
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaoticNeutralCzech committed Jan 22, 2024
1 parent c8c78d6 commit 40e0263
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion embed.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<link rel="stylesheet" href="embed.css"/>
</head>
<body>
<img src="duha.png" id="duha">
<img src="duha.png" id="duha" onload = "startTV()">
<canvas id="tv" width="480" height="270"></canvas>
<script src="embed.js"></script>
</body>
Expand Down
7 changes: 4 additions & 3 deletions embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ const duha = document.getElementById("duha")
duha.style = "display: none";


function startTV(s) //s = scale
function startTV()
{
let s = scale;
if(s==0)
{
tv.width = 1;
Expand Down Expand Up @@ -36,7 +37,7 @@ function startTV(s) //s = scale

function updateTime()
{
s = scale;
let s = scale;
ctx.fillStyle = "#000";
if(s < 1) {ctx.fillStyle = "#00000080"}; //afterglow half-life 40 ms, simulates compression artifacts
ctx.fillRect(s*183, s*126, s*110, s*18);
Expand Down Expand Up @@ -74,5 +75,5 @@ function stopUpdatingTime()
clearInterval(updater);
}

startTV(scale);
startTV();
startUpdatingTime();

0 comments on commit 40e0263

Please sign in to comment.