mirror of
https://github.com/penpot/penpot.git
synced 2025-01-10 00:40:30 -05:00
✨ Improve ruler scale calculation.
This commit is contained in:
parent
994a1fa144
commit
f3e1d35f3d
2 changed files with 21 additions and 6 deletions
|
@ -36,16 +36,16 @@
|
|||
profile (:profile storage)
|
||||
authed? (and (not (nil? profile))
|
||||
(not= (:id profile) uuid/zero))]
|
||||
|
||||
(cond
|
||||
(and (or (= path "")
|
||||
(nil? match))
|
||||
(not authed?))
|
||||
(st/emit! (rt/nav :login))
|
||||
|
||||
(and (= path "") authed?)
|
||||
(and (nil? match) authed?)
|
||||
(st/emit! (rt/nav :dashboard-team {:team-id (:default-team-id profile)}))
|
||||
|
||||
|
||||
(nil? match)
|
||||
(st/emit! (rt/nav :not-found))
|
||||
|
||||
|
|
|
@ -13,15 +13,30 @@
|
|||
[uxbox.util.math :as mth]
|
||||
[uxbox.util.object :as obj]))
|
||||
|
||||
(defn- calculate-step-size
|
||||
[zoom]
|
||||
(cond
|
||||
(< 0 zoom 0.008) 10000
|
||||
(< 0.008 zoom 0.015) 5000
|
||||
(< 0.015 zoom 0.04) 2500
|
||||
(< 0.04 zoom 0.07) 1000
|
||||
(< 0.07 zoom 0.2) 500
|
||||
(< 0.2 zoom 0.5) 250
|
||||
(< 0.5 zoom 1) 100
|
||||
(< 1 zoom 2) 50
|
||||
(< 2 zoom 4) 25
|
||||
(< 4 zoom 6) 10
|
||||
(< 6 zoom 15) 5
|
||||
(< 15 zoom 25) 2
|
||||
(< 25 zoom) 1
|
||||
:else 1))
|
||||
|
||||
(defn draw-rule!
|
||||
[dctx {:keys [zoom size start count type] :or {count 200}}]
|
||||
(let [txfm (- (* (- 0 start) zoom) 20)
|
||||
minv (mth/round start)
|
||||
maxv (mth/round (+ start (/ size zoom)))
|
||||
|
||||
step (mth/round (/ (mth/abs (- maxv minv)) count))
|
||||
step (max (* 1 (* 10 step)) 1)]
|
||||
|
||||
step (calculate-step-size zoom)]
|
||||
(obj/set! dctx "fillStyle" "#E8E9EA")
|
||||
(if (= type :horizontal)
|
||||
(do
|
||||
|
|
Loading…
Reference in a new issue