Update
This commit is contained in:
parent
f36f132e42
commit
eb92a8ef2a
3 changed files with 50 additions and 7 deletions
15
www/js/p5_custom.js
Normal file
15
www/js/p5_custom.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
|
||||
draw_arrow=function(p,x1,y1,x2,y2){
|
||||
p.push()
|
||||
p.strokeWeight(5)
|
||||
p.line(x1,y1,x2,y2)
|
||||
offset=5
|
||||
var angle = p.atan2(y1 - y2, x1 - x2); //gets the angle of the line
|
||||
p.translate(x2, y2); //translates to the destination vertex
|
||||
p.rotate(angle-p.HALF_PI); //rotates the arrow point
|
||||
p.triangle(-offset*0.8, offset, offset*0.8, offset, 0, -offset/2); //draws the arrow point as a triangle
|
||||
p.pop();
|
||||
|
||||
// Return the center of the arrow
|
||||
return(p.createVector(x1+(x2-x1)/2,y1+(y2-y1)/2))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue