Skip to content

Instantly share code, notes, and snippets.

@cormullion
Last active April 5, 2019 17:01
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 cormullion/7f5d5708cfc81add014f2ecb2ef263f8 to your computer and use it in GitHub Desktop.
Save cormullion/7f5d5708cfc81add014f2ecb2ef263f8 to your computer and use it in GitHub Desktop.
juliadebug icon
using Luxor, Colors
function scarab(pos, heading;
legposition=1,
colorant=colorant"blue",
scalefactor=0.5)
sethue(colorant)
@layer begin
translate(pos)
scale(scalefactor)
rotate(mod2pi(heading + π/2))
setlinejoin("round")
@layer begin
for i in 1:2
# right front leg
move(O + (0, legposition))
rline.((polar(80, -π/6),
polar(60, -π/2),
polar(12, -5π/6),
polar(60, -π/4)))
#middle leg
move(0, 35 + legposition)
rline.((
polar(100, -π/6),
polar(40, π/2)))
#back leg
move(0, 100 + legposition)
rline.((polar(120, -π/6),
polar(100, π/2)))
strokepath()
# other side
transform([-1 0 0 1 0 0])
end
# body
@layer begin
squircle(Point(0, -25), 26, 75, :fillpreserve)
fillpath()
squircle(Point(0, 0), 50, 70, :fillpreserve)
fillpath()
squircle(Point(0, 40), 65, 90, :fillpreserve)
fillpath()
end
end
# body
@layer begin
squircle(Point(0, -25), 30, 70, :fillpreserve)
fillpath()
squircle(Point(0, 0), 50, 70, :fillpreserve)
fillpath()
squircle(Point(0, 40), 65, 90, :fillpreserve)
fillpath()
sethue(colorant)
circle(Point(0, 0), 25, :fill)
end
end
end
function magnifyingglass(pos, rotation, outerradius, innerradius, handle)
@layer begin
translate(pos)
rotate(rotation)
setlinecap("round")
circlepath(O, outerradius, :path)
newsubpath()
circlepath(O, innerradius, reversepath=true, :fill)
setline(outerradius-innerradius)
handlestart = O + (outerradius, 0)
handleend = O + (outerradius + handle, 0)
line(handlestart, handleend, :stroke)
# thicker handle
setline((outerradius - innerradius) * 1.3)
f = (outerradius - innerradius) / handle
line(between(handlestart, handleend, f), between(handlestart, handleend, 1-f), :stroke)
end
end
function main(w, h, fname)
Drawing(w, h, fname)
setantialias(6)
origin()
glassouterradius = 170
@layer begin
translate(-40, -50)
sethue("white")
circle(O, glassouterradius, :fill)
setline(9)
scarab(O, -π/2, colorant="midnightblue", scalefactor=0.8)
translate(0, 30)
setline(6)
for (n, pos) in enumerate(ngon(O, 28, 3, π/6, vertices=true))
sethue("white")
circle(pos, 18, :stroke)
sethue([Luxor.darker_red, Luxor.darker_green, Luxor.darker_purple][n])
circle(pos, 18, :fill)
end
end
sethue("grey30")
# position, rotation, outerradius, innerradius, handlelength
magnifyingglass(O - (40, 50), π/4, glassouterradius, 135, 210)
finish()
preview()
end
main(500, 500, "/tmp/debug.png")
@cormullion
Copy link
Author

cormullion commented Apr 5, 2019

debug

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