Created
January 12, 2022 11:25
-
-
Save cormullion/a5dd0e517555a2e5d30557b94b76eaa3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
output