Penrose tiling: Difference between revisions

Added Fōrmulæ entry
m (→‎{{header|Wren}}: Changed to Wren S/H)
(Added Fōrmulæ entry)
 
(3 intermediate revisions by one other user not shown)
Line 158:
{{out}}
[[Media:Penrose tiling cpp.svg]]
 
=={{header|EasyLang}}==
[https://easylang.online/show/#cod=jVTLbqQwELz7K0oWymFbRpnMbm4c/RXIBwOexIoDCJMM8/er5jXOzKy0EkKmqlztbgr6oasR4iW6qUdw3y4gh51895lh+AouZqVBLgCcugEBY7eoGAFg2wwFpFwfWVNn8C3iONTvdoir18qvEo8CB8TR9XhZHNu92FUJwJ823BsUqLMfLMDFil0CwsHcKqrB2Q8cfsC5eLTkXp6SIhsVz7bfRmLbmc1FLuJo64+Sj1XCiH6bYzPY86aecIFt3xDaN+SLX/CtO/tmfMdzfmTgs/t2LBT/MT5/WhqWWl6PPYEK1F1E4wf84lpX7sJc9O0jjk+yFQbgwu6uEnfeqAru4l5HNzr6h65MdNvUngpMD9HLQ7Txw72vSXwDijlG6550PMUKBii8mHQ4KZMmh5vZuQRPCkAdr3j6DrfgcETWGPAIKkN0f5Ni/8Y4RtJKyFoTNVoppSpdqnpeWW2IJGQlIYmhRpczzCLDTC0hldVElS6JaDExSkI2zCgGiKwuqZlXlTa8V3KWICWM2H4Cr7efv7iN9Z9nvo6v+C3EXw== Run it]
 
<syntaxhighlight>
proc lsysexp level . axiom$ rules$[] .
for l to level
an$ = ""
for c$ in strchars axiom$
for i = 1 step 2 to len rules$[]
if rules$[i] = c$
c$ = rules$[i + 1]
break 1
.
.
an$ &= c$
.
swap axiom$ an$
.
.
stack[] = [ ]
proc lsysdraw axiom$ x y ang lng . .
linewidth 0.3
move x y
for c$ in strchars axiom$
if c$ = "E"
x += cos dir * lng
y += sin dir * lng
line x y
elif c$ = "-"
dir -= ang
elif c$ = "+"
dir += ang
elif c$ = "["
stack[] &= x
stack[] &= y
stack[] &= dir
elif c$ = "]"
l = len stack[]
x = stack[l - 2]
y = stack[l - 1]
dir = stack[l]
len stack[] -3
move x y
.
.
.
axiom$ = "[b]++[b]++[b]++[b]++[b]"
rules$[] = [ "a" "cE++dE----bE[-cE----aE]++" "b" "+cE--dE[---aE--bE]+" "c" "-aE++bE[+++cE++dE]-" "d" "--cE++++aE[+dE++++bE]--bE" "E" "" ]
lsysexp 6 axiom$ rules$[]
lsysdraw axiom$ 50 50 36 4
</syntaxhighlight>
 
=={{header|FreeBASIC}}==
Line 200 ⟶ 252:
penrose(6)
Close #1</syntaxhighlight>
 
=={{header|Fōrmulæ}}==
 
{{FormulaeEntry|page=https://formulae.org/?script=examples/L-system}}
 
'''Solution'''
 
It can be done using an [[wp:L-system|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 Penrose tiling is:
 
[[File:Fōrmulæ - L-system - Penrose tiling 01.png]]
 
[[File:Fōrmulæ - L-system - Penrose tiling 02.png]]
 
=={{header|Go}}==
2,120

edits