“Draw an arrow” utility

Post Reply
Henko
Posts: 849
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

“Draw an arrow” utility

Post by Henko »

IMG_1456.jpeg
IMG_1456.jpeg (130.59 KiB) Viewed 9 times

Code: Select all

graphics ! graphics clear .8,.8,.8 ! draw color 0,0,0
get screen size sw,sh ! xc=sw/2 ! yc=sh/2
option angle degrees
draw size 2 ! R=300 ! da=15
for alfa=0 to 360-da step da
  R=50+.6*alfa
  xo=xc+8*cos(alfa) ! yo=yc-8*sin(alfa)
  xe=xc+R*cos(alfa) ! ye=yc-R*sin(alfa)
  draw_arrow(xo,yo,xe,ye)
  next alfa
end

'*** draw an arrow from xo,yo to xe,ye ***
' current draw color and draw size are used
'
def draw_arrow(xo,yo,xe,ye)
dim x(6),y(6)
dx=xe-xo ! dy=ye-yo ! L=sqrt(dx^2+dy^2)
a=min(30,0.15*L) ! b=0.2*a ! sina=dy/L ! cosa=dx/L
x(1)=0 ! x(2)=L ! x(3)=L-a ! x(4)=L-a ! x(5)=L-a
y(1)=0 ! y(2)=0 ! y(3)=-b ! y(4)=0 ! y(5)=b
for i=1 to 5
  xx=x(i) ! yy=y(i)
  x(i)=xo+cosa*xx-sina*yy
  y(i)=yo+(sina*xx+cosa*yy)
  next i
draw line x(1),y(1) to x(4),y(4)
draw tri x(2),y(2),x(3),y(3),x(5),y(5)
end def

Post Reply