Hilbert curve: Difference between revisions

→‎{{header|Fōrmulæ}}: Added L-system solution
(→‎{{header|Fōrmulæ}}: Added L-system solution)
(One intermediate revision by one other user not shown)
Line 1,402:
=={{header|Forth}}==
{{trans|Yabasic}}
{{works with|4tH |v3.62}}
<syntaxhighlight lang="forth">include lib/graphics.4th
 
64 constant /width \ hilbertHilbert curve order^2
9 constant /length \ length of a line
 
Line 1,434:
color_image 255 whiteout blue \ paint blue on white
0 dup origin! \ set point of origin
0 dup /width over dup hilbert \ hilbertHilbert curve, order=8
s" ghilbert.ppm" save_image \ save the image
</syntaxhighlight>
Line 1,468:
 
'''Solution'''
 
=== Recursive ===
 
The following defines a function that creates a graphics of the Hilbert curve of a given order and size:
Line 1,480 ⟶ 1,482:
 
[[File:Fōrmulæ - Hilbert curve 03.png|279px]]
 
=== L-system ===
 
There are generic functions written in Fōrmulæ to compute an L-system in the page [[L-system#Fōrmulæ | L-system]].
 
The program that creates a Hilbert curve is:
 
[[File:Fōrmulæ - L-system - Hilbert curve 01.png]]
 
[[File:Fōrmulæ - L-system - Hilbert curve 02.png]]
 
=={{header|Frink}}==
2,120

edits