Draw an arrow
| Project: | Draw! jQuery drawing plugin. |
| Version: | 1.2.0 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | samiraek |
| Status: | closed |
Jump to:
$.fn.drawArrow = function(x, y, l, angle, opts)
{
var elm = AssignOpts($(this), opts);
var x1 = x+Math.floor(l*Math.cos(angle));
var y1 = y-Math.floor(l*Math.sin(angle));
elm.drawLine(elm, x, y, x1, y1);
var x2 = x1+Math.floor(l/2*Math.cos(angle-5*Math.PI/6));
var y2 = y1-Math.floor(l/2*Math.sin(angle-5*Math.PI/6));
elm.drawLine(elm, x2, y2, x1, y1);
var x3 = x1+Math.floor(l/2*Math.cos(angle+5*Math.PI/6));
var y3 = y1-Math.floor(l/2*Math.sin(angle+5*Math.PI/6));
elm.drawLine(elm, x3, y3, x1, y1);
return $(this);
}
example:
$("#myCanvas").drawArrow(500, 500, 30, (Math.PI/4), {color:'red', stroke: 3});
start point:(x,y)
length of arrow:l
angle:angle from x-axis

Comments
#1
Hi samiraek,
Thanks for the code! It's been added to version 1.3.0
- Aaron
#2
Automatically closed -- issue fixed for two weeks with no activity.