Chaos game: Difference between revisions
Content added Content deleted
(→{{header|Java}}: cleanup) |
m (update for Julia 1+ restrictions on global scope variables) |
||
Line 1,289: | Line 1,289: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
{{works with|Julia|0.6}} |
|||
Run in REPL. |
Run in REPL. |
||
<lang julia> |
<lang julia>using Luxor |
||
using Luxor |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
function chaos() |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
for l in 1:30_000 |
for l in 1:30_000 |
||
v = rand(1:3) |
v = rand(1:3) |
||
if v == 1 |
if v == 1 |
||
x /= 2 |
x /= 2 |
||
y /= 2 |
y /= 2 |
||
elseif v == 2 |
elseif v == 2 |
||
x = width/2 + (width/2 - x)/2 |
x = width/2 + (width/2 - x)/2 |
||
y = height - (height - y)/2 |
y = height - (height - y)/2 |
||
else |
else |
||
x = width - (width - x)/2 |
x = width - (width - x)/2 |
||
y = y / 2 |
y = y / 2 |
||
end |
|||
⚫ | |||
⚫ | |||
end |
end |
||
⚫ | |||
⚫ | |||
end |
end |
||
chaos() |
|||
finish() |
|||
preview() |
preview() |
||
</lang> |
</lang> |