We have two methods, one method draw an arrow at same length, and a direction (zero is right, pi/2 top, pi left, -pi/2 bottom) from the current pos.x and pos.y (graphic cursor), also we pass the size of the triangle at the head of the arrow.
The second method use the current pos.x and pos.y (graphic cursor) and need a displacement for X and Y twips (so we can give negative values also).
Using Smooth On we draw lines with antialiasing (GDI+, is slower than GDI32 when we draw using Smooth Off - if we using animation we don't use antialiasing)
We use SINGLE type values (4bytes float). @PI is the original decimal (29 digits) value, and we make PI as single, rounding the decimal value. Expression -3*PI/2+A is DOUBLE because 3 and 2 are literal for double )we have to place 2~ for a literal single of value 2)
SINGLE PI=@PI, A, I
SMOOTH ON
CLS 15
PEN 0
DOUBLE
REPORT 2, "ARROWS"
NORMAL
MOVE 6600,8000
FOR A=0 TO 2*PI STEP PI/7
STEP ANGLE A, 300
ARROW(4000, 300, A)
ARROW(4000, 300, 3*PI/2+A, 2)
ARROW(4000, 300, PI+A, 3)
ARROW(4000, 300, -3*PI/2+A, 4)
NEXT
FOR I=-6000 TO 5000 STEP 1000
MOVE 20000, 8000
ARROW2(-6000, I, 300, #FF00FF)
MOVE 20000, 8000
ARROW2(6000, -I, 300, #FFFF00)
MOVE 20000, 8000
ARROW2(I+1000, -6000, 300, #00FFFF)
MOVE 20000, 8000
ARROW2(I, 6000, 300, #FF7777)
NEXT
PUSH KEY$
DROP
SUB ARROW(LE AS SINGLE, AR AS SINGLE, ANG AS SINGLE, COL=1)
LOCAL AR1=AR*1.11803398~, P2=0.463647609~
WIDTH 3 {DRAW ANGLE ANG, LE, COL}
LOCAL X=POS.X, Y=POS.Y
STEP ANGLE ANG, -AR
PEN COL {POLYGON COL, ANGLE ANG+PI/2, AR/2, ANG+PI-P2, -AR1, ANG+PI+P2, AR1, 0,0}
DRAW ANGLE ANG+PI/2, AR, 15
MOVE X, Y
END SUB
SUB ARROW2(POSX AS SINGLE, POSY AS SINGLE, AR AS SINGLE, COL=1)
LOCAL AR1=AR*1.11803398~, P2=0.463647609~
IF POSY=0 THEN
IF POSX>0 THEN
LOCAL ANG=2*PI
ELSE
LOCAL ANG=PI
END IF
ELSE
ANG=ATN(POSX/POSY)/180*PI-SGN(POSY)*PI/2
END IF
WIDTH 3 {DRAW POSX, POSY, COL}
LOCAL X=POS.X, Y=POS.Y
STEP ANGLE ANG, -AR
PEN COL {POLYGON COL, ANGLE ANG+PI/2, AR/2, ANG+PI-P2, -AR1, ANG+PI+P2, AR1, 0,0}
DRAW ANGLE ANG+PI/2, AR, 15
MOVE X, Y
END SUB
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου
You can feel free to write any suggestion, or idea on the subject.