Skip to content

Instantly share code, notes, and snippets.

@cormullion
Last active April 5, 2020 18:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save cormullion/b212622d4e92d26596ea800ce7753272 to your computer and use it in GitHub Desktop.
Save cormullion/b212622d4e92d26596ea800ce7753272 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")
@cormullion
Copy link
Author

juliaclimate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment