Skip to content

Instantly share code, notes, and snippets.

@gaelforget
Forked from cormullion/julia-climate.jl
Last active February 27, 2020 16:21
Show Gist options
  • Save gaelforget/4744a63b86f74362a71a89d27de44c90 to your computer and use it in GitHub Desktop.
Save gaelforget/4744a63b86f74362a71a89d27de44c90 to your computer and use it in GitHub Desktop.
using Luxor, Colors
function main(fname)
Drawing(600, 600, fname)
origin()
circle(O, 290, :clip)
sethue("white")
paint()
colors = [Luxor.julia_purple, Luxor.julia_blue, Luxor.julia_green, Luxor.julia_red]
# make a table with rows smaller in the middle
progression = [70, 55, 47, 40, 30, 20, 14]
fatrows = vcat(progression, reverse(progression))
# every other row is blank
thinrows = fill(12, 2 * length(progression))
table = Table(collect(Iterators.flatten(zip(fatrows, thinrows))), [500])
L = length(table)
wavelength = 70
for (pos, n) in table
table.rowheights[n] < minimum(progression) && continue # skip thin rows
# march through the four Julia colors
col = convert(Int, min(1 + floor((n - 1) / L * 4), 4))
sethue(colors[col])
@layer begin
translate(pos)
# amplitude of sine scales by y coordinate
sf = rescale(abs(pos.y), 0, 300, 5, 32)
pts = [Point(x, sf * sin(x * 1 / wavelength)) for x = -300:300]
setline(table.rowheights[n])
poly(pts, :stroke)
end
end
# outer ring
#@layer begin
# setcolor("#635")
# setline(30)
# circle(O, 291, :stroke)
#end
finish()
preview()
end
main("/tmp/juliaclimate-gf1.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment