CONST PI = 3.141592653#
SCREEN 12
' 30 случайных разнонаправленных стрелок
FOR i = 1 TO 30
acol = INT(RND(1) * 7) + 7
lcol = INT(RND(1) * 7) + 7
x1 = INT(RND(1) * 640)
x2 = INT(RND(1) * 640)
y1 = INT(RND(1) * 480)
y2 = INT(RND(1) * 480)
CALL DrawArrow(x1, y1, x2, y2, acol, lcol)
NEXT
A$ = INPUT$(1): CLS
SCREEN 0: END
'/////////////////////////////////////////////////////////////////////
' Процедура рисования стрелки
'/////////////////////////////////////////////////////////////////////
SUB DrawArrow (x1, y1, x2, y2, acol, lcol)
' Треугольник - стрелка
dx = x2 - x1
dy = y2 - y1
IF dx = 0 THEN A = 90 ELSE A = ATN(dy / dx) * 180 / PI
IF dx < 0 OR (dx = 0 AND dy < 0) THEN A = 180 + A
r1 = 4: w = 120: e = 0
tx1 = (r1 * COS(PI / 180 * (A - e)))
ty1 = (r1 * SIN(PI / 180 * (A - e)))
tx2 = (r1 * COS(PI / 180 * (A + w - e)))
ty2 = (r1 * SIN(PI / 180 * (A + w - e)))
tx3 = (r1 * COS(PI / 180 * (A - w - e)))
ty3 = (r1 * SIN(PI / 180 * (A - w - e)))
LINE (x2 + tx1, y2 + ty1)-(x2 + tx2, y2 + ty2), acol
LINE (x2 + tx2, y2 + ty2)-(x2 + tx3, y2 + ty3), acol
LINE (x2 + tx3, y2 + ty3)-(x2 + tx1, y2 + ty1), acol
PSET (x2 + tx1, y2 + ty1), acol
LINE (x1, y1)-(x2, y2), lcol
END SUB
Справочник алгоритмов v0.05 © 2007-2025 Igor Salnikov aka SunDoctor