diff --git a/src/renderer/frame/handlers.cljs b/src/renderer/frame/handlers.cljs index 001eff02..b448d2f3 100644 --- a/src/renderer/frame/handlers.cljs +++ b/src/renderer/frame/handlers.cljs @@ -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] @@ -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) diff --git a/src/renderer/tools/blob.cljs b/src/renderer/tools/blob.cljs index e20f193a..ee5b8732 100644 --- a/src/renderer/tools/blob.cljs +++ b/src/renderer/tools/blob.cljs @@ -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] @@ -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 @@ -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) diff --git a/src/renderer/tools/brush.cljs b/src/renderer/tools/brush.cljs index be1a75b5..0e93ca0b 100644 --- a/src/renderer/tools/brush.cljs +++ b/src/renderer/tools/brush.cljs @@ -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] @@ -110,8 +110,8 @@ 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)) @@ -119,11 +119,9 @@ (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 diff --git a/src/renderer/tools/flower.cljs b/src/renderer/tools/flower.cljs index 2bd34ef3..3a0b1330 100644 --- a/src/renderer/tools/flower.cljs +++ b/src/renderer/tools/flower.cljs @@ -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) diff --git a/src/renderer/utils/math.cljs b/src/renderer/utils/math.cljs new file mode 100644 index 00000000..fc9f66c1 --- /dev/null +++ b/src/renderer/utils/math.cljs @@ -0,0 +1,5 @@ +(ns renderer.utils.math) + +(defn clamp + [x minimum maximum] + (min (max x minimum) maximum))