mirror of
https://github.com/penpot/penpot.git
synced 2026-10-30 06:20:32 +00:00
🚧 WIP Step 21.2 Cosmetic simplifications
This commit is contained in:
parent
fe99cd46d1
commit
693b0f5706
@ -11,39 +11,36 @@
|
||||
[benches.render-wasm.declarations :as decl :include-macros true]
|
||||
[benches.render-wasm.runtime.camera :as camera]))
|
||||
|
||||
(def ^:private default-params
|
||||
(def ^:const ^:private default-params
|
||||
{:width 1920 :height 1080})
|
||||
|
||||
(def ^:private schema:params
|
||||
(def ^:const ^:private schema:params
|
||||
[:map {:closed true}
|
||||
[:width [:int {:min 1920}]]
|
||||
[:height [:int {:min 1080}]]])
|
||||
|
||||
(defn build
|
||||
[params]
|
||||
(let [params (merge default-params params)]
|
||||
(sb/scene {:seed (:seed params)
|
||||
:root {:x 0 :y 0 :width (:width params) :height (:height params)}}
|
||||
(doseq [i (range 24)]
|
||||
(let [x (+ 25 (* 310 (mod i 6)))
|
||||
y (+ 25 (* 255 (quot i 6)))]
|
||||
(sb/group [:mask i] {:masked-group true}
|
||||
(sb/circle {:x x :y y :width 180 :height 180
|
||||
:fills [{:fill-color "#ffffff"}]})
|
||||
(doseq [j (range 8)]
|
||||
(sb/rect {:x (+ x (* 28 j) -22)
|
||||
:y (- y 12)
|
||||
:width 25
|
||||
:height 205
|
||||
:fills [{:fill-color (if (even? j) "#1254b8" "#ff8b38")}]}))))))))
|
||||
|
||||
(decl/defscene :masks
|
||||
{:version 1
|
||||
:description "Twenty-four circle masks with ordered striped descendants"
|
||||
:params-schema schema:params}
|
||||
build)
|
||||
(fn [params]
|
||||
(let [params (merge default-params params)]
|
||||
(sb/scene {:seed (:seed params)
|
||||
:root {:x 0 :y 0 :width (:width params) :height (:height params)}}
|
||||
(doseq [i (range 24)]
|
||||
(let [x (+ 25 (* 310 (mod i 6)))
|
||||
y (+ 25 (* 255 (quot i 6)))]
|
||||
(sb/group [:mask i] {:masked-group true}
|
||||
(sb/circle {:x x :y y :width 180 :height 180
|
||||
:fills [{:fill-color "#ffffff"}]})
|
||||
(doseq [j (range 8)]
|
||||
(sb/rect {:x (+ x (* 28 j) -22)
|
||||
:y (- y 12)
|
||||
:width 25
|
||||
:height 205
|
||||
:fills [{:fill-color (if (even? j) "#1254b8" "#ff8b38")}]})))))))))
|
||||
|
||||
(def ^:private base-view {:scale 1 :x 0 :y 0})
|
||||
(def ^:const ^:private base-view {:scale 1 :x 0 :y 0})
|
||||
|
||||
(decl/defcase :masks/load :masks
|
||||
{:params default-params :view base-view :context :fresh}
|
||||
|
||||
@ -13,15 +13,21 @@
|
||||
[benches.render-wasm.declarations :as decl :include-macros true]
|
||||
[benches.render-wasm.runtime.camera :as camera]))
|
||||
|
||||
(def ^:private default-params
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Config
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(def ^:const ^:private default-params
|
||||
{:count 1000 :width 1920 :height 1080})
|
||||
|
||||
(def ^:private schema:params
|
||||
(def ^:const ^:private schema:params
|
||||
[:map {:closed true}
|
||||
[:count [:int {:min 1 :max 100000}]]
|
||||
[:width ::sm/positive-safe-number]
|
||||
[:height ::sm/positive-safe-number]])
|
||||
|
||||
(def ^:const ^:private base-view {:scale 1 :x 0 :y 0})
|
||||
|
||||
(defn- curved-content
|
||||
[{:keys [width height]}]
|
||||
(fn [rng]
|
||||
@ -38,24 +44,21 @@
|
||||
{:command :line-to :params {:x x :y (+ y h)}}
|
||||
{:command :close-path}]))))
|
||||
|
||||
(defn build
|
||||
[params]
|
||||
(let [params (merge default-params params)]
|
||||
(sb/scene {:seed (:seed params)
|
||||
:root {:x 0 :y 0 :width (:width params) :height (:height params)}
|
||||
:defaults {:path {:content (curved-content params)
|
||||
:fills (sb/gen-vector (sb/gen-fill))
|
||||
:strokes (sb/gen-vector (sb/gen-stroke 3))}}}
|
||||
(doseq [_ (range (:count params))]
|
||||
(sb/path)))))
|
||||
|
||||
(decl/defscene :paths
|
||||
{:version 1
|
||||
:description "Curved paths"
|
||||
:params-schema schema:params}
|
||||
build)
|
||||
(fn [params]
|
||||
(let [params (merge default-params params)]
|
||||
(sb/scene {:seed (:seed params)
|
||||
:root {:x 0 :y 0 :width (:width params) :height (:height params)}
|
||||
:defaults {:path {:content (curved-content params)
|
||||
:fills (sb/gen-vector (sb/gen-fill))
|
||||
:strokes (sb/gen-vector (sb/gen-stroke 3))}}}
|
||||
(doseq [_ (range (:count params))]
|
||||
(sb/path))))))
|
||||
|
||||
(def ^:private base-view {:scale 1 :x 0 :y 0})
|
||||
|
||||
(decl/defcase :paths/load :paths
|
||||
{:params default-params :view base-view :context :fresh}
|
||||
|
||||
@ -33,22 +33,21 @@
|
||||
{:command :move-to :params {:x x :y (- y r)}}
|
||||
{:command :line-to :params {:x x :y (+ y r)}}]))))
|
||||
|
||||
(defn build
|
||||
[params]
|
||||
(let [params (merge default-params params)]
|
||||
(sb/scene {:seed (:seed params)
|
||||
:root {:x 0 :y 0 :width (:width params) :height (:height params)}
|
||||
:defaults {:path {:content (plus-content params)
|
||||
:fills []
|
||||
:strokes (sb/gen-vector (sb/gen-stroke 4))}}}
|
||||
(doseq [_ (range (:count params))]
|
||||
(sb/path)))))
|
||||
|
||||
(decl/defscene :plus
|
||||
{:version 1
|
||||
:description "Plus signs made of two open line subpaths"
|
||||
:params-schema schema:params}
|
||||
build)
|
||||
(fn build
|
||||
[params]
|
||||
(let [params (merge default-params params)]
|
||||
(sb/scene {:seed (:seed params)
|
||||
:root {:x 0 :y 0 :width (:width params) :height (:height params)}
|
||||
:defaults {:path {:content (plus-content params)
|
||||
:fills []
|
||||
:strokes (sb/gen-vector (sb/gen-stroke 4))}}}
|
||||
(doseq [_ (range (:count params))]
|
||||
(sb/path))))))
|
||||
|
||||
(def ^:private base-view {:scale 1 :x 0 :y 0})
|
||||
|
||||
|
||||
@ -11,8 +11,7 @@
|
||||
fills and centered strokes, all drawn from the scope's seeded generator.
|
||||
`build` produces the scene snapshot; `defscene` and `defcase` declare
|
||||
the scene and its standard cases. The three cases share parameters, so
|
||||
they render the same scene. Each case body runs through the compiled
|
||||
browser executor; collection keeps only plain descriptors."
|
||||
they render the same scene."
|
||||
(:require
|
||||
[app.common.schema :as sm]
|
||||
[benches.render-wasm.builder :as sb :include-macros true]
|
||||
@ -24,7 +23,7 @@
|
||||
;; through rtx, not in this require list or its transitive dependencies.
|
||||
;; See declarations' dependency contract before adding a capability.
|
||||
|
||||
(def ^:private default-params
|
||||
(def ^:const ^:private default-params
|
||||
{:count 1000
|
||||
:width 1920
|
||||
:height 1080
|
||||
@ -32,9 +31,7 @@
|
||||
:max-size 100})
|
||||
|
||||
(def ^:private schema:params
|
||||
"Workload parameters. Sizes are finite (`pos?` accepts Infinity, which the
|
||||
generator cannot honor); `:min-size` above `:max-size`
|
||||
is rejected so parameter sweeps cannot silently measure a reversed range."
|
||||
"Workload parameters. Sizes are finite. `:min-size` > `:max-size` is rejected"
|
||||
[:and
|
||||
[:map {:closed true}
|
||||
[:count [:int {:min 1 :max 100000}]]
|
||||
|
||||
@ -9,6 +9,8 @@
|
||||
[app.common.types.path :as path]
|
||||
[app.common.uuid :as uuid]
|
||||
[benches.render-wasm.cases :as cases]
|
||||
[benches.render-wasm.declarations :as decl]
|
||||
;; These 3 register the scenes, do not remove
|
||||
[benches.render-wasm.scenes.masks :as masks]
|
||||
[benches.render-wasm.scenes.paths :as paths]
|
||||
[benches.render-wasm.scenes.plus :as plus]
|
||||
@ -18,8 +20,9 @@
|
||||
|
||||
(t/deftest curved-paths-use-canonical-content-and-stable-order
|
||||
(let [params {:count 12 :width 1920 :height 1080 :seed 42}
|
||||
scene (paths/build params)
|
||||
again (paths/build params)
|
||||
build (get-in @decl/registry [:scenes :paths :build])
|
||||
scene (build params)
|
||||
again (build params)
|
||||
shapes (helpers/children-of scene uuid/zero)
|
||||
first (first shapes)
|
||||
content (vec (:content first))]
|
||||
@ -34,7 +37,8 @@
|
||||
(t/is (= scene (common/validate! scene)))))
|
||||
|
||||
(t/deftest plus-paths-have-two-crossing-open-lines
|
||||
(let [scene (plus/build {:count 8 :width 1920 :height 1080 :seed 42})
|
||||
(let [build (get-in @decl/registry [:scenes :plus :build])
|
||||
scene (build {:count 8 :width 1920 :height 1080 :seed 42})
|
||||
first (first (helpers/children-of scene uuid/zero))
|
||||
segments (vec (:content first))
|
||||
[a b c d] segments]
|
||||
@ -51,7 +55,8 @@
|
||||
(t/is (= scene (common/validate! scene)))))
|
||||
|
||||
(t/deftest mask-child-order-and-descendants-are-reachable
|
||||
(let [scene (masks/build {:width 1920 :height 1080 :seed 42})
|
||||
(let [build (get-in @decl/registry [:scenes :masks :build])
|
||||
scene (build {:width 1920 :height 1080 :seed 42})
|
||||
groups (helpers/children-of scene uuid/zero)
|
||||
group (first groups)
|
||||
children (helpers/children-of scene (:id group))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user