Skip to content

Instantly share code, notes, and snippets.

@tdhooper
Created June 18, 2020 14:27
Show Gist options
  • Save tdhooper/e627f980bf80af59b7ab0b987145450d to your computer and use it in GitHub Desktop.
Save tdhooper/e627f980bf80af59b7ab0b987145450d to your computer and use it in GitHub Desktop.
glisp voronoi
(def diagrams [
(point-cloud [812 334.203125] [463 886.203125] [301 588.203125] [451 316.203125] [627 599.203125] [994 598.203125] [807 880.203125] [1180 328.203125] [1317 597.203125] [1164 889.203125] [643 59.203125] [990 61.203125] [994 1137.203125] [645 1140.203125])
(point-cloud [812 334.203125] [463 886.203125] [301 588.203125] [450 317.203125] [627 599.203125] [994 598.203125] [807 880.203125] [1180 328.203125] [1317 597.203125] [1164 889.203125] [643 59.203125] [990 61.203125] [994 1137.203125] [645 1140.203125] [714 459.203125] [903 458.203125] [809 593.203125])
(point-cloud [812 334.203125] [463 886.203125] [301 588.203125] [451 316.203125] [627 599.203125] [994 598.203125] [807 880.203125] [1180 328.203125] [1317 597.203125] [1164 889.203125] [643 59.203125] [990 61.203125] [994 1137.203125] [645 1140.203125] [719 458.203125] [903 465.203125] [809 593.203125] [946 528.203125] [856 529.203125] [901 595.203125])
(point-cloud [812 334.203125] [463 886.203125] [301 588.203125] [451 316.203125] [627 599.203125] [1089 671.203125] [807 880.203125] [1180 328.203125] [1317 597.203125] [1164 889.203125] [643 59.203125] [990 61.203125] [994 1137.203125] [645 1140.203125] [872 551.203125])
(point-cloud [812 334.203125] [463 886.203125] [301 588.203125] [451 316.203125] [627 599.203125] [1089 671.203125] [807 880.203125] [1180 328.203125] [1317 597.203125] [1164 889.203125] [643 59.203125] [990 61.203125] [994 1137.203125] [645 1140.203125] [982 471.203125] [825 584.203125])
(point-cloud [812 334.203125] [463 886.203125] [301 588.203125] [451 316.203125] [627 599.203125] [1052 736.203125] [807 880.203125] [1180 328.203125] [1317 597.203125] [1164 889.203125] [643 59.203125] [990 61.203125] [994 1137.203125] [645 1140.203125] [916 514.203125])
])
(def n 5)
(def points (nth diagrams n))
:start-sketch
(background "#252525")
(g {
:transform (translate [0 0])
}
[
(style (stroke "#544" 2)
(for [tri (delaunay points)]
(let [[a b c] tri]
[
(line a b)
(line b c)
(line c a)
]
)
)
)
(style (stroke "#FCC" 2)
(path/voronoi
"edge"
[0 0 *width* *height*]
points
)
)
(style (fill "#FCC")
(map #(circle % 3) points)
)
]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment