Skip to content

Instantly share code, notes, and snippets.

@cormullion
Last active February 27, 2022 16:58
Show Gist options
  • Save cormullion/8909c0204e38cbe044a7bd7c06e52c08 to your computer and use it in GitHub Desktop.
Save cormullion/8909c0204e38cbe044a7bd7c06e52c08 to your computer and use it in GitHub Desktop.
new-makie.jl
using Luxor, Colors, Thebes
# requires Luxor >= 2.15.0
function make_conical_mesh(;
origin = O,
radius = 250,
startangle = 0,
endangle = 2π,
startoutsidecolor = colorant"red",
endoutsidecolor = colorant"green",
startinsidecolor = colorant"blue",
endinsidecolor = colorant"orange",
steps = 50)
outsidecolors = range(startoutsidecolor, endoutsidecolor, length=steps)
insidecolors = range(startinsidecolor, endinsidecolor, length=steps)
if startangle > endangle
endangle += 2π
end
sectorangle=abs(endangle-startangle)/steps
tri = Point[origin, origin + polar(radius, startangle), origin + polar(radius, startangle)]
mesh1 = mesh([Point(0, 0), polar(radius, startangle), polar(radius, startangle)], [startoutsidecolor])
for (n, θ) in enumerate(range(startangle, step=sectorangle, length=steps))
tri = Point[origin, origin + polar(radius, θ), origin + polar(radius, θ + sectorangle)]
add_mesh_patch(mesh1, tri, [
insidecolors[n],
outsidecolors[n],
outsidecolors[n]
])
end
return mesh1
end
# make petal shape and project to XY plane
function make_petal()
eyepoint(500, 500, 500)
D = 260
d = 144
# make a 3D path from box with rounded corners
newpath()
box(O, D, D, [85, 0, 85, 0], :path)
path = first(pathtopoly())
s = convert.(Point3D, path)
moveby!(s, Point3D(d, d, 0))
# convert back to 2D
return project.(s)
end
# petal is in XY plane, copy to XZ and YZ
function draw_petal(pgon, n)
@layer begin
rotate((n - 1) * 2π/3)
poly(pgon, :fill)
end
end
function draw_logo(pos)
# petal
@layer begin
translate(pos)
# clipping mask is 2D, and creates the holes
ngon(O, 250, 6, π/6, :path)
circlepath(O + (0, -95), 30, :path)
circlepath(O + (80, 46), 40, :path)
circlepath(O + (-90, 45), 50, :path)
clip()
radius = 260
steps = 50
# bottom blue to greenyblue
mesh1 = make_conical_mesh(origin = O,
radius = radius,
steps=steps,
startangle = π/6,
endangle = π - π/6,
startoutsidecolor = HSB(215, 0.8, 0.7),
endoutsidecolor = HSB(180, 0.99, 0.8),
startinsidecolor = HSB(220, 0.4, 0.7),
endinsidecolor = HSB(180, 0.6, 0.7))
# top left yellow to orangey
mesh2 = make_conical_mesh(origin = O,
radius = radius,
steps=steps,
startangle = π - π/6,
endangle = 3π/2,
startoutsidecolor = HSB(60, 1, 1.0),
endoutsidecolor = HSB(20, 1, 0.9),
startinsidecolor = HSB(90, 0.8, 0.85),
endinsidecolor = HSB(60, 0.8, 0.85))
# top right red to purpley
mesh3 = make_conical_mesh(origin = O,
radius = radius,
steps=steps,
startangle = 3π/2,
endangle = π/6,
startoutsidecolor = HSB(380, 0.99, 0.9),
endoutsidecolor = HSB(341, 0.99, 0.8),
startinsidecolor = HSB(320, 0.7, 0.7),
endinsidecolor = HSB(300, 0.9, 0.7))
pgon = make_petal()
for i in 1:3
setmesh([mesh1, mesh2, mesh3][i])
draw_petal(pgon, i)
end
end
end
function logo()
@drawsvg begin
squircle(O, 260, 260, rt = 0.2, :clip)
background("black")
draw_logo(O)
end 550 550
end
function logo_wordmark()
@drawsvg begin
panes = Table([500], [200, 1000])
# transparent or
# background("white")
draw_logo(panes[1])
# text
@layer begin
translate(panes[2])
fsize = 360
fontsize(fsize)
fontface("Barlow-Medium")
sethue("grey0")
texttrack("Makie", Point(-350, 100), -50, fsize, halign=:left)
fillpath()
end
end 1500 500
end
logo()
logo_wordmark()
@cormullion
Copy link
Author

new-makie-logo

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