If someone has the answer could you help me, please?
I have 2 images – background similar to arc and arrow. And i need to move arrow image over background image like this is a clock ticker arrow. So i need :
- Rotate arrow to make it parallel to current tick on the arc
- Move arrow to the next point
For this i need to use Canvas object in JavaScript and its method transform – this will allow to move arrow and rotate it.
The question is : how to use canvas.transform method to rotate (and desirable move) arrow around the arc? And which values and what relation between them should be in this case :
contextData.clearRect (0, 0, contextData.canvas.width, contextData.canvas.height);
contextData.save ();
contextData.translate(indicatorData.width () / 2, indicatorData.height () / 2);
contextData.transform(1, 0, 0, 1, x, y); // the question is HERE
contextData.drawImage(rotationArrow, -rotationArrow.width / 2, -rotationArrow.height / 2);
contextData.restore ();
Thanks in advance.
Almost forgot … i found the answer, it works and this is the final code. To make it worked in IE you should add excanvas library from Google and to fix some IE8 issues you need to add compatibility meta tag :