mirror of
https://github.com/penpot/penpot.git
synced 2025-06-15 17:23:02 +02:00
✨ Snap to square grid
This commit is contained in:
parent
3308d762f1
commit
d2229f43c7
12 changed files with 159 additions and 171 deletions
|
@ -12,17 +12,7 @@
|
|||
[cljs.spec.alpha :as s]
|
||||
[clojure.set :as set]
|
||||
[uxbox.util.geom.shapes :as gsh]
|
||||
[uxbox.util.geom.point :as gpt]
|
||||
[uxbox.util.geom.layout :as gla]))
|
||||
|
||||
(defn- layout-rect-snaps [{:keys [x y width height]}]
|
||||
#{(gpt/point x y)
|
||||
(gpt/point (+ x width) y)
|
||||
(gpt/point (+ x width) (+ y height))
|
||||
(gpt/point x (+ y height))})
|
||||
|
||||
(defn- layout-snap-points [frame {:keys [type] :as layout}]
|
||||
(mapcat layout-rect-snaps (gla/layout-rects frame layout)))
|
||||
[uxbox.util.geom.point :as gpt]))
|
||||
|
||||
(defn- frame-snap-points [{:keys [x y width height layouts] :as frame}]
|
||||
(into #{(gpt/point x y)
|
||||
|
@ -32,11 +22,7 @@
|
|||
(gpt/point (+ x width) (+ y height))
|
||||
(gpt/point (+ x (/ width 2)) (+ y height))
|
||||
(gpt/point x (+ y height))
|
||||
(gpt/point x (+ y (/ height 2)))}
|
||||
(->>
|
||||
layouts
|
||||
(filter #(and (not= :grid (:type %)) (:display %)))
|
||||
(mapcat #(layout-snap-points frame %)))))
|
||||
(gpt/point x (+ y (/ height 2)))}))
|
||||
|
||||
(defn shape-snap-points
|
||||
[shape]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue