mirror of
https://github.com/penpot/penpot.git
synced 2025-02-02 12:28:54 -05:00
Merge remote-tracking branch 'origin/staging' into develop
This commit is contained in:
commit
e9d3cb16c0
1 changed files with 34 additions and 27 deletions
|
@ -12,7 +12,6 @@
|
||||||
[app.common.types.shape.impl :as ctsi]
|
[app.common.types.shape.impl :as ctsi]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
[app.util.object :as obj]
|
|
||||||
[promesa.core :as p]))
|
[promesa.core :as p]))
|
||||||
|
|
||||||
(defn initialize
|
(defn initialize
|
||||||
|
@ -28,21 +27,24 @@
|
||||||
|
|
||||||
(defn create-shape
|
(defn create-shape
|
||||||
[id]
|
[id]
|
||||||
(let [buffer (uuid/uuid->u32 id)]
|
(let [buffer (uuid/uuid->u32 id)
|
||||||
(._create_shape ^js internal-module (aget buffer 0) (aget buffer 1) (aget buffer 2) (aget buffer 3))))
|
create-shape (unchecked-get internal-module "_create_shape")]
|
||||||
|
(^function create-shape (aget buffer 0) (aget buffer 1) (aget buffer 2) (aget buffer 3))))
|
||||||
|
|
||||||
(defn use-shape
|
(defn use-shape
|
||||||
[id]
|
[id]
|
||||||
(let [buffer (uuid/uuid->u32 id)]
|
(let [buffer (uuid/uuid->u32 id)
|
||||||
(._use_shape ^js internal-module (aget buffer 0) (aget buffer 1) (aget buffer 2) (aget buffer 3))))
|
use-shape (unchecked-get internal-module "_use_shape")]
|
||||||
|
(^function use-shape (aget buffer 0) (aget buffer 1) (aget buffer 2) (aget buffer 3))))
|
||||||
|
|
||||||
(defn set-shape-selrect
|
(defn set-shape-selrect
|
||||||
[selrect]
|
[selrect]
|
||||||
(let [x1 (:x1 selrect)
|
(let [x1 (:x1 selrect)
|
||||||
y1 (:y1 selrect)
|
y1 (:y1 selrect)
|
||||||
x2 (:x2 selrect)
|
x2 (:x2 selrect)
|
||||||
y2 (:y2 selrect)]
|
y2 (:y2 selrect)
|
||||||
(._set_shape_selrect ^js internal-module x1 y1 x2 y2)))
|
set-shape-selrect (unchecked-get internal-module "_set_shape_selrect")]
|
||||||
|
(^function set-shape-selrect x1 y1 x2 y2)))
|
||||||
|
|
||||||
(defn set-shape-transform
|
(defn set-shape-transform
|
||||||
[transform]
|
[transform]
|
||||||
|
@ -51,27 +53,33 @@
|
||||||
c (:c transform)
|
c (:c transform)
|
||||||
d (:d transform)
|
d (:d transform)
|
||||||
e (:e transform)
|
e (:e transform)
|
||||||
f (:f transform)]
|
f (:f transform)
|
||||||
(._set_shape_transform ^js internal-module a b c d e f)))
|
set-shape-transform (unchecked-get internal-module "_set_shape_transform")]
|
||||||
|
(^function set-shape-transform a b c d e f)))
|
||||||
|
|
||||||
(defn set-shape-rotation
|
(defn set-shape-rotation
|
||||||
[rotation]
|
[rotation]
|
||||||
(._set_shape_rotation ^js internal-module rotation))
|
(let [set-shape-rotation (unchecked-get internal-module "_set_shape_rotation")]
|
||||||
|
(^function set-shape-rotation rotation)))
|
||||||
|
|
||||||
(defn set-shape-children
|
(defn set-shape-children
|
||||||
[shape_ids]
|
[shape_ids]
|
||||||
(._clear_shape_children ^js internal-module)
|
(let [clear-shape-children (unchecked-get internal-module "_clear_shape_children")
|
||||||
(doseq [id shape_ids]
|
add-shape-child (unchecked-get internal-module "_add_shape_child")]
|
||||||
(let [buffer (uuid/uuid->u32 id)]
|
(^function clear-shape-children)
|
||||||
(._add_shape_child ^js internal-module (aget buffer 0) (aget buffer 1) (aget buffer 2) (aget buffer 3)))))
|
(doseq [id shape_ids]
|
||||||
|
(let [buffer (uuid/uuid->u32 id)]
|
||||||
|
(^function add-shape-child (aget buffer 0) (aget buffer 1) (aget buffer 2) (aget buffer 3))))))
|
||||||
|
|
||||||
(defn set-shape-fills
|
(defn set-shape-fills
|
||||||
[fills]
|
[fills]
|
||||||
(._clear_shape_fills ^js internal-module)
|
(let [clear-shape-fills (unchecked-get internal-module "_clear_shape_fills")
|
||||||
(doseq [fill (filter #(contains? % :fill-color) fills)]
|
add-shape-fill (unchecked-get internal-module "_add_shape_solid_fill")]
|
||||||
(let [a (:fill-opacity fill)
|
(^function clear-shape-fills)
|
||||||
[r g b] (cc/hex->rgb (:fill-color fill))]
|
(doseq [fill (filter #(contains? % :fill-color) fills)]
|
||||||
(._add_shape_solid_fill ^js internal-module r g b a))))
|
(let [a (:fill-opacity fill)
|
||||||
|
[r g b] (cc/hex->rgb (:fill-color fill))]
|
||||||
|
(^function add-shape-fill r g b a)))))
|
||||||
|
|
||||||
(defn set-objects
|
(defn set-objects
|
||||||
[objects]
|
[objects]
|
||||||
|
@ -98,9 +106,10 @@
|
||||||
[zoom vbox]
|
[zoom vbox]
|
||||||
(js/requestAnimationFrame
|
(js/requestAnimationFrame
|
||||||
(fn []
|
(fn []
|
||||||
(let [pan-x (- (dm/get-prop vbox :x))
|
(let [pan-x (- (dm/get-prop vbox :x))
|
||||||
pan-y (- (dm/get-prop vbox :y))]
|
pan-y (- (dm/get-prop vbox :y))
|
||||||
(._draw_all_shapes ^js internal-module zoom pan-x pan-y)))))
|
draw-all-shapes (unchecked-get internal-module "_draw_all_shapes")]
|
||||||
|
(^function draw-all-shapes zoom pan-x pan-y)))))
|
||||||
|
|
||||||
(defn cancel-draw
|
(defn cancel-draw
|
||||||
[frame-id]
|
[frame-id]
|
||||||
|
@ -129,12 +138,10 @@
|
||||||
handle (.registerContext ^js gl context #js {"majorVersion" 2})]
|
handle (.registerContext ^js gl context #js {"majorVersion" 2})]
|
||||||
(.makeContextCurrent ^js gl handle)
|
(.makeContextCurrent ^js gl handle)
|
||||||
;; Initialize Skia
|
;; Initialize Skia
|
||||||
(init-fn (.-width ^js canvas)
|
(^function init-fn (.-width ^js canvas)
|
||||||
(.-height ^js canvas))
|
(.-height ^js canvas))
|
||||||
(set! (.-width canvas) (.-clientWidth ^js canvas))
|
(set! (.-width canvas) (.-clientWidth ^js canvas))
|
||||||
(set! (.-height canvas) (.-clientHeight ^js canvas))
|
(set! (.-height canvas) (.-clientHeight ^js canvas))))
|
||||||
|
|
||||||
(obj/set! js/window "shape_list" (fn [] ((unchecked-get internal-module "_shape_list"))))))
|
|
||||||
|
|
||||||
(defonce module
|
(defonce module
|
||||||
(if (exists? js/dynamicImport)
|
(if (exists? js/dynamicImport)
|
||||||
|
|
Loading…
Add table
Reference in a new issue