Plugins

User login
Can't find a Plugin?

Can't find a Plugin you are looking for? Check out the jQuery Wiki page.

Are you a plugin developer? Please move your plugin over to this site.

Website Bug or Feature Request?

Found a bug on the new jQuery Plugin website? Have a feature request?

Submit it to the jQuery Plugin website issue queue to ensure it is noticed!

Draw an arrow


Project:Draw! jQuery drawing plugin.
Version:1.2.0
Component:Code
Category:feature request
Priority:normal
Assigned:samiraek
Status:closed
Description

$.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

Status:active» fixed

Hi samiraek,
Thanks for the code! It's been added to version 1.3.0

- Aaron

#2

Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.