Turtle Graphics for Toddy Forth-79
Turtle Graphics for Toddy Forth-79
In the 1980s, one of the things that most caught my attention in computer science journals were the articles about the Logo language. I managed to replicate some of those fascinating graphics on my TK82C, but on a 64x44 pixel screen and with Basic's slowness, the result left much to be desired.
But today, thanks to the ZXpand and the Toddy Forth-79, the fascinating world of the turtle is within reach of anyone who wants to experience it in the little Zeddy. But I'll warn you right away, it's a path of no return!
If you don't already have Toddy Forth-79 go here and download it, you will need it to run Turtle.
See Turtle Graphics in action:
https://youtu.be/9HHbTW5Z4oM
https://youtu.be/B9s5ymYmB0s
https://youtu.be/_cN6luvogM0
1 x ZX81, 2 x TK85 , 1 TK82C, 1 TK95, 1 x Alphacom 32 printer, 1 x ZXpand
ZeXtender board, Joy81 - Programmable Joystick Controller, Turbo Sound 81
http://zx81.eu5.org
https://toddysoftware.itch.io/
ZeXtender board, Joy81 - Programmable Joystick Controller, Turbo Sound 81
http://zx81.eu5.org
https://toddysoftware.itch.io/
Fractal Fern
Below is a procedure for drawing a variation of the Barnsley fern. Usage is:The Barnsley fern is a fractal named after the British mathematician Michael Barnsley who first described it in his book Fractals Everywhere.
from Wikipedia
size angle FERN
Where size is the lenght of leaf and angle is the value that will be added or subtracted when making the turtle rotate, drawing a more inclined leaf.
Code: Select all
\ FRACTAL FERN 1/1
DEFINE FERN ( size angle -- )
OVER 500 < IF 2DROP EXIT THEN
OVER 20 / FORWARD 80 LEFT
OVER 3 10 */ OVER RECURSE
DUP 82 + RIGHT
OVER 20 / FORWARD 80 RIGHT
OVER 3 10 */ OVER RECURSE
78 OVER - LEFT
OVER 9 10 */ OVER RECURSE
DUP 2 + LEFT OVER 20 / BACK
2 + LEFT 20 / BACK
END
Usage examples:
Code: Select all
16000 2 FERN (takes about 4 minutes to complete)
Code: Select all
PU -5600 -8200 SETXY PD (takes about 12 minutes to complete)
30000 2 FERN
1 x ZX81, 2 x TK85 , 1 TK82C, 1 TK95, 1 x Alphacom 32 printer, 1 x ZXpand
ZeXtender board, Joy81 - Programmable Joystick Controller, Turbo Sound 81
http://zx81.eu5.org
https://toddysoftware.itch.io/
ZeXtender board, Joy81 - Programmable Joystick Controller, Turbo Sound 81
http://zx81.eu5.org
https://toddysoftware.itch.io/
Lévy's C Curve
A procedure for drawing the Levy c-curve:
Set an appropriate segment length and then execute C-CURVE with the number of iterations on the stack.
Examples of use:
Code: Select all
VALUE SIZE
DEFINE C-CURVE ( n -- )
?DUP 0= IF SIZE FORWARD EXIT
THEN
45 LEFT DUP 1- RECURSE
90 RIGHT DUP 1- RECURSE
45 LEFT DROP
END
Set an appropriate segment length and then execute C-CURVE with the number of iterations on the stack.
Examples of use:
Code: Select all
400 TO SIZE 8 C-CURVE
200 TO SIZE
PU -6200 -4400 SETXY PD 90 RT
12 C-CURVE
1 x ZX81, 2 x TK85 , 1 TK82C, 1 TK95, 1 x Alphacom 32 printer, 1 x ZXpand
ZeXtender board, Joy81 - Programmable Joystick Controller, Turbo Sound 81
http://zx81.eu5.org
https://toddysoftware.itch.io/
ZeXtender board, Joy81 - Programmable Joystick Controller, Turbo Sound 81
http://zx81.eu5.org
https://toddysoftware.itch.io/
Sierpinski Tree Fractal
This is a very interesting fractal, where the variation of the angle between the branches generates very nice results.
The first figure was obtained with the sequence below, with an angle of 15 degrees between the branches. The others correspond to angles of 30, 45, 60, 75, 90, 105 and 120 degrees, respectively.
Code: Select all
VALUE ANGLE
DEFINE SIERPT ( size n -- )
?DUP 0= IF DROP EXIT THEN
ANGLE LEFT OVER FORWARD
OVER 2/ OVER 1- RECURSE
OVER BACK
ANGLE RIGHT OVER FORWARD
OVER 2/ OVER 1- RECURSE
OVER BACK
ANGLE RIGHT OVER FORWARD
OVER 2/ SWAP 1- RECURSE
BACK ANGLE LEFT
END
The first figure was obtained with the sequence below, with an angle of 15 degrees between the branches. The others correspond to angles of 30, 45, 60, 75, 90, 105 and 120 degrees, respectively.
Code: Select all
15 TO ANGLE
CL 3000 BK 6400 6 SIERPT
1 x ZX81, 2 x TK85 , 1 TK82C, 1 TK95, 1 x Alphacom 32 printer, 1 x ZXpand
ZeXtender board, Joy81 - Programmable Joystick Controller, Turbo Sound 81
http://zx81.eu5.org
https://toddysoftware.itch.io/
ZeXtender board, Joy81 - Programmable Joystick Controller, Turbo Sound 81
http://zx81.eu5.org
https://toddysoftware.itch.io/