Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulhendricks/058874bc03f1508eb98d9dac8e0e2ae0 to your computer and use it in GitHub Desktop.
Save paulhendricks/058874bc03f1508eb98d9dac8e0e2ae0 to your computer and use it in GitHub Desktop.
Julia flower
#!/usr/bin/env julia
using Luxor
Drawing(500, 500, "/tmp/julia-flowers.png")
background("white")
function juliaflowers(cpos::Point, radius; petals=30, outercircleratio=0.75, innercircleratio=0.65)
# clockwise, from bottom LEFT...
points3 = ngon(cpos, radius, 3, pi/6, vertices=true)
gsave()
theta = 0
for (n, centerp) in enumerate(points3) # each circle
for i in 1:petals # each flower
theta = mod2pi(theta + deg2rad(137.5))
gsave()
setopacity(0.95)
translate(centerp)
rotate(theta)
translate(radius * (outercircleratio + 0.15), 0) # dist from centerp
sethue(darker_blue...)
squircle(O, 30, 10,:stroke, rt=0.9)
sethue("yellow")
squircle(O, 30, 10, :fill, rt=0.9)
grestore()
end
# julia circles
sethue(color_sequence[n][1]...)
circle(centerp, outercircleratio * radius, :fill)
sethue(color_sequence[n][2]...)
circle(centerp, innercircleratio * radius, :fill)
end
grestore()
end
const darker_blue = (0.251, 0.388, 0.847)
const darker_purple = (0.584, 0.345, 0.698)
const lighter_purple = (0.667, 0.475, 0.757)
const darker_green = (0.22, 0.596, 0.149)
const lighter_green = (0.376, 0.678, 0.318)
const darker_red = (0.796, 0.235, 0.2)
const lighter_red = (0.835, 0.388, 0.361)
const purples = (darker_purple, lighter_purple)
const greens = (darker_green, lighter_green)
const reds = (darker_red, lighter_red)
const color_sequence = [reds, greens, purples]
origin()
translate(0, 30)
setline(5)
juliaflowers(O, 150, petals = 27, outercircleratio=0.4, innercircleratio=0.3)
finish()
preview()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment