Skip to content

Instantly share code, notes, and snippets.

@cormullion
Created January 12, 2022 11:25
Show Gist options
  • Save cormullion/a5dd0e517555a2e5d30557b94b76eaa3 to your computer and use it in GitHub Desktop.
Save cormullion/a5dd0e517555a2e5d30557b94b76eaa3 to your computer and use it in GitHub Desktop.
using Luxor, ColorSchemes
@png begin
background("black")
setlinejoin("bevel")
setline(3)
verts = randompointarray(BoundingBox() * 1.2, 50)
triangles = polytriangulate(verts)
dict = Dict{Point, Vector{Int}}()
for (n, t) in enumerate(triangles)
for pt in t
if haskey(dict, pt)
push!(dict[pt], n)
else
dict[pt] = [n]
end
end
end
for v in verts
hull = Point[]
# vertex v belongs in triangle tri
tris = dict[v]
for tri in tris
push!(hull, trianglecenter(triangles[tri]...))
end
sethue(ColorSchemes.Hiroshige[rand(1:end)])
if length(hull) >= 3
ph = polyhull(hull)
poly(ph, :fillpreserve, close=true)
sethue("black")
strokepath()
end
end
@layer begin
img = readpng("/tmp/Hiroshige-sample.png")
box(O, 550, 275, :clip)
scale(0.25)
placeimage(img, centered=true)
end
end 800 800 "/tmp/Hiroshige.png"
@cormullion
Copy link
Author

output

Hiroshige

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