mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02:00
♻️ Rename fill to fills namespace
This commit is contained in:
parent
158f759cde
commit
4e2998a366
18 changed files with 75 additions and 74 deletions
|
@ -26,7 +26,7 @@
|
||||||
[app.common.types.component :as ctk]
|
[app.common.types.component :as ctk]
|
||||||
[app.common.types.container :as ctn]
|
[app.common.types.container :as ctn]
|
||||||
[app.common.types.file :as ctf]
|
[app.common.types.file :as ctf]
|
||||||
[app.common.types.fill :as types.fill]
|
[app.common.types.fills :as types.fills]
|
||||||
[app.common.types.path :as path]
|
[app.common.types.path :as path]
|
||||||
[app.common.types.path.segment :as path.segment]
|
[app.common.types.path.segment :as path.segment]
|
||||||
[app.common.types.shape :as cts]
|
[app.common.types.shape :as cts]
|
||||||
|
@ -838,7 +838,7 @@
|
||||||
(d/update-when :components d/update-vals update-container))))
|
(d/update-when :components d/update-vals update-container))))
|
||||||
|
|
||||||
(def ^:private valid-fill?
|
(def ^:private valid-fill?
|
||||||
(sm/lazy-validator types.fill/schema:fill))
|
(sm/lazy-validator types.fills/schema:fill))
|
||||||
|
|
||||||
(defmethod migrate-data "legacy-43"
|
(defmethod migrate-data "legacy-43"
|
||||||
[data _]
|
[data _]
|
||||||
|
@ -1466,7 +1466,7 @@
|
||||||
|
|
||||||
(clear-fill [fill]
|
(clear-fill [fill]
|
||||||
(-> fill
|
(-> fill
|
||||||
(select-keys types.fill/fill-attrs)
|
(select-keys types.fills/fill-attrs)
|
||||||
(d/update-when :fill-image clear-color-image)
|
(d/update-when :fill-image clear-color-image)
|
||||||
(d/update-when :fill-color-gradient clear-color-gradient)))
|
(d/update-when :fill-color-gradient clear-color-gradient)))
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) KALEIDOS INC
|
;; Copyright (c) KALEIDOS INC
|
||||||
|
|
||||||
(ns app.common.types.fill
|
(ns app.common.types.fills
|
||||||
(:require
|
(:require
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.common.types.color :as types.color]
|
[app.common.types.color :as types.color]
|
||||||
[app.common.types.fill.impl :as impl]
|
[app.common.types.fills.impl :as impl]
|
||||||
[clojure.set :as set]))
|
[clojure.set :as set]))
|
||||||
|
|
||||||
(def ^:const MAX-GRADIENT-STOPS impl/MAX-GRADIENT-STOPS)
|
(def ^:const MAX-GRADIENT-STOPS impl/MAX-GRADIENT-STOPS)
|
|
@ -4,7 +4,7 @@
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) KALEIDOS INC
|
;; Copyright (c) KALEIDOS INC
|
||||||
|
|
||||||
(ns app.common.types.fill.impl
|
(ns app.common.types.fills.impl
|
||||||
(:require
|
(:require
|
||||||
#?(:clj [clojure.data.json :as json])
|
#?(:clj [clojure.data.json :as json])
|
||||||
#?(:cljs [app.common.weak-map :as weak-map])
|
#?(:cljs [app.common.weak-map :as weak-map])
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
(def ^:cosnt bool-group-style-properties bool/group-style-properties)
|
(def ^:cosnt bool-group-style-properties bool/group-style-properties)
|
||||||
(def ^:const bool-style-properties bool/style-properties)
|
(def ^:const bool-style-properties bool/style-properties)
|
||||||
|
|
||||||
(def ^:const default-bool-fills bool/default-fills)
|
(def ^:const default-bool-fills bool/default-fills)
|
||||||
|
|
||||||
(def schema:content impl/schema:content)
|
(def schema:content impl/schema:content)
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
[app.common.text :as txt]
|
[app.common.text :as txt]
|
||||||
[app.common.transit :as t]
|
[app.common.transit :as t]
|
||||||
[app.common.types.color :as types.color]
|
[app.common.types.color :as types.color]
|
||||||
[app.common.types.fill :refer [schema:fill]]
|
[app.common.types.fills :refer [schema:fill]]
|
||||||
[app.common.types.grid :as ctg]
|
[app.common.types.grid :as ctg]
|
||||||
[app.common.types.path :as path]
|
[app.common.types.path :as path]
|
||||||
[app.common.types.path.segment :as path.segment]
|
[app.common.types.path.segment :as path.segment]
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
(ns app.common.types.shape.text
|
(ns app.common.types.shape.text
|
||||||
(:require
|
(:require
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.common.types.fill :refer [schema:fill]]
|
[app.common.types.fills :refer [schema:fill]]
|
||||||
[app.common.types.shape :as-alias shape]
|
[app.common.types.shape :as-alias shape]
|
||||||
[app.common.types.shape.text.position-data :as-alias position-data]))
|
[app.common.types.shape.text.position-data :as-alias position-data]))
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
(t/use-fixtures :each thi/test-fixture)
|
(t/use-fixtures :each thi/test-fixture)
|
||||||
|
|
||||||
|
|
||||||
(t/deftest test-sync-unchanged-copy-when-changed-attribute
|
(t/deftest sync-unchanged-copy-when-changed-attribute
|
||||||
(let [;; ==== Setup
|
(let [;; ==== Setup
|
||||||
file (-> (thf/sample-file :file1)
|
file (-> (thf/sample-file :file1)
|
||||||
(tho/add-frame-with-text :main-root :main-child "hello world")
|
(tho/add-frame-with-text :main-root :main-child "hello world")
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
(t/is (= "32" (:font-size line)))
|
(t/is (= "32" (:font-size line)))
|
||||||
(t/is (= "hello world" (:text line)))))
|
(t/is (= "hello world" (:text line)))))
|
||||||
|
|
||||||
(t/deftest test-sync-unchanged-copy-when-changed-text
|
(t/deftest sync-unchanged-copy-when-changed-text
|
||||||
(let [;; ==== Setup
|
(let [;; ==== Setup
|
||||||
file (-> (thf/sample-file :file1)
|
file (-> (thf/sample-file :file1)
|
||||||
(tho/add-frame-with-text :main-root :main-child "hello world")
|
(tho/add-frame-with-text :main-root :main-child "hello world")
|
||||||
|
@ -91,7 +91,7 @@
|
||||||
(t/is (= "14" (:font-size line)))
|
(t/is (= "14" (:font-size line)))
|
||||||
(t/is (= "Bye" (:text line)))))
|
(t/is (= "Bye" (:text line)))))
|
||||||
|
|
||||||
(t/deftest test-sync-unchanged-copy-when-changed-both
|
(t/deftest sync-unchanged-copy-when-changed-both
|
||||||
(let [;; ==== Setup
|
(let [;; ==== Setup
|
||||||
file (-> (thf/sample-file :file1)
|
file (-> (thf/sample-file :file1)
|
||||||
(tho/add-frame-with-text :main-root :main-child "hello world")
|
(tho/add-frame-with-text :main-root :main-child "hello world")
|
||||||
|
@ -129,7 +129,7 @@
|
||||||
(t/is (= "32" (:font-size line)))
|
(t/is (= "32" (:font-size line)))
|
||||||
(t/is (= "Bye" (:text line)))))
|
(t/is (= "Bye" (:text line)))))
|
||||||
|
|
||||||
(t/deftest test-sync-updated-attr-copy-when-changed-attribute
|
(t/deftest sync-updated-attr-copy-when-changed-attribute
|
||||||
(let [;; ==== Setup
|
(let [;; ==== Setup
|
||||||
file0 (-> (thf/sample-file :file1)
|
file0 (-> (thf/sample-file :file1)
|
||||||
(tho/add-frame-with-text :main-root :main-child "hello world")
|
(tho/add-frame-with-text :main-root :main-child "hello world")
|
||||||
|
@ -176,7 +176,7 @@
|
||||||
(t/is (= "14" (:font-size line)))
|
(t/is (= "14" (:font-size line)))
|
||||||
(t/is (= "hello world" (:text line)))))
|
(t/is (= "hello world" (:text line)))))
|
||||||
|
|
||||||
(t/deftest test-sync-updated-attr-copy-when-changed-text
|
(t/deftest sync-updated-attr-copy-when-changed-text
|
||||||
(let [;; ==== Setup
|
(let [;; ==== Setup
|
||||||
file0 (-> (thf/sample-file :file1)
|
file0 (-> (thf/sample-file :file1)
|
||||||
(tho/add-frame-with-text :main-root :main-child "hello world")
|
(tho/add-frame-with-text :main-root :main-child "hello world")
|
||||||
|
@ -223,7 +223,7 @@
|
||||||
;; The text is updated because only attrs were touched
|
;; The text is updated because only attrs were touched
|
||||||
(t/is (= "Bye" (:text line)))))
|
(t/is (= "Bye" (:text line)))))
|
||||||
|
|
||||||
(t/deftest test-sync-updated-attr-copy-when-changed-both
|
(t/deftest sync-updated-attr-copy-when-changed-both
|
||||||
(let [;; ==== Setup
|
(let [;; ==== Setup
|
||||||
file0 (-> (thf/sample-file :file1)
|
file0 (-> (thf/sample-file :file1)
|
||||||
(tho/add-frame-with-text :main-root :main-child "hello world")
|
(tho/add-frame-with-text :main-root :main-child "hello world")
|
||||||
|
@ -273,7 +273,7 @@
|
||||||
;; The text is updated because only attrs were touched
|
;; The text is updated because only attrs were touched
|
||||||
(t/is (= "Bye" (:text line)))))
|
(t/is (= "Bye" (:text line)))))
|
||||||
|
|
||||||
(t/deftest test-sync-updated-text-copy-when-changed-attribute
|
(t/deftest sync-updated-text-copy-when-changed-attribute
|
||||||
(let [;; ==== Setup
|
(let [;; ==== Setup
|
||||||
file0 (-> (thf/sample-file :file1)
|
file0 (-> (thf/sample-file :file1)
|
||||||
(tho/add-frame-with-text :main-root :main-child "hello world")
|
(tho/add-frame-with-text :main-root :main-child "hello world")
|
||||||
|
@ -320,7 +320,7 @@
|
||||||
(t/is (= "32" (:font-size line)))
|
(t/is (= "32" (:font-size line)))
|
||||||
(t/is (= "Hi" (:text line)))))
|
(t/is (= "Hi" (:text line)))))
|
||||||
|
|
||||||
(t/deftest test-sync-updated-text-copy-when-changed-text
|
(t/deftest sync-updated-text-copy-when-changed-text
|
||||||
(let [;; ==== Setup
|
(let [;; ==== Setup
|
||||||
file0 (-> (thf/sample-file :file1)
|
file0 (-> (thf/sample-file :file1)
|
||||||
(tho/add-frame-with-text :main-root :main-child "hello world")
|
(tho/add-frame-with-text :main-root :main-child "hello world")
|
||||||
|
@ -367,7 +367,7 @@
|
||||||
;; The text doesn't change, because it was touched
|
;; The text doesn't change, because it was touched
|
||||||
(t/is (= "Hi" (:text line)))))
|
(t/is (= "Hi" (:text line)))))
|
||||||
|
|
||||||
(t/deftest test-sync-updated-text-copy-when-changed-both
|
(t/deftest sync-updated-text-copy-when-changed-both
|
||||||
(let [;; ==== Setup
|
(let [;; ==== Setup
|
||||||
file0 (-> (thf/sample-file :file1)
|
file0 (-> (thf/sample-file :file1)
|
||||||
(tho/add-frame-with-text :main-root :main-child "hello world")
|
(tho/add-frame-with-text :main-root :main-child "hello world")
|
||||||
|
@ -417,7 +417,7 @@
|
||||||
;; The text doesn't change, because it was touched
|
;; The text doesn't change, because it was touched
|
||||||
(t/is (= "Hi" (:text line)))))
|
(t/is (= "Hi" (:text line)))))
|
||||||
|
|
||||||
(t/deftest test-sync-updated-both-copy-when-changed-attribute
|
(t/deftest sync-updated-both-copy-when-changed-attribute
|
||||||
(let [;; ==== Setup
|
(let [;; ==== Setup
|
||||||
file0 (-> (thf/sample-file :file1)
|
file0 (-> (thf/sample-file :file1)
|
||||||
(tho/add-frame-with-text :main-root :main-child "hello world")
|
(tho/add-frame-with-text :main-root :main-child "hello world")
|
||||||
|
@ -466,7 +466,7 @@
|
||||||
(t/is (= "14" (:font-size line)))
|
(t/is (= "14" (:font-size line)))
|
||||||
(t/is (= "Hi" (:text line)))))
|
(t/is (= "Hi" (:text line)))))
|
||||||
|
|
||||||
(t/deftest test-sync-updated-both-copy-when-changed-text
|
(t/deftest sync-updated-both-copy-when-changed-text
|
||||||
(let [;; ==== Setup
|
(let [;; ==== Setup
|
||||||
file0 (-> (thf/sample-file :file1)
|
file0 (-> (thf/sample-file :file1)
|
||||||
(tho/add-frame-with-text :main-root :main-child "hello world")
|
(tho/add-frame-with-text :main-root :main-child "hello world")
|
||||||
|
@ -515,7 +515,7 @@
|
||||||
;; The text doesn't change, because it was touched
|
;; The text doesn't change, because it was touched
|
||||||
(t/is (= "Hi" (:text line)))))
|
(t/is (= "Hi" (:text line)))))
|
||||||
|
|
||||||
(t/deftest test-sync-updated-both-copy-when-changed-both
|
(t/deftest sync-updated-both-copy-when-changed-both
|
||||||
(let [;; ==== Setup
|
(let [;; ==== Setup
|
||||||
file0 (-> (thf/sample-file :file1)
|
file0 (-> (thf/sample-file :file1)
|
||||||
(tho/add-frame-with-text :main-root :main-child "hello world")
|
(tho/add-frame-with-text :main-root :main-child "hello world")
|
||||||
|
@ -567,7 +567,7 @@
|
||||||
;; The text doesn't change, because it was touched
|
;; The text doesn't change, because it was touched
|
||||||
(t/is (= "Hi" (:text line)))))
|
(t/is (= "Hi" (:text line)))))
|
||||||
|
|
||||||
(t/deftest test-sync-updated-structure-same-attrs-copy-when-changed-attribute
|
(t/deftest sync-updated-structure-same-attrs-copy-when-changed-attribute
|
||||||
(let [;; ==== Setup
|
(let [;; ==== Setup
|
||||||
file0 (-> (thf/sample-file :file1)
|
file0 (-> (thf/sample-file :file1)
|
||||||
(tho/add-frame-with-text :main-root :main-child "hello world")
|
(tho/add-frame-with-text :main-root :main-child "hello world")
|
||||||
|
@ -619,7 +619,7 @@
|
||||||
(t/is (= "32" (:font-size line)))
|
(t/is (= "32" (:font-size line)))
|
||||||
(t/is (= "hello world" (:text line)))))
|
(t/is (= "hello world" (:text line)))))
|
||||||
|
|
||||||
(t/deftest test-sync-updated-structure-same-attrs-copy-when-changed-text
|
(t/deftest sync-updated-structure-same-attrs-copy-when-changed-text
|
||||||
(let [;; ==== Setup
|
(let [;; ==== Setup
|
||||||
file0 (-> (thf/sample-file :file1)
|
file0 (-> (thf/sample-file :file1)
|
||||||
(tho/add-frame-with-text :main-root :main-child "hello world")
|
(tho/add-frame-with-text :main-root :main-child "hello world")
|
||||||
|
@ -668,7 +668,7 @@
|
||||||
;; The text doesn't change, because the structure was touched
|
;; The text doesn't change, because the structure was touched
|
||||||
(t/is (= "hello world" (:text line)))))
|
(t/is (= "hello world" (:text line)))))
|
||||||
|
|
||||||
(t/deftest test-sync-updated-structure-same-attrs-copy-when-changed-both
|
(t/deftest sync-updated-structure-same-attrs-copy-when-changed-both
|
||||||
(let [;; ==== Setup
|
(let [;; ==== Setup
|
||||||
file0 (-> (thf/sample-file :file1)
|
file0 (-> (thf/sample-file :file1)
|
||||||
(tho/add-frame-with-text :main-root :main-child "hello world")
|
(tho/add-frame-with-text :main-root :main-child "hello world")
|
||||||
|
@ -722,7 +722,7 @@
|
||||||
;; The text doesn't change, because the structure was touched
|
;; The text doesn't change, because the structure was touched
|
||||||
(t/is (= "hello world" (:text line)))))
|
(t/is (= "hello world" (:text line)))))
|
||||||
|
|
||||||
(t/deftest test-sync-updated-structure-diff-attrs-copy-when-changed-attribute
|
(t/deftest sync-updated-structure-diff-attrs-copy-when-changed-attribute
|
||||||
(let [;; ==== Setup
|
(let [;; ==== Setup
|
||||||
file0 (-> (thf/sample-file :file1)
|
file0 (-> (thf/sample-file :file1)
|
||||||
(tho/add-frame-with-text :main-root :main-child "hello world")
|
(tho/add-frame-with-text :main-root :main-child "hello world")
|
||||||
|
@ -775,7 +775,7 @@
|
||||||
(t/is (= "14" (:font-size line)))
|
(t/is (= "14" (:font-size line)))
|
||||||
(t/is (= "hello world" (:text line)))))
|
(t/is (= "hello world" (:text line)))))
|
||||||
|
|
||||||
(t/deftest test-sync-updated-structure-diff-attrs-copy-when-changed-text
|
(t/deftest sync-updated-structure-diff-attrs-copy-when-changed-text
|
||||||
(let [;; ==== Setup
|
(let [;; ==== Setup
|
||||||
file0 (-> (thf/sample-file :file1)
|
file0 (-> (thf/sample-file :file1)
|
||||||
(tho/add-frame-with-text :main-root :main-child "hello world")
|
(tho/add-frame-with-text :main-root :main-child "hello world")
|
||||||
|
@ -825,7 +825,7 @@
|
||||||
;; The text doesn't change, because the structure was touched
|
;; The text doesn't change, because the structure was touched
|
||||||
(t/is (= "hello world" (:text line)))))
|
(t/is (= "hello world" (:text line)))))
|
||||||
|
|
||||||
(t/deftest test-sync-updated-structure-diff-attrs-copy-when-changed-both
|
(t/deftest sync-updated-structure-diff-attrs-copy-when-changed-both
|
||||||
(let [;; ==== Setup
|
(let [;; ==== Setup
|
||||||
file0 (-> (thf/sample-file :file1)
|
file0 (-> (thf/sample-file :file1)
|
||||||
(tho/add-frame-with-text :main-root :main-child "hello world")
|
(tho/add-frame-with-text :main-root :main-child "hello world")
|
||||||
|
@ -878,4 +878,4 @@
|
||||||
;; The attr doesn't change, because not all the attrs on the structure are equal
|
;; The attr doesn't change, because not all the attrs on the structure are equal
|
||||||
(t/is (= "14" (:font-size line)))
|
(t/is (= "14" (:font-size line)))
|
||||||
;; The text doesn't change, because the structure was touched
|
;; The text doesn't change, because the structure was touched
|
||||||
(t/is (= "hello world" (:text line)))))
|
(t/is (= "hello world" (:text line)))))
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
[app.common.schema.generators :as sg]
|
[app.common.schema.generators :as sg]
|
||||||
[app.common.schema.test :as smt]
|
[app.common.schema.test :as smt]
|
||||||
[app.common.transit :as trans]
|
[app.common.transit :as trans]
|
||||||
[app.common.types.fill :as types.fill]
|
[app.common.types.fills :as types.fills]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[clojure.test :as t]))
|
[clojure.test :as t]))
|
||||||
|
|
||||||
|
@ -85,8 +85,8 @@
|
||||||
:fill-opacity 0.7})
|
:fill-opacity 0.7})
|
||||||
|
|
||||||
(t/deftest build-from-plain-1
|
(t/deftest build-from-plain-1
|
||||||
(let [fills (types.fill/from-plain [sample-fill-1])]
|
(let [fills (types.fills/from-plain [sample-fill-1])]
|
||||||
(t/is (types.fill/fills? fills))
|
(t/is (types.fills/fills? fills))
|
||||||
(t/is (= 1 (count fills)))
|
(t/is (= 1 (count fills)))
|
||||||
(t/is (equivalent-fill? (first fills) sample-fill-1))))
|
(t/is (equivalent-fill? (first fills) sample-fill-1))))
|
||||||
|
|
||||||
|
@ -99,8 +99,8 @@
|
||||||
:keep-aspect-ratio false}})
|
:keep-aspect-ratio false}})
|
||||||
|
|
||||||
(t/deftest build-from-plain-2
|
(t/deftest build-from-plain-2
|
||||||
(let [fills (types.fill/from-plain [sample-fill-2])]
|
(let [fills (types.fills/from-plain [sample-fill-2])]
|
||||||
(t/is (types.fill/fills? fills))
|
(t/is (types.fills/fills? fills))
|
||||||
(t/is (= 1 (count fills)))
|
(t/is (= 1 (count fills)))
|
||||||
(t/is (equivalent-fill? (first fills) sample-fill-2))))
|
(t/is (equivalent-fill? (first fills) sample-fill-2))))
|
||||||
|
|
||||||
|
@ -117,8 +117,8 @@
|
||||||
:stops [{:color "#631aa8", :offset 0.5}]}})
|
:stops [{:color "#631aa8", :offset 0.5}]}})
|
||||||
|
|
||||||
(t/deftest build-from-plain-3
|
(t/deftest build-from-plain-3
|
||||||
(let [fills (types.fill/from-plain [sample-fill-3])]
|
(let [fills (types.fills/from-plain [sample-fill-3])]
|
||||||
(t/is (types.fill/fills? fills))
|
(t/is (types.fills/fills? fills))
|
||||||
(t/is (= 1 (count fills)))
|
(t/is (= 1 (count fills)))
|
||||||
(t/is (equivalent-fill? (first fills) sample-fill-3))))
|
(t/is (equivalent-fill? (first fills) sample-fill-3))))
|
||||||
|
|
||||||
|
@ -136,8 +136,8 @@
|
||||||
:fill-color-ref-id #uuid "2eef07f1-e38a-8062-8006-3aa264d5b785"})
|
:fill-color-ref-id #uuid "2eef07f1-e38a-8062-8006-3aa264d5b785"})
|
||||||
|
|
||||||
(t/deftest build-from-plain-4
|
(t/deftest build-from-plain-4
|
||||||
(let [fills (types.fill/from-plain [sample-fill-4])]
|
(let [fills (types.fills/from-plain [sample-fill-4])]
|
||||||
(t/is (types.fill/fills? fills))
|
(t/is (types.fills/fills? fills))
|
||||||
(t/is (= 1 (count fills)))
|
(t/is (= 1 (count fills)))
|
||||||
(t/is (equivalent-fill? (first fills) sample-fill-4))))
|
(t/is (equivalent-fill? (first fills) sample-fill-4))))
|
||||||
|
|
||||||
|
@ -154,8 +154,8 @@
|
||||||
:stops [{:color "#bba1aa", :opacity 0.37, :offset 0.84}]}})
|
:stops [{:color "#bba1aa", :opacity 0.37, :offset 0.84}]}})
|
||||||
|
|
||||||
(t/deftest build-from-plain-5
|
(t/deftest build-from-plain-5
|
||||||
(let [fills (types.fill/from-plain [sample-fill-5])]
|
(let [fills (types.fills/from-plain [sample-fill-5])]
|
||||||
(t/is (types.fill/fills? fills))
|
(t/is (types.fills/fills? fills))
|
||||||
(t/is (= 1 (count fills)))
|
(t/is (= 1 (count fills)))
|
||||||
(t/is (equivalent-fill? (first fills) sample-fill-5))))
|
(t/is (equivalent-fill? (first fills) sample-fill-5))))
|
||||||
|
|
||||||
|
@ -170,14 +170,14 @@
|
||||||
:stops [{:color "#e15610", :offset 0.4} {:color "#005a9e", :opacity 0.62, :offset 0.81}]}})
|
:stops [{:color "#e15610", :offset 0.4} {:color "#005a9e", :opacity 0.62, :offset 0.81}]}})
|
||||||
|
|
||||||
(t/deftest build-from-plain-6
|
(t/deftest build-from-plain-6
|
||||||
(let [fills (types.fill/from-plain [sample-fill-6])]
|
(let [fills (types.fills/from-plain [sample-fill-6])]
|
||||||
(t/is (types.fill/fills? fills))
|
(t/is (types.fills/fills? fills))
|
||||||
(t/is (= 1 (count fills)))
|
(t/is (= 1 (count fills)))
|
||||||
(t/is (equivalent-fill? (first fills) sample-fill-6))))
|
(t/is (equivalent-fill? (first fills) sample-fill-6))))
|
||||||
|
|
||||||
(t/deftest fills-datatype-roundtrip
|
(t/deftest fills-datatype-roundtrip
|
||||||
(smt/check!
|
(smt/check!
|
||||||
(smt/for [fill (->> (sg/generator types.fill/schema:fill)
|
(smt/for [fill (->> (sg/generator types.fills/schema:fill)
|
||||||
(sg/fmap d/without-nils)
|
(sg/fmap d/without-nils)
|
||||||
(sg/fmap (fn [fill]
|
(sg/fmap (fn [fill]
|
||||||
(cond-> fill
|
(cond-> fill
|
||||||
|
@ -187,27 +187,27 @@
|
||||||
(contains? fill :fill-color-ref-file)))
|
(contains? fill :fill-color-ref-file)))
|
||||||
(-> (assoc :fill-color-ref-file (uuid/next))
|
(-> (assoc :fill-color-ref-file (uuid/next))
|
||||||
(assoc :fill-color-ref-id (uuid/next)))))))]
|
(assoc :fill-color-ref-id (uuid/next)))))))]
|
||||||
(let [bfills (types.fill/from-plain [fill])]
|
(let [bfills (types.fills/from-plain [fill])]
|
||||||
(and (= (count bfills) 1)
|
(and (= (count bfills) 1)
|
||||||
(equivalent-fill? (first bfills) fill))))
|
(equivalent-fill? (first bfills) fill))))
|
||||||
{:num 2000}))
|
{:num 2000}))
|
||||||
|
|
||||||
(t/deftest equality-operation
|
(t/deftest equality-operation
|
||||||
(let [fills1 (types.fill/from-plain [sample-fill-6])
|
(let [fills1 (types.fills/from-plain [sample-fill-6])
|
||||||
fills2 (types.fill/from-plain [sample-fill-6])]
|
fills2 (types.fills/from-plain [sample-fill-6])]
|
||||||
(t/is (= fills1 fills2))))
|
(t/is (= fills1 fills2))))
|
||||||
|
|
||||||
(t/deftest reduce-impl
|
(t/deftest reduce-impl
|
||||||
(let [fills1 (types.fill/from-plain [sample-fill-6])
|
(let [fills1 (types.fills/from-plain [sample-fill-6])
|
||||||
fills2 (reduce (fn [result fill]
|
fills2 (reduce (fn [result fill]
|
||||||
(conj result fill))
|
(conj result fill))
|
||||||
[]
|
[]
|
||||||
fills1)
|
fills1)
|
||||||
fills3 (types.fill/from-plain fills2)]
|
fills3 (types.fills/from-plain fills2)]
|
||||||
(t/is (= fills1 fills3))))
|
(t/is (= fills1 fills3))))
|
||||||
|
|
||||||
(t/deftest indexed-access
|
(t/deftest indexed-access
|
||||||
(let [fills1 (types.fill/from-plain [sample-fill-6])
|
(let [fills1 (types.fills/from-plain [sample-fill-6])
|
||||||
fill0 (nth fills1 0)
|
fill0 (nth fills1 0)
|
||||||
fill1 (nth fills1 1)]
|
fill1 (nth fills1 1)]
|
||||||
(t/is (nil? fill1))
|
(t/is (nil? fill1))
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
[app.common.logic.shapes :as cls]
|
[app.common.logic.shapes :as cls]
|
||||||
[app.common.transit :as t]
|
[app.common.transit :as t]
|
||||||
[app.common.types.component :as ctc]
|
[app.common.types.component :as ctc]
|
||||||
[app.common.types.fill :as types.fill]
|
[app.common.types.fills :as types.fills]
|
||||||
[app.common.types.shape :as cts]
|
[app.common.types.shape :as cts]
|
||||||
[app.common.types.shape-tree :as ctst]
|
[app.common.types.shape-tree :as ctst]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
|
@ -144,7 +144,7 @@
|
||||||
(letfn [(process-map-form [form]
|
(letfn [(process-map-form [form]
|
||||||
(let [fills (get form :fills)]
|
(let [fills (get form :fills)]
|
||||||
(if (vector? fills)
|
(if (vector? fills)
|
||||||
(assoc form :fills (types.fill/from-plain fills))
|
(assoc form :fills (types.fills/from-plain fills))
|
||||||
form)))
|
form)))
|
||||||
|
|
||||||
(process-form [form]
|
(process-form [form]
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.common.text :as txt]
|
[app.common.text :as txt]
|
||||||
[app.common.types.color :as types.color]
|
[app.common.types.color :as types.color]
|
||||||
[app.common.types.fill :as types.fill]
|
[app.common.types.fills :as types.fills]
|
||||||
[app.common.types.shape :as shp]
|
[app.common.types.shape :as shp]
|
||||||
[app.common.types.shape.shadow :refer [check-shadow]]
|
[app.common.types.shape.shadow :refer [check-shadow]]
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
|
@ -153,7 +153,7 @@
|
||||||
(d/without-nils)
|
(d/without-nils)
|
||||||
|
|
||||||
:always
|
:always
|
||||||
(types.fill/check-fill))
|
(types.fills/check-fill))
|
||||||
|
|
||||||
transform-attrs
|
transform-attrs
|
||||||
#(transform % fill)]
|
#(transform % fill)]
|
||||||
|
@ -893,7 +893,7 @@
|
||||||
(update state :colorpicker
|
(update state :colorpicker
|
||||||
(fn [{:keys [stops editing-stop] :as state}]
|
(fn [{:keys [stops editing-stop] :as state}]
|
||||||
(let [cap-stops? (or (features/active-feature? state "render-wasm/v1") (contains? cfg/flags :frontend-binary-fills))
|
(let [cap-stops? (or (features/active-feature? state "render-wasm/v1") (contains? cfg/flags :frontend-binary-fills))
|
||||||
can-add-stop? (or (not cap-stops?) (< (count stops) types.fill/MAX-GRADIENT-STOPS))]
|
can-add-stop? (or (not cap-stops?) (< (count stops) types.fills/MAX-GRADIENT-STOPS))]
|
||||||
(if can-add-stop?
|
(if can-add-stop?
|
||||||
(if (cc/uniform-spread? stops)
|
(if (cc/uniform-spread? stops)
|
||||||
;; Add to uniform
|
;; Add to uniform
|
||||||
|
@ -939,7 +939,7 @@
|
||||||
(fn [state]
|
(fn [state]
|
||||||
(let [stops (:stops state)
|
(let [stops (:stops state)
|
||||||
cap-stops? (or (features/active-feature? state "render-wasm/v1") (contains? cfg/flags :frontend-binary-fills))
|
cap-stops? (or (features/active-feature? state "render-wasm/v1") (contains? cfg/flags :frontend-binary-fills))
|
||||||
can-add-stop? (or (not cap-stops?) (< (count stops) types.fill/MAX-GRADIENT-STOPS))]
|
can-add-stop? (or (not cap-stops?) (< (count stops) types.fills/MAX-GRADIENT-STOPS))]
|
||||||
(if can-add-stop? (let [new-stop (-> (cc/interpolate-gradient stops offset)
|
(if can-add-stop? (let [new-stop (-> (cc/interpolate-gradient stops offset)
|
||||||
(split-color-components))
|
(split-color-components))
|
||||||
stops (conj stops new-stop)
|
stops (conj stops new-stop)
|
||||||
|
@ -963,7 +963,7 @@
|
||||||
(contains? cfg/flags :frontend-binary-fills))
|
(contains? cfg/flags :frontend-binary-fills))
|
||||||
stops (mapv split-color-components
|
stops (mapv split-color-components
|
||||||
(if cap-stops?
|
(if cap-stops?
|
||||||
(take types.fill/MAX-GRADIENT-STOPS stops)
|
(take types.fills/MAX-GRADIENT-STOPS stops)
|
||||||
stops))]
|
stops))]
|
||||||
(-> state
|
(-> state
|
||||||
(assoc :current-color (get stops stop))
|
(assoc :current-color (get stops stop))
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
[app.common.text :as txt]
|
[app.common.text :as txt]
|
||||||
[app.common.types.fill :as types.fill]
|
[app.common.types.fills :as types.fills]
|
||||||
[app.common.types.modifiers :as ctm]
|
[app.common.types.modifiers :as ctm]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.main.data.event :as ev]
|
[app.main.data.event :as ev]
|
||||||
|
@ -237,7 +237,7 @@
|
||||||
|
|
||||||
(defn- to-new-fills
|
(defn- to-new-fills
|
||||||
[data]
|
[data]
|
||||||
[(d/without-nils (select-keys data types.fill/fill-attrs))])
|
[(d/without-nils (select-keys data types.fills/fill-attrs))])
|
||||||
|
|
||||||
(defn- shape-current-values
|
(defn- shape-current-values
|
||||||
[shape pred attrs]
|
[shape pred attrs]
|
||||||
|
@ -247,7 +247,7 @@
|
||||||
(if (txt/is-text-node? node)
|
(if (txt/is-text-node? node)
|
||||||
(let [fills
|
(let [fills
|
||||||
(cond
|
(cond
|
||||||
(types.fill/has-valid-fill-attrs? node)
|
(types.fills/has-valid-fill-attrs? node)
|
||||||
(to-new-fills node)
|
(to-new-fills node)
|
||||||
|
|
||||||
(some? (:fills node))
|
(some? (:fills node))
|
||||||
|
@ -466,7 +466,7 @@
|
||||||
|
|
||||||
(defn migrate-node
|
(defn migrate-node
|
||||||
[node]
|
[node]
|
||||||
(let [color-attrs (not-empty (select-keys node types.fill/fill-attrs))]
|
(let [color-attrs (not-empty (select-keys node types.fills/fill-attrs))]
|
||||||
(cond-> node
|
(cond-> node
|
||||||
(nil? (:fills node))
|
(nil? (:fills node))
|
||||||
(assoc :fills [])
|
(assoc :fills [])
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.geom.matrix :as gmt]
|
[app.common.geom.matrix :as gmt]
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.types.fill :as types.fill]
|
[app.common.types.fills :as types.fills]
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.main.data.event :as-alias ev]
|
[app.main.data.event :as-alias ev]
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
@ -413,7 +413,7 @@
|
||||||
(when (= selected-mode :gradient)
|
(when (= selected-mode :gradient)
|
||||||
[:> gradients*
|
[:> gradients*
|
||||||
{:type (:type state)
|
{:type (:type state)
|
||||||
:stops (if cap-stops? (vec (take types.fill/MAX-GRADIENT-STOPS (:stops state))) (:stops state))
|
:stops (if cap-stops? (vec (take types.fills/MAX-GRADIENT-STOPS (:stops state))) (:stops state))
|
||||||
:editing-stop (:editing-stop state)
|
:editing-stop (:editing-stop state)
|
||||||
:on-stop-edit-start handle-stop-edit-start
|
:on-stop-edit-start handle-stop-edit-start
|
||||||
:on-stop-edit-finish handle-stop-edit-finish
|
:on-stop-edit-finish handle-stop-edit-finish
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
[app.common.types.fill :as types.fill]
|
[app.common.types.fills :as types.fills]
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.main.features :as features]
|
[app.main.features :as features]
|
||||||
[app.main.ui.components.numeric-input :refer [numeric-input*]]
|
[app.main.ui.components.numeric-input :refer [numeric-input*]]
|
||||||
|
@ -288,7 +288,7 @@
|
||||||
(when on-reverse-stops
|
(when on-reverse-stops
|
||||||
(on-reverse-stops))))
|
(on-reverse-stops))))
|
||||||
cap-stops? (or (features/use-feature "render-wasm/v1") (contains? cfg/flags :frontend-binary-fills))
|
cap-stops? (or (features/use-feature "render-wasm/v1") (contains? cfg/flags :frontend-binary-fills))
|
||||||
add-stop-disabled? (when cap-stops? (>= (count stops) types.fill/MAX-GRADIENT-STOPS))]
|
add-stop-disabled? (when cap-stops? (>= (count stops) types.fills/MAX-GRADIENT-STOPS))]
|
||||||
|
|
||||||
[:div {:class (stl/css :gradient-panel)}
|
[:div {:class (stl/css :gradient-panel)}
|
||||||
[:div {:class (stl/css :gradient-preview)}
|
[:div {:class (stl/css :gradient-preview)}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
(:require-macros [app.main.style :as stl])
|
(:require-macros [app.main.style :as stl])
|
||||||
(:require
|
(:require
|
||||||
[app.common.types.color :as ctc]
|
[app.common.types.color :as ctc]
|
||||||
[app.common.types.fill :as types.fill]
|
[app.common.types.fills :as types.fills]
|
||||||
[app.common.types.shape.attrs :refer [default-color]]
|
[app.common.types.shape.attrs :refer [default-color]]
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.main.data.workspace :as udw]
|
[app.main.data.workspace :as udw]
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
(def ^:private
|
(def ^:private
|
||||||
xf:take-max-fills
|
xf:take-max-fills
|
||||||
(take types.fill/MAX-FILLS))
|
(take types.fills/MAX-FILLS))
|
||||||
|
|
||||||
(def ^:private
|
(def ^:private
|
||||||
xf:enumerate
|
xf:enumerate
|
||||||
|
@ -101,7 +101,7 @@
|
||||||
can-add-fills?
|
can-add-fills?
|
||||||
(if binary-fills-enabled?
|
(if binary-fills-enabled?
|
||||||
(and (not multiple?)
|
(and (not multiple?)
|
||||||
(< (count fills) types.fill/MAX-FILLS))
|
(< (count fills) types.fills/MAX-FILLS))
|
||||||
(not ^boolean multiple?))
|
(not ^boolean multiple?))
|
||||||
|
|
||||||
label
|
label
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.common.geom.shapes.points :as gsp]
|
[app.common.geom.shapes.points :as gsp]
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
[app.common.types.fill :as types.fill]
|
[app.common.types.fills :as types.fills]
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.main.data.workspace.colors :as dc]
|
[app.main.data.workspace.colors :as dc]
|
||||||
[app.main.features :as features]
|
[app.main.features :as features]
|
||||||
|
@ -135,7 +135,7 @@
|
||||||
handler-state (mf/use-state {:display? false :offset 0 :hover nil})
|
handler-state (mf/use-state {:display? false :offset 0 :hover nil})
|
||||||
|
|
||||||
cap-stops? (or (features/use-feature "render-wasm/v1") (contains? cfg/flags :frontend-binary-fills))
|
cap-stops? (or (features/use-feature "render-wasm/v1") (contains? cfg/flags :frontend-binary-fills))
|
||||||
can-add-stop? (if cap-stops? (< (count stops) types.fill/MAX-GRADIENT-STOPS) true)
|
can-add-stop? (if cap-stops? (< (count stops) types.fills/MAX-GRADIENT-STOPS) true)
|
||||||
|
|
||||||
endpoint-on-pointer-down
|
endpoint-on-pointer-down
|
||||||
(fn [position event]
|
(fn [position event]
|
||||||
|
@ -527,7 +527,7 @@
|
||||||
gradient (:gradient state)
|
gradient (:gradient state)
|
||||||
cap-stops? (or (features/use-feature "render-wasm/v1") (contains? cfg/flags :frontend-binary-fills))
|
cap-stops? (or (features/use-feature "render-wasm/v1") (contains? cfg/flags :frontend-binary-fills))
|
||||||
stops (if cap-stops?
|
stops (if cap-stops?
|
||||||
(vec (take types.fill/MAX-GRADIENT-STOPS (:stops state)))
|
(vec (take types.fills/MAX-GRADIENT-STOPS (:stops state)))
|
||||||
(:stops state))
|
(:stops state))
|
||||||
editing-stop (:editing-stop state)]
|
editing-stop (:editing-stop state)]
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
[app.common.types.component :as ctk]
|
[app.common.types.component :as ctk]
|
||||||
[app.common.types.container :as ctn]
|
[app.common.types.container :as ctn]
|
||||||
[app.common.types.file :as ctf]
|
[app.common.types.file :as ctf]
|
||||||
[app.common.types.fill :as types.fill]
|
[app.common.types.fills :as types.fills]
|
||||||
[app.common.types.grid :as ctg]
|
[app.common.types.grid :as ctg]
|
||||||
[app.common.types.path :as path]
|
[app.common.types.path :as path]
|
||||||
[app.common.types.path.segment :as path.segm]
|
[app.common.types.path.segment :as path.segm]
|
||||||
|
@ -709,7 +709,7 @@
|
||||||
id (:id shape)
|
id (:id shape)
|
||||||
value (parser/parse-fills value)]
|
value (parser/parse-fills value)]
|
||||||
(cond
|
(cond
|
||||||
(not (sm/validate [:vector types.fill/schema:fill] value))
|
(not (sm/validate [:vector types.fills/schema:fill] value))
|
||||||
(u/display-not-valid :fills value)
|
(u/display-not-valid :fills value)
|
||||||
|
|
||||||
(cfh/text-shape? shape)
|
(cfh/text-shape? shape)
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.geom.matrix :as gmt]
|
[app.common.geom.matrix :as gmt]
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.types.fill :as types.fill]
|
[app.common.types.fills :as types.fills]
|
||||||
[app.common.types.path :as path]
|
[app.common.types.path :as path]
|
||||||
[app.common.types.shape.layout :as ctl]
|
[app.common.types.shape.layout :as ctl]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
|
@ -248,7 +248,7 @@
|
||||||
[shape-id fills]
|
[shape-id fills]
|
||||||
(if (empty? fills)
|
(if (empty? fills)
|
||||||
(h/call wasm/internal-module "_clear_shape_fills")
|
(h/call wasm/internal-module "_clear_shape_fills")
|
||||||
(let [fills (take types.fill/MAX-FILLS fills)
|
(let [fills (take types.fills/MAX-FILLS fills)
|
||||||
image-fills (filter :fill-image fills)
|
image-fills (filter :fill-image fills)
|
||||||
offset (mem/alloc-bytes (* (count fills) sr-fills/FILL-BYTE-SIZE))
|
offset (mem/alloc-bytes (* (count fills) sr-fills/FILL-BYTE-SIZE))
|
||||||
heap (mem/get-heap-u8)
|
heap (mem/get-heap-u8)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(ns app.render-wasm.serializers.fills
|
(ns app.render-wasm.serializers.fills
|
||||||
(:require
|
(:require
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.types.fill :as types.fill]
|
[app.common.types.fills :as types.fills]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.render-wasm.serializers.color :as clr]))
|
[app.render-wasm.serializers.color :as clr]))
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
end-x (:end-x gradient)
|
end-x (:end-x gradient)
|
||||||
end-y (:end-y gradient)
|
end-y (:end-y gradient)
|
||||||
width (or (:width gradient) 0)
|
width (or (:width gradient) 0)
|
||||||
stops (take types.fill/MAX-GRADIENT-STOPS (:stops gradient))
|
stops (take types.fills/MAX-GRADIENT-STOPS (:stops gradient))
|
||||||
type (if (= (:type gradient) :linear) 0x01 0x02)]
|
type (if (= (:type gradient) :linear) 0x01 0x02)]
|
||||||
(.setUint8 dview offset type true)
|
(.setUint8 dview offset type true)
|
||||||
(.setFloat32 dview (+ offset 4) start-x true)
|
(.setFloat32 dview (+ offset 4) start-x true)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue