+ 6
How do i insert an image and animate it using web? will it be possible?
6 Respostas
+ 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