|
3 | 3 | (:require
|
4 | 4 | ["perfect-freehand" :refer [getStroke]]
|
5 | 5 | [clojure.core.matrix :as matrix]
|
6 |
| - [clojure.core.matrix.stats :as mat.stats] |
| 6 | + [clojure.core.matrix.stats :as matrix.stats] |
7 | 7 | [clojure.string :as string]
|
8 |
| - [renderer.attribute.hierarchy :as attr.hierarchy] |
9 |
| - [renderer.attribute.impl.range :as attr.range] |
| 8 | + [renderer.attribute.hierarchy :as attribute.hierarchy] |
| 9 | + [renderer.attribute.impl.range :as attribute.impl.range] |
10 | 10 | [renderer.attribute.views :as attribute.views]
|
11 | 11 | [renderer.element.hierarchy :as element.hierarchy]
|
12 | 12 | [renderer.event.impl.pointer :as event.impl.pointer]
|
|
35 | 35 | (defonce option-keys
|
36 | 36 | [:size :thinning :smoothing :streamline])
|
37 | 37 |
|
38 |
| -(derive :thinning ::attr.range/range) |
39 |
| -(derive :smoothing ::attr.range/range) |
40 |
| -(derive :streamline ::attr.range/range) |
| 38 | +(derive :thinning ::attribute.impl.range/range) |
| 39 | +(derive :smoothing :attribute.impl.range/range) |
| 40 | +(derive :streamline ::attribute.impl.range/range) |
41 | 41 |
|
42 |
| -(defmethod attr.hierarchy/form-element [:brush :size] |
| 42 | +(defmethod attribute.hierarchy/form-element [:brush :size] |
43 | 43 | [_ k v attrs]
|
44 | 44 | [attribute.views/range-input k v (merge attrs {:min 1
|
45 | 45 | :max 100
|
46 | 46 | :step 1})])
|
47 | 47 |
|
48 |
| -(defmethod attr.hierarchy/form-element [:brush :points] |
| 48 | +(defmethod attribute.hierarchy/form-element [:brush :points] |
49 | 49 | [_ _k v]
|
50 | 50 | [:input.form-element {:value v
|
51 | 51 | :disabled true
|
52 | 52 | :placeholder (when-not v "multiple")}])
|
53 | 53 |
|
54 |
| -(defmethod attr.hierarchy/description [:brush ::points] |
| 54 | +(defmethod attribute.hierarchy/description [:brush ::points] |
55 | 55 | []
|
56 | 56 | "Input points recorded from a user's mouse movement.")
|
57 | 57 |
|
58 |
| -(defmethod attr.hierarchy/description [:brush :size] |
| 58 | +(defmethod attribute.hierarchy/description [:brush :size] |
59 | 59 | []
|
60 | 60 | "The base size (diameter) of the stroke.")
|
61 | 61 |
|
62 |
| -(defmethod attr.hierarchy/description [:brush :thinning] |
| 62 | +(defmethod attribute.hierarchy/description [:brush :thinning] |
63 | 63 | []
|
64 | 64 | "The effect of pressure on the stroke's size.")
|
65 | 65 |
|
66 |
| -(defmethod attr.hierarchy/description [:brush :smoothing] |
| 66 | +(defmethod attribute.hierarchy/description [:brush :smoothing] |
67 | 67 | []
|
68 | 68 | "How much to soften the stroke's edges.")
|
69 | 69 |
|
70 |
| -(defmethod attr.hierarchy/description [:brush :streamline] |
| 70 | +(defmethod attribute.hierarchy/description [:brush :streamline] |
71 | 71 | []
|
72 | 72 | "How much to streamline the stroke.")
|
73 | 73 |
|
|
84 | 84 | d (str
|
85 | 85 | "M" (.toFixed (first a) 2) "," (.toFixed (second a) 2)
|
86 | 86 | " Q" (.toFixed (first b) 2) "," (.toFixed (second b) 2)
|
87 |
| - " " (.toFixed (mat.stats/mean [(first b) (first c)]) 2) "," |
88 |
| - (.toFixed (mat.stats/mean [(second b) (second c)]) 2) " T")] |
| 87 | + " " (.toFixed (matrix.stats/mean [(first b) (first c)]) 2) "," |
| 88 | + (.toFixed (matrix.stats/mean [(second b) (second c)]) 2) " T")] |
89 | 89 | (reduce-kv
|
90 | 90 | (fn [result index]
|
91 | 91 | (if (or (= len (inc index)) (< index 2))
|
92 | 92 | result
|
93 | 93 | (let [a (nth points index)
|
94 | 94 | b (nth points (inc index))]
|
95 | 95 | (str result
|
96 |
| - (.toFixed (mat.stats/mean [(first a) (first b)]) 2) |
| 96 | + (.toFixed (matrix.stats/mean [(first a) (first b)]) 2) |
97 | 97 | ","
|
98 |
| - (.toFixed (mat.stats/mean [(second a) (second b)]) 2) |
| 98 | + (.toFixed (matrix.stats/mean [(second a) (second b)]) 2) |
99 | 99 | " ")))) d points)))))
|
100 | 100 |
|
101 | 101 | (def partition-to-px
|
|
0 commit comments