Skip to content

Commit

Permalink
(wip) remove google closure deps
Browse files Browse the repository at this point in the history
  • Loading branch information
sprocketc committed Feb 6, 2024
1 parent 1fd14c8 commit 2286326
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/renderer/frame/handlers.cljs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(ns renderer.frame.handlers
(:require
[clojure.core.matrix :as mat]
[goog.math]
[renderer.element.handlers :as el]
[renderer.element.utils :as el.utils]
[renderer.tools.base :as tools]
[renderer.utils.bounds :as bounds]))
[renderer.utils.bounds :as bounds]
[renderer.utils.math :as math]))

(defn pan
[{:keys [active-document] :as db} offset]
Expand All @@ -18,7 +18,7 @@
(defn zoom-in-position
[{:keys [active-document] :as db} factor pos]
(let [zoom (get-in db [:documents active-document :zoom])
updated-zoom (goog.math.clamp (* zoom factor) 0.01 100)
updated-zoom (math/clamp (* zoom factor) 0.01 100)
updated-factor (/ updated-zoom zoom)
pan (get-in db [:documents active-document :pan])
updated-pan (mat/sub (mat/div pan updated-factor)
Expand Down
5 changes: 2 additions & 3 deletions src/renderer/tools/blob.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
["blobs/v2" :as blobs]
["svgpath" :as svgpath]
[clojure.core.matrix :as mat]
[goog.math]
[re-frame.core :as rf]
[renderer.attribute.hierarchy :as attr.hierarchy]
[renderer.attribute.length :as length]
Expand Down Expand Up @@ -36,7 +35,7 @@

(defmethod attr.hierarchy/form-element ::seed
[k v disabled?]
(let [random-seed (goog.math/randomInt 1000000)]
(let [random-seed (rand-int 1000000)]
[:<>
[attr.v/form-input {:key k
:value v
Expand Down Expand Up @@ -98,7 +97,7 @@
radius (mat/distance adjusted-pointer-pos adjusted-pointer-offset)
attrs {::x (- offset-x radius)
::y (- offset-y radius)
::seed (goog.math/randomInt 1000000)
::seed (rand-int 1000000)
::extraPoints 8
::randomness 4
::size (* radius 2)
Expand Down
12 changes: 5 additions & 7 deletions src/renderer/tools/brush.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
["perfect-freehand" :refer [getStroke]]
["svg-path-bbox" :as svg-path-bbox]
[clojure.core.matrix :as mat]
[goog.math]
[clojure.core.matrix.stats :as mat.stats]
[renderer.attribute.color :as attr.color]
[renderer.attribute.hierarchy :as attr.hierarchy]
[renderer.attribute.range :as attr.range]
Expand Down Expand Up @@ -110,20 +110,18 @@
d (str
"M" (units/->fixed (first a)) "," (units/->fixed (second a))
" Q" (units/->fixed (first b)) "," (units/->fixed (second b))
" " (units/->fixed (goog.math/average (first b) (first c))) ","
(units/->fixed (goog.math/average (second b) (second c))) " T")]
" " (units/->fixed (mat.stats/mean [(first b) (first c)])) ","
(units/->fixed (mat.stats/mean [(second b) (second c)])) " T")]
(reduce-kv
(fn [result index]
(if (or (= len (inc index)) (< index 2))
result
(let [a (nth points index)
b (nth points (inc index))]
(str result
(units/->fixed (goog.math/average (first a)
(first b)))
(units/->fixed (mat.stats/mean [(first a) (first b)]))
","
(units/->fixed (goog.math/average (second a)
(second b)))
(units/->fixed (mat.stats/mean [(second a) (second b)]))
" ")))) d points)))))

(defn points->path
Expand Down
1 change: 0 additions & 1 deletion src/renderer/tools/flower.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
https://gist.github.com/Askarizadeh986/2bb64fe3a134236fe6ff30875cf81d00
License https://codepen.io/license/pen/XGLZLp"
(:require
[goog.math]
[renderer.tools.base :as tools]))

(derive :flower ::tools/custom)
5 changes: 5 additions & 0 deletions src/renderer/utils/math.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(ns renderer.utils.math)

(defn clamp
[x minimum maximum]
(min (max x minimum) maximum))

0 comments on commit 2286326

Please sign in to comment.