Reputation: 121
I have a canvas with some shapes in it (ovals, triangles, squares) , my question is of I can get a reference to one of the objects and animate it when an event happens.
Thank you for your time. I hope it's not a stupid question.
Upvotes: 0
Views: 61
Reputation: 68393
Canvas doesn't store the handle of all the objects you paint on it, so in essence you will have to paint the entire canvas again.
But there are libraries which can help you in doing that. Have you tried fabric.js and its examples on animation on shapes and images?
rect.animate('angle', 45, {
onChange: canvas.renderAll.bind(canvas)
});
Upvotes: 1