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
Post a Comment