I will rotate the arrow to any angle I need to add / modify so that it can be rotated at any angle. It currently has 180 degrees.
function drawArrowAtAngle (cx, cy, angle, context) {context.save (); Context.beginPath (); Context.lineWidth = 1; Context.strokeStyle = '#aaa'; Context.moveTo (CX + 25, CX-2); Context.lineTo (CX-55, CX-2); Context.lineTo (CX-58, CX); Context.lineTo (CX-55, cx + 2); Context.lineTo (CX + 25, cx + 2); Context.lineTo (CX + 25, CX-2); Context.stroke (); Context.closePath (); Context.restore ();
Assuming you get the center of rotation to
(cx, cx)
,context.save ();
Enter the following three lines after the statement.context.translate (cx, cx); Context.rotate (angle); Context.translate (-cx, -cx);
This will rotate the arrow to
angle (in radians). If you really mean
(cx, cy)
in your code to anchor an arrow, then(cx, cx)
Adjust the above snippet accordingly.
Comments
Post a Comment