mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 02:11:38 +02:00
✨ Snap for beziers
This commit is contained in:
parent
d8ab3473bf
commit
05366eac6f
7 changed files with 44 additions and 26 deletions
|
@ -195,7 +195,7 @@
|
|||
(or (filter-shapes id)
|
||||
(not (contains? layout :dynamic-alignment)))))
|
||||
shape (if (> (count shapes) 1)
|
||||
(->> shapes (map gsh/transform-shape) gsh/selection-rect)
|
||||
(->> shapes (map gsh/transform-shape) gsh/selection-rect (gsh/setup {:type :rect}))
|
||||
(->> shapes (first)))
|
||||
|
||||
shapes-points (->> shape
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
(mf/defc path-editor
|
||||
[{:keys [shape zoom]}]
|
||||
|
||||
(let [points (:points shape)
|
||||
(let [points (gsp/content->points (:content shape))
|
||||
drag-handler (:drag-handler shape)
|
||||
prev-handler (:prev-handler shape)
|
||||
last-command (last (:content shape))
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
(defn get-snap
|
||||
[coord {:keys [shapes page-id filter-shapes local]}]
|
||||
(let [shape (if (> (count shapes) 1)
|
||||
(->> shapes (map gsh/transform-shape) gsh/selection-rect)
|
||||
(->> shapes (map gsh/transform-shape) gsh/selection-rect (gsh/setup {:type :rect}))
|
||||
(->> shapes (first)))
|
||||
|
||||
shape (if (:modifiers local)
|
||||
|
|
|
@ -14,22 +14,25 @@
|
|||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.geom.point :as gpt]))
|
||||
|
||||
(defn- frame-snap-points [{:keys [x y width height] :as frame}]
|
||||
(into #{(gpt/point x y)
|
||||
(gpt/point (+ x (/ width 2)) y)
|
||||
(gpt/point (+ x width) y)
|
||||
(defn- selrect-snap-points [{: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- frame-snap-points [{:keys [x y width height] :as selrect}]
|
||||
(into (selrect-snap-points selrect)
|
||||
#{(gpt/point (+ x (/ width 2)) y)
|
||||
(gpt/point (+ x width) (+ y (/ height 2)))
|
||||
(gpt/point (+ x width) (+ y height))
|
||||
(gpt/point (+ x (/ width 2)) (+ y height))
|
||||
(gpt/point x (+ y height))
|
||||
(gpt/point x (+ y (/ height 2)))}))
|
||||
|
||||
(defn shape-snap-points
|
||||
[shape]
|
||||
(let [shape (gsh/transform-shape shape)
|
||||
shape-center (gsh/center-shape shape)]
|
||||
(if (= :frame (:type shape))
|
||||
(-> shape
|
||||
:selrect
|
||||
(frame-snap-points))
|
||||
(into #{shape-center} (:points shape)))))
|
||||
(let [shape (gsh/transform-shape shape)]
|
||||
|
||||
(case (:type shape)
|
||||
:frame (-> shape :selrect frame-snap-points)
|
||||
(:path :curve) (-> shape :selrect selrect-snap-points)
|
||||
(into #{(gsh/center-shape shape)} (:points shape)))
|
||||
))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue