Page 1 of 1
Turtle Graphics for Toddy Forth-79
Posted: Mon Nov 28, 2022 12:16 am
by kmurta
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
Fractal Fern
Posted: Sat Dec 03, 2022 1:22 am
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 64 times
Usage examples:
Code: Select all
16000 2 FERN (takes about 4 minutes to complete)
- fern16K_2.png (6.59 KiB) Viewed 2141 times
Code: Select all
PU -5600 -8200 SETXY PD (takes about 12 minutes to complete)
30000 2 FERN
- fern30K_2.png (10.2 KiB) Viewed 2141 times
Lévy's C Curve
Posted: Mon Dec 05, 2022 8:05 pm
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
Sierpinski Tree Fractal
Posted: Fri Dec 09, 2022 8:25 pm
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
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