0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-08 16:00:19 -05:00

Pixel grid

This commit is contained in:
alonso.torres 2021-02-05 11:27:01 +01:00 committed by Hirunatan
parent 8313f1d96e
commit a8a036206b
3 changed files with 32 additions and 2 deletions

View file

@ -2,7 +2,12 @@
## Next ## Next
- ... ### New features
- Add images lock proportions by default
- Shows a pixel grid when zoom greater than 800%
### Bug fixed
## 1.1.0-alpha ## 1.1.0-alpha

View file

@ -22,7 +22,7 @@
(defonce ^:private default-square-params (defonce ^:private default-square-params
{:size 16 {:size 16
:color {:color "#59B9E2" :color {:color "#59B9E2"
:opacity 0.2}}) :opacity 0.4}})
(defonce ^:private default-layout-params (defonce ^:private default-layout-params
{:size 12 {:size 12

View file

@ -231,6 +231,27 @@
:shape (gsh/transform-shape shape) :shape (gsh/transform-shape shape)
:color color}])]))) :color color}])])))
(mf/defc pixel-grid
[{:keys [vbox zoom]}]
[:g.pixel-grid
[:defs
[:pattern {:id "pixel-grid"
:viewBox "0 0 1 1"
:width 1
:height 1
:pattern-units "userSpaceOnUse"}
[:path {:d "M 1 0 L 0 0 0 1"
:style {:fill "none"
:stroke "#59B9E2"
:stroke-opacity "0.2"
:stroke-width (str (/ 1 zoom))}}]]]
[:rect {:x (:x vbox)
:y (:y vbox)
:width (:width vbox)
:height (:height vbox)
:fill (str "url(#pixel-grid)")
:style {:pointer-events "none"}}]])
(mf/defc frames (mf/defc frames
{::mf/wrap [mf/memo] {::mf/wrap [mf/memo]
::mf/wrap-props false} ::mf/wrap-props false}
@ -779,6 +800,10 @@
(when show-grids? (when show-grids?
[:& frame-grid {:zoom zoom}]) [:& frame-grid {:zoom zoom}])
(when (>= zoom 8)
[:& pixel-grid {:vbox vbox
:zoom zoom}])
(when show-snap-points? (when show-snap-points?
[:& snap-points {:layout layout [:& snap-points {:layout layout
:transform transform :transform transform