Saturday, 15 January 2011

javascript - How to convert HTML object's coordinates (top left) to canvas and back -



javascript - How to convert HTML object's coordinates (top left) to canvas and back -

i have image object drawn in canvas element. have div object in html (not in canvas). aim move both objects in canvas , in html together. in case of div object in html, can utilize jquery animate function move using top , left css parameters.

by using step function in animate: illustration that:

animate({width:100}, { duration:1000, step: function(){}, complete: function(){} });

i can figure out each position of moving div element in html. have convert top , left position coords. canvas coordinates , move canvas object too.

moreover have know move div element. should go above object in canvas.

so need create function converts top , left css coordinates canvas , backwards, canvas coordinates top left coordinates in html.

the question how , may there way it, different i'm trying do?

javascript jquery html css canvas

No comments:

Post a Comment