Skip to content

Commit b59f32c

Browse files
committed
add docstrings to element multimethods
1 parent 817e2ec commit b59f32c

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/renderer/tool/base.cljs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,21 @@
4242
(defmethod properties :default [])
4343

4444
;; Element multimethods.
45-
(defmulti render :tag)
46-
(defmulti render-to-string :tag)
47-
(defmulti path :tag)
48-
(defmulti area :tag)
49-
(defmulti centroid :tag)
50-
(defmulti snapping-points :tag)
51-
(defmulti render-edit :tag)
52-
(defmulti bounds (fn [el _elements] (:tag el))) ; REVIEW
53-
(defmulti translate (fn [el _offset] (:tag el)))
54-
(defmulti position (fn [el _position] (:tag el)))
55-
(defmulti scale (fn [el _ration _pivot-point] (:tag el)))
56-
(defmulti edit (fn [el _offset _handle] (:tag el)))
45+
;; The context of the element methods should be limited to the element.
46+
;; Additional arguments should not include the global db.
47+
(defmulti render "Renders the element to dom." :tag)
48+
(defmulti render-to-string "Returns an SVG string of the element." :tag)
49+
(defmulti path "Converts the elemnt to path commands (d)." :tag)
50+
(defmulti area "Calculates the area enclosed by the shape." :tag)
51+
(defmulti centroid "Returns the elements' center of mass." :tag)
52+
(defmulti snapping-points "Returns additional snapping point for the element." :tag)
53+
(defmulti render-edit "Renders the edit overlay of the element." :tag)
54+
;; REVIEW: Is there a way to avoid passing all elelemts?
55+
(defmulti bounds "Returns the local bounds of the element." (fn [el _elements] (:tag el)))
56+
(defmulti translate "Translates the element by a given offset." (fn [el _offset] (:tag el)))
57+
(defmulti position "Moves the element to a given global position." (fn [el _position] (:tag el)))
58+
(defmulti scale "Scales the element by a given ratio and pivot-point." (fn [el _ration _pivot-point] (:tag el)))
59+
(defmulti edit "Edits the element by a given offset and handle." (fn [el _offset _handle] (:tag el)))
5760

5861
(defmethod render :default [])
5962
(defmethod render-to-string :default [element] [render element])

0 commit comments

Comments
 (0)