Created
December 6, 2020 14:23
-
-
Save 911992/d0a22d21bc1d49c2c6dede8323bf8c58 to your computer and use it in GitHub Desktop.
Javascript graphic load image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Kode</title> | |
</head> | |
<body> | |
<canvas id="c" width="200" height="200"> | |
</canvas> | |
<script> | |
var g2d = document.getElementById('c').getContext('2d'); | |
function img_draw(arg_img) { | |
g2d.fillStyle="#911992"; | |
g2d.fillRect(0,0,200,200); | |
g2d.drawImage(arg_img,2,2,196,196); | |
} | |
g2d.fillStyle="#911992"; | |
g2d.textBaseline = "top"; | |
g2d.font="bold 14pt arial"; | |
g2d.fillText("Low-ding...", 2,2); | |
var _img = new Image(); | |
_img.addEventListener("load",function(){ | |
img_draw(_img); | |
}); | |
setTimeout(function(){ | |
_img.src="https://i.kym-cdn.com/entries/icons/original/000/032/379/Screen_Shot_2020-01-09_at_2.22.56_PM.png"; | |
},2911); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment