+ 6
How do i insert an image and animate it using web? will it be possible?
6 Answers
+ 3
Do it like this:
drawImage(element, x, y);
The x is how many pixels from the left, and the y from the top.
You canât put the URL for element, as it actually needs to be an <img> element:
<img src = âSomeURLâ id = âimageâ/>
<canvas></canvas>
<script>
let ctx = document.getElementsByTagName(âcanvasâ)[0].getContext(â2dâ);
let image = document.getElementById(âimageâ);
ctx.drawImage(image, 50, 50);
</script>
Hope that helps!
+ 6
thanks
+ 5
Use sprites to form the sequential frames, enable them one after another..
https://code.sololearn.com/WFrv82FuZwg2/?ref=app
+ 1
yes its possible
+ 1
try this đ
https://www.sololearn.com/learn/CSS/2253/
+ 1
You can use the drawImage( ) method.
https://www.w3schools.com/tags/canvas_drawimage.asp
And yes, animation is also possible. Have a look at this: https://code.sololearn.com/WmP6CuzCPFta/?ref=app