Skip to content

Instantly share code, notes, and snippets.

@amejiarosario
Last active December 16, 2015 03:49
Show Gist options
  • Save amejiarosario/5372819 to your computer and use it in GitHub Desktop.
Save amejiarosario/5372819 to your computer and use it in GitHub Desktop.
// single arrow at the end
Raphael.fn.arrow = function(x1, y1, x2, y2, size) {
var angle = Raphael.angle(x1, y1, x2, y2);
var a45 = Raphael.rad(angle-45);
var a45m = Raphael.rad(angle+45);
var x2a = x2 + Math.cos(a45) * size;
var y2a = y2 + Math.sin(a45) * size;
var x2b = x2 + Math.cos(a45m) * size;
var y2b = y2 + Math.sin(a45m) * size;
return this.path(
"M"+x1+" "+y1+"L"+x2+" "+y2+
"M"+x2+" "+y2+"L"+x2a+" "+y2a+
"M"+x2+" "+y2+"L"+x2b+" "+y2b
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment