javascript - How to draw images on circles -


i've drawn 2 circles on canvas (one velocity , 1 controls) , i've been trying draw image on each of them, have no clue how this. i've uploaded images. know how? also, know why velocity x keys red circle aren't working? code: http://jsbin.com/vawitiziro/4/edit

here updated jsbin: http://jsbin.com/tibuxezaca/5/edit

1) use context.clip drawing images in custom path:

context.clip(); var w = imageobject.width || 0; var h = imageobject.height || 0; context.drawimage(imageobject, circle.x - (w / 2), circle.y - (h / 2)); 

2) update x velocity in update function

circle.x += circle.vx; 

Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -