Dragon curve: Difference between revisions

Content added Content deleted
(→‎{{header|BASIC}}: In the direct and indirect translations of BASIC256, removed the unnecessary variable ITER (in BASIC256 it serves for colors). In Commodore BASIC and its translations, replaced num MOD 8 (previously realized by nested IFs) by bitwise num AND 7.)
(→‎{{header|QuickBASIC}}: Added a solution.)
Line 975: Line 975:


Repeat: Until WaitWindowEvent(10) = #PB_Event_CloseWindow</syntaxhighlight>
Repeat: Until WaitWindowEvent(10) = #PB_Event_CloseWindow</syntaxhighlight>

==={{header|QuickBASIC}}===
{{trans|GW-BASIC}}
<syntaxhighlight lang="basic">
REM Dragon curve
REM SIN, COS in arrays for PI/4 multipl.
DECLARE SUB Dragon ()
DIM SHARED S(7), C(7), X, Y, RotQPi%, Level%, Insize, RQ%, SQ
QPi = ATN(1)
SQ = SQR(2)
FOR I = 0 TO 7
S(I) = SIN(I * QPi)
C(I) = COS(I * QPi)
NEXT I
Level% = 15
Insize = 128: REM 2^WHOLE_NUM (looks better)
X = 112: Y = 70
RotQPi% = 0: RQ% = 1
DIM SHARED R%(Level%)
SCREEN 2: CLS
CALL Dragon
END

SUB Dragon
RotQPi% = RotQPi% AND 7
IF Level% <= 1 THEN
YN = S(RotQPi%) * Insize + Y
XN = C(RotQPi%) * Insize + X
LINE (2 * X, Y)-(2 * XN, YN): REM For SCREEN 2 doubled x-coords
X = XN: Y = YN
ELSE
Insize = Insize * SQ / 2
RotQPi% = (RotQPi% + RQ%) AND 7
Level% = Level% - 1
R%(Level%) = RQ%: RQ% = 1
CALL Dragon
RotQPi% = (RotQPi% - R%(Level%) * 2) AND 7
RQ% = -1
CALL Dragon
RQ% = R%(Level%)
RotQPi% = (RotQPi% + RQ%) AND 7
Level% = Level% + 1
Insize = Insize * SQ
END IF
END SUB
</syntaxhighlight>


==={{header|RapidQ}}===
==={{header|RapidQ}}===