简体   繁体   中英

Grabbing one or more shapes from a canvas

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.

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)
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM