简体   繁体   中英

Move object from one canvas to another

i Have Canvas A and Canvas B and want to move star object from Canvas A and place it on Canvas B. Is it possible? if yes how can i do it ? for more understanding look picture below 在此处输入图片说明

This is not a straightforward feature of canvas. You can use some of existing libraries to achieve this or can refer them to write your own code.

The idea includes:

  1. register mouse events (up, down, move) on canvas objects
  2. maintain mouse drag state (dragging or mousemove)
  3. save the object state in variable (copy)
  4. repaint the canvas while dragging to give it a proper dragging like look & feel
  5. on drop (mouseup) render the object (copied previously) on target 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