Turtle Graphics for Toddy Forth-79

Discussion about ZX80 / ZX81 Software
Post Reply
User avatar
kmurta
Posts: 302
Joined: Tue Sep 01, 2009 5:04 am
Location: Belo Horizonte - BR
Contact:

Turtle Graphics for Toddy Forth-79

Post by kmurta »

TF79TG.PNG

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.

Turtle37.png
TURTLE.zip
(534.08 KiB) Downloaded 86 times

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/
User avatar
kmurta
Posts: 302
Joined: Tue Sep 01, 2009 5:04 am
Location: Belo Horizonte - BR
Contact:

Fractal Fern

Post by kmurta »

The Barnsley fern is a fractal named after the British mathematician Michael Barnsley who first described it in his book Fractals Everywhere.
from Wikipedia
Below is a procedure for drawing a variation of the Barnsley fern. Usage is:

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
FERN.zip
(331 Bytes) Downloaded 60 times


Usage examples:

Code: Select all

16000 2 FERN    (takes about 4 minutes to complete)
fern16K_2.png
fern16K_2.png (6.59 KiB) Viewed 1985 times

Code: Select all

PU -5600 -8200 SETXY PD     (takes about 12 minutes to complete)
30000 2 FERN 

fern30K_2.png
fern30K_2.png (10.2 KiB) Viewed 1985 times
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/
User avatar
kmurta
Posts: 302
Joined: Tue Sep 01, 2009 5:04 am
Location: Belo Horizonte - BR
Contact:

Lévy's C Curve

Post by kmurta »

A procedure for drawing the Levy c-curve:

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
C-CURVE.PNG
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/
User avatar
kmurta
Posts: 302
Joined: Tue Sep 01, 2009 5:04 am
Location: Belo Horizonte - BR
Contact:

Sierpinski Tree Fractal

Post by kmurta »

This is a very interesting fractal, where the variation of the angle between the branches generates very nice results.

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

sierpt.png

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/
Post Reply