1
0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-05-21 21:26:11 +02:00

Change resize to use DOM transformations

This commit is contained in:
alonso.torres 2021-12-21 12:32:04 +01:00
parent fa09fff2b5
commit b2211aec59
38 changed files with 839 additions and 717 deletions
frontend/src

View file

@ -5,13 +5,14 @@
;; Copyright (c) UXBOX Labs SL
(ns debug
(:import [goog.math AffineTransform])
#_(:import [goog.math AffineTransform])
(:require
[app.common.data :as d]
[app.common.geom.matrix :as gmt]
#_[app.common.geom.matrix :as gmt]
[app.common.math :as mth]
[app.common.pages :as cp]
[app.common.perf :as perf]
#_[app.common.perf :as perf]
[app.common.uuid :as uuid]
[app.main.store :as st]
[app.util.object :as obj]
[app.util.timers :as timers]
@ -20,7 +21,32 @@
[cuerdas.core :as str]
[potok.core :as ptk]))
(def debug-options #{:bounding-boxes :group :events :rotation-handler :resize-handler :selection-center :export :import #_:simple-selection})
(def debug-options
#{;; Displays the bounding box for the shapes
:bounding-boxes
;; Displays an overlay over the groups
:group
;; Displays in the console log the events through the application
:events
;; Display the boxes that represent the rotation handlers
:rotation-handler
;; Display the boxes that represent the resize handlers
:resize-handler
;; Displays the center of a selection
:selection-center
;; When active the single selection will not take into account previous transformations
;; this is useful to debug transforms
:simple-selection
;; When active the thumbnails will be displayed with a sepia filter
:thumbnails
})
;; These events are excluded when we activate the :events flag
(def debug-exclude-events
@ -109,27 +135,40 @@
(do-thing)))
(defn ^:export dump-state []
(logjs "state" @st/state))
(logjs "state" @st/state)
nil)
(defn ^:export dump-buffer []
(logjs "state" @st/last-events))
(logjs "state" @st/last-events)
nil)
(defn ^:export get-state [str-path]
(let [path (->> (str/split str-path " ")
(map d/read-string))]
(clj->js (get-in @st/state path))))
(clj->js (get-in @st/state path)))
nil)
(defn ^:export dump-objects []
(let [page-id (get @st/state :current-page-id)]
(logjs "state" (get-in @st/state [:workspace-data :pages-index page-id :objects]))))
(let [page-id (get @st/state :current-page-id)
objects (get-in @st/state [:workspace-data :pages-index page-id :objects])]
(logjs "objects" objects)
nil))
(defn ^:export dump-object [name]
(let [page-id (get @st/state :current-page-id)
objects (get-in @st/state [:workspace-data :pages-index page-id :objects])
target (or (d/seek (fn [[_ shape]] (= name (:name shape))) objects)
(get objects (uuid name)))]
(->> target
(logjs "state"))))
result (or (d/seek (fn [[_ shape]] (= name (:name shape))) objects)
(get objects (uuid/uuid name)))]
(logjs name result)
nil))
(defn ^:export dump-selected []
(let [page-id (get @st/state :current-page-id)
objects (get-in @st/state [:workspace-data :pages-index page-id :objects])
selected (get-in @st/state [:workspace-local :selected])
result (->> selected (map (d/getf objects)))]
(logjs "selected" result)
nil))
(defn ^:export dump-tree
([] (dump-tree false false))
@ -212,7 +251,7 @@
(not (debug-exclude-events (ptk/type s))))))
(rx/subs #(println "[stream]: " (ptk/repr-event %))))))
(defn ^:export bench-matrix
#_(defn ^:export bench-matrix
[]
(let [iterations 1000000
@ -247,3 +286,6 @@
(println "Clojure matrix. Total: " m1 " (" (/ m1 iterations) ")")
(println "Clojure matrix (NEW). Total: " m2 " (" (/ m2 iterations) ")")
(println "Affine transform (with new). Total: " m3 " (" (/ m3 iterations) ")")))