This program written for rosettacode.org.
Use Courier New for Windows OS. Works in linux with Courier. (For the title, see Legend statement)
Use second monitor (if there is no second monitor then open to default).
Use second monitor (if there is no second monitor then open to default).
Update 2022: Esc key now blocked, you can use ctrl+C.
Module Checkit {
Escape off
def double angle, d45, d90, change=5000
const sr2 as double= .70710676237
Cls 0
Pen 14
Desktop Hide
\\ move console full screen to second monitor (1 or 2)
Window 12, 1
\\ reduce size (tv as second monitor cut pixels from edges)
Window 12, scale.x*.9, scale.y*.9;
\\ opacity 100%, but for 0 (black is 100%, and we can hit anything under console window)
Desktop 255, 0
\\ M2000 console can divide screen to characters/lines with automatic line space
Form 60, 30
\\ cut the border from window
Form
\\ scale.x and scale.y in twips
\\ all graphic/console commands works for printer also (except for Input)
Move scale.x/2,scale.y/10
\\ outline graphics, here outline text
\\ legend text$, font, size, angle, justify(2 for center), quality (non zero for antialiasing, works for angle 0), letter spacing.
Color {
Legend "DRAGON CURVE", "Courier New",SCALE.Y/200,0,2, 1, SCALE.X/50
}
angle=0
d45=pi/4
d90=pi/2
Move scale.x/3, scale.y*2/3
bck=point
\\ twipsx is width in twips of pixel. twipsy are height in twips of a pixel
\\ so we use length:twips.x*scale.x/40 or scale.x/40 pixels.
\\ use % for integer - we can omit these, and we get integer by automatic conversion (overflow raise error)
dragon(twipsx*scale.x/40,14%, 1)
a$=key$
Pen 14
Cls 5
\\ set opacity to 100%
Desktop 255
Desktop Hide
Escape On
End
\\ Subs are private to this module
\\ Subs have same scope as module
Sub turn(rand as double)
angle+=rand
End Sub
\\ angle is absolute, length is relative
Sub forward(length as double)
Draw Angle angle, length
End Sub
Sub dragon(length as double, split as integer, d as double)
If split=0 then {
forward(length)
} else {
Gosub turn(d*d45)
\\ we can omit Gosub
dragon(length*sr2,split-1,1)
turn(-d*d90)
dragon(length*sr2,split-1,-1)
turn(d*d45)
change--
If change else {
push 0: do {drop: push random(11,15) : over } until number<>pen: pen number
change=5000
}
}
End Sub
}
Checkit
Module Checkit {
Escape off
def double angle, d45, d90, change=5000
const sr2 as double= .70710676237
Cls 0
Pen 14
Desktop Hide
\\ move console full screen to second monitor (1 or 2)
Window 12, 1
\\ reduce size (tv as second monitor cut pixels from edges)
Window 12, scale.x*.9, scale.y*.9;
\\ opacity 100%, but for 0 (black is 100%, and we can hit anything under console window)
Desktop 255, 0
\\ M2000 console can divide screen to characters/lines with automatic line space
Form 60, 30
\\ cut the border from window
Form
\\ scale.x and scale.y in twips
\\ all graphic/console commands works for printer also (except for Input)
Move scale.x/2,scale.y/10
\\ outline graphics, here outline text
\\ legend text$, font, size, angle, justify(2 for center), quality (non zero for antialiasing, works for angle 0), letter spacing.
Color {
Legend "DRAGON CURVE", "Courier New",SCALE.Y/200,0,2, 1, SCALE.X/50
}
angle=0
d45=pi/4
d90=pi/2
Move scale.x/3, scale.y*2/3
bck=point
\\ twipsx is width in twips of pixel. twipsy are height in twips of a pixel
\\ so we use length:twips.x*scale.x/40 or scale.x/40 pixels.
\\ use % for integer - we can omit these, and we get integer by automatic conversion (overflow raise error)
dragon(twipsx*scale.x/40,14%, 1)
a$=key$
Pen 14
Cls 5
\\ set opacity to 100%
Desktop 255
Desktop Hide
Escape On
End
\\ Subs are private to this module
\\ Subs have same scope as module
Sub turn(rand as double)
angle+=rand
End Sub
\\ angle is absolute, length is relative
Sub forward(length as double)
Draw Angle angle, length
End Sub
Sub dragon(length as double, split as integer, d as double)
If split=0 then {
forward(length)
} else {
Gosub turn(d*d45)
\\ we can omit Gosub
dragon(length*sr2,split-1,1)
turn(-d*d90)
dragon(length*sr2,split-1,-1)
turn(d*d45)
change--
If change else {
push 0: do {drop: push random(11,15) : over } until number<>pen: pen number
change=5000
}
}
End Sub
}
Checkit
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου
You can feel free to write any suggestion, or idea on the subject.