mirror of
https://github.com/penpot/penpot.git
synced 2025-02-15 11:38:24 -05:00
Add rect rendering.
This commit is contained in:
parent
b4b98428d4
commit
00cc51c6d3
4 changed files with 20 additions and 0 deletions
|
@ -104,6 +104,13 @@
|
||||||
(assoc shape
|
(assoc shape
|
||||||
:x2 x2 :y2 y2))
|
:x2 x2 :y2 y2))
|
||||||
|
|
||||||
|
(defmethod -resize :builtin/rect
|
||||||
|
[shape [x2 y2]]
|
||||||
|
(let [{:keys [x y]} shape]
|
||||||
|
(assoc shape
|
||||||
|
:width (- x2 x)
|
||||||
|
:height (- y2 y))))
|
||||||
|
|
||||||
(defmethod -resize :default
|
(defmethod -resize :default
|
||||||
[shape _]
|
[shape _]
|
||||||
(throw (ex-info "Not implemented" (select-keys shape [:type]))))
|
(throw (ex-info "Not implemented" (select-keys shape [:type]))))
|
||||||
|
|
|
@ -68,6 +68,17 @@
|
||||||
(html
|
(html
|
||||||
[:line attrs])))
|
[:line attrs])))
|
||||||
|
|
||||||
|
|
||||||
|
(defmethod sh/-render :builtin/rect
|
||||||
|
[{:keys [id x1 y1 x2 y2] :as shape}]
|
||||||
|
(let [key (str id)
|
||||||
|
props (select-keys shape [:x :y :width :height])
|
||||||
|
attrs (-> (extract-style-attrs shape)
|
||||||
|
(merge {:id key :key key})
|
||||||
|
(merge props))]
|
||||||
|
(html
|
||||||
|
[:rect attrs])))
|
||||||
|
|
||||||
;; FIXME: the impl should be more clear.
|
;; FIXME: the impl should be more clear.
|
||||||
|
|
||||||
(defmethod sh/-render :builtin/group
|
(defmethod sh/-render :builtin/group
|
||||||
|
|
|
@ -78,6 +78,7 @@
|
||||||
(when-let [shape (:drawing @wb/workspace-l)]
|
(when-let [shape (:drawing @wb/workspace-l)]
|
||||||
(case (:type shape)
|
(case (:type shape)
|
||||||
:builtin/icon (init-icon shape)
|
:builtin/icon (init-icon shape)
|
||||||
|
:builtin/rect (init-shape shape)
|
||||||
:builtin/line (init-shape shape))))]
|
:builtin/line (init-shape shape))))]
|
||||||
|
|
||||||
(as-> wb/interactions-b $
|
(as-> wb/interactions-b $
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
(def +menus-map+
|
(def +menus-map+
|
||||||
{:builtin/icon [:menu/icon-measures :menu/fill :menu/stroke]
|
{:builtin/icon [:menu/icon-measures :menu/fill :menu/stroke]
|
||||||
:builtin/line [:menu/stroke]
|
:builtin/line [:menu/stroke]
|
||||||
|
:builtin/rect [:menu/icon-measures :menu/stroke :menu/fill]
|
||||||
:builtin/group []})
|
:builtin/group []})
|
||||||
|
|
||||||
(def +menus-by-id+
|
(def +menus-by-id+
|
||||||
|
|
Loading…
Add table
Reference in a new issue