diff --git a/src/shimmers/algorithm/polygon_detection.cljc b/src/shimmers/algorithm/polygon_detection.cljc index 5c07845d..2433a6db 100644 --- a/src/shimmers/algorithm/polygon_detection.cljc +++ b/src/shimmers/algorithm/polygon_detection.cljc @@ -212,7 +212,7 @@ ;; TODO: inline cycle-clockwise-from-edge and keep track of a single list of ;; seen edges (defn simple-polygons - "`graph` is a digraph of points, returns a set of cycles, where cycles are a list of points. + "`graph` is a digraph of points, returns a set of polygons from each point cycles. They should be simple cycles without any internal edges/chords." [graph] @@ -225,7 +225,7 @@ (if (or (empty? pending) (zero? limit)) (do (when (and (zero? limit) (> (count polygons) 2)) (println "halted after " (count polygons) " polygons")) - polygons) + (map gp/polygon2 polygons)) (let [edge (first pending) [p q] edge cycle (cycle-clockwise-from-edge g p q)] @@ -413,6 +413,5 @@ (for [[p q] (partition 2 1 (concat [a] isecs [b]))] [p q (g/dist p q)])))))) (lg/weighted-graph)) - simple-polygons - (map gp/polygon2)) + simple-polygons) [polygon])) diff --git a/src/shimmers/sketches/intertwined.cljs b/src/shimmers/sketches/intertwined.cljs index a9d5cdd8..528a3e80 100644 --- a/src/shimmers/sketches/intertwined.cljs +++ b/src/shimmers/sketches/intertwined.cljs @@ -228,7 +228,7 @@ :polygon polygon)) :polygons - (let [polygons (mapv gp/polygon2 (poly-detect/simple-polygons graph))] + (let [polygons (poly-detect/simple-polygons graph)] (q/stroke 0 0.5) (q/stroke-weight 0.5) (swap! defo assoc :polygons polygons) diff --git a/src/shimmers/sketches/network_effects.cljs b/src/shimmers/sketches/network_effects.cljs index e70fe663..68f644f1 100644 --- a/src/shimmers/sketches/network_effects.cljs +++ b/src/shimmers/sketches/network_effects.cljs @@ -99,7 +99,8 @@ polygons (->> conns (mapv :points) poly-detect/edges->graph - poly-detect/simple-polygons)] + poly-detect/simple-polygons + (map g/vertices))] (assoc state :nodes nodes' :quadtree (build-tree bounds nodes') diff --git a/src/shimmers/sketches/spaces_divided.cljs b/src/shimmers/sketches/spaces_divided.cljs index 2abd8117..23381cd1 100644 --- a/src/shimmers/sketches/spaces_divided.cljs +++ b/src/shimmers/sketches/spaces_divided.cljs @@ -66,8 +66,7 @@ (defn calculate-polygons [edges] (->> edges poly-detect/edges->graph - poly-detect/simple-polygons - (mapv gp/polygon2))) + poly-detect/simple-polygons)) (defn inset-shapes [polygons] (->> (for [poly polygons