From 494abd17dd5dc67883bc3998712f5b6515f321ea Mon Sep 17 00:00:00 2001 From: Miguel de Benito Delgado Date: Fri, 2 Oct 2026 12:08:20 +0200 Subject: [PATCH] :construction: WIP Step 19 New scenes, use camera --- frontend/test/benches/render_wasm/cases.cljs | 3 + .../benches/render_wasm/scenes/masks.cljs | 60 +++++++++++++++++ .../test/benches/render_wasm/scenes/plus.cljs | 67 +++++++++++++++++++ .../benches/render_wasm/scenes/rects.cljs | 17 +++-- 4 files changed, 141 insertions(+), 6 deletions(-) create mode 100644 frontend/test/benches/render_wasm/scenes/masks.cljs create mode 100644 frontend/test/benches/render_wasm/scenes/plus.cljs diff --git a/frontend/test/benches/render_wasm/cases.cljs b/frontend/test/benches/render_wasm/cases.cljs index b9f276800f..09d002a036 100644 --- a/frontend/test/benches/render_wasm/cases.cljs +++ b/frontend/test/benches/render_wasm/cases.cljs @@ -40,6 +40,9 @@ (:require [app.common.schema :as sm] [benches.render-wasm.scenes.core :as core] + benches.render-wasm.scenes.masks + benches.render-wasm.scenes.paths + benches.render-wasm.scenes.plus benches.render-wasm.scenes.rects [clojure.string :as str])) diff --git a/frontend/test/benches/render_wasm/scenes/masks.cljs b/frontend/test/benches/render_wasm/scenes/masks.cljs new file mode 100644 index 0000000000..c4fe33d874 --- /dev/null +++ b/frontend/test/benches/render_wasm/scenes/masks.cljs @@ -0,0 +1,60 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) KALEIDOS SUBSIDIARY SL + +(ns benches.render-wasm.scenes.masks + "Fixed grid of masked groups with circle masks and ordered descendants." + (:require + [benches.render-wasm.scenes.builder :as sb :include-macros true] + [benches.render-wasm.scenes.camera :as camera] + [benches.render-wasm.scenes.core :as core :include-macros true])) + +(def ^:private default-params + {:width 1920 :height 1080}) + +(def ^: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")}]})))))))) + +(core/defscene :masks + {:version 1 + :description "Twenty-four circle masks with ordered striped descendants" + :params-schema schema:params} + build) + +(def ^:private base-view {:scale 1 :x 0 :y 0}) + +(core/defcase :masks/load :masks + {:params default-params :view base-view :context :fresh} + (fn [rtx] (camera/load! rtx))) + +(core/defcase :masks/pan :masks + {:params default-params :view base-view :context :reuse + :operation {:steps 20 :dx 120 :dy 40 :settle-ms 100}} + (fn [rtx] (camera/pan! rtx))) + +(core/defcase :masks/zoom :masks + {:params default-params :view base-view :context :reuse + :operation {:steps 20 :factor 1.6 :settle-ms 100}} + (fn [rtx] (camera/zoom! rtx))) diff --git a/frontend/test/benches/render_wasm/scenes/plus.cljs b/frontend/test/benches/render_wasm/scenes/plus.cljs new file mode 100644 index 0000000000..9113d4fca2 --- /dev/null +++ b/frontend/test/benches/render_wasm/scenes/plus.cljs @@ -0,0 +1,67 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) KALEIDOS SUBSIDIARY SL + +(ns benches.render-wasm.scenes.plus + "Plus signs made of two open line subpaths" + (:require + [app.common.types.path :as path] + [benches.render-wasm.scenes.builder :as sb :include-macros true] + [benches.render-wasm.scenes.camera :as camera] + [benches.render-wasm.scenes.core :as core :include-macros true])) + +(def ^:private default-params + {:count 1000 :width 1920 :height 1080}) + +(def ^:private schema:params + [:map {:closed true} + [:count [:int {:min 1 :max 100000}]] + [:width [:int {:min 100}]] + [:height [:int {:min 100}]]]) + +(defn- plus-content + [{:keys [width height]}] + (fn [rng] + (let [x (sb/rng-int rng 20 width) + y (sb/rng-int rng 20 height) + r (sb/rng-int rng 10 40)] + (path/from-plain + [{:command :move-to :params {:x (- x r) :y y}} + {:command :line-to :params {:x (+ x r) :y y}} + {: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))))) + +(core/defscene :plus + {:version 1 + :description "Plus signs made of two open line subpaths" + :params-schema schema:params} + build) + +(def ^:private base-view {:scale 1 :x 0 :y 0}) + +(core/defcase :plus/load :plus + {:params default-params :view base-view :context :fresh} + (fn [rtx] (camera/load! rtx))) + +(core/defcase :plus/pan :plus + {:params default-params :view base-view :context :reuse + :operation {:steps 20 :dx 140 :dy 60 :settle-ms 100}} + (fn [rtx] (camera/pan! rtx))) + +(core/defcase :plus/zoom :plus + {:params default-params :view base-view :context :reuse + :operation {:steps 20 :factor 1.4 :settle-ms 100}} + (fn [rtx] (camera/zoom! rtx))) diff --git a/frontend/test/benches/render_wasm/scenes/rects.cljs b/frontend/test/benches/render_wasm/scenes/rects.cljs index c2a5851adb..1cf6b02e52 100644 --- a/frontend/test/benches/render_wasm/scenes/rects.cljs +++ b/frontend/test/benches/render_wasm/scenes/rects.cljs @@ -11,12 +11,12 @@ 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. The path and effect scenes arrive in - tickets 07/08. The bridge supplies the current pan and zoom gestures; - scene case bodies arrive with ticket 14." + they render the same scene. Each case body runs through the compiled + browser executor; collection keeps only plain descriptors." (:require [app.common.schema :as sm] [benches.render-wasm.scenes.builder :as sb :include-macros true] + [benches.render-wasm.scenes.camera :as camera] [benches.render-wasm.scenes.core :as core :include-macros true])) ;; This namespace is also loaded by Node discovery. Keep operation helpers @@ -86,16 +86,21 @@ (core/defcase :rects/load :rects {:params default-params :view base-view - :context :fresh}) + :context :fresh} + (fn [rtx] (camera/load! rtx))) (core/defcase :rects/pan :rects {:params default-params :view base-view :context :reuse - :completion :render-full}) + :completion :render-full + :operation {:steps 20 :dx 200 :dy 0 :settle-ms 100}} + (fn [rtx] (camera/pan! rtx))) (core/defcase :rects/zoom :rects {:params default-params :view base-view :context :reuse - :completion :render-full}) + :completion :render-full + :operation {:steps 20 :factor 1.5 :settle-ms 100}} + (fn [rtx] (camera/zoom! rtx)))