Skip to content

Instantly share code, notes, and snippets.

@briochemc
Forked from cormullion/julia-climate.jl
Created February 20, 2020 15:51
Show Gist options
  • Save briochemc/60561a74f4fde32dd5d45fbf8a2324cd to your computer and use it in GitHub Desktop.
Save briochemc/60561a74f4fde32dd5d45fbf8a2324cd 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_blue, Luxor.julia_red, Luxor.julia_green, Luxor.julia_purple]
# 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.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment