Jump to content

Sierpinski pentagon: Difference between revisions

(Added FreeBasic)
Line 515:
}
}</syntaxhighlight>
 
=={{header|EasyLang}}==
{{Trans|Processing}}
[https://easylang.dev/ide/#run=order%20%3D%205%0A%23%20%0Abackground%20005%0Aclear%0Acolor%20999%0Alinewidth%200.2%0Ascale%20%3D%201%20%2F%20(2%20%2B%20cos%2072%20*%202)%0A%23%20%0Aproc%20pentagon%20x%20y%20side%20depth%20.%20.%0A%20%20%20if%20depth%20%3D%200%0A%20%20%20%20%20%20move%20x%20y%0A%20%20%20%20%20%20for%20angle%20%3D%200%20step%2072%20to%20288%0A%20%20%20%20%20%20%20%20%20x%20%2B%3D%20cos%20angle%20*%20side%0A%20%20%20%20%20%20%20%20%20y%20%2B%3D%20sin%20angle%20*%20side%0A%20%20%20%20%20%20%20%20%20line%20x%20y%0A%20%20%20%20%20%20.%0A%20%20%20else%0A%20%20%20%20%20%20side%20*%3D%20scale%0A%20%20%20%20%20%20dist%20%3D%20side%20%2B%20side%20*%20cos%2072%20*%202%0A%20%20%20%20%20%20for%20angle%20%3D%200%20step%2072%20to%20288%0A%20%20%20%20%20%20%20%20%20x%20%2B%3D%20cos%20angle%20*%20dist%0A%20%20%20%20%20%20%20%20%20y%20%2B%3D%20sin%20angle%20*%20dist%0A%20%20%20%20%20%20%20%20%20call%20pentagon%20x%20y%20side%20depth%20-%201%0A%20%20%20%20%20%20.%0A%20%20%20.%0A.%0Acall%20pentagon%2025%2015%2050%20order%20-%201%0A Run it]
<syntaxhighlight lang="easylang">
order = 5
#
background 005
clear
color 999
linewidth 0.2
scale = 1 / (2 + cos 72 * 2)
#
proc pentagon x y side depth . .
if depth = 0
move x y
for angle = 0 step 72 to 288
x += cos angle * side
y += sin angle * side
line x y
.
else
side *= scale
dist = side + side * cos 72 * 2
for angle = 0 step 72 to 288
x += cos angle * dist
y += sin angle * dist
call pentagon x y side depth - 1
.
.
.
call pentagon 25 15 50 order - 1
</syntaxhighlight>
 
 
=={{header|FreeBASIC}}==
2,060

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.