Rich Wareham's Julia set code
# Copyright (c) 2017: Rich Wareham, Simon Byrne | |
# Available under the MIT "Expat" license. | |
using Colors | |
using SenseHat | |
const LED = led_matrix() | |
function julia(z, c) | |
maxit = 50 | |
cols = [RGB(HSV(360*h, 1, sqrt(h))) for h in linspace(0, 1, maxit)] | |
for it in 1:maxit | |
z = z^2 + c | |
if abs(z) > 2 | |
return cols[it] | |
end | |
end | |
cols[end] | |
end | |
function julia_render(n) | |
for a in linspace(0, n*2*pi, 200*n) | |
r = sin(0.5 + a/2) | |
cx = sin(a) * r | |
cy = cos(a/3) * r | |
LED[:] = [julia(zx + im*zy, cx+im*cy) for zx in linspace(-1, 1, 8), zy in linspace(-1, 1, 8)] | |
end | |
end | |
julia_render(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment