Last active
December 16, 2015 03:49
-
-
Save amejiarosario/5372819 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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