Skip to content

Instantly share code, notes, and snippets.

@cormullion
Created October 5, 2020 17:16
Show Gist options
  • Save cormullion/015e4721a8c8fe6dbe1342e9980c9a1c to your computer and use it in GitHub Desktop.
Save cormullion/015e4721a8c8fe6dbe1342e9980c9a1c to your computer and use it in GitHub Desktop.
rr-logo
using Luxor, Colors
function main(nrows, ncols, startpattern;
firstcolor = "rebeccapurple",
secondcolor = "darkorange",
backgroundcolor = "black",
backgrounddotcolor = "grey15",
highlightcolor = "white")
lw = (500/ncols) - 20
r_pattern = [
[startpattern, startpattern + ncols, startpattern + 2ncols], # downstroke
startpattern + 1, # single dot
[startpattern + 2, startpattern + 2 + ncols, startpattern + 2 + 2ncols], # downstroke
startpattern + 3 # single dot
]
Drawing(500, 500, "/tmp/rr-dotpattern-$(backgroundcolor)-$(backgrounddotcolor).svg")
origin()
squircle(O, 245, 245, :clip, rt=0.13)
background(parse(Colorant, backgroundcolor))
setlinecap("round")
setline(lw)
t = Tiler(500, 500, nrows, ncols, margin=10)
cellpositions = first.(t)
@layer begin
for cell in cellpositions
#setopacity(rescale(distance(cell, O), 0, 250, 1, 0.3))
sethue(backgrounddotcolor)
circle(cell, lw/2 , :fill)
end
end
# the r pattern
for (n, e) in enumerate(r_pattern)
if isa(e, Array) # r downstroke
n <= 2 ? sethue(firstcolor) : sethue(secondcolor)
@layer begin
setline(lw+2)
sethue(highlightcolor)
line(cellpositions[first(e)], cellpositions[last(e)], :stroke)
end
line(cellpositions[first(e)], cellpositions[last(e)], :stroke)
else
@layer begin
setline(1)
circle(cellpositions[e], lw/2, :fill)
sethue(highlightcolor)
circle(cellpositions[e], lw/2, :stroke)
end
end
end
clipreset()
finish()
preview()
end
main(5, 6, 8, firstcolor=HSB(32, 0.99, 0.85), secondcolor=HSB(280, 0.9, 0.950), highlightcolor="grey20", backgroundcolor=HSB(18, 0, 1), backgrounddotcolor="white")
main(5, 6, 8, firstcolor=HSB(32, 0.99, 0.85), secondcolor=HSB(280, 0.9, 0.950), highlightcolor="grey25", backgroundcolor=HSB(18, 0, 1), backgrounddotcolor="grey20")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment