mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-04 04:52:54 -05:00
Merge main into feat/scripts-pageitem-transforms
This commit is contained in:
commit
e61533b320
322 files changed
+16094
-2567
No files matched your search
@@ -26,7 +26,7 @@ jobs:
|
||||
uses: storytold/craft-common-actions/.github/workflows/gate.yml@main
|
||||
with:
|
||||
# Same craft-fonts commit as release.yml.
|
||||
craft-fonts-ref: b076417b5880bd4154bd22f00695b1d28c6bea83
|
||||
craft-fonts-ref: 16bbfc3d451fad51971ca3f2a28c1e69e279b67c
|
||||
# A cold `cache warm` leg (the nightly run, or any run after a toolchain or lockfile change)
|
||||
# took 90 minutes to reach its last three steps on 2026-11-27 and was canceled there; with
|
||||
# those steps and the save it needs about two hours.
|
||||
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
uses: storytold/craft-common-actions/.github/workflows/freebsd.yml@main
|
||||
with:
|
||||
require-craft-fonts: true
|
||||
craft-fonts-ref: b076417b5880bd4154bd22f00695b1d28c6bea83
|
||||
craft-fonts-ref: 16bbfc3d451fad51971ca3f2a28c1e69e279b67c
|
||||
run-package-check: true
|
||||
# The test builds of this workspace's largest crates (engine, ui-egui) need more than the
|
||||
# VM's 12 GB when two compile at once: the build was killed (exit 137) every night with
|
||||
|
||||
@@ -47,7 +47,7 @@ jobs:
|
||||
- name: Check out craft-fonts
|
||||
uses: storytold/craft-common-actions/actions/checkout-craft-fonts@main
|
||||
with:
|
||||
ref: b076417b5880bd4154bd22f00695b1d28c6bea83
|
||||
ref: 16bbfc3d451fad51971ca3f2a28c1e69e279b67c
|
||||
- id: rust
|
||||
uses: storytold/craft-common-actions/actions/rust-channel@main
|
||||
with:
|
||||
|
||||
@@ -28,7 +28,7 @@ jobs:
|
||||
tooling-revision: main
|
||||
app-name: vectorcraft
|
||||
manual-actors: '["bflatastic","dylanmtaylor","echelon","FredApps","skylartaylor"]'
|
||||
craft-fonts-ref: b076417b5880bd4154bd22f00695b1d28c6bea83
|
||||
craft-fonts-ref: 16bbfc3d451fad51971ca3f2a28c1e69e279b67c
|
||||
# One producer run builds every listed platform for one all-or-nothing release. The pin is the
|
||||
# craft-common-actions main commit that merged the exact-analysis admission (#371, after #370,
|
||||
# #369 and #364).
|
||||
|
||||
@@ -44,7 +44,7 @@ jobs:
|
||||
app-title: VectorCraft
|
||||
macos-runner: macos-15
|
||||
macos-split-build: true
|
||||
craft-fonts-ref: b076417b5880bd4154bd22f00695b1d28c6bea83
|
||||
craft-fonts-ref: 16bbfc3d451fad51971ca3f2a28c1e69e279b67c
|
||||
web-craft-fonts: true
|
||||
version: ${{ inputs.version }}
|
||||
contributors-artifact: ${{ needs.credits.outputs.artifact-name }}
|
||||
|
||||
Generated
+98
-97
@@ -1231,7 +1231,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-automation",
|
||||
"craft-behavior",
|
||||
@@ -1272,7 +1272,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-affinity"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"flate2",
|
||||
@@ -1283,7 +1283,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-appkit"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"block2 0.6.2",
|
||||
"objc2 0.6.5",
|
||||
@@ -1295,7 +1295,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-atomic"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"rustix 1.1.6",
|
||||
]
|
||||
@@ -1303,7 +1303,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-automation"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"base64 0.23.1",
|
||||
"craft-behavior",
|
||||
@@ -1328,7 +1328,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-behavior"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"bitflags 2.13.2",
|
||||
@@ -1346,7 +1346,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-browse"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-docpath",
|
||||
@@ -1364,7 +1364,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-cdr"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"flate2",
|
||||
@@ -1373,7 +1373,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-cloud-ui"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"egui",
|
||||
]
|
||||
@@ -1381,7 +1381,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-cms"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"md-5",
|
||||
"rayon",
|
||||
@@ -1390,12 +1390,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-codepage"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
|
||||
[[package]]
|
||||
name = "craft-color-ui"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-cms",
|
||||
@@ -1415,7 +1415,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-control"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-control-protocol",
|
||||
"craft-platform",
|
||||
@@ -1426,7 +1426,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-control-protocol"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"getrandom 0.3.4",
|
||||
"serde_json",
|
||||
@@ -1436,7 +1436,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-dds"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"rayon",
|
||||
]
|
||||
@@ -1444,7 +1444,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-dialogs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"block2 0.6.2",
|
||||
"craft-appkit",
|
||||
@@ -1470,7 +1470,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-doc"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"craft-ecproj-format",
|
||||
@@ -1486,7 +1486,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-docpath"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
@@ -1494,7 +1494,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-draw"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-color-ui",
|
||||
@@ -1513,7 +1513,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-dxf"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-codepage",
|
||||
"encoding_rs",
|
||||
@@ -1525,7 +1525,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ecproj-format"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -1535,12 +1535,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-eps"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
|
||||
[[package]]
|
||||
name = "craft-font-catalog"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"fontique",
|
||||
"harfrust 0.13.3",
|
||||
@@ -1555,7 +1555,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-font-manager"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-font-catalog",
|
||||
@@ -1574,7 +1574,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-font-os-windows"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"windows-registry",
|
||||
"windows-sys 0.61.2",
|
||||
@@ -1583,7 +1583,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-font-store"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"cap-primitives",
|
||||
"craft-atomic",
|
||||
@@ -1606,12 +1606,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-fonts-build"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
|
||||
[[package]]
|
||||
name = "craft-gif"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"gif",
|
||||
]
|
||||
@@ -1619,7 +1619,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-gzip"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
]
|
||||
@@ -1627,7 +1627,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-host"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"craft-i18n",
|
||||
@@ -1640,7 +1640,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-i18n"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"brotli 9.1.3",
|
||||
"brotli-decompressor 6.3.2",
|
||||
@@ -1670,7 +1670,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-image-codecs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-dds",
|
||||
"craft-jpeg",
|
||||
@@ -1697,7 +1697,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-imaging"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-color-ui",
|
||||
@@ -1715,7 +1715,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-jpeg"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
@@ -1723,7 +1723,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-jxl"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"brotli-decompressor 5.0.3",
|
||||
"jixel",
|
||||
@@ -1734,7 +1734,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-keymap"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-host",
|
||||
"craft-i18n",
|
||||
@@ -1749,7 +1749,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-layers"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-i18n",
|
||||
@@ -1763,7 +1763,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-menu"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -1781,7 +1781,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-metadata"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"brotli-decompressor 6.3.2",
|
||||
"chrono",
|
||||
@@ -1793,7 +1793,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-metafile"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"encoding_rs",
|
||||
"image",
|
||||
@@ -1804,7 +1804,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-mime"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"craft-codepage",
|
||||
@@ -1814,7 +1814,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-nightly"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"uds_windows",
|
||||
"winsafe",
|
||||
@@ -1823,7 +1823,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-pages"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-keymap",
|
||||
@@ -1839,7 +1839,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-pcraft-format"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"serde",
|
||||
@@ -1850,7 +1850,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-pdf"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"hayro-interpret",
|
||||
"hayro-syntax",
|
||||
@@ -1862,7 +1862,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-platform"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"async-io",
|
||||
@@ -1895,7 +1895,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-plotter"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"kurbo 0.13.1",
|
||||
"thiserror 2.0.21",
|
||||
@@ -1904,7 +1904,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-print"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -1928,7 +1928,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-proof"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"log",
|
||||
"miniz_oxide 0.9.1",
|
||||
@@ -1939,7 +1939,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ps"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-eps",
|
||||
"flate2",
|
||||
@@ -1953,7 +1953,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-psd"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"encoding_rs",
|
||||
"flate2",
|
||||
@@ -1964,7 +1964,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-quit"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"dispatch2",
|
||||
"egui",
|
||||
@@ -1977,7 +1977,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-review"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"base64 0.23.1",
|
||||
"craft-behavior",
|
||||
@@ -1996,7 +1996,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-settings"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-atomic",
|
||||
"craft-host",
|
||||
@@ -2013,7 +2013,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-stream-codecs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"fax",
|
||||
"hayro-ccitt",
|
||||
@@ -2024,7 +2024,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-svg"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-image-codecs",
|
||||
"craft-xml",
|
||||
@@ -2045,7 +2045,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-table"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-keymap",
|
||||
@@ -2057,7 +2057,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-text"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-font-manager",
|
||||
@@ -2082,7 +2082,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-theme"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"craft-tracked",
|
||||
@@ -2097,7 +2097,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-theme-store"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-atomic",
|
||||
"craft-behavior",
|
||||
@@ -2112,7 +2112,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-tiff"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"thiserror 2.0.21",
|
||||
@@ -2122,7 +2122,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-time"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"thiserror 2.0.21",
|
||||
@@ -2131,7 +2131,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-timeline"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-keymap",
|
||||
@@ -2146,12 +2146,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-tracked"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
|
||||
[[package]]
|
||||
name = "craft-ui"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-cloud-ui",
|
||||
"craft-ui-canvas",
|
||||
@@ -2165,9 +2165,10 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-canvas"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-font-catalog",
|
||||
"craft-i18n",
|
||||
"craft-keymap",
|
||||
"craft-theme",
|
||||
@@ -2181,7 +2182,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-contract"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"craft-behavior",
|
||||
@@ -2219,7 +2220,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-macros"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
@@ -2230,7 +2231,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-panels"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2248,7 +2249,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-patterns"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2269,7 +2270,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-shell"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2290,7 +2291,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-widgets"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2309,7 +2310,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-update"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"chrono",
|
||||
@@ -2341,7 +2342,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-vectorcraft-format"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"serde",
|
||||
@@ -2352,7 +2353,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-wayland"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"raw-window-handle",
|
||||
"wayland-backend",
|
||||
@@ -2362,7 +2363,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-web-api"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"serde_json",
|
||||
@@ -2373,7 +2374,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-win32"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"winsafe",
|
||||
]
|
||||
@@ -2381,7 +2382,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-window"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"craft-appkit",
|
||||
"craft-atomic",
|
||||
@@ -2413,7 +2414,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-xml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"quick-xml 0.41.0",
|
||||
"serde",
|
||||
@@ -2758,7 +2759,7 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813"
|
||||
[[package]]
|
||||
name = "ecolor"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"emath",
|
||||
@@ -2791,7 +2792,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "eframe"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"bytemuck",
|
||||
@@ -2826,7 +2827,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"ahash",
|
||||
@@ -2845,7 +2846,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui-wgpu"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"bytemuck",
|
||||
@@ -2864,7 +2865,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui-winit"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6"
|
||||
dependencies = [
|
||||
"accesskit_winit",
|
||||
"arboard",
|
||||
@@ -2889,7 +2890,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui_extras"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"egui",
|
||||
@@ -2903,7 +2904,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui_glow"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"egui",
|
||||
@@ -2916,7 +2917,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui_kittest"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6"
|
||||
dependencies = [
|
||||
"dify",
|
||||
"eframe",
|
||||
@@ -2942,7 +2943,7 @@ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
|
||||
[[package]]
|
||||
name = "emath"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
@@ -3023,7 +3024,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "epaint"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"bytemuck",
|
||||
@@ -3049,7 +3050,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "epaint_default_fonts"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6"
|
||||
dependencies = [
|
||||
"brotli 9.1.3",
|
||||
"brotli-decompressor 6.3.2",
|
||||
@@ -3772,7 +3773,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a"
|
||||
[[package]]
|
||||
name = "hayro-cmap"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"brotli 8.0.4",
|
||||
"hayro-postscript",
|
||||
@@ -3781,7 +3782,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hayro-interpret"
|
||||
version = "0.7.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"hayro-cmap",
|
||||
@@ -3799,7 +3800,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hayro-jbig2"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"fearless_simd",
|
||||
"hayro-ccitt",
|
||||
@@ -3817,12 +3818,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hayro-postscript"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
|
||||
[[package]]
|
||||
name = "hayro-syntax"
|
||||
version = "0.7.2"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"hayro-ccitt",
|
||||
@@ -4805,7 +4806,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "krilla"
|
||||
version = "0.8.2"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"bumpalo",
|
||||
@@ -4962,7 +4963,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4"
|
||||
[[package]]
|
||||
name = "linesweeper"
|
||||
version = "0.5.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0#a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"kurbo 0.13.1",
|
||||
|
||||
+49
-49
@@ -10,51 +10,51 @@ license = "MIT OR Apache-2.0"
|
||||
rust-version = "1.95"
|
||||
|
||||
[workspace.dependencies]
|
||||
craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0", default-features = false, features = ["interpret", "write"] }
|
||||
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6", default-features = false, features = ["interpret", "write"] }
|
||||
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
# Language packs: the Craft apps' shared font store installs them (#4936).
|
||||
craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
# The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON.
|
||||
craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
# `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile.
|
||||
craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0", features = ["pcraft-pixels"] }
|
||||
craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6", features = ["pcraft-pixels"] }
|
||||
# Native Affinity documents (craft-libs#914).
|
||||
craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
# Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778).
|
||||
craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
# SVG parsing, limits, SVGZ and writer (craft-libs#778).
|
||||
craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0", features = ["tree"] }
|
||||
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6", features = ["tree"] }
|
||||
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
# EPS container, previews, ASCII85 and DSC comments (craft-libs#778).
|
||||
craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
# DXF tags, reader and writer (craft-libs#778, #926, #927).
|
||||
craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
# WMF, EMF and EMF+ reader (craft-libs#778).
|
||||
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0", default-features = false, features = ["read", "write"] }
|
||||
craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6", default-features = false, features = ["read", "write"] }
|
||||
craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
# The framework facade (`craft::ui`, `craft::settings`, `craft::platform`, ...). No default features: each crate names
|
||||
# the members it imports.
|
||||
craft = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
# Below the egui layer, so not through the facade: the colour harmony rules and their settings (craft-color-ui
|
||||
# without its `ui` feature), the colour type they work in, and the craft-fonts tables the text crate's build writes.
|
||||
craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
# Nightly profile isolation, launch protocol, and security fence.
|
||||
craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
# internal
|
||||
vectorcraft-geom = { path = "crates/geom" }
|
||||
vectorcraft-color = { path = "crates/color" }
|
||||
@@ -194,22 +194,22 @@ lto = "thin"
|
||||
codegen-units = 1
|
||||
|
||||
[patch.crates-io]
|
||||
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
krilla = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0" }
|
||||
ecolor = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" }
|
||||
emath = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" }
|
||||
epaint = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" }
|
||||
epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" }
|
||||
egui = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" }
|
||||
egui-winit = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" }
|
||||
egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" }
|
||||
egui_glow = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" }
|
||||
egui_extras = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" }
|
||||
egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" }
|
||||
eframe = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" }
|
||||
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
krilla = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" }
|
||||
ecolor = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" }
|
||||
emath = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" }
|
||||
epaint = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" }
|
||||
epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" }
|
||||
egui = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" }
|
||||
egui-winit = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" }
|
||||
egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" }
|
||||
egui_glow = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" }
|
||||
egui_extras = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" }
|
||||
egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" }
|
||||
eframe = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" }
|
||||
winit = { git = "https://github.com/storytold/winit.git", rev = "0dfcec0eb62fda5904137a63a6dd0c3d83295f45" }
|
||||
@@ -155,6 +155,7 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap
|
||||
- 2026-11-19: Quick Pen tool, in the Pen tool's group (Alt+P, Option+P on macOS): clicks or drags add straight lines, continuous arcs or sharp-corner arcs; Alt tapped on its own switches the action, C flips the last arc, `[` and `]` size it, a click on the first point closes the path and a click on an open end continues it (`path.quickPen`, part of #2660). Headline numbers unchanged.
|
||||
- 2026-11-19: Quick Pen length handles: a handle beyond the start and the end of the path being drawn, or of the selected path, makes the line or arc there longer or shorter when dragged; a line keeps its direction and an arc its circle (`path.quickPenLength`, part of #2660). Headline numbers unchanged.
|
||||
- 2026-11-19: Quick Pen toolbar on the canvas while the tool is active: Straight Line, Continuous Arc and Sharp Corner Arc, Flip Arc, and More Options with Hide Toolbar, Pin Toolbar Position and Reset Toolbar Position; it follows the drawing beside the path's last point and its handle drags it (`tool.quickPen.flipArc`, `window.quickPenToolbar`, Window › Quick Pen Toolbar; part of #2660). Headline numbers unchanged.
|
||||
- 2026-11-19: Quick Pen arc size with Ctrl+wheel: over the canvas, a touchpad scroll or a mouse wheel turned with Ctrl makes the arc size 15° larger or smaller per step, as `]` and `[` do, and the view stays put (`tool.quickPen.arcLarger`, `tool.quickPen.arcSmaller`; part of #2660). Headline numbers unchanged.
|
||||
- 2026-11-19: Quick Pen editing: with no path being drawn, a drag on an anchor or a segment of a selected path moves it, a line staying a line and an arc an arc beside a moved corner anchor (at a smooth anchor the handles stay in line and the segments bend to meet); a click selects an anchor, Shift-click adds one, and the canvas context menu's Delete removes the selected anchors (`path.moveAnchors`, `edit.clear`; #2660). Headline numbers unchanged.
|
||||
- 2026-10-31: Pattern libraries: Window › Swatch Libraries › Patterns and the Swatches panel's library menu open Geometric Patterns, a built-in library of eleven pattern swatches (dots, stripes, checks, a grid and shapes); clicking one adds its pattern and swatch to the document, once, and applies it to the active fill or stroke (`swatch.library.add`).
|
||||
- 2026-11-11: Pattern libraries: Patterns › Grit Textures, a second built-in pattern library, holds eight seamless black textures (Fine Grain, Coarse Grit, Sand, Speckle, Stipple, Scratches, Sparse Flecks and Dense Flecks) on tiles of 18 to 36 pt, each drawn the same way every time; marks that reach past a tile edge continue on the next tile, so the tiles join without a seam (`swatch.library.add`). Scores and estimates unchanged.
|
||||
@@ -182,6 +183,7 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap
|
||||
- 2026-11-28: The Three-Point Arc tool joins an arc to the open paths whose ends its ends are placed on, with Join to Open Path Ends (Tool Options, or J while drawing; `shape.threePointArc` `join`), and in direction mode snaps the third point to where the arc carries an open path on, the same way or turned back (Snap Where the Arc Continues a Path, on by default). Headline numbers unchanged.
|
||||
- 2026-11-15: Smooth Bridge joins the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools): two selected circles become one closed outline joined by two concave arcs that touch both circles, so every anchor is smooth; the arcs' radius is a percentage of the smaller circle's radius (1 to 1000%, 100% by default), and Keep Originals adds the outline above the circles instead of replacing them. A dialog with Preview, one undo step (`addon.pathtools.bridge`). A VectorCraft addition: headline numbers unchanged.
|
||||
- 2026-11-18: Smooth Bridge also joins three or more circles: every two whose outlines are within Reach (10 pt by default) are joined, the bridges that connect become one shape each, and a circle bridged to no other stays as it is (at most 2000 circles); with Constant Gap the arcs' radius is the smaller circle's radius plus a gap (#8030). A VectorCraft addition: headline numbers unchanged.
|
||||
- 2026-12-01: Common Tangents and Smooth Bridge are one dialog, Common Tangents… (#10465): Connect tangents joins the two tangents of each kind into one closed shape, and with External, Straight or Curved picks between the tangent lines and Smooth Bridge's curved outline, with Radius, Constant Gap, Reach and Keep Originals; the Smooth Bridge… menu item is gone, and `addon.pathtools.bridge` still runs and opens the dialog with External and Curved (`connect` and `curved` on `addon.pathtools.commonTangents`). A VectorCraft addition: headline numbers unchanged.
|
||||
- 2026-11-03: Text Tweaker, the first tool of the Type Tools add-on (Object › Plug-ins › Type Tools): one character attribute (size, baseline shift, rotation, horizontal or vertical scale, tracking, leading or stroke weight) goes letter by letter from a start value to an end value along a straight ramp, an ease, a bow, a spike or at random with a seed, set as the Character panel sets it, while the text stays live; a dialog with Preview, one undo step (`addon.type.textTweaker`, #4924). A VectorCraft addition: headline numbers unchanged.
|
||||
- 2026-11-01: Group Overlapping Objects joins the Arrange Tools add-on (Object › Plug-ins › Arrange Tools): the selected objects whose visual bounds overlap or touch, chains included, go into one group each, within their own layer or group, at the stacking place of their frontmost member; objects that overlap nothing stay as they are. One undo step, a sweep along x so thousands of loose pieces group quickly (at most 20000 objects). A VectorCraft addition: headline numbers unchanged.
|
||||
- 2026-10-31: Export for Screens works as the reference app's dialog: Artboards and Assets tabs with a grid or list of thumbnails, Clear Selection and Prefix, Create Sub-folders by Scale or Format (on by default), Export PDFs As Single File (the chosen artboards as one PDF's pages, `pdfs: "single"`) or Multiple Files, iOS and Android rows, format presets in a ☰ menu, and a count of the files the export writes (#4895). About 55 community PRs and fixes landed the same day: Find Font, Replace Font, Outline Stroke and Expand leave hidden and locked art alone (with a warning); DXF export writes LINE and ELLIPSE entities and outlines only the strokes a CAD line can't draw; Blob Brush Angle and Roundness; Shift-constrained Perspective Selection; Grid Repeat Options Preview; a gradient mesh from a file budgeted at about a million quads; width-profile strokes keep their shape zoomed out; `.ai`/EPS import fidelity (area type, envelopes, transparency in dictionaries, character styles); PDF import finds hyphenated and CMap-suffixed font names; Windows renders follow the process's core affinity; Enter or Escape in a floating panel's field no longer reaches the canvas (#4803); Properties shows Blend Options for any selected blend (#4817); Artwork Cleanup finds doubled type (#4835) and joins stacked lines into one object (Join Point Text, #4826). Headline numbers unchanged.
|
||||
|
||||
@@ -629,6 +629,7 @@ mod tests {
|
||||
|
||||
/// On Windows `busy_cores` gives a number between 0 and the cores.
|
||||
#[cfg(windows)]
|
||||
// test-lint: allow never-run Windows only; CI runs tests on Linux and FreeBSD
|
||||
#[test]
|
||||
fn windows_reads_how_many_cores_are_busy() {
|
||||
let cores = std::thread::available_parallelism().map_or(1, |c| c.get());
|
||||
@@ -639,6 +640,7 @@ mod tests {
|
||||
/// On Windows `rss_mb` gives this process's working set: more than 0 MB and less than
|
||||
/// 10,000 MB.
|
||||
#[cfg(windows)]
|
||||
// test-lint: allow never-run Windows only; CI runs tests on Linux and FreeBSD
|
||||
#[test]
|
||||
fn windows_reads_the_working_set() {
|
||||
let mb = rss_mb().map(|(mb, _)| mb);
|
||||
|
||||
@@ -28,7 +28,7 @@ egui_extras = { workspace = true }
|
||||
# `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback.
|
||||
eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] }
|
||||
# The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft.
|
||||
craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "a5669ed2f1ba62545a1f0d884ecbd0fd0fbd06e0", version = "0.1.0" }
|
||||
craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6", version = "0.1.0" }
|
||||
|
||||
wasm-bindgen = "0.2"
|
||||
serde_json = { workspace = true }
|
||||
|
||||
@@ -553,10 +553,9 @@ fn the_saved_engine_preference_is_found() {
|
||||
let saved = prefs.to_json();
|
||||
assert_eq!(power_preference(saved.get("gpuPreference").and_then(serde_json::Value::as_str), None), power);
|
||||
}
|
||||
// Every choice Preferences offer means something here.
|
||||
for (value, _) in vectorcraft_engine::cmd::prefscmds::GPU_PREFERENCES {
|
||||
assert!(["automatic", "lowPower", "highPerformance"].contains(value), "{value}");
|
||||
}
|
||||
// Preferences offer the three choices read above, and no other.
|
||||
let offered: Vec<&str> = vectorcraft_engine::cmd::prefscmds::GPU_PREFERENCES.iter().map(|(value, _)| *value).collect();
|
||||
assert_eq!(offered, ["automatic", "lowPower", "highPerformance"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -188,7 +188,7 @@ pub(crate) fn services(window: Parent) -> Services {
|
||||
check_application: Some(Box::new(|p| check_app(std::path::Path::new(p)))),
|
||||
open_in_application: Some(Box::new(open_in_application)),
|
||||
// File → Print: the system's printers and print queue.
|
||||
print: Some(Box::new(printing::SystemPrint)),
|
||||
print: Some(Box::new(printing::SystemPrint::default())),
|
||||
// The tablet driver's Wintab context, which reads an airbrush pen's finger wheel, opens
|
||||
// only while the active tool uses the wheel.
|
||||
#[cfg(all(windows, not(target_vendor = "win7")))]
|
||||
|
||||
@@ -99,6 +99,7 @@ mod tests {
|
||||
}
|
||||
|
||||
/// A layer without a color space is tagged sRGB once; the second call leaves it as it is.
|
||||
// test-lint: allow never-run macOS only; CI runs tests on Linux and FreeBSD
|
||||
#[test]
|
||||
fn an_untagged_layer_becomes_srgb() {
|
||||
let layer = CAMetalLayer::new();
|
||||
@@ -110,6 +111,7 @@ mod tests {
|
||||
}
|
||||
|
||||
/// A layer with a color space of its own keeps it.
|
||||
// test-lint: allow never-run macOS only; CI runs tests on Linux and FreeBSD
|
||||
#[test]
|
||||
fn a_layer_with_a_color_space_keeps_it() {
|
||||
let layer = CAMetalLayer::new();
|
||||
@@ -121,6 +123,7 @@ mod tests {
|
||||
|
||||
/// The Metal layer is found as the view's layer or as one of its sublayers, and only Metal
|
||||
/// layers are returned.
|
||||
// test-lint: allow never-run macOS only; CI runs tests on Linux and FreeBSD
|
||||
#[test]
|
||||
fn metal_layers_are_found_under_the_view_layer() {
|
||||
let metal = CAMetalLayer::new();
|
||||
|
||||
@@ -52,6 +52,7 @@ mod tests {
|
||||
use objc2_core_text::{CTFontManagerRegisterFontsForURL, CTFontManagerScope, CTFontManagerUnregisterFontsForURL};
|
||||
|
||||
/// CoreText lists the installed fonts, by their files' full paths.
|
||||
// test-lint: allow never-run macOS only; CI runs tests on Linux and FreeBSD
|
||||
#[test]
|
||||
fn coretext_lists_the_installed_font_files() {
|
||||
let files = super::font_files();
|
||||
@@ -61,6 +62,7 @@ mod tests {
|
||||
|
||||
/// A font registered with CoreText from another folder, as apps and font managers register
|
||||
/// fonts, is listed while it is registered.
|
||||
// test-lint: allow never-run macOS only; CI runs tests on Linux and FreeBSD
|
||||
#[test]
|
||||
fn fonts_registered_from_other_folders_are_listed() {
|
||||
let dir = tempfile::Builder::new().prefix("vectorcraft-mac-fonts-").tempdir().unwrap();
|
||||
|
||||
@@ -94,6 +94,7 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
/// Files queue until the UI takes them; URLs that aren't files are left out.
|
||||
// test-lint: allow never-run macOS only; CI runs tests on Linux and FreeBSD
|
||||
#[test]
|
||||
fn opened_files_wait_for_the_ui() {
|
||||
let web = NSURL::URLWithString(&NSString::from_str("https://example.com/a.svg")).unwrap();
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::path::PathBuf;
|
||||
use std::sync::{Mutex, PoisonError};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use craft::settings::{LegacyFile, LoadReport, Location, OpenOptions, SettingsStore, SharedSettings};
|
||||
use craft::settings::{LegacyFile, LoadReport, Location, OpenOptions, SectionError, SettingsStore, SharedSettings};
|
||||
use vectorcraft_ui_egui::{AppSettings, from_app, parse_legacy};
|
||||
|
||||
use super::{VectorcraftApp, prefs_dir};
|
||||
@@ -18,6 +18,15 @@ fn legacy_dir() -> Option<PathBuf> {
|
||||
prefs_dir::profile::prefs_dir(true)
|
||||
}
|
||||
|
||||
/// Parses the one `ui.json` slot of a legacy import: its bytes, or why it could not be read.
|
||||
fn parse_legacy_slot(slots: &[Result<Option<&[u8]>, &std::io::Error>]) -> Result<(AppSettings, Vec<SectionError>), String> {
|
||||
match slots.first() {
|
||||
Some(Ok(Some(bytes))) => parse_legacy(bytes),
|
||||
Some(Err(e)) => Err(e.to_string()),
|
||||
_ => Err("the preferences file is missing".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Where the log files live: `logs` in the preferences folder (see `logging`).
|
||||
pub(crate) fn log_dir() -> Option<PathBuf> {
|
||||
Some(prefs_dir::prefs_dir()?.join("logs"))
|
||||
@@ -34,7 +43,7 @@ pub(crate) fn prefs_enabled() -> bool {
|
||||
pub(crate) fn open_store() -> (SharedSettings<AppSettings>, LoadReport) {
|
||||
let (location, legacy) = match prefs_dir::prefs_dir().filter(|_| prefs_enabled()) {
|
||||
Some(dir) => {
|
||||
let file = |dir: PathBuf| LegacyFile { path: dir.join(LEGACY_FILE), parse: parse_legacy };
|
||||
let file = |dir: PathBuf| LegacyFile { paths: vec![dir.join(LEGACY_FILE)], parse: parse_legacy_slot };
|
||||
let legacy = std::iter::once(file(dir.clone())).chain(legacy_dir().map(file)).collect();
|
||||
(Location::Dir(dir), legacy)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
//! Desktop printer transport. VectorCraft composes every page and copy before submission;
|
||||
//! craft-print owns discovery and spooling.
|
||||
use std::process::Command;
|
||||
use vectorcraft_ui_egui::print::{PrintJob, PrintService, Printer};
|
||||
use vectorcraft_ui_egui::print::{Paper, Papers, PrintJob, PrintService, Printer};
|
||||
|
||||
mod direct_pdf;
|
||||
|
||||
pub struct SystemPrint;
|
||||
#[derive(Default)]
|
||||
pub struct SystemPrint {
|
||||
/// The paper-size lookup in flight, dropped when its worker answers or disconnects.
|
||||
papers: PaperLookup,
|
||||
}
|
||||
|
||||
impl PrintService for SystemPrint {
|
||||
fn printers(&mut self) -> Vec<Printer> {
|
||||
system::printers()
|
||||
@@ -15,7 +20,7 @@ impl PrintService for SystemPrint {
|
||||
Ok(sent(job.title, job.printer, ¬e))
|
||||
}
|
||||
fn shared_print(&self) -> Option<vectorcraft_ui_egui::print::SharedPrintFn> {
|
||||
Some(std::sync::Arc::new(|job| SystemPrint.print(job)))
|
||||
Some(std::sync::Arc::new(|job| system::print(job).map(|note| sent(job.title, job.printer, ¬e))))
|
||||
}
|
||||
fn turns_landscape(&self) -> bool {
|
||||
// macOS's `lp` doesn't turn a landscape page to the paper: it cuts it off on upright
|
||||
@@ -31,6 +36,43 @@ impl PrintService for SystemPrint {
|
||||
fn scripts_may_print(&self) -> bool {
|
||||
true
|
||||
}
|
||||
fn papers(&mut self, printer: &str, fresh: bool) -> Papers {
|
||||
self.papers.poll(printer, fresh, |printer| installed_papers(&printer))
|
||||
}
|
||||
}
|
||||
|
||||
/// The paper-size lookup in flight: the printer it reads and its worker's channel.
|
||||
#[derive(Default)]
|
||||
struct PaperLookup(Option<(String, std::sync::mpsc::Receiver<Vec<Paper>>)>);
|
||||
|
||||
impl PaperLookup {
|
||||
/// Poll the lookup of `printer`. A new lookup runs `read` on a worker when `fresh` is set, when the one in flight
|
||||
/// reads another printer, or when none is in flight; the earlier one's answer is dropped.
|
||||
fn poll(&mut self, printer: &str, fresh: bool, read: impl FnOnce(String) -> Vec<Paper> + Send + 'static) -> Papers {
|
||||
if fresh || self.0.as_ref().is_none_or(|(p, _)| p != printer) {
|
||||
let (send, receive) = std::sync::mpsc::channel();
|
||||
let name = printer.to_string();
|
||||
let _ = std::thread::Builder::new().name("printer-papers".into()).spawn(move || {
|
||||
let _ = send.send(read(name));
|
||||
});
|
||||
self.0 = Some((printer.to_string(), receive));
|
||||
}
|
||||
let result = match self.0.as_ref().map(|(_, receive)| receive.try_recv()) {
|
||||
Some(Ok(papers)) => Papers::Ready(papers),
|
||||
Some(Err(std::sync::mpsc::TryRecvError::Empty)) => return Papers::Pending,
|
||||
Some(Err(std::sync::mpsc::TryRecvError::Disconnected)) | None => Papers::Ready(Vec::new()),
|
||||
};
|
||||
self.0 = None;
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
/// Look up only an installed printer's own name.
|
||||
fn installed_papers(printer: &str) -> Vec<Paper> {
|
||||
if printer.is_empty() || !system::printers().iter().any(|p| p.name == printer) {
|
||||
return Vec::new();
|
||||
}
|
||||
system::papers(printer)
|
||||
}
|
||||
|
||||
/// The status after the job `title` went to `printer` (the default one without a name), with the
|
||||
@@ -43,10 +85,80 @@ fn sent(title: &str, printer: Option<&str>, note: &str) -> String {
|
||||
}
|
||||
|
||||
mod system {
|
||||
use super::{Command, PrintJob, Printer};
|
||||
use super::{Command, Paper, PrintJob, Printer};
|
||||
pub fn printers() -> Vec<Printer> {
|
||||
craft::print::printers().into_iter().map(Printer::from).collect()
|
||||
}
|
||||
/// The paper sizes of an installed printer's driver: its CUPS PPD, or Windows' printer settings.
|
||||
pub fn papers(printer: &str) -> Vec<Paper> {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
// The name goes in as an environment variable, never into the script's text.
|
||||
const SCRIPT: &str = "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; Add-Type -AssemblyName System.Drawing; $s = New-Object System.Drawing.Printing.PrinterSettings; \
|
||||
$s.PrinterName = $env:VC_PRINTER; foreach ($p in $s.PaperSizes) { \"$($p.RawKind)`t$($p.PaperName)`t$($p.Width)`t$($p.Height)\" }";
|
||||
use std::os::windows::process::CommandExt as _;
|
||||
// CREATE_NO_WINDOW: no console window opens over the app.
|
||||
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
|
||||
let mut command = Command::new("powershell.exe");
|
||||
command.args(["-NoProfile", "-NonInteractive", "-Command", SCRIPT]).env("VC_PRINTER", printer).creation_flags(CREATE_NO_WINDOW);
|
||||
paper_output(&mut command).map(|out| vectorcraft_ui_egui::print::windows_papers(&String::from_utf8_lossy(&out))).unwrap_or_default()
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
use std::io::Read as _;
|
||||
// CUPS queue names never hold `/`, so the name can't leave the PPD folder.
|
||||
if printer.contains(['/', '\\']) || printer.starts_with('.') {
|
||||
return Vec::new();
|
||||
}
|
||||
const PPD_CAP: u64 = 16 << 20;
|
||||
let mut bytes = Vec::new();
|
||||
let read = std::fs::File::open(format!("/etc/cups/ppd/{printer}.ppd")).and_then(|f| f.take(PPD_CAP).read_to_end(&mut bytes));
|
||||
if read.is_err() {
|
||||
return Vec::new();
|
||||
}
|
||||
vectorcraft_ui_egui::print::ppd_papers(&craft::print::ppd_text(&bytes))
|
||||
}
|
||||
}
|
||||
/// Drain output while polling the child, and stop discovery after ten seconds.
|
||||
#[cfg(windows)]
|
||||
fn paper_output(command: &mut Command) -> Option<Vec<u8>> {
|
||||
use std::io::Read as _;
|
||||
use std::process::Stdio;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
const LIMIT: Duration = Duration::from_secs(10);
|
||||
let started = Instant::now();
|
||||
let mut child = command.stdout(Stdio::piped()).stderr(Stdio::null()).spawn().ok()?;
|
||||
let (send, receive) = std::sync::mpsc::channel();
|
||||
let stdout = child.stdout.take();
|
||||
let reader = std::thread::Builder::new().name("printer-paper-output".into()).spawn(move || {
|
||||
let mut bytes = Vec::new();
|
||||
// Retain at most 16 MiB, but drain the rest so the child can finish.
|
||||
let read = stdout.map(|mut out| {
|
||||
out.by_ref().take(16 << 20).read_to_end(&mut bytes)?;
|
||||
std::io::copy(&mut out, &mut std::io::sink())
|
||||
});
|
||||
let _ = send.send(read.and_then(Result::ok).map(|_| bytes));
|
||||
});
|
||||
if reader.is_err() {
|
||||
let _ = child.kill();
|
||||
let _ = child.wait();
|
||||
return None;
|
||||
}
|
||||
loop {
|
||||
match child.try_wait() {
|
||||
Ok(Some(status)) => {
|
||||
return if status.success() { receive.recv_timeout(LIMIT.saturating_sub(started.elapsed())).ok().flatten() } else { None };
|
||||
}
|
||||
Ok(None) if started.elapsed() < LIMIT => std::thread::sleep(Duration::from_millis(25)),
|
||||
_ => {
|
||||
let _ = child.kill();
|
||||
let _ = child.wait();
|
||||
return None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn print(job: &PrintJob) -> Result<String, String> {
|
||||
if job.direct_pdf {
|
||||
return super::direct_pdf::print(job);
|
||||
@@ -133,6 +245,55 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod paper_lookup_tests {
|
||||
use super::PaperLookup;
|
||||
use vectorcraft_ui_egui::print::{Paper, Papers};
|
||||
|
||||
fn paper(key: &str) -> Vec<Paper> {
|
||||
vec![Paper { key: key.into(), label: key.into(), width: 100.0, height: 200.0 }]
|
||||
}
|
||||
|
||||
/// Start a fresh lookup of `printer` that answers `key`, and poll it until it answers.
|
||||
fn answer(lookup: &mut PaperLookup, printer: &str, key: &'static str) -> Vec<Paper> {
|
||||
let mut polled = lookup.poll(printer, true, move |_| paper(key));
|
||||
loop {
|
||||
match polled {
|
||||
Papers::Ready(papers) => return papers,
|
||||
Papers::Pending => std::thread::yield_now(),
|
||||
}
|
||||
polled = lookup.poll(printer, false, |_| panic!("polling starts no lookup"));
|
||||
}
|
||||
}
|
||||
|
||||
/// A read that answers `key` once `gate` lets it.
|
||||
fn gated(key: &'static str) -> (std::sync::mpsc::Sender<()>, impl FnOnce(String) -> Vec<Paper> + Send + 'static) {
|
||||
let (open, gate) = std::sync::mpsc::channel::<()>();
|
||||
(open, move |_| {
|
||||
let _ = gate.recv();
|
||||
paper(key)
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_fresh_lookup_drops_the_answer_of_an_earlier_one() {
|
||||
let mut lookup = PaperLookup::default();
|
||||
let (open, read) = gated("Old");
|
||||
assert!(matches!(lookup.poll("Card", true, read), Papers::Pending));
|
||||
let (other, read) = gated("Office");
|
||||
assert!(matches!(lookup.poll("Office", true, read), Papers::Pending));
|
||||
let _ = open.send(());
|
||||
let _ = other.send(());
|
||||
// Back on the card printer.
|
||||
assert_eq!(answer(&mut lookup, "Card", "New"), paper("New"));
|
||||
// The dialog opens again on the card printer while a lookup of it is still running.
|
||||
let (open, read) = gated("Stale");
|
||||
assert!(matches!(lookup.poll("Card", true, read), Papers::Pending));
|
||||
let _ = open.send(());
|
||||
assert_eq!(answer(&mut lookup, "Card", "Newer"), paper("Newer"));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod turn_tests {
|
||||
use super::sent;
|
||||
|
||||
@@ -2220,7 +2220,10 @@ fn brushes_without_modes_vary_randomly_as_before() {
|
||||
serde_json::to_value(Variation::ALL).unwrap(),
|
||||
serde_json::json!(["fixed", "random", "pressure", "tilt", "bearing", "rotation", "stylusWheel"])
|
||||
);
|
||||
assert!(Variation::ALL.iter().all(|v| Variation::parse(v.id()) == Some(*v) && serde_json::to_value(v).unwrap() == v.id()));
|
||||
let ids: Vec<&str> = Variation::ALL.iter().map(|v| v.id()).collect();
|
||||
assert_eq!(serde_json::to_value(Variation::ALL).unwrap(), serde_json::json!(ids), "saved names are the ids");
|
||||
assert_eq!(Variation::parse("stylusWheel"), Some(Variation::StylusWheel));
|
||||
assert_eq!(Variation::parse("wheel"), None);
|
||||
assert!(!Variation::offered(false).contains(&Variation::StylusWheel) && Variation::offered(true).contains(&Variation::StylusWheel));
|
||||
}
|
||||
|
||||
@@ -2228,6 +2231,7 @@ fn brushes_without_modes_vary_randomly_as_before() {
|
||||
#[test]
|
||||
fn junk_pressure_brushes_draw_finite_art() {
|
||||
let bp = preview_path(120.0, 24.0);
|
||||
let mut drawn = 0;
|
||||
for (size, var) in [(1e308, 1e308), (-1e308, 1e308), (0.0, -1e308), (f64::MAX, f64::MAX)] {
|
||||
for profile in [vec![], vec![(0.0, 2.0), (0.0, -1.0), (5.0, 0.5)], vec![(1.0, 1.0), (0.0, 0.0)]] {
|
||||
let out = stroke_pieces(&Document::new(1.0, 1.0), &pressure_calli(size, var), &bp, &pressed(profile));
|
||||
@@ -2236,8 +2240,10 @@ fn junk_pressure_brushes_draw_finite_art() {
|
||||
all_points(n, &mut pts);
|
||||
}
|
||||
assert!(pts.iter().all(|p| p.x.is_finite() && p.y.is_finite()), "{size} {var}");
|
||||
drawn += usize::from(!pts.is_empty());
|
||||
}
|
||||
}
|
||||
assert_eq!(drawn, 12, "brushes that draw");
|
||||
}
|
||||
|
||||
/// A scatter brush of 10 × 4 pt rectangles whose size goes from `lo` % to `hi` % as `mode` says.
|
||||
|
||||
@@ -131,7 +131,7 @@ fn pens_pick_colors_and_widths() {
|
||||
let i = plot("IN;SP1;PW1;PD0,0,10,0;PU;PW2,2;SP2;PD0,10,10,10;PU;SP1;PD0,20,10,20;PU;IN;SP1;PD0,30,10,30;");
|
||||
let widths: Vec<f64> = leaves(&i.document).iter().map(|n| stroke(n).width).collect();
|
||||
let want = [MM, 2.0 * MM, MM, 0.35 * MM];
|
||||
assert!(widths.iter().zip(want).all(|(a, b)| (a - b).abs() < 1e-9), "{widths:?}");
|
||||
assert!(widths.len() == want.len() && widths.iter().zip(want).all(|(a, b)| (a - b).abs() < 1e-9), "{widths:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1448,7 +1448,8 @@ fn crop_keeps_an_instance_whose_art_reaches_the_region() {
|
||||
let art = path(&mut d, shapes::rectangle(Rect::new(100.0, 50.0, 140.0, 90.0)), Paint::solid(Color::rgb(1.0, 0.0, 0.0)), Paint::None, 0.0);
|
||||
d.symbols.push(vectorcraft_doc::Symbol { dynamic: false, name: "Far".into(), art: Arc::new(art) });
|
||||
let o = DxfOptions { crop: true, ..opts(&d) };
|
||||
assert!(!kinds(&export(&d, &o).unwrap()).is_empty());
|
||||
// The red fill: its outline and its hatch.
|
||||
assert_eq!(kinds(&export(&d, &o).unwrap()), ["LWPOLYLINE", "HATCH"]);
|
||||
}
|
||||
|
||||
/// An instance stained blue by its fill writes its symbol's red art in blue, as the canvas draws it.
|
||||
|
||||
@@ -313,8 +313,10 @@ mod tests {
|
||||
assert_eq!(BlendMode::parse("ColorBurn"), Some(BlendMode::ColorBurn));
|
||||
assert_eq!(BlendMode::parse("soft_light"), Some(BlendMode::SoftLight));
|
||||
assert_eq!(BlendMode::parse("nope"), None);
|
||||
for m in BlendMode::ALL {
|
||||
assert_eq!(BlendMode::parse(m.label()), Some(m));
|
||||
}
|
||||
assert_eq!(BlendMode::parse(""), None);
|
||||
// A label that starts another one names its own mode.
|
||||
assert_eq!(BlendMode::parse("Color"), Some(BlendMode::Color));
|
||||
assert_eq!(BlendMode::parse("Color Dodge"), Some(BlendMode::ColorDodge));
|
||||
assert_eq!(BlendMode::parse("HARD-LIGHT"), Some(BlendMode::HardLight));
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,14 @@ fn de(a: [f32; 3], b: [f32; 3]) -> f32 {
|
||||
|
||||
#[test]
|
||||
fn intents_parse_and_name() {
|
||||
for i in Intent::ALL {
|
||||
assert_eq!(Intent::parse(i.id()), Some(i));
|
||||
assert_eq!(Intent::parse(i.label()), Some(i));
|
||||
}
|
||||
// The id settings save and the label the menu shows both read back, in any case and spacing.
|
||||
assert_eq!(Intent::RelativeColorimetric.id(), "relative");
|
||||
assert_eq!(Intent::parse("relative"), Some(Intent::RelativeColorimetric));
|
||||
assert_eq!(Intent::parse("Relative Colorimetric"), Some(Intent::RelativeColorimetric));
|
||||
assert_eq!(Intent::parse("absolute_colorimetric"), Some(Intent::AbsoluteColorimetric));
|
||||
assert_eq!(Intent::parse("PERCEPTUAL"), Some(Intent::Perceptual));
|
||||
assert_eq!(Intent::parse("bogus"), None);
|
||||
assert_eq!(Intent::parse(""), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -322,21 +325,29 @@ fn bad_icc_rejected() {
|
||||
assert!(matches!(register_icc(b"not a profile", None), Err(CmsError::BadProfile(_))));
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
/// A profile file is read and registered as its bytes are: a missing file is an I/O error naming
|
||||
/// the path, a file that is not a profile is refused as one, and a file holding a built-in
|
||||
/// profile is refused for its name.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[test]
|
||||
fn loads_system_cmyk_icc() {
|
||||
let path = std::path::Path::new("/System/Library/ColorSync/Profiles/Generic CMYK Profile.icc");
|
||||
if !path.exists() {
|
||||
return;
|
||||
fn loads_icc_files_and_refuses_bad_ones() {
|
||||
let dir = std::env::temp_dir().join(format!("vectorcraft-color-icc-{}", std::process::id()));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let missing = dir.join("missing.icc");
|
||||
match load_icc_file(&missing) {
|
||||
Err(CmsError::Io(e)) => assert!(e.contains("missing.icc"), "{e}"),
|
||||
other => panic!("{other:?}"),
|
||||
}
|
||||
let info = load_icc_file(path).unwrap();
|
||||
assert_eq!(info.kind, ProfileKind::Cmyk);
|
||||
assert!(profiles().iter().any(|p| p.name == info.name && !p.builtin));
|
||||
let c = Cms::new(&ColorSettings { cmyk: info.name.clone(), ..Default::default() }).unwrap();
|
||||
let rgb = [0.7, 0.5, 0.4];
|
||||
let back = c.cmyk_to_srgb(c.srgb_to_cmyk(rgb, Intent::RelativeColorimetric), false);
|
||||
assert!(de(rgb, back) < 5.0, "{back:?}");
|
||||
assert_eq!(c.cmyk_to_srgb([0.0; 4], false).map(|v| (v * 255.0).round() as u8), [255, 255, 255]);
|
||||
let junk = dir.join("junk.icc");
|
||||
std::fs::write(&junk, b"not a profile").unwrap();
|
||||
assert!(matches!(load_icc_file(&junk), Err(CmsError::BadProfile(_))));
|
||||
let builtin = dir.join("generic.icc");
|
||||
std::fs::write(&builtin, &*icc_bytes(GENERIC_CMYK).unwrap()).unwrap();
|
||||
match load_icc_file(&builtin) {
|
||||
Err(CmsError::Unsupported(e)) => assert!(e.contains("built-in"), "{e}"),
|
||||
other => panic!("{other:?}"),
|
||||
}
|
||||
std::fs::remove_dir_all(&dir).unwrap();
|
||||
}
|
||||
|
||||
/// With black-point compensation, sRGB black separates to the press's black point and that black
|
||||
@@ -568,10 +579,10 @@ fn a_document_gets_the_same_context_for_the_same_profiles() {
|
||||
/// settings saved before the policies existed read with the default policy.
|
||||
#[test]
|
||||
fn policies_parse_and_default_in_saved_settings() {
|
||||
for p in Policy::CMYK {
|
||||
assert_eq!(Policy::parse(p.id()), Some(p));
|
||||
}
|
||||
assert_eq!(Policy::parse("preserveNumbers"), Some(Policy::PreserveNumbers));
|
||||
assert_eq!(Policy::parse("convert"), Some(Policy::Convert));
|
||||
assert_eq!(Policy::parse("bogus"), None);
|
||||
assert_eq!(Policy::parse("Preserve Numbers"), None, "only ids parse");
|
||||
assert!(!Policy::RGB.contains(&Policy::PreserveNumbers));
|
||||
let old: ColorSettings =
|
||||
serde_json::from_str(r#"{"rgb": "sRGB IEC61966-2.1", "cmyk": "Device CMYK (uncalibrated)", "intent": "perceptual", "bpc": false}"#).unwrap();
|
||||
|
||||
@@ -395,5 +395,5 @@ fn cmyk_to_cmyk_compensates_the_black_point() {
|
||||
assert_ne!(convert(true), convert(false));
|
||||
// White is untouched.
|
||||
let white = generic.to_same_model_of(&device, &[0.0; 4], rel, true).unwrap();
|
||||
assert!(white.iter().all(|v| *v < 0.01), "{white:?}");
|
||||
assert!(white.len() == 4 && white.iter().all(|v| *v < 0.01), "{white:?}");
|
||||
}
|
||||
@@ -108,6 +108,7 @@ fn the_fit_predicts_patches_it_left_out() {
|
||||
let corner = |p: &measured::Patch| p.cmyk.iter().all(|v| *v == 0.0 || *v == 1.0);
|
||||
let first = |p: &measured::Patch| patches.iter().position(|q| q.cmyk == p.cmyk).unwrap_or(0);
|
||||
let (kept, left): (Vec<&measured::Patch>, Vec<_>) = patches.iter().partition(|p| first(p) % 4 != 3 || corner(p));
|
||||
assert!(!left.is_empty(), "{}: nothing left out", c.reference);
|
||||
assert!(left.iter().all(|l| kept.iter().all(|k| k.cmyk != l.cmyk)), "{}", c.reference);
|
||||
let kept: Vec<measured::Patch> = kept.into_iter().copied().collect();
|
||||
let left: Vec<measured::Patch> = left.into_iter().copied().collect();
|
||||
|
||||
@@ -464,9 +464,10 @@ impl Gradient {
|
||||
self.repeats.clamp(1, MAX_REPEATS)
|
||||
}
|
||||
/// Does it paint something other than its end colors past the ends of its stops, or run its
|
||||
/// stops more than once: a linear, radial, conic or diamond gradient that repeats or reflects?
|
||||
/// stops more than once: a linear, radial, conic or diamond gradient with stops that repeats or
|
||||
/// reflects? One without stops paints as one that pads.
|
||||
pub fn is_spread(&self) -> bool {
|
||||
!self.spread.is_pad() && self.kind != GradientKind::Freeform
|
||||
!self.spread.is_pad() && self.kind != GradientKind::Freeform && !self.stops.is_empty()
|
||||
}
|
||||
/// The spread and count as the gradient paints them: Pad and 1 for one that pads (whatever
|
||||
/// count it keeps) and for a freeform one, else its spread and [`Self::repeat_count`]. Equal
|
||||
|
||||
@@ -36,6 +36,10 @@ fn spread_maps_the_parameter_to_a_place_along_the_stops() {
|
||||
let free = spread(GradientKind::Freeform, GradientSpread::Repeat, 3);
|
||||
assert_eq!(free.spread_param(0.7), 0.7);
|
||||
assert!(!free.is_spread() && !pad.is_spread() && repeat.is_spread());
|
||||
// Without stops it paints as one that pads.
|
||||
let empty = Gradient { stops: vec![], ..repeat.clone() };
|
||||
assert!(!empty.is_spread());
|
||||
assert_eq!(empty.painted_spread(), (GradientSpread::Pad, 1));
|
||||
assert!(repeat.spread_param(f64::NAN).is_nan());
|
||||
// A count out of range (set in code) counts as the nearest one in range.
|
||||
assert_eq!(spread(GradientKind::Linear, GradientSpread::Repeat, 0).repeat_count(), 1);
|
||||
|
||||
@@ -184,6 +184,7 @@ fn reverse_mirrors_midpoints() {
|
||||
r.reverse();
|
||||
let mids: Vec<f32> = r.stops.iter().map(|s| s.midpoint).collect();
|
||||
let want: Vec<f32> = g.stops.iter().rev().skip(1).map(|s| 1.0 - s.midpoint).chain([0.5]).collect();
|
||||
assert_eq!(mids.len(), g.stops.len(), "reversing keeps every stop");
|
||||
assert!(mids.iter().zip(&want).all(|(a, b)| (a - b).abs() < 1e-6), "{mids:?} {want:?}");
|
||||
for i in 0..=20 {
|
||||
let t = i as f32 / 20.0;
|
||||
@@ -291,6 +292,7 @@ fn remove_keeps_two() {
|
||||
fn move_reorders_and_tracks_index() {
|
||||
let g = g3();
|
||||
let (v, i) = move_stop(&g.stops, 0, 0.8);
|
||||
assert_eq!(v.len(), g.stops.len(), "moving keeps every stop");
|
||||
assert_eq!(i, 1);
|
||||
assert_eq!(v[1].color.to_hex(), "#ffffff");
|
||||
assert!(v.windows(2).all(|w| w[0].offset <= w[1].offset));
|
||||
@@ -1176,7 +1178,8 @@ fn a_conic_with_no_extent_or_bad_numbers_still_sweeps() {
|
||||
assert!(t(90.0, 50.0).abs() < 1e-12, "{g:?}");
|
||||
assert!((t(50.0, 90.0) - 0.25).abs() < 1e-12, "{g:?}");
|
||||
let wedges = g.conic_wedges(Rect::new(0.0, 0.0, 100.0, 100.0), 4, false);
|
||||
assert!(wedges.iter().flat_map(|(pts, _)| pts).all(|p| p.is_finite()), "{g:?}");
|
||||
assert_eq!(wedges.len(), 4, "{g:?}");
|
||||
assert!(wedges.iter().all(|(pts, _)| pts.len() >= 3 && pts.iter().all(|p| p.is_finite())), "{g:?}: {wedges:?}");
|
||||
}
|
||||
// A flat extent keeps the vector's direction and the sign of its aspect.
|
||||
let down = GradientGeom { end: Point::new(50.0, 80.0), ..conic_at(c, 30.0, 0.0) };
|
||||
|
||||
@@ -177,20 +177,23 @@ mod tests {
|
||||
fn harmonies_keep_the_base_model() {
|
||||
let base = Color::cmyk(0.0, 1.0, 1.0, 0.0);
|
||||
for h in Harmony::ALL {
|
||||
assert!(apply(h, base).iter().all(|c| matches!(c, Color::Cmyk { .. })), "{}", label(h));
|
||||
let colors = apply(h, base);
|
||||
assert!(colors.len() >= 2 && colors.iter().all(|c| matches!(c, Color::Cmyk { .. })), "{}: {colors:?}", label(h));
|
||||
}
|
||||
let Color::Cmyk { c, m, y, .. } = apply(Harmony::Complementary, base)[1] else { panic!("a CMYK complement") };
|
||||
assert!(c > m && c > y, "the complement of red is a cyan: {c} {m} {y}");
|
||||
let g = Guide::new(Color::gray(0.4), Harmony::Triad, &GuideOptions::default());
|
||||
assert!(g.grid.iter().flatten().all(|c| matches!(c, Color::Gray { .. })));
|
||||
let cells: Vec<&Color> = g.grid.iter().flatten().collect();
|
||||
assert!(!cells.is_empty() && cells.iter().all(|c| matches!(c, Color::Gray { .. })), "{cells:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rules_parse_by_id_and_label() {
|
||||
for h in Harmony::ALL {
|
||||
assert_eq!(parse(h.id()), Some(h));
|
||||
assert_eq!(parse(label(h)), Some(h));
|
||||
}
|
||||
// A label reads back as its rule, its spaces and case ignored, and so does an id.
|
||||
assert_eq!(parse("Split Complementary"), Some(Harmony::SplitComplementary));
|
||||
assert_eq!(parse("high contrast 3"), Some(Harmony::HighContrast3));
|
||||
assert_eq!(parse("tetrad2"), Some(Harmony::Tetrad2));
|
||||
assert_eq!(parse(""), None);
|
||||
assert_eq!(Harmony::SplitComplementary.id(), "splitComplementary");
|
||||
assert_eq!(Harmony::HighContrast3.id(), "highContrast3");
|
||||
assert_eq!(parse("square"), None);
|
||||
|
||||
@@ -825,16 +825,4 @@ mod tests {
|
||||
let [l, ..] = to_oklab(&stop("Violet Edge", 4));
|
||||
assert!(l < 0.5 && to_oklab(&stop("Prism Veil", 2))[0] > 0.95, "{l}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_other_libraries_keep_classic_mixing_and_centered_midpoints() {
|
||||
for b in builtins().filter(|b| !["organic-fades", "holographic"].contains(&b.id)) {
|
||||
for s in builtin_library(b.id).unwrap().iter() {
|
||||
if let Paint::Gradient(g) = &s.paint {
|
||||
assert_eq!(g.gradient.method, GradientMethod::Classic, "{}", s.name);
|
||||
assert!(g.gradient.stops.iter().all(|st| st.midpoint == 0.5), "{}", s.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -796,12 +796,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn methods_parse_by_id_and_label() {
|
||||
for m in Method::ALL {
|
||||
assert_eq!(Method::parse(m.id()), Some(m));
|
||||
assert_eq!(Method::parse(m.label()), Some(m));
|
||||
}
|
||||
assert_eq!(Method::parse("preserveTints"), Some(Method::PreserveTints));
|
||||
assert_eq!(Method::parse("Hue Shift"), Some(Method::HueShift));
|
||||
assert_eq!(Method::parse("Tints and Shades"), Some(Method::TintsShades));
|
||||
assert_eq!(Method::parse("tints & shades"), Some(Method::TintsShades));
|
||||
assert_eq!(Method::parse("nope"), None);
|
||||
assert_eq!(Method::parse(""), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -186,13 +186,20 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn default_swatches_parse() {
|
||||
// `solid`/`grad` fall back to black or white on a bad literal instead of panicking; make sure
|
||||
// none falls back.
|
||||
let src = include_str!("swatch.rs");
|
||||
let hexes: Vec<&str> = src.split('"').filter(|t| t.starts_with('#') && t.len() == 7).collect();
|
||||
assert!(hexes.len() > 30);
|
||||
for h in hexes {
|
||||
assert!(Color::from_hex(h).is_some(), "{h}");
|
||||
}
|
||||
// `solid` and `grad` fall back to black or white on a bad hex literal. A fallback gives a
|
||||
// solid the color of Black or White, and a gradient a stop that differs from the swatch
|
||||
// its hex literal names.
|
||||
let (s, g) = default_swatches(Model::Rgb);
|
||||
let solids: Vec<Color> = s.iter().chain(g.iter().flat_map(|g| &g.swatches)).filter_map(|w| w.paint.color()).collect();
|
||||
assert!(solids.len() > 40, "{}", solids.len());
|
||||
let repeated: Vec<&Color> = solids.iter().enumerate().filter(|(i, c)| solids[..*i].contains(c)).map(|(_, c)| c).collect();
|
||||
assert_eq!(repeated, Vec::<&Color>::new(), "colors of more than one default swatch");
|
||||
let color = |name: &str| s.iter().find(|w| w.name == name).and_then(|w| w.paint.color());
|
||||
let stops = |name: &str| match s.iter().find(|w| w.name == name).map(|w| &w.paint) {
|
||||
Some(Paint::Gradient(gp)) => gp.gradient.stops.iter().map(|st| Some(st.color)).collect::<Vec<_>>(),
|
||||
other => panic!("{name}: {other:?}"),
|
||||
};
|
||||
assert_eq!(stops("Sunset"), [color("Amber"), color("Rose")]);
|
||||
assert_eq!(stops("Ocean"), [color("Cyan"), color("Blue")]);
|
||||
}
|
||||
}
|
||||
@@ -208,10 +208,11 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn category_ids_parse_back() {
|
||||
for c in Category::ALL {
|
||||
assert_eq!(Category::parse(c.id()), Some(c));
|
||||
}
|
||||
// Commands and saved settings name a category by its id, exactly.
|
||||
assert_eq!(Category::parse("largeText"), Some(Category::LargeText));
|
||||
assert_eq!(Category::parse("graphics"), Some(Category::Graphics));
|
||||
assert_eq!(Category::parse("NormalText"), None);
|
||||
assert_eq!(Category::parse("Large Text"), None, "a label is not an id");
|
||||
}
|
||||
|
||||
fn hue(srgb: [f32; 3]) -> f64 {
|
||||
|
||||
+17
-3
@@ -2784,10 +2784,13 @@ mod tests {
|
||||
Paint::Gradient(Box::new(GradientPaint::new(Gradient { stops, ..Gradient::default() })))
|
||||
};
|
||||
let Paint::Gradient(m) = lerp_paint(&spot_gradient(0.2), &spot_gradient(1.0), 0.5) else { panic!() };
|
||||
assert_eq!(m.gradient.stops.len(), 2);
|
||||
assert!(m.gradient.stops.iter().all(|s| s.swatch.as_deref() == Some("Spot") && (s.tint - 0.6).abs() < 1e-6), "{:?}", m.gradient.stops);
|
||||
let Paint::Gradient(m) = lerp_paint(&tinted(0.2), &spot_gradient(1.0), 0.5) else { panic!() };
|
||||
assert_eq!(m.gradient.stops.len(), 2);
|
||||
assert!(m.gradient.stops.iter().all(|s| s.swatch.as_deref() == Some("Spot") && (s.tint - 0.6).abs() < 1e-6), "{:?}", m.gradient.stops);
|
||||
let Paint::Gradient(m) = lerp_paint(&Paint::solid(Color::BLACK), &spot_gradient(1.0), 0.5) else { panic!() };
|
||||
assert_eq!(m.gradient.stops.len(), 2);
|
||||
assert!(m.gradient.stops.iter().all(|s| s.swatch.is_none()), "{:?}", m.gradient.stops);
|
||||
}
|
||||
|
||||
@@ -2840,6 +2843,7 @@ mod tests {
|
||||
let a = gradient_paint(vec![spot_stop(0.0, 0.2, Some(p)), spot_stop(1.0, 0.2, Some(p))]);
|
||||
let b = gradient_paint(vec![spot_stop(0.0, 1.0, Some(q)), spot_stop(1.0, 1.0, Some(q))]);
|
||||
let Paint::Gradient(m) = lerp_paint(&a, &b, 0.25) else { panic!() };
|
||||
assert_eq!(m.gradient.stops.len(), 2);
|
||||
for s in &m.gradient.stops {
|
||||
assert_eq!(s.swatch.as_deref(), Some("Spot"));
|
||||
assert!((s.tint - 0.4).abs() < 1e-6, "{}", s.tint);
|
||||
@@ -2848,6 +2852,7 @@ mod tests {
|
||||
// Without plates on either side the steps print the spot ink alone, as before.
|
||||
let bare = |tint| gradient_paint(vec![spot_stop(0.0, tint, None), spot_stop(1.0, tint, None)]);
|
||||
let Paint::Gradient(m) = lerp_paint(&bare(0.2), &bare(1.0), 0.5) else { panic!() };
|
||||
assert_eq!(m.gradient.stops.len(), 2);
|
||||
assert!(m.gradient.stops.iter().all(|s| s.plates.is_none()), "{:?}", m.gradient.stops);
|
||||
}
|
||||
|
||||
@@ -2882,10 +2887,12 @@ mod tests {
|
||||
let with = gradient_paint(vec![spot_stop(0.0, 1.0, Some(p)), spot_stop(1.0, 1.0, Some(p))]);
|
||||
let without = gradient_paint(vec![spot_stop(0.0, 1.0, None), spot_stop(1.0, 1.0, None)]);
|
||||
let Paint::Gradient(m) = lerp_paint(&without, &with, 0.25) else { panic!() };
|
||||
assert_eq!(m.gradient.stops.len(), 2);
|
||||
assert!(m.gradient.stops.iter().all(|s| s.swatch.as_deref() == Some("Spot")), "{:?}", m.gradient.stops);
|
||||
m.gradient.stops.iter().for_each(|s| assert_plates(s.plates, [0.1, 0.2, 0.0, 0.05]));
|
||||
// The ends keep their own plates.
|
||||
let Paint::Gradient(m) = lerp_paint(&without, &with, 0.0) else { panic!() };
|
||||
assert_eq!(m.gradient.stops.len(), 2);
|
||||
assert!(m.gradient.stops.iter().all(|s| s.plates.is_none()), "{:?}", m.gradient.stops);
|
||||
|
||||
// Another swatch, or an unlinked stop: process steps with no plates, as before.
|
||||
@@ -2897,6 +2904,7 @@ mod tests {
|
||||
let plain = gradient_paint(vec![plain.clone(), GradientStop { offset: 1.0, ..plain }]);
|
||||
for b in [&other, &plain] {
|
||||
let Paint::Gradient(m) = lerp_paint(&with, b, 0.5) else { panic!() };
|
||||
assert_eq!(m.gradient.stops.len(), 2);
|
||||
assert!(m.gradient.stops.iter().all(|s| s.swatch.is_none() && s.plates.is_none()), "{:?}", m.gradient.stops);
|
||||
}
|
||||
}
|
||||
@@ -2906,11 +2914,14 @@ mod tests {
|
||||
let p = [0.4, 0.8, 0.0, 0.2];
|
||||
let gradient = gradient_paint(vec![spot_stop(0.0, 1.0, Some(p)), spot_stop(1.0, 1.0, Some(p))]);
|
||||
let Paint::Gradient(g) = &gradient else { panic!() };
|
||||
assert!(solid_gradient(Color::BLACK, Some("Spot"), 0.2, &g.gradient).stops.iter().all(|s| s.plates.is_none()));
|
||||
let linked = solid_gradient(Color::BLACK, Some("Spot"), 0.2, &g.gradient);
|
||||
assert_eq!(linked.stops.len(), 2);
|
||||
assert!(linked.stops.iter().all(|s| s.plates.is_none() && s.swatch.as_deref() == Some("Spot") && s.tint == 0.2), "{:?}", linked.stops);
|
||||
let solid = Paint::Solid { color: Color::cmyk(1.0, 0.7, 0.0, 0.4).tinted(0.2), swatch: Some("Spot".into()), tint: 0.2 };
|
||||
// The solid's end has no plates: they grow from none toward the gradient's, both ways round.
|
||||
for (a, b, t) in [(&solid, &gradient, 0.25), (&gradient, &solid, 0.75)] {
|
||||
let Paint::Gradient(m) = lerp_paint(a, b, t) else { panic!() };
|
||||
assert_eq!(m.gradient.stops.len(), 2);
|
||||
for s in &m.gradient.stops {
|
||||
assert_eq!(s.swatch.as_deref(), Some("Spot"));
|
||||
assert!((s.tint - 0.4).abs() < 1e-6, "{}", s.tint);
|
||||
@@ -2919,6 +2930,7 @@ mod tests {
|
||||
}
|
||||
// A process solid unlinks the steps, and they take no plates.
|
||||
let Paint::Gradient(m) = lerp_paint(&Paint::solid(Color::BLACK), &gradient, 0.5) else { panic!() };
|
||||
assert_eq!(m.gradient.stops.len(), 2);
|
||||
assert!(m.gradient.stops.iter().all(|s| s.swatch.is_none() && s.plates.is_none()), "{:?}", m.gradient.stops);
|
||||
}
|
||||
|
||||
@@ -3401,7 +3413,8 @@ mod tests {
|
||||
#[test]
|
||||
fn odd_dash_blends_to_solid_with_closed_gaps() {
|
||||
let d = lerp_dash(Some(&Dash { pattern: vec![2.0, 3.0, 4.0], ..Default::default() }), None, 1.0).unwrap();
|
||||
assert!(d.pattern.iter().skip(1).step_by(2).all(|g| *g == 0.0), "{:?}", d.pattern);
|
||||
// Doubled to dash, gap, dash, gap, dash, gap; each dash takes the gap after it.
|
||||
assert_eq!(d.pattern, [5.0, 0.0, 6.0, 0.0, 7.0, 0.0]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -3412,7 +3425,8 @@ mod tests {
|
||||
let mid = lerp_node(&a, &b, 0.4);
|
||||
let mut ids = vec![];
|
||||
mid.walk(&mut |n| ids.push(n.id));
|
||||
assert!(ids.iter().all(|i| *i == NodeId(0)), "{ids:?}");
|
||||
// The step and its two members, all of them new.
|
||||
assert_eq!(ids, [NodeId(0); 3]);
|
||||
}
|
||||
|
||||
/// A blend of `a` and `b` spaced by `spacing`.
|
||||
|
||||
@@ -64,11 +64,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn modes_read_back_and_unknown_ones_are_add() {
|
||||
for m in ShapeMode::ALL {
|
||||
let v = serde_json::to_value(m).unwrap();
|
||||
assert_eq!(v, serde_json::json!(m.name()));
|
||||
assert_eq!(serde_json::from_value::<ShapeMode>(v).unwrap(), m);
|
||||
}
|
||||
assert_eq!(serde_json::to_value(ShapeMode::Subtract).unwrap(), serde_json::json!("subtract"));
|
||||
assert_eq!(serde_json::from_value::<ShapeMode>(serde_json::json!("exclude")).unwrap(), ShapeMode::Exclude);
|
||||
assert_eq!(ShapeMode::parse("intersect"), Some(ShapeMode::Intersect));
|
||||
assert_eq!(ShapeMode::parse("Intersect"), None);
|
||||
for v in [serde_json::json!("divide"), serde_json::json!(3), serde_json::json!(null), serde_json::json!({"a": [1]})] {
|
||||
assert_eq!(serde_json::from_value::<ShapeMode>(v).unwrap(), ShapeMode::Add);
|
||||
}
|
||||
|
||||
@@ -613,6 +613,7 @@ mod tests {
|
||||
d.limit_depth_noting(&mut warnings);
|
||||
assert_eq!(warnings, [symbols_note()]);
|
||||
assert!(!d.too_deep(None), "{count} {last}");
|
||||
assert_eq!(d.symbols.len(), count, "every symbol is kept");
|
||||
assert!(d.symbols.iter().all(|s| s.art.children().is_some()), "the art is still a group");
|
||||
}
|
||||
// An edit that makes one hold itself is seen, whatever else stayed as it was.
|
||||
|
||||
@@ -253,6 +253,7 @@ mod tests {
|
||||
let mut a = Node::group(NodeId(1), vec![Arc::new(text)]);
|
||||
apply(&mut a, &[SymbolOverride { path: vec![0], stroke: Some(red.clone()), ..Default::default() }]);
|
||||
let Some(NodeKind::Text(t)) = part(&a, &[0]).map(|n| &n.kind) else { panic!("type") };
|
||||
assert_eq!(t.runs.len(), 1);
|
||||
assert!(t.runs.iter().all(|r| r.style.stroke == red && r.style.stroke_width == 1.0), "the stroke draws at 1 pt");
|
||||
|
||||
// A path whose stroke has neither paint nor weight gets 1 pt too.
|
||||
|
||||
@@ -44,7 +44,7 @@ pub use tabs_lists::{
|
||||
Bullet, DEFAULT_TAB_INTERVAL, LIST_HANGING_INDENT, LIST_LEVEL_INDENT, LIST_LEVELS, ListAlign, ListCounts, MAX_LIST_START, NumberStyle, ParaList,
|
||||
TabAlign, TabStop,
|
||||
};
|
||||
pub use wrap::{resolve_wrap, wrap_copy_units, wrap_outline, wrap_sources, wrap_work};
|
||||
pub use wrap::{resolve_wrap, wrap_copy_units, wrap_outline, wrap_source_objects, wrap_sources, wrap_work};
|
||||
|
||||
/// A text object. `runs` split into paragraphs at `\n`.
|
||||
///
|
||||
|
||||
@@ -217,11 +217,10 @@ fn indic_digits_map_to_their_scripts_block() {
|
||||
assert_eq!(map(d, "a-Z ٪"), "a-Z ٪");
|
||||
}
|
||||
assert_eq!(map(Digits::Devanagari, "page 12"), "page १२");
|
||||
for d in Digits::ALL {
|
||||
assert_eq!(serde_json::to_value(d).unwrap(), d.id());
|
||||
assert_eq!(serde_json::from_value::<Digits>(d.id().into()).unwrap(), d);
|
||||
assert_eq!(Digits::from_id(d.id()), Some(d));
|
||||
}
|
||||
assert_eq!(serde_json::to_value(Digits::Devanagari).unwrap(), "devanagari");
|
||||
assert_eq!(serde_json::from_value::<Digits>("farsi".into()).unwrap(), Digits::Farsi);
|
||||
assert_eq!(Digits::Malayalam.id(), "malayalam");
|
||||
assert_eq!(Digits::from_id("default"), Some(Digits::Default));
|
||||
assert_eq!(Digits::from_id("roman"), None);
|
||||
assert!(serde_json::from_value::<Digits>("roman".into()).is_err());
|
||||
}
|
||||
@@ -695,6 +694,15 @@ fn a_wrap_object_below_every_area_type_object_makes_no_outline() {
|
||||
});
|
||||
assert_eq!(sources, 1);
|
||||
assert_eq!(wrap::OUTLINES_MADE.with(|c| c.get()), 1, "only the wrap object above the type is outlined");
|
||||
// The objects alone come without a copy of any shape into text space.
|
||||
let mut found = vec![];
|
||||
wrap_source_objects(&d, |n, objects| found.push((n.id, objects.iter().map(|o| o.id).collect::<Vec<_>>())));
|
||||
let mut expected = vec![];
|
||||
wrap_sources(&d, |n, objects, _| expected.push((n.id, objects.iter().map(|o| o.id).collect::<Vec<_>>())));
|
||||
assert_eq!(found, expected);
|
||||
wrap::SHAPES_COPIED.with(|c| c.set(0));
|
||||
wrap_source_objects(&d, |_, _| {});
|
||||
assert_eq!(wrap::SHAPES_COPIED.with(|c| c.get()), 0, "no wrap shape is copied");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -11,6 +11,8 @@ use crate::{Document, Node, NodeId, NodeKind};
|
||||
thread_local! {
|
||||
/// How many wrap outlines [`each_text`] has made on this thread (for tests).
|
||||
pub(super) static OUTLINES_MADE: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
|
||||
/// How many wrap shapes [`shapes_of`] has copied into text space on this thread (for tests).
|
||||
pub(super) static SHAPES_COPIED: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
|
||||
}
|
||||
|
||||
/// Outline of a wrap object in document coordinates: its paths, or its bounds for other art.
|
||||
@@ -167,6 +169,8 @@ fn shapes_of(t: &TextObject, above: &[(&Node, WrapShape)]) -> Vec<WrapShape> {
|
||||
.iter()
|
||||
.rev()
|
||||
.map(|(_, s)| {
|
||||
#[cfg(test)]
|
||||
SHAPES_COPIED.with(|c| c.set(c.get() + 1));
|
||||
let mut path = s.path.clone();
|
||||
path.transform(inv);
|
||||
WrapShape { path, wrap: s.wrap }
|
||||
@@ -189,6 +193,18 @@ pub fn wrap_sources<'a>(doc: &'a Document, mut f: impl FnMut(&'a Node, Vec<&'a N
|
||||
}
|
||||
}
|
||||
|
||||
/// [`wrap_sources`] without the shapes: each area text object that gets wrap shapes, with the wrap
|
||||
/// objects whose outlines make them, bottom first. No shape is copied into text space.
|
||||
pub fn wrap_source_objects<'a>(doc: &'a Document, mut f: impl FnMut(&'a Node, Vec<&'a Node>)) {
|
||||
for layer in &doc.layers {
|
||||
each_text(layer, |n, above| {
|
||||
if matches!(n.kind, NodeKind::Text(_)) && !above.is_empty() {
|
||||
f(n, above.iter().rev().map(|(s, _)| *s).collect());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Resolve the wrap shapes (`TextObject::wrap`, text space) of each area text object from the
|
||||
/// outlines of the wrap objects above it in its layer. With `before`, the layers it holds unchanged
|
||||
/// are skipped; without it, every layer is resolved. Returns the area text objects whose shapes
|
||||
|
||||
@@ -98,11 +98,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn ids_round_trip_and_unknown_views_show_the_result() {
|
||||
for v in TraceView::ALL {
|
||||
assert_eq!(TraceView::from_id(v.id()), Some(v));
|
||||
assert_eq!(TraceView::from_id(&v.id().to_ascii_uppercase()), Some(v));
|
||||
assert!(v.shows_result() || v.shows_outlines() || v.shows_source(), "{v:?} shows something");
|
||||
}
|
||||
assert_eq!(TraceView::Source.id(), "sourceImage");
|
||||
assert_eq!(TraceView::from_id("outlinesWithSourceImage"), Some(TraceView::OutlinesWithSource));
|
||||
assert_eq!(TraceView::from_id("TRACINGRESULT"), Some(TraceView::Result), "case does not matter");
|
||||
assert_eq!(TraceView::from_id("tracing"), None);
|
||||
let mut g = Node::group(crate::NodeId(1), vec![]);
|
||||
assert_eq!(g.trace_view(), TraceView::Result);
|
||||
g.extras_mut().trace = Some(Box::new(serde_json::json!({"view": "outlines"})));
|
||||
|
||||
@@ -109,10 +109,9 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn the_effects_are_colour_adjustments_in_their_own_menu() {
|
||||
for id in EFFECTS {
|
||||
assert!(crate::is_adjustment(id), "{id}");
|
||||
assert_eq!(crate::effect_info(id).unwrap().menu, ["Effect", "Color Effects"]);
|
||||
}
|
||||
assert!(crate::is_adjustment(DUOTONE));
|
||||
assert_eq!(crate::effect_info(DUOTONE).unwrap().menu, ["Effect", "Color Effects"]);
|
||||
assert!(!crate::is_adjustment("stylize.dropShadow"), "an effect outside the add-on is not one");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1065,60 +1065,6 @@ fn linear_light_blur_mixes_light_not_values() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Timings on a 2000 × 2000 raster (`cargo test -p vectorcraft-effects --release -- --ignored
|
||||
/// --nocapture pixel_timings`).
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn pixel_timings() {
|
||||
let (w, h) = (2000, 2000);
|
||||
let src = image(w, h, |x, y| [(x % 256) as u8, (y % 256) as u8, ((x ^ y) % 256) as u8, 255]);
|
||||
let s = PixelSpace {
|
||||
to_doc: Affine::IDENTITY,
|
||||
px: 1.0,
|
||||
center: Point::new(1000.0, 1000.0),
|
||||
size: vectorcraft_geom::Vec2::new(2000.0, 2000.0),
|
||||
channels: Channels::Rgb,
|
||||
line: 1.0,
|
||||
extent: 0.0,
|
||||
};
|
||||
let cases = [
|
||||
("blur.radial", json!({"quality": "draft"})),
|
||||
("blur.radial", json!({"quality": "good"})),
|
||||
("blur.radial", json!({"quality": "best", "method": "zoom"})),
|
||||
("blur.smart", json!({"quality": "low"})),
|
||||
("blur.smart", json!({"quality": "high", "radius": 30})),
|
||||
("sharpen.unsharpMask", json!({"radius": 20})),
|
||||
("brushStrokes.accentedEdges", json!({"edgeWidth": 14})),
|
||||
("brushStrokes.angledStrokes", json!({"strokeLength": 50})),
|
||||
("brushStrokes.crosshatch", json!({"strokeLength": 50, "strength": 3})),
|
||||
("brushStrokes.darkStrokes", json!({})),
|
||||
("brushStrokes.inkOutlines", json!({"strokeLength": 50})),
|
||||
("brushStrokes.spatter", json!({"sprayRadius": 25})),
|
||||
("brushStrokes.sprayedStrokes", json!({"strokeLength": 20, "sprayRadius": 25})),
|
||||
("brushStrokes.sumiE", json!({"strokeWidth": 15})),
|
||||
("pixelate.colorHalftone", json!({"maxRadius": 4})),
|
||||
("pixelate.crystallize", json!({"cellSize": 3})),
|
||||
("pixelate.crystallize", json!({"cellSize": 300})),
|
||||
("pixelate.mezzotint", json!({"type": "grainyDots"})),
|
||||
("pixelate.pointillize", json!({"cellSize": 3})),
|
||||
("pixelate.pointillize", json!({"cellSize": 300})),
|
||||
("texture.craquelure", json!({"crackSpacing": 2})),
|
||||
("texture.craquelure", json!({"crackSpacing": 100})),
|
||||
("texture.grain", json!({"grainType": "clumped"})),
|
||||
("texture.mosaicTiles", json!({"tileSize": 2})),
|
||||
("texture.patchwork", json!({"squareSize": 0})),
|
||||
("texture.stainedGlass", json!({"cellSize": 2})),
|
||||
("texture.texturizer", json!({"texture": "sandstone", "scaling": 50})),
|
||||
("texture.texturizer", json!({"texture": "burlap"})),
|
||||
];
|
||||
for (id, p) in cases {
|
||||
let mut d = src.clone();
|
||||
let t = std::time::Instant::now();
|
||||
fx(id, p.clone()).apply(&mut d, w, h, &s);
|
||||
println!("{id} {p}: {:?}", t.elapsed());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pixelate_params_take_defaults_and_stay_in_range() {
|
||||
assert_eq!(fx("pixelate.colorHalftone", json!({})), PixelFx::ColorHalftone { max_radius: 8.0, angles: [108.0, 162.0, 90.0, 45.0] });
|
||||
|
||||
@@ -466,14 +466,16 @@ fn wireframe_mode_is_checked_against_the_edges_it_draws() {
|
||||
assert!(refused.contains("simplify the gradient"), "{refused}");
|
||||
assert_eq!(crate::validate_revolve(&n, &wire), Ok(()));
|
||||
n.appearance.effects.push(crate::new_effect(crate::REVOLVE, &wire).unwrap());
|
||||
assert!(leaves(&drawn(&n)).iter().all(|(_, filled, stroke)| !filled && stroke.is_some()));
|
||||
let edges = leaves(&drawn(&n));
|
||||
assert!(!edges.is_empty() && edges.iter().all(|(_, filled, stroke)| !filled && stroke.is_some()), "{} pieces", edges.len());
|
||||
// On the fill.
|
||||
let fx = n.appearance.effects.remove(0);
|
||||
let at = n.appearance.items.iter().position(|i| matches!(i, AppearanceItem::Fill(_))).unwrap();
|
||||
assert!(crate::revolve::validate_item_revolve(&n, &shaded, at, 0).is_err());
|
||||
assert_eq!(crate::revolve::validate_item_revolve(&n, &wire, at, 0), Ok(()));
|
||||
n.appearance.items[at].effects_mut().push(fx);
|
||||
assert!(leaves(&drawn(&n)).iter().all(|(_, filled, stroke)| !filled && stroke.is_some()));
|
||||
let edges = leaves(&drawn(&n));
|
||||
assert!(!edges.is_empty() && edges.iter().all(|(_, filled, stroke)| !filled && stroke.is_some()), "{} pieces", edges.len());
|
||||
}
|
||||
|
||||
/// A 3D (Classic) effect ignores a `render` it does not take in a loaded file: it draws as before.
|
||||
|
||||
@@ -155,6 +155,7 @@ fn fitted_dashes_on_curves_and_degenerate_paths_stay_finite() {
|
||||
s.profile = profile.clone();
|
||||
});
|
||||
let o = line_outline(&mixed, &st, 4.0, 0.01);
|
||||
assert!(!o.elements().is_empty(), "{pat:?}: the curve's dashes are drawn");
|
||||
assert!(o.elements().iter().filter_map(|e| e.end_point()).all(|p| p.x.is_finite() && p.y.is_finite()), "{pat:?}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,7 +301,9 @@ fn a_spread_gradient_runs_its_stops_along_the_stroke_that_many_times() {
|
||||
let mut st = stroke(10.0, mode);
|
||||
let g = Gradient { spread, repeats: 3, ..Gradient::default() };
|
||||
st.paint = Paint::Gradient(Box::new(GradientPaint::new(g.clone())));
|
||||
for s in slices(&bp, &st) {
|
||||
let pieces = slices(&bp, &st);
|
||||
assert!(!pieces.is_empty(), "{mode:?} {spread:?}: the stroke is painted in slices");
|
||||
for s in pieces {
|
||||
let Paint::Gradient(p) = s.paint(&g.unrolled()) else { panic!("a gradient slice") };
|
||||
let geom = p.geom.unwrap();
|
||||
for u in [0.1, 0.5, 0.9] {
|
||||
|
||||
@@ -247,15 +247,14 @@ fn a_warp_draws_with_the_map_its_version_names() {
|
||||
fn a_warp_bends_a_flat_box_as_the_middle_of_its_patch() {
|
||||
let anchors = |p: &PathData| p.subpaths.iter().flat_map(|s| s.anchors.clone()).collect::<Vec<_>>();
|
||||
let vertical = shapes::line(Point::new(100.0, 0.0), Point::new(100.0, 100.0));
|
||||
let out = run("warp.arc", json!({"bend": 50, "version": 1}), &vertical);
|
||||
assert!(anchors(&out).iter().all(|a| close(a.p.x, 100.0, 1e-9) && close(a.h_in.x, 100.0, 1e-9) && close(a.h_out.x, 100.0, 1e-9)), "{out:?}");
|
||||
let out = anchors(&run("warp.arc", json!({"bend": 50, "version": 1}), &vertical));
|
||||
assert!(out.len() >= 2, "{out:?}");
|
||||
assert!(out.iter().all(|a| close(a.p.x, 100.0, 1e-9) && close(a.h_in.x, 100.0, 1e-9) && close(a.h_out.x, 100.0, 1e-9)), "{out:?}");
|
||||
let horizontal = shapes::line(Point::new(0.0, 50.0), Point::new(200.0, 50.0));
|
||||
for style in ["bulge", "fisheye", "inflate", "squeeze"] {
|
||||
let out = run(&format!("warp.{style}"), json!({"bend": 50, "version": 1}), &horizontal);
|
||||
assert!(
|
||||
anchors(&out).iter().all(|a| close(a.p.y, 50.0, 1e-9) && close(a.h_in.y, 50.0, 1e-9) && close(a.h_out.y, 50.0, 1e-9)),
|
||||
"{style}: {out:?}"
|
||||
);
|
||||
let out = anchors(&run(&format!("warp.{style}"), json!({"bend": 50, "version": 1}), &horizontal));
|
||||
assert!(out.len() >= 2, "{style}: {out:?}");
|
||||
assert!(out.iter().all(|a| close(a.p.y, 50.0, 1e-9) && close(a.h_in.y, 50.0, 1e-9) && close(a.h_out.y, 50.0, 1e-9)), "{style}: {out:?}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2084,18 +2083,6 @@ fn bad_params_fall_back_to_defaults() {
|
||||
assert!(close(out.bounds().unwrap().width(), 124.0, 0.1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn bench_catalog_lookup() {
|
||||
let t = std::time::Instant::now();
|
||||
let mut n = 0;
|
||||
for _ in 0..10_000 {
|
||||
n += crate::is_geometry("distort.roughen") as usize;
|
||||
n += crate::merged_params("stylize.dropShadow", &serde_json::Value::Null).as_object().unwrap().len();
|
||||
}
|
||||
eprintln!("10k lookups: {:?} ({n})", t.elapsed());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_repeat_of_a_symbol_whose_art_is_a_repeat_shares_the_instance_budget() {
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -1002,7 +1002,8 @@ pub use variablecmds::{VariableSort, VariableSortKey, variable_order};
|
||||
|
||||
/// Command ids kept only so older scripts keep working: `(alias, the command it duplicates)`.
|
||||
/// They run as before but the command palette leaves them out (it lists the command once).
|
||||
pub const ALIASES: &[(&str, &str)] = &[("object.convertDocumentColorMode", "file.documentColorMode")];
|
||||
pub const ALIASES: &[(&str, &str)] =
|
||||
&[("object.convertDocumentColorMode", "file.documentColorMode"), ("addon.pathtools.bridge", "addon.pathtools.commonTangents")];
|
||||
|
||||
/// Is `id` an [`ALIASES`] entry?
|
||||
pub fn is_alias(id: &str) -> bool {
|
||||
|
||||
@@ -36,7 +36,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Mark Bounds of Each",
|
||||
["Object", "Plug-ins", "Arrange Tools"],
|
||||
None,
|
||||
"{style?: \"corners\" (an L-shaped mark on each corner, its two legs running inward along the edges) | \"rectangle\" (a rectangle on the bounds) (\"corners\"), bounds?: \"geometric\" (strokes not counted) | \"visual\" (strokes, brush art and effects as drawn) (\"geometric\"), length?: pt 0.001..1000000 (10; corners: each leg's length, at most half the side it runs along), weight?: pt 0.01..1000 (1), color?: color (\"#ff0000\"; an RGB color takes the document's color mode)} draw marks on the bounds of each selected object (the top-level ones, at most 20000) as new art: a group of four corner marks, or one rectangle, with no fill and the stroke given, stacked directly above its object (above the outermost clip group or clipping sublayer that holds it, so the clip does not hide them). A clip group is measured by its clipping path and other groups by their members together. Guides, and objects without bounds such as empty groups, get no marks. The marks are selected; one undo step, and none when nothing gets marks (an error) → {ids: [the new marks…], count}",
|
||||
"{style?: \"corners\" (an L-shaped mark on each corner, its two legs running inward along the edges) | \"rectangle\" (a rectangle on the bounds) (\"corners\"), bounds?: \"geometric\" (strokes not counted) | \"visual\" (strokes, brush art and effects as drawn) (\"geometric\"), length?: pt 0.001..1000000 (10; corners: each leg's length, at most half the side it runs along), weight?: pt 0.01..1000 (1), color?: color (\"#ff0000\"; an RGB color takes the document's color mode)} draw marks on the bounds of each selected object (the top-level ones, at most 20000) as new art: a group of four corner marks, or one rectangle, with no fill and the stroke given, stacked directly above its object (above the outermost clip group or clipping sublayer that holds it, so the clip does not hide them). A clip group is measured by its clipping path and other groups by their members together. Guides, objects without bounds such as empty groups, and (for corners) objects whose sides are too short for any leg get no marks. The marks are selected; one undo step, and none when nothing gets marks (an error) → {ids: [the new marks…], count}",
|
||||
has_selection,
|
||||
mark_bounds
|
||||
)]
|
||||
@@ -55,10 +55,16 @@ fn corners(r: Rect) -> Vec<(Point, f64, f64)> {
|
||||
out
|
||||
}
|
||||
|
||||
/// The lengths of the across and down legs of the corner marks of `r`: `length`, at most half the
|
||||
/// side each runs along.
|
||||
fn legs(r: Rect, length: f64) -> (f64, f64) {
|
||||
(length.min(r.width() / 2.0), length.min(r.height() / 2.0))
|
||||
}
|
||||
|
||||
/// The corner marks of `r` with legs `length` long, each at most half its side: one open path per
|
||||
/// corner, a line where `r` has no width or no height.
|
||||
fn corner_paths(r: Rect, length: f64) -> Vec<PathData> {
|
||||
let (lx, ly) = (length.min(r.width() / 2.0), length.min(r.height() / 2.0));
|
||||
let (lx, ly) = legs(r, length);
|
||||
corners(r)
|
||||
.into_iter()
|
||||
.filter_map(|(p, sx, sy)| {
|
||||
@@ -103,14 +109,23 @@ fn mark_bounds(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let d = &s.doc()?.doc;
|
||||
let symbols = d.symbol_boxes();
|
||||
let mut marked: Vec<(NodeId, Rect)> = Vec::with_capacity(roots.len());
|
||||
let mut too_small = false;
|
||||
for id in roots {
|
||||
let Some(n) = d.node(id).filter(|n| !n.is_guide()) else { continue };
|
||||
let bounds = if visual { drawn_bounds_with(&symbols, n) } else { n.geometric_bounds_with(&symbols) };
|
||||
if let Some(r) = bounds.filter(|r| r.width() > FLAT || r.height() > FLAT) {
|
||||
let Some(r) = bounds.filter(|r| r.width() > FLAT || r.height() > FLAT) else { continue };
|
||||
// Corner legs are at most half a side, so an object too small for any leg gets no marks.
|
||||
let (lx, ly) = legs(r, length);
|
||||
if rectangle || lx > FLAT || ly > FLAT {
|
||||
marked.push((anchor(d, id), r));
|
||||
} else {
|
||||
too_small = true;
|
||||
}
|
||||
}
|
||||
if marked.is_empty() {
|
||||
if too_small {
|
||||
return Err(bad(C, "nothing to mark: the selection is too small for corner marks"));
|
||||
}
|
||||
return Err(bad(C, "nothing to mark: the selection has no bounds"));
|
||||
}
|
||||
let ap = Appearance::basic(Paint::None, Paint::solid(color), weight);
|
||||
|
||||
@@ -325,6 +325,28 @@ fn flat_objects_get_lines_and_guides_and_empty_groups_none() {
|
||||
assert!(near(marks_bounds(&s, ids_of(&r)[0]), (100.0, 100.0, 120.0, 120.0)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_object_too_small_for_corner_legs_gets_no_empty_group() {
|
||||
let mut s = session();
|
||||
// Wider than the flat limit, but each leg (half the side at most) is shorter than it.
|
||||
let tiny = NodeId(s.execute("shape.line", &json!({"x1": 0, "y1": 50, "x2": 1.5e-9, "y2": 50})).unwrap()["id"].as_u64().unwrap());
|
||||
select(&mut s, &[tiny]);
|
||||
let (before, n) = (s.doc().unwrap().doc.clone(), steps(&s));
|
||||
let refused = s.execute(COMMAND, &json!({})).unwrap_err().to_string();
|
||||
assert!(refused.contains("nothing to mark") && refused.contains("too small for corner marks"), "{refused}");
|
||||
assert_eq!(steps(&s), n, "no undo step");
|
||||
assert!(*s.doc().unwrap().doc == *before);
|
||||
// The rectangle style still marks it, and a real object beside it gets its corner marks alone.
|
||||
let r = s.execute(COMMAND, &json!({"style": "rectangle"})).unwrap();
|
||||
assert_eq!(r["count"], 1);
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
let a = rect(&mut s, 100.0, 100.0, 20.0, 20.0);
|
||||
select(&mut s, &[tiny, a]);
|
||||
let r = s.execute(COMMAND, &json!({})).unwrap();
|
||||
assert_eq!(r["count"], 1);
|
||||
assert!(near(marks_bounds(&s, ids_of(&r)[0]), (100.0, 100.0, 120.0, 120.0)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bad_params_are_refused_and_it_is_off_without_a_selection() {
|
||||
let mut s = session();
|
||||
|
||||
@@ -449,6 +449,7 @@ fn cropping_off_the_pixel_grid_keeps_the_hidden_colors_in_the_pixels() {
|
||||
})
|
||||
.unwrap()
|
||||
.to_rgba8();
|
||||
assert_eq!(own.dimensions(), (6, 5), "the cut's pixels");
|
||||
assert!(own.pixels().all(|p| p.0[3] == 255), "the cut pixels are the image's own, white included");
|
||||
assert_eq!(drawn(d, id, 0, 0)[3], 0, "white is hidden");
|
||||
s.execute(REMOVE_COLOR_MASK, &json!({"ids": [id.0]})).unwrap();
|
||||
|
||||
@@ -32,15 +32,15 @@ pub(super) fn specs() -> Vec<CommandSpec> {
|
||||
vec![cmd!(
|
||||
"addon.pathtools.bridge",
|
||||
"Smooth Bridge",
|
||||
["Object", "Plug-ins", "Path Precision Tools"],
|
||||
[],
|
||||
None,
|
||||
"{radius?: % 1..1000 (100; the radius of each bridge's two arcs as a percentage of the smaller circle's radius: larger makes a wider, gentler bridge), gap?: pt 0..1000 (instead of radius: the arcs' radius is the smaller circle's radius plus this gap, so each arc stays this gap away from a circle of the smaller circle's size about the arc's center; for equal circles this gap apart that is where a third circle this gap from both sits, as in a triangular grid, so the channels around an empty place in such a grid are one width; giving both is an error), reach?: pt 0..10000 (10; with three or more circles: how far apart two circles' outlines may be for a bridge between them, overlapping ones included; two circles are bridged at any distance), keepOriginals?: bool (false: each outline replaces its circles, painted as the topmost of them, and a group or compound path the other circles leave empty goes; true: it goes directly above that circle and the circles stay), ids?: [id] (default: the selection; a group, other than a clipping group, gives the objects inside it)} join circles (paths whose outline is a circle, not hidden or locked) into metaball (aka meatball) shapes. Two circles become one closed outline: around each circle on its side away from the other, and along two concave arcs, one on each side, that touch both circles so the outline runs on smoothly into them. With three or more, every two circles within reach are bridged the same way, and the bridges that connect are united into one shape each (holes smaller than 1% of the smallest circle's area are filled); a pair within reach but too far apart for the radius gets no bridge, and so does one whose neck would be thinner than the precision its shape is united at, and a circle bridged to no other is left as it is. Overlapping and touching circles are joined too. An object that is not a circle is an error that says why (an ellipse whose width and height differ, a compound path, a hidden or locked object, or another object). One circle inside another (among three or more, any such pair within reach) is an error; so are two circles too far apart for the radius (the arcs would not reach both, or would cross), or three or more with no pair the arcs can join, which suggests a larger radius or gap when the largest one would bridge them; so are no two circles within reach, more than 2000 circles and more than 8000 bridges. One undo step; the outlines (and the circles left as they are) are selected → {ids, alone}, with {id} too for two circles",
|
||||
"{radius?: % 1..1000 (100; the radius of each bridge's two arcs as a percentage of the smaller circle's radius: larger makes a wider, gentler bridge), gap?: pt 0..1000 (instead of radius: the arcs' radius is the smaller circle's radius plus this gap, so each arc stays this gap away from a circle of the smaller circle's size about the arc's center; for equal circles this gap apart that is where a third circle this gap from both sits, as in a triangular grid, so the channels around an empty place in such a grid are one width; giving both is an error), reach?: pt 0..10000 (10; with three or more circles: how far apart two circles' outlines may be for a bridge between them, overlapping ones included; two circles are bridged at any distance), keepOriginals?: bool (false: each outline replaces its circles, painted as the topmost of them, and a group or compound path the other circles leave empty goes; true: it goes directly above that circle and the circles stay), ids?: [id] (default: the selection; a group, other than a clipping group, gives the objects inside it)} join circles (paths whose outline is a circle, not hidden or locked) into metaball (aka meatball) shapes. Two circles become one closed outline: around each circle on its side away from the other, and along two concave arcs, one on each side, that touch both circles so the outline runs on smoothly into them. With three or more, every two circles within reach are bridged the same way, and the bridges that connect are united into one shape each (holes smaller than 1% of the smallest circle's area are filled); a pair within reach but too far apart for the radius gets no bridge, and so does one whose neck would be thinner than the precision its shape is united at, and a circle bridged to no other is left as it is. Overlapping and touching circles are joined too. An object that is not a circle is an error that says why (an ellipse whose width and height differ, a compound path, a hidden or locked object, or another object). One circle inside another (among three or more, any such pair within reach) is an error; so are two circles too far apart for the radius (the arcs would not reach both, or would cross), or three or more with no pair the arcs can join, which suggests a larger radius or gap when the largest one would bridge them; so are no two circles within reach, more than 2000 circles and more than 8000 bridges. One undo step; the outlines (and the circles left as they are) are selected → {ids, alone}, with {id} too for two circles (kept for older scripts: Common Tangents makes the same outline with `curved`, and the command palette leaves this command out)",
|
||||
has_selection,
|
||||
bridge
|
||||
)]
|
||||
}
|
||||
|
||||
fn bridge(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
pub(super) fn bridge(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let percent = given(p, "radius", Some(RADII), C)?;
|
||||
let gap = given(p, "gap", Some(GAPS), C)?;
|
||||
let reach = given(p, "reach", Some(REACHES), C)?.unwrap_or(REACH);
|
||||
|
||||
@@ -31,7 +31,7 @@ pub(super) fn specs() -> Vec<CommandSpec> {
|
||||
"Common Tangents",
|
||||
["Object", "Plug-ins", "Path Precision Tools"],
|
||||
None,
|
||||
"{tangents?: \"external\" (both paths on the same side of each line) | \"internal\" (the lines that run between them) | \"all\" (\"all\"), centerline?: bool (false: true also adds the line joining the two centers, an ellipse's center or a path's center of area), ids?: [id, id] (default: the selection)} add the common tangent lines of two convex closed paths as separate open paths, each from where it touches the first path to where it touches the second (the whole stretch where a straight side lies along it), stroked with the current stroke color and weight (black when the stroke is None) and unfilled, directly above the upper of the two, as one undo step; the new lines are selected. An ellipse drawn with the Ellipse tool, turned or scaled, is measured as an exact ellipse; any other path must be closed, have one outline, bend the same way all around and have at most 10000 segments. Separate paths have two external and two internal tangents; overlapping paths only external ones; one path inside the other has none. Paths that touch, from outside or from inside, share one tangent there instead: a line centered on the point where they touch and as long as the narrower path is wide along it; paths that meet at a corner or along a shared stretch of outline get one such line, at the middle of the directions that touch both. Paths count as touching when the gap between them is at most a billionth of the larger of their sizes and the distance between their centers. One of the two may be a point (a path of one anchor): the lines then run from the point to where they touch the path, two when the point lies outside it (one that lies along a straight side covers the whole side), one when the point lies on its outline, that is, at most the touching tolerance from it, with the point's distance from the path's center in place of the distance between centers (centered on the point and as long as the path is wide along it, or the whole straight side the point lies on), none when it lies inside; every `tangents` value gives the same lines, counted as internal when `tangents` is \"internal\" and as external otherwise, and the centerline runs from the point to the path's center; two points are refused. When there is no tangent of the kind asked for, nothing changes and the result has a `warning` → {ids, external, internal, centerline (its id or null), warning?}",
|
||||
"{tangents?: \"external\" (both paths on the same side of each line) | \"internal\" (the lines that run between them) | \"all\" (\"all\"), centerline?: bool (false: true also adds the line joining the two centers, an ellipse's center or a path's center of area), connect?: bool (false: true joins the two tangents of each kind into one closed path, along the chords between where they touch each path; a kind with one tangent stays a line), curved?: bool (false: true joins the selected circles into one outline along concave arcs that touch both, as `addon.pathtools.bridge` does, in place of the external tangents; `tangents` other than \"external\", `centerline` and `connect: false` are then an error), radius?: % 1..1000 (100; with curved, as for `addon.pathtools.bridge`), gap?: pt 0..1000 (with curved, instead of radius), reach?: pt 0..10000 (10; with curved, for three or more circles), keepOriginals?: bool (false; with curved), ids?: [id, id] (default: the selection; with curved, two or more circles)} add the common tangent lines of two convex closed paths (with curved, join circles with a smooth bridge into metaball, aka meatball, shapes instead) as separate open paths, each from where it touches the first path to where it touches the second (the whole stretch where a straight side lies along it), stroked with the current stroke color and weight (black when the stroke is None) and unfilled, directly above the upper of the two, as one undo step; the new lines are selected. An ellipse drawn with the Ellipse tool, turned or scaled, is measured as an exact ellipse; any other path must be closed, have one outline, bend the same way all around and have at most 10000 segments. Separate paths have two external and two internal tangents; overlapping paths only external ones; one path inside the other has none. Paths that touch, from outside or from inside, share one tangent there instead: a line centered on the point where they touch and as long as the narrower path is wide along it; paths that meet at a corner or along a shared stretch of outline get one such line, at the middle of the directions that touch both. Paths count as touching when the gap between them is at most a billionth of the larger of their sizes and the distance between their centers. One of the two may be a point (a path of one anchor): the lines then run from the point to where they touch the path, two when the point lies outside it (one that lies along a straight side covers the whole side), one when the point lies on its outline, that is, at most the touching tolerance from it, with the point's distance from the path's center in place of the distance between centers (centered on the point and as long as the path is wide along it, or the whole straight side the point lies on), none when it lies inside; every `tangents` value gives the same lines, counted as internal when `tangents` is \"internal\" and as external otherwise, and the centerline runs from the point to the path's center; two points are refused. When there is no tangent of the kind asked for, nothing changes and the result has a `warning` → {ids, external, internal, centerline (its id or null), warning?}, or with curved `addon.pathtools.bridge`'s {ids, alone, id?}",
|
||||
has_selection,
|
||||
common_tangents
|
||||
)]
|
||||
@@ -71,9 +71,36 @@ fn refusal(e: pt::OutlineError) -> EngineError {
|
||||
)
|
||||
}
|
||||
|
||||
/// The parameters that shape a curved bridge.
|
||||
const CURVED_KEYS: [&str; 4] = ["radius", "gap", "reach", "keepOriginals"];
|
||||
|
||||
fn common_tangents(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
const C: &str = COMMON_TANGENTS;
|
||||
let kinds = choice(p, C, "tangents", &KINDS)?.unwrap_or("all");
|
||||
let given = |key: &str| p.get(key).is_some_and(|v| !v.is_null());
|
||||
let kinds = choice(p, C, "tangents", &KINDS)?;
|
||||
let connect = if given("connect") { Some(switch_or(p, "connect", false, C)?) } else { None };
|
||||
if switch_or(p, "curved", false, C)? {
|
||||
if kinds.is_some_and(|k| k != "external") {
|
||||
return Err(bad(C, "`curved` joins the circles along their external tangents: give `tangents` \"external\" or leave it out"));
|
||||
}
|
||||
if given("centerline") {
|
||||
return Err(bad(C, "`centerline` applies to the tangent lines: leave it out with `curved`"));
|
||||
}
|
||||
if connect == Some(false) {
|
||||
return Err(bad(C, "a curved bridge is always connected: leave `connect` out or set it true"));
|
||||
}
|
||||
// The outline is Smooth Bridge's.
|
||||
let mut bridged = serde_json::Map::new();
|
||||
for key in CURVED_KEYS.iter().chain(&["ids"]).filter(|k| given(k)) {
|
||||
bridged.insert((*key).to_owned(), p[*key].clone());
|
||||
}
|
||||
return super::bridge::bridge(s, &Value::Object(bridged));
|
||||
}
|
||||
if let Some(key) = CURVED_KEYS.iter().find(|k| given(k)) {
|
||||
return Err(bad(C, format!("`{key}` applies to a curved bridge: give `curved` with it")));
|
||||
}
|
||||
let kinds = kinds.unwrap_or("all");
|
||||
let connect = connect.unwrap_or(false);
|
||||
let centerline = switch_or(p, "centerline", false, C)?;
|
||||
let roots = checked_ids_or_selection(s, p, C)?;
|
||||
let d = &s.doc()?.doc;
|
||||
@@ -105,6 +132,33 @@ fn common_tangents(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
_ => (count(pt::TangentKind::External), count(pt::TangentKind::Internal)),
|
||||
};
|
||||
let lines: Vec<(Point, Point)> = kept.iter().map(|t| (t.from, t.to)).collect();
|
||||
// With `connect`, the two tangents of each kind and the chords between their ends on each path make one closed
|
||||
// shape; a kind with one tangent (paths that touch) keeps it as a line. A point's lines are all one kind.
|
||||
let shapes: Vec<(Vec<Point>, bool)> = if connect {
|
||||
let mut out = vec![];
|
||||
for kind in [pt::TangentKind::External, pt::TangentKind::Internal] {
|
||||
let of: Vec<&pt::Tangent> = kept.iter().copied().filter(|t| point || t.kind == kind).collect();
|
||||
match of.as_slice() {
|
||||
[l, m] => {
|
||||
// A point's two lines share the point, which then closes the ring once.
|
||||
let same = |q: Point, p: Point| (q - p).hypot() <= 1e-9 * a.size().max(b.size());
|
||||
let mut ring = vec![l.from, l.to, m.to, m.from];
|
||||
ring.dedup_by(|q, p| same(*q, *p));
|
||||
if ring.len() > 2 && same(ring[0], ring[ring.len() - 1]) {
|
||||
ring.pop();
|
||||
}
|
||||
out.push((ring, true));
|
||||
}
|
||||
_ => out.extend(of.iter().map(|t| (vec![t.from, t.to], false))),
|
||||
}
|
||||
if point {
|
||||
break;
|
||||
}
|
||||
}
|
||||
out
|
||||
} else {
|
||||
lines.iter().map(|&(from, to)| (vec![from, to], false)).collect()
|
||||
};
|
||||
if lines.is_empty() && point {
|
||||
// Written as `EngineError::Other` so that the i18n message scan finds it.
|
||||
let warning = EngineError::Other("The point lies inside the path, so it has no tangents".into());
|
||||
@@ -133,13 +187,14 @@ fn common_tangents(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let (parent, idx, _) = d.position(top).ok_or(EngineError::NoNode(top))?;
|
||||
let mut ids = vec![];
|
||||
let mut center_id = None;
|
||||
for (k, (from, to)) in lines.iter().copied().chain(center).enumerate() {
|
||||
let center = center.map(|(from, to)| (vec![from, to], false));
|
||||
for (k, (points, closed)) in shapes.iter().cloned().chain(center).enumerate() {
|
||||
let id = d.alloc_id();
|
||||
let path = PathData::single(SubPath::polyline(&[from, to], false));
|
||||
let path = PathData::single(SubPath::polyline(&points, closed));
|
||||
let mut n = Node::new(id, NodeKind::Path { path, rule: FillRule::NonZero, live: None, clipping: false, guide: false });
|
||||
look.apply(d, &mut n);
|
||||
d.insert(parent, idx + 1 + k, n)?;
|
||||
if k == lines.len() {
|
||||
if k == shapes.len() {
|
||||
center_id = Some(id);
|
||||
}
|
||||
ids.push(id);
|
||||
|
||||
@@ -354,3 +354,113 @@ fn bad_selections_and_params_are_refused() {
|
||||
let g = group_of(&mut s, &[b]);
|
||||
assert!(err(&mut s, json!({"ids": [a.0, g.0]})).contains("select two closed paths"));
|
||||
}
|
||||
|
||||
/// The one closed outline of path `id`.
|
||||
fn outline(s: &Session, id: NodeId) -> vectorcraft_geom::SubPath {
|
||||
let n = s.doc().unwrap().doc.node(id).unwrap();
|
||||
let NodeKind::Path { path, .. } = &n.kind else { panic!("not a path") };
|
||||
let [sp] = path.subpaths.as_slice() else { panic!("{} subpaths", path.subpaths.len()) };
|
||||
assert!(sp.closed);
|
||||
sp.clone()
|
||||
}
|
||||
|
||||
/// The anchors of path `id`'s one closed outline.
|
||||
fn corners(s: &Session, id: NodeId) -> Vec<Point> {
|
||||
outline(s, id).anchors.iter().map(|a| a.p).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn connect_joins_the_external_tangents_and_the_chords_into_one_closed_shape_in_one_step() {
|
||||
let mut s = session();
|
||||
let (a, b) = (circle(&mut s, 100.0, 100.0, 20.0), circle(&mut s, 200.0, 100.0, 20.0));
|
||||
let (before, count) = (steps(&s), s.doc().unwrap().doc.node_count());
|
||||
let r = s.execute(C, &json!({"tangents": "external", "connect": true, "ids": [a.0, b.0]})).unwrap();
|
||||
assert_eq!(steps(&s), before + 1, "one undo step");
|
||||
let ids = r["ids"].as_array().unwrap();
|
||||
assert_eq!(ids.len(), 1, "one shape in place of two lines");
|
||||
assert_eq!(s.doc().unwrap().doc.node_count(), count + 1, "the circles stay");
|
||||
let found = corners(&s, NodeId(ids[0].as_u64().unwrap()));
|
||||
assert_eq!(found.len(), 4);
|
||||
// The tangents above and below both circles, joined by each circle's vertical diameter.
|
||||
for p in [Point::new(100.0, 80.0), Point::new(200.0, 80.0), Point::new(200.0, 120.0), Point::new(100.0, 120.0)] {
|
||||
assert!(found.iter().any(|&q| near(p, q)), "{p:?} in {found:?}");
|
||||
}
|
||||
// In order around the band, not crossing itself: the area is the 100 by 40 rectangle's.
|
||||
let area = found.iter().zip(found.iter().cycle().skip(1)).map(|(p, q)| p.x * q.y - q.x * p.y).sum::<f64>() / 2.0;
|
||||
assert!((area.abs() - 4000.0).abs() < 1e-6, "area {area} of {found:?}");
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!(s.doc().unwrap().doc.node_count(), count);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn connect_with_all_makes_one_shape_of_each_kind_and_a_point_makes_a_triangle() {
|
||||
let mut s = session();
|
||||
let (ca, cb) = ((Point::new(100.0, 100.0), 20.0), (Point::new(220.0, 140.0), 40.0));
|
||||
let (a, b) = (circle(&mut s, ca.0.x, ca.0.y, ca.1), circle(&mut s, cb.0.x, cb.0.y, cb.1));
|
||||
let r = s.execute(C, &json!({"connect": true, "centerline": true, "ids": [a.0, b.0]})).unwrap();
|
||||
let ids: Vec<NodeId> = r["ids"].as_array().unwrap().iter().map(|v| NodeId(v.as_u64().unwrap())).collect();
|
||||
assert_eq!(ids.len(), 3, "an external shape, an internal shape and the centerline");
|
||||
for &id in &ids[..2] {
|
||||
let found = corners(&s, id);
|
||||
assert_eq!(found.len(), 4);
|
||||
let on = |(c, r): (Point, f64)| found.iter().filter(|p| ((**p - c).hypot() - r).abs() < 1e-6).count();
|
||||
assert_eq!((on(ca), on(cb)), (2, 2), "two corners where the tangents touch each circle: {found:?}");
|
||||
}
|
||||
assert_ne!(corners(&s, ids[0]), corners(&s, ids[1]));
|
||||
assert_eq!(r["centerline"], json!(ids[2].0));
|
||||
|
||||
let mut s = session();
|
||||
let (p, c) = (point(&mut s, 0.0, 100.0), circle(&mut s, 100.0, 100.0, 20.0));
|
||||
let r = s.execute(C, &json!({"connect": true, "ids": [p.0, c.0]})).unwrap();
|
||||
let ids = r["ids"].as_array().unwrap();
|
||||
assert_eq!(ids.len(), 1);
|
||||
let found = corners(&s, NodeId(ids[0].as_u64().unwrap()));
|
||||
assert_eq!(found.len(), 3, "the point and where its two lines touch the circle: {found:?}");
|
||||
assert!(found.iter().any(|&q| near(q, Point::new(0.0, 100.0))));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn curved_makes_the_bridge_the_smooth_bridge_command_makes() {
|
||||
let build = || {
|
||||
let mut s = session();
|
||||
let ids = [circle(&mut s, 100.0, 100.0, 20.0), circle(&mut s, 150.0, 100.0, 20.0), circle(&mut s, 125.0, 140.0, 20.0)];
|
||||
select(&mut s, &ids);
|
||||
s
|
||||
};
|
||||
for (merged, old) in [
|
||||
(json!({"curved": true}), json!({})),
|
||||
(
|
||||
json!({"tangents": "external", "connect": true, "curved": true, "gap": 5, "reach": 30, "keepOriginals": true}),
|
||||
json!({"gap": 5, "reach": 30, "keepOriginals": true}),
|
||||
),
|
||||
] {
|
||||
let (mut s, mut t) = (build(), build());
|
||||
let r = s.execute(C, &merged).unwrap();
|
||||
let q = t.execute("addon.pathtools.bridge", &old).unwrap();
|
||||
assert_eq!(r, q, "{merged}");
|
||||
let kinds = |s: &Session| s.doc().unwrap().doc.layers[0].children().unwrap().iter().map(|n| n.kind.clone()).collect::<Vec<_>>();
|
||||
assert_eq!(kinds(&s), kinds(&t), "{merged}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn options_of_the_other_mode_are_refused() {
|
||||
let mut s = session();
|
||||
let (a, b) = (circle(&mut s, 100.0, 100.0, 20.0), circle(&mut s, 200.0, 100.0, 20.0));
|
||||
select(&mut s, &[a, b]);
|
||||
let before = (steps(&s), s.doc().unwrap().doc.node_count());
|
||||
let err = |s: &mut Session, p: Value| s.execute(C, &p).unwrap_err().to_string();
|
||||
for (p, says) in [
|
||||
(json!({"connect": "yes"}), "connect"),
|
||||
(json!({"curved": true, "tangents": "all"}), "external"),
|
||||
(json!({"curved": true, "centerline": true}), "centerline"),
|
||||
(json!({"curved": true, "connect": false}), "connected"),
|
||||
(json!({"radius": 50}), "curved"),
|
||||
(json!({"connect": true, "keepOriginals": true}), "curved"),
|
||||
(json!({"curved": true, "radius": 50, "gap": 2}), "not both"),
|
||||
(json!({"curved": true, "radius": 0}), "radius"),
|
||||
] {
|
||||
assert!(err(&mut s, p.clone()).contains(says), "{p}: {}", err(&mut s, p.clone()));
|
||||
}
|
||||
assert_eq!((steps(&s), s.doc().unwrap().doc.node_count()), before, "nothing changes");
|
||||
}
|
||||
@@ -237,6 +237,7 @@ fn add_points_splits_selected_segments_evenly() {
|
||||
let n = steps(&s);
|
||||
assert_eq!(s.execute("addon.pathtools.addPoints", &json!({"count": 3})).unwrap()["added"], json!(3));
|
||||
let xs: Vec<f64> = path(&s, l).anchors().map(|(_, _, a)| a.p.x).collect();
|
||||
assert_eq!(xs.len(), 5, "{xs:?}");
|
||||
assert!(xs.iter().zip([0.0, 25.0, 50.0, 75.0, 100.0]).all(|(x, w)| (x - w).abs() < 1e-3), "{xs:?}");
|
||||
assert_eq!(steps(&s), n + 1);
|
||||
refuses(&mut s, "addon.pathtools.addPoints", &[json!({"count": 0}), json!({"count": 101}), json!({"count": 1.5})]);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//! (#5532). The reference app has no command for it, so it goes beyond parity and changes no
|
||||
//! parity score. Its submenu (Object › Plug-ins › Type Tools) and dialogs are the UI's.
|
||||
|
||||
pub mod numbers;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
@@ -65,6 +66,15 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
has_selection,
|
||||
release_path
|
||||
),
|
||||
cmd!(
|
||||
"addon.type.numbers",
|
||||
"Make Numbers Sequence…",
|
||||
["Object", "Plug-ins", "Type Tools"],
|
||||
None,
|
||||
"{start?: number (1), step?: number (1; its sign is set to run toward `end`; 0: every object gets `start`), end?: number (omitted: the numbers run to the last type object; given: they stop past `end`, and the objects after the last number keep their text), order?: \"stacking\" (stacking order, from the back) | \"rows\" (top to bottom, each row left to right) | \"columns\" (left to right, each column top to bottom) (\"stacking\"; rows and columns group objects whose centers are within half the median height or width), replace?: \"all\" (the whole text) | \"numbers\" (every number in the text: digits, with any `.` or `,` between digits and a `-` before them that does not follow a letter or digit) | \"placeholder\" (every {%n}, in any case) (\"all\"; with numbers or placeholder, objects that hold none are skipped, get no number and order leaves them out; the remaining objects are ordered before end limits the sequence, so objects past end still count for rows and columns; at most 10000 numbers or placeholders are replaced in one run (matches that already read their number do not count); more is an error), shuffle?: false (true: the numbers go to the objects in random order, and order is not used), seed?: whole number (0; the same seed gives the same order; checked even with shuffle off), leadingZeros?: true (non-negative numbers are padded with zeros to the whole digits of the widest of start and end, or of the last number), digits?: 1..30 (with leadingZeros, at least this many whole digits), trailingZeros?: false (true: every number gets as many decimal places as the one with the most), removeUnused?: false (true, with end: the objects left without a number are deleted, except a clipping mask), ids?: [id…], id? (instead of ids; neither: the selection)} number the type objects among the objects (inside groups too), as one undo step. Locked or hidden type is left alone. A frame of threaded type among them is an error. Values are -1e12..1e12, rounded to the most decimal places among start, step and end (at most 6). Replaced text takes the style of the text it replaces, and a match that already reads its number keeps its style. Objects that already read so are left as they are, and when nothing changes no undo step is made → {count (objects changed), ids (numbered, in order), removed}",
|
||||
has_selection,
|
||||
numbers::make_numbers
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,384 @@
|
||||
//! Make Numbers Sequence (`addon.type.numbers`): numbers the selected type objects from a start
|
||||
//! value by a step, replacing each object's whole text, the numbers in it, or a `{%n}` placeholder.
|
||||
//! The objects are taken in stacking order, by rows or by columns. Leading and trailing zeros pad
|
||||
//! the numbers to one width. Based on Sergey Osokin's MIT-licensed MakeNumbersSequence script
|
||||
//! (<https://github.com/creold/illustrator-scripts/blob/master/md/Text.md#makenumberssequence>).
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_color::recolor::Rng;
|
||||
use vectorcraft_doc::{NodeId, NodeKind};
|
||||
use vectorcraft_geom::Rect;
|
||||
use vectorcraft_render::effects;
|
||||
use vectorcraft_text::edit;
|
||||
use vectorcraft_text::retype::is_combining_mark;
|
||||
|
||||
use super::super::super::menucmds::whole_or;
|
||||
use super::super::super::object::choice;
|
||||
use super::super::super::textedit::text_mut;
|
||||
use super::super::super::threads;
|
||||
use super::super::super::typecmd::refresh_bounds;
|
||||
use super::super::super::typemenu::text_ids;
|
||||
use super::super::super::{bad, number_or, switch_or, targets};
|
||||
use crate::{EngineError, Result, Session};
|
||||
|
||||
/// The command id.
|
||||
pub const COMMAND: &str = "addon.type.numbers";
|
||||
/// The orders the objects are numbered in.
|
||||
pub const ORDERS: [&str; 3] = ["stacking", "rows", "columns"];
|
||||
/// What each object's number replaces.
|
||||
pub const REPLACES: [&str; 3] = ["all", "numbers", "placeholder"];
|
||||
/// The placeholder `replace: "placeholder"` replaces, in any case.
|
||||
pub const PLACEHOLDER: &str = "{%n}";
|
||||
/// The largest start, end or step.
|
||||
const MAX_VALUE: f64 = 1e12;
|
||||
/// The most decimal places a number keeps.
|
||||
const MAX_DECIMALS: usize = 6;
|
||||
/// The largest fixed number of digits.
|
||||
pub const MAX_DIGITS: u64 = 30;
|
||||
/// The most type objects one run numbers.
|
||||
const MAX_TEXTS: usize = 100_000;
|
||||
/// The most numbers or placeholders one run replaces.
|
||||
pub(crate) const MAX_MATCHES: usize = 10_000;
|
||||
|
||||
/// What one run does, read from its params.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub(crate) struct Options {
|
||||
pub start: f64,
|
||||
/// None: the numbers run to the last type object.
|
||||
pub end: Option<f64>,
|
||||
pub step: f64,
|
||||
pub order: &'static str,
|
||||
pub replace: &'static str,
|
||||
/// Some(seed): the numbers go to the objects in random order.
|
||||
pub shuffle: Option<u64>,
|
||||
pub leading_zeros: bool,
|
||||
/// The least number of whole digits with leading zeros; None: as many as the widest number.
|
||||
pub digits: Option<usize>,
|
||||
pub trailing_zeros: bool,
|
||||
pub remove_unused: bool,
|
||||
}
|
||||
|
||||
impl Options {
|
||||
pub(crate) fn parse(p: &Value) -> Result<Self> {
|
||||
const C: &str = COMMAND;
|
||||
let value = |key: &str, default: f64| -> Result<f64> {
|
||||
let v = number_or(p, key, default, C)?;
|
||||
if !v.is_finite() || v.abs() > MAX_VALUE {
|
||||
return Err(bad(C, format!("`{key}` must be from -{MAX_VALUE} to {MAX_VALUE}")));
|
||||
}
|
||||
Ok(v)
|
||||
};
|
||||
let start = value("start", 1.0)?;
|
||||
let step = value("step", 1.0)?;
|
||||
let end = match p.get("end") {
|
||||
None | Some(Value::Null) => None,
|
||||
Some(_) => Some(value("end", 0.0)?),
|
||||
};
|
||||
let order = pick(choice(p, C, "order", &ORDERS)?.unwrap_or("stacking"), &ORDERS);
|
||||
let replace = pick(choice(p, C, "replace", &REPLACES)?.unwrap_or("all"), &REPLACES);
|
||||
let seed = whole_or(p, "seed", 0, C)?;
|
||||
let shuffle = if switch_or(p, "shuffle", false, C)? { Some(seed) } else { None };
|
||||
let digits = match p.get("digits") {
|
||||
None | Some(Value::Null) => None,
|
||||
Some(_) => {
|
||||
let d = whole_or(p, "digits", 1, C)?;
|
||||
if !(1..=MAX_DIGITS).contains(&d) {
|
||||
return Err(bad(C, format!("`digits` must be from 1 to {MAX_DIGITS}")));
|
||||
}
|
||||
Some(usize::try_from(d).unwrap_or(1))
|
||||
}
|
||||
};
|
||||
let remove_unused = switch_or(p, "removeUnused", false, C)?;
|
||||
if remove_unused && end.is_none() {
|
||||
return Err(bad(C, "`removeUnused` needs an `end`"));
|
||||
}
|
||||
Ok(Self {
|
||||
start,
|
||||
end,
|
||||
step,
|
||||
order,
|
||||
replace,
|
||||
shuffle,
|
||||
leading_zeros: switch_or(p, "leadingZeros", true, C)?,
|
||||
digits,
|
||||
trailing_zeros: switch_or(p, "trailingZeros", false, C)?,
|
||||
remove_unused,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// `v` as the static entry of `list` it equals.
|
||||
fn pick(v: &str, list: &[&'static str]) -> &'static str {
|
||||
list.iter().copied().find(|x| *x == v).unwrap_or(list[0])
|
||||
}
|
||||
|
||||
/// The decimal places `v` is written with, at most [`MAX_DECIMALS`].
|
||||
fn decimals(v: f64) -> usize {
|
||||
let s = format!("{v}");
|
||||
s.split_once('.').map_or(0, |(_, f)| f.len()).min(MAX_DECIMALS)
|
||||
}
|
||||
|
||||
/// Round the shortest decimal representation of `v` to fixed point at `places`.
|
||||
fn scaled(v: f64, places: usize) -> i128 {
|
||||
let s = format!("{v}");
|
||||
let magnitude = s.trim_start_matches('-');
|
||||
let (whole, fraction) = magnitude.split_once('.').unwrap_or((magnitude, ""));
|
||||
let digits = whole.bytes().chain(fraction.bytes().chain(std::iter::repeat(b'0')).take(places));
|
||||
let mut value = digits.fold(0_i128, |n, digit| n * 10 + i128::from(digit - b'0'));
|
||||
if fraction.as_bytes().get(places).is_some_and(|digit| *digit >= b'5') {
|
||||
value += 1;
|
||||
}
|
||||
if v < 0.0 { -value } else { value }
|
||||
}
|
||||
|
||||
/// `v` scaled by `10^places`, without trailing zeros and with no minus sign on zero.
|
||||
fn write(v: i128, places: usize) -> String {
|
||||
let scale = 10_u128.pow(places as u32);
|
||||
let magnitude = v.unsigned_abs();
|
||||
let sign = if v < 0 { "-" } else { "" };
|
||||
let whole = magnitude / scale;
|
||||
if places == 0 {
|
||||
return format!("{sign}{whole}");
|
||||
}
|
||||
let fraction = magnitude % scale;
|
||||
let s = format!("{sign}{whole}.{fraction:0places$}");
|
||||
s.trim_end_matches('0').trim_end_matches('.').to_string()
|
||||
}
|
||||
|
||||
/// The numbers for `count` objects as text: from `start` by `step` (its sign set to run toward
|
||||
/// `end`), stopping past `end`, then padded with zeros as `o` says.
|
||||
pub(crate) fn sequence(o: &Options, count: usize) -> Vec<String> {
|
||||
let places = [Some(o.start), Some(o.step), o.end].into_iter().flatten().map(decimals).max().unwrap_or(0);
|
||||
let step = match o.end {
|
||||
Some(end) if (o.start <= end) == (o.step < 0.0) => -o.step,
|
||||
_ => o.step,
|
||||
};
|
||||
// Count steps at the supported decimal precision so an inclusive end survives rounding.
|
||||
let scaled = |v: f64| scaled(v, places);
|
||||
let start_i = scaled(o.start);
|
||||
let step_i = scaled(step);
|
||||
let fit = match o.end {
|
||||
Some(end) if step_i != 0 => usize::try_from((scaled(end) - start_i) / step_i + 1).unwrap_or(usize::MAX),
|
||||
_ => count,
|
||||
};
|
||||
let values: Vec<i128> = (0..count.min(fit)).map(|i| start_i + i as i128 * step_i).collect();
|
||||
let mut out: Vec<String> = values.iter().map(|v| write(*v, places)).collect();
|
||||
if o.trailing_zeros {
|
||||
let most = out.iter().map(|s| s.split_once('.').map_or(0, |(_, f)| f.len())).max().unwrap_or(0);
|
||||
if most > 0 {
|
||||
for s in &mut out {
|
||||
let have = s.split_once('.').map_or(0, |(_, f)| f.len());
|
||||
if have == 0 {
|
||||
s.push('.');
|
||||
}
|
||||
s.extend(std::iter::repeat_n('0', most - have));
|
||||
}
|
||||
}
|
||||
}
|
||||
if o.leading_zeros {
|
||||
let last = o.end.map(scaled).unwrap_or_else(|| values.last().copied().unwrap_or(start_i));
|
||||
// Whole digits as written, after rounding to `places`.
|
||||
let whole = |v: i128| {
|
||||
let s = write(v, places);
|
||||
let s = s.trim_start_matches('-');
|
||||
s.split_once('.').map_or(s.len(), |(w, _)| w.len())
|
||||
};
|
||||
let width = whole(start_i).max(whole(last)).max(o.digits.unwrap_or(1));
|
||||
for s in &mut out {
|
||||
if s.starts_with('-') {
|
||||
continue;
|
||||
}
|
||||
let have = s.split_once('.').map_or(s.len(), |(w, _)| w.len());
|
||||
if have < width {
|
||||
s.insert_str(0, &"0".repeat(width - have));
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// The byte ranges of `text` a number replaces: each run of ASCII digits, with any `.` or `,`
|
||||
/// followed by more digits inside it, and a `-` before it that does not follow a letter or digit.
|
||||
pub(crate) fn number_spans(text: &str) -> Vec<(usize, usize)> {
|
||||
let b = text.as_bytes();
|
||||
let mut out = vec![];
|
||||
let mut i = 0;
|
||||
while i < b.len() {
|
||||
if !b[i].is_ascii_digit() {
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
let signed = i > 0 && b[i - 1] == b'-' && !text[..i - 1].chars().rev().find(|c| !is_combining_mark(*c)).is_some_and(char::is_alphanumeric);
|
||||
let start = if signed { i - 1 } else { i };
|
||||
while i < b.len() && b[i].is_ascii_digit() {
|
||||
i += 1;
|
||||
}
|
||||
while i + 1 < b.len() && matches!(b[i], b'.' | b',') && b[i + 1].is_ascii_digit() {
|
||||
i += 1;
|
||||
while i < b.len() && b[i].is_ascii_digit() {
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
out.push((start, i));
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// The byte ranges of `text` that hold the placeholder, in any case.
|
||||
pub(crate) fn placeholder_spans(text: &str) -> Vec<(usize, usize)> {
|
||||
let lower = text.to_ascii_lowercase();
|
||||
lower.match_indices(PLACEHOLDER).map(|(i, m)| (i, i + m.len())).collect()
|
||||
}
|
||||
|
||||
/// `ids` in rows (top to bottom, each row left to right) or columns (left to right, each top to
|
||||
/// bottom), by the centres of `bounds`. Objects whose centres are within half the median height
|
||||
/// (width for columns) of a row's first object share its row.
|
||||
fn by_position(ids: Vec<(NodeId, Rect)>, rows: bool) -> Vec<NodeId> {
|
||||
let along = |r: &Rect| if rows { r.center().y } else { r.center().x };
|
||||
let across = |r: &Rect| if rows { r.center().x } else { r.center().y };
|
||||
let mut sizes: Vec<f64> = ids.iter().map(|(_, r)| if rows { r.height() } else { r.width() }).collect();
|
||||
sizes.sort_by(f64::total_cmp);
|
||||
let n = sizes.len();
|
||||
let median = match n {
|
||||
0 | 1 => 0.0,
|
||||
_ if n.is_multiple_of(2) => (sizes[n / 2 - 1] + sizes[n / 2]) / 2.0,
|
||||
_ => sizes[n / 2],
|
||||
};
|
||||
let tolerance = median / 2.0;
|
||||
let mut ids = ids;
|
||||
ids.sort_by(|a, b| along(&a.1).total_cmp(&along(&b.1)));
|
||||
let mut out = Vec::with_capacity(ids.len());
|
||||
let mut row: Vec<(NodeId, Rect)> = vec![];
|
||||
for item in ids {
|
||||
if row.first().is_some_and(|first| along(&item.1) - along(&first.1) > tolerance) {
|
||||
row.sort_by(|a, b| across(&a.1).total_cmp(&across(&b.1)));
|
||||
out.extend(row.drain(..).map(|(id, _)| id));
|
||||
}
|
||||
row.push(item);
|
||||
}
|
||||
row.sort_by(|a, b| across(&a.1).total_cmp(&across(&b.1)));
|
||||
out.extend(row.into_iter().map(|(id, _)| id));
|
||||
out
|
||||
}
|
||||
|
||||
/// One replacement in a text: its start and end bytes and the number that goes there.
|
||||
type Edit = (usize, usize, String);
|
||||
|
||||
/// Each span of `spans` in `text` replaced by `number`, as edits from the last to the first. A
|
||||
/// span that already reads `number` is left out, so its formatting stays.
|
||||
pub(crate) fn edits(text: &str, spans: Vec<(usize, usize)>, number: &str) -> Vec<Edit> {
|
||||
spans.into_iter().rev().filter(|(a, b)| text.get(*a..*b) != Some(number)).map(|(a, b)| (a, b, number.to_string())).collect()
|
||||
}
|
||||
|
||||
pub(crate) fn make_numbers(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
const C: &str = COMMAND;
|
||||
let o = Options::parse(p)?;
|
||||
let named = targets(s, p)?;
|
||||
let d = &s.doc()?.doc;
|
||||
if let Some(id) = named.iter().find(|id| d.node(**id).is_none()) {
|
||||
return Err(EngineError::NoNode(*id));
|
||||
}
|
||||
// Type objects, groups' included, in stacking order from the back; locked or hidden ones stay.
|
||||
let mut texts = text_ids(d, &named);
|
||||
{
|
||||
let editable = d.editable();
|
||||
texts.retain(|id| editable(*id));
|
||||
}
|
||||
let paths = d.index_paths(texts.iter().copied());
|
||||
texts.sort_by(|a, b| paths.get(a).cmp(&paths.get(b)));
|
||||
if texts.len() > MAX_TEXTS {
|
||||
return Err(bad(C, format!("too many type objects: at most {MAX_TEXTS}")));
|
||||
}
|
||||
let threads = threads::ThreadIndex::of(d);
|
||||
if texts.iter().any(|id| threads.threaded(*id)) {
|
||||
return Err(bad(C, "threaded type can't be numbered: its frames share one story"));
|
||||
}
|
||||
let plain = |id: NodeId| match d.node(id).map(|n| &n.kind) {
|
||||
Some(NodeKind::Text(t)) => t.plain_text(),
|
||||
_ => String::new(),
|
||||
};
|
||||
// Only objects that hold a number or the placeholder count, for the order too.
|
||||
let mut texts: Vec<(NodeId, String)> = texts
|
||||
.into_iter()
|
||||
.map(|id| (id, plain(id)))
|
||||
.filter(|(_, t)| match o.replace {
|
||||
"numbers" => t.bytes().any(|b| b.is_ascii_digit()),
|
||||
"placeholder" => !placeholder_spans(t).is_empty(),
|
||||
_ => true,
|
||||
})
|
||||
.collect();
|
||||
if o.order != "stacking" && o.shuffle.is_none() {
|
||||
let placed: Vec<(NodeId, Rect)> = texts
|
||||
.iter()
|
||||
.map(|(id, _)| (*id, effects::preview::bounds_of(d, &[*id], false).unwrap_or(Rect::new(f64::MAX, f64::MAX, f64::MAX, f64::MAX))))
|
||||
.collect();
|
||||
let mut by_id: std::collections::HashMap<NodeId, String> = texts.into_iter().collect();
|
||||
texts = by_position(placed, o.order == "rows").into_iter().filter_map(|id| by_id.remove(&id).map(|t| (id, t))).collect();
|
||||
}
|
||||
// The objects are shuffled, not the numbers, so an end limit can number any of them.
|
||||
if let Some(seed) = o.shuffle {
|
||||
let mut rng = Rng::new(seed);
|
||||
for i in (1..texts.len()).rev() {
|
||||
let j = usize::try_from(rng.next_u64() % (i as u64 + 1)).unwrap_or(0);
|
||||
texts.swap(i, j);
|
||||
}
|
||||
}
|
||||
let numbers = sequence(&o, texts.len());
|
||||
let mut plans: Vec<(NodeId, Vec<Edit>)> = vec![];
|
||||
let mut matches = 0;
|
||||
for ((id, text), number) in texts.iter().zip(&numbers) {
|
||||
let spans = match o.replace {
|
||||
"numbers" => number_spans(text),
|
||||
"placeholder" => placeholder_spans(text),
|
||||
_ => vec![],
|
||||
};
|
||||
// Checked before any replacement text is made.
|
||||
matches += spans.iter().filter(|(a, b)| text.get(*a..*b) != Some(number.as_str())).count();
|
||||
if matches > MAX_MATCHES {
|
||||
return Err(bad(C, format!("too many numbers or placeholders to replace: at most {MAX_MATCHES}")));
|
||||
}
|
||||
let changes = match o.replace {
|
||||
"numbers" | "placeholder" => edits(text, spans, number),
|
||||
_ => vec![(0, text.len(), number.clone())],
|
||||
};
|
||||
// The text it would have, to leave out objects that already read so.
|
||||
let mut after = text.clone();
|
||||
for (a, b, n) in &changes {
|
||||
after.replace_range(*a..*b, n);
|
||||
}
|
||||
if after != *text {
|
||||
plans.push((*id, changes));
|
||||
}
|
||||
}
|
||||
let numbered: Vec<u64> = texts.iter().take(numbers.len()).map(|(id, _)| id.0).collect();
|
||||
// A clipping group's or layer's mask is its first child; removing it would make the next child the mask.
|
||||
let mask = |id: NodeId| {
|
||||
d.parent_of(id).and_then(|g| d.node(g)).is_some_and(|g| g.clips() && g.children().and_then(|c| c.first()).is_some_and(|c| c.id == id))
|
||||
};
|
||||
let removed: Vec<NodeId> =
|
||||
if o.remove_unused { texts.iter().skip(numbers.len()).map(|(id, _)| *id).filter(|id| !mask(*id)).collect() } else { vec![] };
|
||||
if plans.is_empty() && removed.is_empty() {
|
||||
return Ok(json!({ "count": 0, "ids": numbered, "removed": [] }));
|
||||
}
|
||||
let count = plans.len();
|
||||
s.edit("Make Numbers Sequence", |d, sel| {
|
||||
for (id, changes) in &plans {
|
||||
let t = text_mut(d, *id).ok_or(EngineError::NoNode(*id))?;
|
||||
for (a, b, n) in changes {
|
||||
t.splice_paras(*a, *b, n);
|
||||
edit::replace_range(&mut t.runs, *a, *b, n);
|
||||
t.ruby_after_replace(*a, *b, n.len());
|
||||
}
|
||||
refresh_bounds(t);
|
||||
}
|
||||
d.remove_many(&removed)?;
|
||||
if !removed.is_empty() {
|
||||
sel.remove_all(removed.iter().copied());
|
||||
}
|
||||
Ok(())
|
||||
})?;
|
||||
Ok(json!({ "count": count, "ids": numbered, "removed": removed.iter().map(|id| id.0).collect::<Vec<_>>() }))
|
||||
}
|
||||
@@ -0,0 +1,337 @@
|
||||
//! Make Numbers Sequence: the numbers a sequence gives, what each replace mode changes, the
|
||||
//! orders, removed objects, one undo step, and bad params refused without a change.
|
||||
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_doc::{NodeId, NodeKind};
|
||||
|
||||
use super::{COMMAND as C, Options, number_spans, placeholder_spans, sequence};
|
||||
use crate::Session;
|
||||
|
||||
fn session() -> Session {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 600, "height": 400})).unwrap();
|
||||
s
|
||||
}
|
||||
|
||||
fn text_at(s: &mut Session, x: f64, y: f64, words: &str) -> NodeId {
|
||||
NodeId(s.execute("text.create", &json!({"x": x, "y": y, "text": words, "size": 20})).unwrap()["id"].as_u64().unwrap())
|
||||
}
|
||||
|
||||
fn plain(s: &Session, id: NodeId) -> String {
|
||||
match &s.doc().unwrap().doc.node(id).unwrap().kind {
|
||||
NodeKind::Text(t) => t.plain_text(),
|
||||
_ => panic!("not text"),
|
||||
}
|
||||
}
|
||||
|
||||
fn steps(s: &Session) -> usize {
|
||||
s.doc().unwrap().history.undo.len()
|
||||
}
|
||||
|
||||
fn seq(p: Value, count: usize) -> Vec<String> {
|
||||
sequence(&Options::parse(&p).unwrap(), count)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_sequence_steps_toward_its_end_and_pads_with_zeros() {
|
||||
assert_eq!(seq(json!({"start": 1, "step": 5, "end": 20}), 10), ["01", "06", "11", "16"], "stops past the end");
|
||||
assert_eq!(seq(json!({"start": 10, "step": 3, "end": 1, "leadingZeros": false}), 10), ["10", "7", "4", "1"], "the step turns to run down");
|
||||
assert_eq!(seq(json!({"start": 8, "digits": 3}), 3), ["008", "009", "010"]);
|
||||
assert_eq!(seq(json!({"start": -1, "step": 1}), 3), ["-1", "0", "1"], "negative numbers get no zeros");
|
||||
assert_eq!(seq(json!({"start": 0.1, "step": 0.1, "leadingZeros": false}), 3), ["0.1", "0.2", "0.3"], "no rounding noise");
|
||||
assert_eq!(seq(json!({"start": 1, "step": 0.25, "trailingZeros": true}), 3), ["1.00", "1.25", "1.50"]);
|
||||
assert_eq!(seq(json!({"start": 4, "step": 0}), 3), ["4", "4", "4"]);
|
||||
assert_eq!(
|
||||
seq(json!({"start": 1e9 + 0.1, "step": 0.1, "end": 1e9 + 0.3}), 5),
|
||||
["1000000000.1", "1000000000.2", "1000000000.3"],
|
||||
"a value that rounds to the end counts"
|
||||
);
|
||||
assert_eq!(
|
||||
seq(json!({"start": 10000000000.1, "step": 0.1, "end": 10000000000.3}), 5),
|
||||
["10000000000.1", "10000000000.2", "10000000000.3"],
|
||||
"large values keep the inclusive decimal end"
|
||||
);
|
||||
assert_eq!(seq(json!({"start": 1e12, "step": 0.000001, "end": 1e12}), 3), ["1000000000000"], "an end equal to the start counts");
|
||||
assert_eq!(
|
||||
seq(json!({"start": 999999999999.9_f64, "step": 0.000001}), 3),
|
||||
["999999999999.9", "999999999999.900001", "999999999999.900002"],
|
||||
"large values keep their decimal digits when scaled for a small step"
|
||||
);
|
||||
assert_eq!(
|
||||
seq(json!({"start": 999999999999.9_f64, "step": 0.000001, "end": 999999999999.9_f64}), 3),
|
||||
["999999999999.9"],
|
||||
"the end uses the same decimal scaling as the start"
|
||||
);
|
||||
assert_eq!(seq(json!({"start": 0.1, "step": 3.3}), 4), ["00.1", "03.4", "06.7", "10"], "padded to the rounded last number");
|
||||
assert_eq!(seq(json!({"start": 1, "step": 1_000_000_000_000_u64}), 9009).last().map(String::as_str), Some("9008000000000001"));
|
||||
assert_eq!(seq(json!({"start": -0.25, "step": 0.125}), 5), ["-0.25", "-0.125", "0", "0.125", "0.25"]);
|
||||
assert_eq!(seq(json!({"start": -0.0000001, "step": 0}), 1), ["0"], "rounded zero has no minus sign");
|
||||
assert_eq!(seq(json!({"start": 9.9999999, "step": 0}), 1), ["10"], "width uses the rounded whole part");
|
||||
assert_eq!(seq(json!({"start": -0.0000005, "step": 0}), 1), ["-0.000001"], "decimal ties round away from zero");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unthreaded_type_checks_the_threads_once() {
|
||||
let mut s = session();
|
||||
let ids: Vec<NodeId> = (0..3).map(|i| text_at(&mut s, 40.0, 100.0 + 40.0 * f64::from(i), "x")).collect();
|
||||
let scans = super::threads::thread_scans();
|
||||
super::make_numbers(&mut s, &json!({"ids": ids.iter().map(|id| id.0).collect::<Vec<_>>()})).unwrap();
|
||||
assert_eq!(super::threads::thread_scans() - scans, 1, "selection size does not multiply thread scans");
|
||||
assert_eq!(ids.iter().map(|id| plain(&s, *id)).collect::<Vec<_>>(), ["1", "2", "3"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn threaded_type_is_refused() {
|
||||
let mut s = session();
|
||||
let a =
|
||||
s.execute("text.create", &json!({"x": 10, "y": 10, "text": "1 2 3", "area": {"width": 150, "height": 60}})).unwrap()["id"].as_u64().unwrap();
|
||||
let b = s.execute("shape.rectangle", &json!({"x": 200, "y": 10, "width": 150, "height": 200})).unwrap()["id"].as_u64().unwrap();
|
||||
s.execute("select.set", &json!({"ids": [a, b]})).unwrap();
|
||||
s.execute("text.thread.create", &json!({})).unwrap();
|
||||
let n = steps(&s);
|
||||
assert!(s.execute(C, &json!({"ids": [a, b]})).is_err());
|
||||
assert_eq!((plain(&s, NodeId(a)), steps(&s)), ("1 2 3".to_string(), n));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_spans_find_numbers_and_placeholders() {
|
||||
assert_eq!(number_spans("No. 12, page 3.5 of 1,000."), [(4, 6), (13, 16), (20, 25)]);
|
||||
assert!(number_spans("none").is_empty());
|
||||
assert_eq!(placeholder_spans("a{%N}b{%n}"), [(1, 5), (6, 10)]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_whole_text_gets_numbered_in_stacking_order_as_one_step() {
|
||||
let mut s = session();
|
||||
let ids: Vec<NodeId> = (0..3).map(|i| text_at(&mut s, 40.0, 100.0 + 40.0 * f64::from(i), "x")).collect();
|
||||
let n = steps(&s);
|
||||
let out = s.execute(C, &json!({"ids": [ids[2].0, ids[0].0, ids[1].0], "start": 7})).unwrap();
|
||||
assert_eq!(out["count"], json!(3));
|
||||
assert_eq!(ids.iter().map(|id| plain(&s, *id)).collect::<Vec<_>>(), ["7", "8", "9"], "from the back");
|
||||
assert_eq!(steps(&s), n + 1, "one undo step");
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert!(ids.iter().all(|id| plain(&s, *id) == "x"), "undone");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn numbers_and_placeholders_are_replaced_inside_the_text() {
|
||||
let mut s = session();
|
||||
let a = text_at(&mut s, 40.0, 100.0, "Seat 99, row 4");
|
||||
let b = text_at(&mut s, 40.0, 140.0, "no digits");
|
||||
let c = text_at(&mut s, 40.0, 180.0, "Seat 1");
|
||||
s.execute(C, &json!({"ids": [a.0, b.0, c.0], "replace": "numbers", "start": 5})).unwrap();
|
||||
assert_eq!([plain(&s, a), plain(&s, b), plain(&s, c)], ["Seat 5, row 5", "no digits", "Seat 6"], "text with no number is skipped");
|
||||
let d = text_at(&mut s, 40.0, 220.0, "Tag {%N} / {%n}");
|
||||
let e = text_at(&mut s, 40.0, 260.0, "Tag 3");
|
||||
s.execute(C, &json!({"ids": [d.0, e.0], "replace": "placeholder", "start": 2})).unwrap();
|
||||
assert_eq!([plain(&s, d), plain(&s, e)], ["Tag 2 / 2", "Tag 3"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ruby_follows_each_number_or_placeholder_replacement() {
|
||||
let mut s = session();
|
||||
let word = "漢字";
|
||||
for (replace, words) in [("numbers", "1 2 漢字"), ("placeholder", "{%n} {%N} 漢字")] {
|
||||
let id = text_at(&mut s, 40.0, 100.0, words);
|
||||
let start = words.find(word).unwrap();
|
||||
s.execute("type.ruby", &json!({"ids": [id.0], "start": start, "end": start + word.len(), "text": "かんじ"})).unwrap();
|
||||
s.execute(C, &json!({"ids": [id.0], "replace": replace, "start": 123456})).unwrap();
|
||||
let NodeKind::Text(t) = &s.doc().unwrap().doc.node(id).unwrap().kind else { panic!("not text") };
|
||||
let text = t.plain_text();
|
||||
assert_eq!(text, "123456 123456 漢字");
|
||||
assert_eq!(t.ruby.len(), 1);
|
||||
let ruby = &t.ruby[0];
|
||||
assert_eq!(&text[ruby.start..ruby.end], word, "ruby follows both replacements in {replace} mode");
|
||||
assert_eq!(ruby.text, "かんじ");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rows_and_columns_order_by_position() {
|
||||
let mut s = session();
|
||||
// Created bottom-right first, so stacking order differs from both positions.
|
||||
let br = text_at(&mut s, 300.0, 200.0, "x");
|
||||
let tl = text_at(&mut s, 40.0, 100.0, "x");
|
||||
let bl = text_at(&mut s, 40.0, 200.0, "x");
|
||||
let tr = text_at(&mut s, 300.0, 102.0, "x");
|
||||
let ids = json!([br.0, tl.0, bl.0, tr.0]);
|
||||
s.execute(C, &json!({"ids": ids, "order": "rows"})).unwrap();
|
||||
assert_eq!([tl, tr, bl, br].map(|id| plain(&s, id)), ["1", "2", "3", "4"], "a small offset stays in its row");
|
||||
s.execute(C, &json!({"ids": ids, "order": "columns"})).unwrap();
|
||||
assert_eq!([tl, bl, tr, br].map(|id| plain(&s, id)), ["1", "2", "3", "4"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_end_leaves_the_rest_or_removes_it() {
|
||||
let mut s = session();
|
||||
let ids: Vec<NodeId> = (0..4).map(|i| text_at(&mut s, 40.0, 100.0 + 40.0 * f64::from(i), "x")).collect();
|
||||
let all = json!(ids.iter().map(|id| id.0).collect::<Vec<_>>());
|
||||
s.execute(C, &json!({"ids": all, "end": 2})).unwrap();
|
||||
assert_eq!(ids.iter().map(|id| plain(&s, *id)).collect::<Vec<_>>(), ["1", "2", "x", "x"]);
|
||||
let out = s.execute(C, &json!({"ids": all, "start": 5, "end": 6, "removeUnused": true})).unwrap();
|
||||
assert_eq!(out["removed"], json!([ids[2].0, ids[3].0]));
|
||||
assert!(s.doc().unwrap().doc.node(ids[3]).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shuffle_gives_every_number_once() {
|
||||
let mut s = session();
|
||||
let ids: Vec<NodeId> = (0..6).map(|i| text_at(&mut s, 40.0, 60.0 + 40.0 * f64::from(i), "x")).collect();
|
||||
let all = json!(ids.iter().map(|id| id.0).collect::<Vec<_>>());
|
||||
s.execute(C, &json!({"ids": all, "shuffle": true, "seed": 3, "leadingZeros": false})).unwrap();
|
||||
let mut got: Vec<String> = ids.iter().map(|id| plain(&s, *id)).collect();
|
||||
assert_ne!(got, ["1", "2", "3", "4", "5", "6"], "seed 3 moves them");
|
||||
got.sort();
|
||||
assert_eq!(got, ["1", "2", "3", "4", "5", "6"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shuffle_with_an_end_can_number_any_object() {
|
||||
let mut numbered = [false; 6];
|
||||
for seed in 0..40 {
|
||||
let mut s = session();
|
||||
let ids: Vec<NodeId> = (0..6).map(|i| text_at(&mut s, 40.0, 60.0 + 40.0 * f64::from(i), "x")).collect();
|
||||
let all = json!(ids.iter().map(|id| id.0).collect::<Vec<_>>());
|
||||
let out = s.execute(C, &json!({"ids": all, "shuffle": true, "seed": seed, "end": 2, "removeUnused": true})).unwrap();
|
||||
assert_eq!(out["removed"].as_array().unwrap().len(), 4);
|
||||
for (i, id) in ids.iter().enumerate() {
|
||||
numbered[i] |= s.doc().unwrap().doc.node(*id).is_some();
|
||||
}
|
||||
}
|
||||
assert_eq!(numbered, [true; 6], "every object is numbered for some seed");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_same_seed_numbers_and_removes_the_same_objects() {
|
||||
let run = || {
|
||||
let mut s = session();
|
||||
let ids: Vec<NodeId> = (0..8).map(|i| text_at(&mut s, 40.0, 40.0 + 40.0 * f64::from(i), "x")).collect();
|
||||
let all = json!(ids.iter().map(|id| id.0).collect::<Vec<_>>());
|
||||
let out = s.execute(C, &json!({"ids": all, "shuffle": true, "seed": 11, "end": 4, "removeUnused": true})).unwrap();
|
||||
let texts: Vec<Option<String>> = ids.iter().map(|id| s.doc().unwrap().doc.node(*id).map(|_| plain(&s, *id))).collect();
|
||||
let removed: Vec<usize> =
|
||||
out["removed"].as_array().unwrap().iter().map(|r| ids.iter().position(|id| Some(id.0) == r.as_u64()).unwrap()).collect();
|
||||
(texts, removed)
|
||||
};
|
||||
let (texts, removed) = run();
|
||||
assert_eq!(removed.len(), 4);
|
||||
assert_eq!(run(), (texts, removed), "seed 11 gives each object the same number and removes the same ones");
|
||||
}
|
||||
|
||||
fn group_of(s: &mut Session, ids: &[NodeId]) -> NodeId {
|
||||
s.execute("select.set", &json!({"ids": ids.iter().map(|id| id.0).collect::<Vec<_>>()})).unwrap();
|
||||
s.execute("object.group", &json!({})).unwrap();
|
||||
s.doc().unwrap().doc.parent_of(ids[0]).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_negative_number_in_the_text_is_replaced_with_its_sign() {
|
||||
assert_eq!(number_spans("Seat -4, A-4"), [(5, 7), (11, 12)], "a hyphen after a letter is not a sign");
|
||||
assert_eq!(number_spans("É-4"), [(3, 4)], "nor after a letter outside ASCII");
|
||||
assert_eq!(number_spans("E\u{301}-4"), [(4, 5)], "nor after a letter with a combining mark");
|
||||
assert_eq!(number_spans("क्-4"), [(7, 8)], "nor after a letter with a virama");
|
||||
let mut s = session();
|
||||
let a = text_at(&mut s, 40.0, 100.0, "Seat -4");
|
||||
let b = text_at(&mut s, 40.0, 140.0, "Seat 9");
|
||||
s.execute(C, &json!({"ids": [a.0, b.0], "replace": "numbers", "start": 2, "step": -3})).unwrap();
|
||||
assert_eq!([plain(&s, a), plain(&s, b)], ["Seat 2", "Seat -1"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_match_that_already_reads_the_number_is_not_edited() {
|
||||
let text = "5 and 4";
|
||||
assert_eq!(super::edits(text, number_spans(text), "5"), [(6, 7, "5".to_string())]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn too_many_matches_in_one_run_are_refused() {
|
||||
let mut unchanged = session();
|
||||
let text = vec!["1"; super::MAX_MATCHES + 1].join(" ");
|
||||
let id = text_at(&mut unchanged, 40.0, 100.0, &text);
|
||||
let before = steps(&unchanged);
|
||||
let out = unchanged.execute(C, &json!({"ids": [id.0], "start": 1, "replace": "numbers"})).unwrap();
|
||||
assert_eq!(out["count"], 0);
|
||||
assert_eq!(plain(&unchanged, id), text);
|
||||
assert_eq!(steps(&unchanged), before);
|
||||
|
||||
let mut s = session();
|
||||
let a = text_at(&mut s, 40.0, 100.0, &"{%n}".repeat(super::MAX_MATCHES + 1));
|
||||
let n = steps(&s);
|
||||
assert!(s.execute(C, &json!({"ids": [a.0], "replace": "placeholder"})).is_err());
|
||||
assert_eq!(steps(&s), n);
|
||||
// Whole texts are not matches: the object limit covers them.
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
text_at(&mut s, 40.0, 140.0, "x");
|
||||
// Each duplicate of the whole selection doubles it: 2^14 objects in 14 steps.
|
||||
for _ in 0..14 {
|
||||
s.execute("edit.duplicate", &json!({})).unwrap();
|
||||
s.execute("select.all", &json!({})).unwrap();
|
||||
}
|
||||
let count = s.doc().unwrap().selection.objects.len();
|
||||
assert!(count > super::MAX_MATCHES, "{count} objects");
|
||||
let out = s.execute(C, &json!({"step": 0}));
|
||||
assert!(out.is_ok());
|
||||
let out = out.unwrap();
|
||||
assert!(out["count"].as_u64().unwrap() > super::MAX_MATCHES as u64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn locked_and_hidden_type_in_a_group_is_left_alone() {
|
||||
let mut s = session();
|
||||
let ids: Vec<NodeId> = (0..3).map(|i| text_at(&mut s, 40.0, 100.0 + 40.0 * f64::from(i), "x")).collect();
|
||||
let group = group_of(&mut s, &ids);
|
||||
s.execute("object.setProps", &json!({"ids": [ids[1].0], "locked": true})).unwrap();
|
||||
s.execute("object.setProps", &json!({"ids": [ids[2].0], "visible": false})).unwrap();
|
||||
let out = s.execute(C, &json!({"ids": [group.0], "end": 1, "removeUnused": true})).unwrap();
|
||||
assert_eq!(out["removed"], json!([]));
|
||||
assert_eq!(ids.iter().map(|id| plain(&s, *id)).collect::<Vec<_>>(), ["1", "x", "x"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn removing_unused_type_keeps_a_clipping_mask_and_the_selection() {
|
||||
let mut s = session();
|
||||
let a = text_at(&mut s, 40.0, 100.0, "x");
|
||||
let b = text_at(&mut s, 40.0, 140.0, "x");
|
||||
// The top object becomes the mask; it sits lowest on the page, so rows number it last.
|
||||
let mask = text_at(&mut s, 40.0, 300.0, "x");
|
||||
s.execute("select.set", &json!({"ids": [a.0, b.0, mask.0]})).unwrap();
|
||||
s.execute("object.clippingMask.make", &json!({})).unwrap();
|
||||
let group = s.doc().unwrap().doc.parent_of(mask).unwrap();
|
||||
s.execute("select.set", &json!({"ids": [group.0]})).unwrap();
|
||||
let out = s.execute(C, &json!({"order": "rows", "end": 1, "removeUnused": true})).unwrap();
|
||||
assert_eq!(out["removed"], json!([b.0]), "the mask stays");
|
||||
assert!(s.doc().unwrap().doc.node(mask).is_some());
|
||||
assert_eq!(s.doc().unwrap().selection.objects, [group], "the group stays selected");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rows_are_found_among_the_type_that_gets_numbers() {
|
||||
let mut s = session();
|
||||
let upper = text_at(&mut s, 300.0, 100.0, "1");
|
||||
let lower = text_at(&mut s, 40.0, 135.0, "1");
|
||||
let h1 = NodeId(s.execute("text.create", &json!({"x": 40, "y": 400, "text": "Title", "size": 200})).unwrap()["id"].as_u64().unwrap());
|
||||
let h2 = NodeId(s.execute("text.create", &json!({"x": 40, "y": 700, "text": "Title", "size": 200})).unwrap()["id"].as_u64().unwrap());
|
||||
s.execute(C, &json!({"ids": [upper.0, lower.0, h1.0, h2.0], "replace": "numbers", "order": "rows", "start": 1, "leadingZeros": false})).unwrap();
|
||||
assert_eq!([plain(&s, upper), plain(&s, lower)], ["1", "2"], "headings without numbers do not merge the rows");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_run_that_changes_nothing_makes_no_step_and_bad_params_fail() {
|
||||
let mut s = session();
|
||||
let a = text_at(&mut s, 40.0, 100.0, "1");
|
||||
let n = steps(&s);
|
||||
assert_eq!(s.execute(C, &json!({"ids": [a.0]})).unwrap()["count"], json!(0));
|
||||
assert_eq!(steps(&s), n);
|
||||
for p in [
|
||||
json!({"ids": [a.0], "start": "one"}),
|
||||
json!({"ids": [a.0], "step": 1e13}),
|
||||
json!({"ids": [a.0], "order": "diagonal"}),
|
||||
json!({"ids": [a.0], "digits": 0}),
|
||||
json!({"ids": [a.0], "removeUnused": true}),
|
||||
json!({"ids": [a.0], "shuffle": "yes"}),
|
||||
json!({"ids": [a.0], "seed": "x"}),
|
||||
] {
|
||||
assert!(s.execute(C, &p).is_err(), "{p} fails");
|
||||
}
|
||||
assert_eq!((plain(&s, a), steps(&s)), ("1".to_string(), n));
|
||||
}
|
||||
@@ -69,7 +69,8 @@ fn a_straight_ramp_sizes_each_letter_and_skips_spaces() {
|
||||
assert_eq!(sizes, [('a', 10.0), ('b', 20.0), (' ', 20.0), ('c', 30.0), ('d', 40.0)], "the space keeps its size");
|
||||
assert_eq!(obj(&s, id).plain_text(), "ab cd", "the text stays live");
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert!(styles(&s, id).iter().all(|(_, st)| st.size == 20.0), "undone");
|
||||
let undone: Vec<(char, f64)> = styles(&s, id).into_iter().map(|(c, st)| (c, st.size)).collect();
|
||||
assert_eq!(undone, [('a', 20.0), ('b', 20.0), (' ', 20.0), ('c', 20.0), ('d', 20.0)], "undone");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -86,7 +86,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Make",
|
||||
["Object", "Live Paint"],
|
||||
Some("Cmd+Alt+X"),
|
||||
"{ids?|id?} build a Live Paint group from the selected paths (paths, compound paths and groups of them; type, images and other objects are refused, nothing changes); each covered face starts with the fill rows that draw (shown, with paint and an opacity above 0) of its front-most covering source that has one and an opacity above 0, and each edge with the stroke rows that draw (also a weight above 0) of its source, in order with their settings and with that source's opacity and blending mode (on a path cut into several edges, dashes go on along the path with the lengths set, without the fit of dashes aligned to corners and path ends, arrowheads stay at its own ends, and a width profile or brush stays only on an edge that runs the whole path); a face or edge given no such row has one unpainted row; with a Live Paint group among them, add the others to it as livePaint.merge does; a Live Paint group alone has nothing to add, so it is selected and nothing changes (no undo step) → {id, faces, edges}",
|
||||
"{ids?|id?} build a Live Paint group from the selected paths (paths, compound paths and groups of them; type, images and other objects are refused, nothing changes); each covered face starts with the fill rows that draw (shown, with paint and an opacity above 0) of its front-most covering source that has one and an opacity above 0, and each edge with the stroke rows that draw (also a weight above 0) of its source, in order with their settings and with that source's opacity and blending mode (on a path cut into several edges, dashes go on along the path with the lengths set, without the fit of dashes aligned to corners and path ends, arrowheads stay at its own ends, and a width profile or brush stays only on an edge that runs the whole path); a face or edge given no such row has one unpainted row; with a Live Paint group among them, add the others to it as livePaint.merge does; a Live Paint group alone has nothing to add, so it is selected and nothing changes (no undo step). The command stops with an error and leaves the art unchanged when the paths are too many or too complex to map. This happens when the paths have more than 131,072 pieces once cut where they meet, or exceed the sweep's work budget, which counts pairs of segments with overlapping bounds. → {id, faces, edges}",
|
||||
has_selection_or_ids,
|
||||
lp_make
|
||||
),
|
||||
@@ -95,7 +95,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Merge",
|
||||
["Object", "Live Paint"],
|
||||
None,
|
||||
"{ids?|id?} add the other selected paths (compound paths, groups of paths and Live Paint groups too; type, images and other objects are refused, nothing changes) to the bottom-most Live Paint group, keeping its id, its paint and its own properties (name, lock, visibility, transparency, appearance, opacity mask, graphic style link); a Live Paint group alone has nothing to add, so it is selected and nothing changes (no undo step) → {id, faces, edges}",
|
||||
"{ids?|id?} add the other selected paths (compound paths, groups of paths and Live Paint groups too; type, images and other objects are refused, nothing changes) to the bottom-most Live Paint group, keeping its id, its paint and its own properties (name, lock, visibility, transparency, appearance, opacity mask, graphic style link); a Live Paint group alone has nothing to add, so it is selected and nothing changes (no undo step). The command stops with an error and leaves the art unchanged when the paths are too many or too complex to map. This happens when the paths have more than 131,072 pieces once cut where they meet, or exceed the sweep's work budget, which counts pairs of segments with overlapping bounds. → {id, faces, edges}",
|
||||
has_multi_or_ids,
|
||||
lp_merge
|
||||
),
|
||||
@@ -122,7 +122,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Gap Options",
|
||||
[],
|
||||
None,
|
||||
"{id?, ids?: [id…] (instead of id; default: the selected Live Paint groups), detect?: bool (Gap Detection: paint stops at gaps up to size wide), size?: \"small\" (3 pt) | \"medium\" (6 pt) | \"large\" (12 pt) | pt (custom, over 0 up to 72) (Paint Stops At), color?: #rrggbb or a layer color's name such as \"Red\" (Gap Preview Color; a hex color with an alpha part, #rrggbbaa or #rgba, is an error), closeGaps?: bool (add an unpainted path across each gap up to size wide to the group's paths)} set the Gap Options of Live Paint groups (what is not given stays as it was; a group starts with detect false, small and Red) and make their faces again, keeping their paint; when every group already has the options and closeGaps finds no gap, nothing changes (no undo step) → {ids, faces, gaps: [[x0,y0,x1,y1]…] (the gaps up to size wide that no path closes, from a loose end of a path to where it closes to; detect closes them for paint), closed (paths added)}",
|
||||
"{id?, ids?: [id…] (instead of id; default: the selected Live Paint groups), detect?: bool (Gap Detection: paint stops at gaps up to size wide), size?: \"small\" (3 pt) | \"medium\" (6 pt) | \"large\" (12 pt) | pt (custom, over 0 up to 72) (Paint Stops At), color?: #rrggbb or a layer color's name such as \"Red\" (Gap Preview Color; a hex color with an alpha part, #rrggbbaa or #rgba, is an error), closeGaps?: bool (add an unpainted path across each gap up to size wide to the group's paths)} set the Gap Options of Live Paint groups (what is not given stays as it was; a group starts with detect false, small and Red) and make their faces again, keeping their paint; when every group already has the options and closeGaps finds no gap, nothing changes (no undo step). The command stops with an error and leaves the art unchanged when a group's paths are too many or too complex to map. This happens when the paths have more than 131,072 pieces once cut where they meet, or exceed the sweep's work budget, which counts pairs of segments with overlapping bounds. The paths include lines across the gaps when detect is on. → {ids, faces, gaps: [[x0,y0,x1,y1]…] (the gaps up to size wide that no path closes, from a loose end of a path to where it closes to; detect closes them for paint), closed (paths added)}",
|
||||
has_selection_or_ids,
|
||||
lp_gap_options
|
||||
),
|
||||
@@ -740,12 +740,13 @@ fn build_children(d: &mut Document, sources: Vec<Arc<Node>>, max_gap: Option<f64
|
||||
src_group.visible = false;
|
||||
children.push(Arc::new(src_group));
|
||||
// Every path is an edge, open ones included; faces are the areas they enclose.
|
||||
let too_many = |e: po::TooManyPieces| EngineError::Other(format!("Live Paint: {e} to paint"));
|
||||
let (regs, edges) = match max_gap {
|
||||
Some(gap) => {
|
||||
let (regs, edges, _) = po::live_paint_with_gaps(&shapes, gap);
|
||||
let (regs, edges, _) = po::try_live_paint_with_gaps(&shapes, gap).map_err(too_many)?;
|
||||
(regs, edges)
|
||||
}
|
||||
None => po::live_paint(&shapes),
|
||||
None => po::try_live_paint(&shapes).map_err(too_many)?,
|
||||
};
|
||||
if regs.is_empty() && edges.is_empty() {
|
||||
return Err(EngineError::Other("Live Paint: these paths are too degenerate to paint".into()));
|
||||
|
||||
@@ -1586,6 +1586,8 @@ mod trace_limit_tests {
|
||||
// anchors each.
|
||||
let strokes = |f: &tr::SeamFills| f.strokes.iter().map(|tp| tp.path.anchor_count()).sum::<usize>();
|
||||
let outlined = seams_within(&res, ¶ms, (24, 16), MAX_TRACE_ANCHORS, true, &go).unwrap().unwrap();
|
||||
assert!(!outlined.strokes.is_empty(), "{res:?}");
|
||||
assert_eq!(outlined.strokes.len(), all.as_ref().unwrap().strokes.len(), "one outline for each seam fill: {outlined:?}");
|
||||
assert!(outlined.strokes.iter().all(|tp| tp.stroke.is_none() && !tp.path.is_empty()), "{outlined:?}");
|
||||
let n = strokes(all.as_ref().unwrap());
|
||||
assert!(strokes(&outlined) <= SEAM_OUTLINE_ANCHORS * n, "{} outline anchors, {n} stroke anchors", strokes(&outlined));
|
||||
|
||||
@@ -696,9 +696,13 @@ mod tests {
|
||||
let c = s.execute("object.compoundPath.make", &json!({})).unwrap()["id"].as_u64().unwrap();
|
||||
assert_eq!(c, layer, "the scenario needs the id to be reused");
|
||||
s.execute("edit.paste", &json!({})).unwrap();
|
||||
let d = &s.doc().unwrap().doc;
|
||||
let st = s.doc().unwrap();
|
||||
let d = &st.doc;
|
||||
let compound = d.node(NodeId(c)).unwrap();
|
||||
assert!(compound.children().unwrap().iter().all(|ch| matches!(ch.kind, vectorcraft_doc::NodeKind::Path { .. })));
|
||||
assert_eq!(compound.children().unwrap().len(), 1, "the compound path holds only the rectangle it was made from");
|
||||
let pasted = st.selection.objects.clone();
|
||||
assert_eq!(pasted.len(), 1);
|
||||
assert!(d.parent_of(pasted[0]).is_some_and(|p| d.node(p).unwrap().is_layer()), "the copy lands on a layer");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1722,7 +1722,7 @@ mod tests {
|
||||
let jags = polyline(&ring);
|
||||
let sp = SubPath::new(jags.clone(), true);
|
||||
assert!(subpath_len(&sp) < 24.0);
|
||||
assert!(smooth_corners(&jags, true, 1e-6).iter().all(|c| *c), "each jag turns sharply at its anchor");
|
||||
assert_eq!(smooth_corners(&jags, true, 1e-6), vec![true; 16], "each jag turns sharply at its anchor");
|
||||
assert_eq!(smooth_corners(&jags, true, 12.0), vec![false; 16]);
|
||||
assert_eq!(smooth_corners(&polyline(&[(0.0, 0.0), (6.0, 0.0), (3.0, 5.196)]), true, 12.0), vec![true; 3]);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use super::write_atomic;
|
||||
use super::{EngineError, Result, Session, Value, bad, json};
|
||||
|
||||
// ---------- the file system (none on the web, where commands take and return bytes) ----------
|
||||
@@ -325,8 +323,30 @@ pub(crate) fn write_file(path: &str, bytes: &[u8]) -> Result<()> {
|
||||
// Work that stops early for a cancel can leave a truncated result: none of it is written.
|
||||
vectorcraft_doc::cancel::check()?;
|
||||
may_write(path)?;
|
||||
// Never a half-written file: see [`write_atomic`].
|
||||
write_atomic(std::path::Path::new(path), bytes).map_err(|e| write_error(path, e))
|
||||
// Never a half-written file: see [`vectorcraft_format::write_atomic`].
|
||||
write_checked(path, |f| std::io::Write::write_all(f, bytes)).map_err(|e| write_error(path, e))
|
||||
}
|
||||
|
||||
/// [`vectorcraft_format::write_atomic_with`] for `path`, which [`may_write`] allowed. While writes
|
||||
/// are checked ([`crate::file_access::writes_checked`]), the folder that receives the file is
|
||||
/// checked again as it is opened, and the file goes into that open folder
|
||||
/// ([`vectorcraft_format::write_atomic_checked`]): a folder on the path that is replaced after the
|
||||
/// check does not redirect the write.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn write_checked(path: &str, fill: impl FnOnce(&mut std::fs::File) -> std::io::Result<()>) -> std::io::Result<()> {
|
||||
let path = std::path::Path::new(path);
|
||||
if !crate::file_access::writes_checked() {
|
||||
return vectorcraft_format::write_atomic_with(path, fill);
|
||||
}
|
||||
vectorcraft_format::write_atomic_checked(path, fill, |opened| {
|
||||
// On Unix `opened` is the open folder's real path with the file's name: compared as it is,
|
||||
// without looking the folder up again. Elsewhere it is `path` itself.
|
||||
#[cfg(unix)]
|
||||
let checked = crate::file_access::check_write_real(opened);
|
||||
#[cfg(not(unix))]
|
||||
let checked = crate::file_access::check_write_unrecorded(&opened.to_string_lossy());
|
||||
checked.map_err(std::io::Error::other)
|
||||
})
|
||||
}
|
||||
|
||||
/// The error writing `path` failed with: [`EngineError::Cancelled`] for work canceled before the
|
||||
@@ -344,7 +364,7 @@ fn write_error(path: &str, error: std::io::Error) -> EngineError {
|
||||
pub fn write_file_with(path: &str, fill: &mut dyn FnMut(&mut dyn std::io::Write) -> std::io::Result<()>) -> Result<()> {
|
||||
vectorcraft_doc::cancel::check()?;
|
||||
may_write(path)?;
|
||||
vectorcraft_format::write_atomic_with(std::path::Path::new(path), |f| fill(f)).map_err(|e| write_error(path, e))
|
||||
write_checked(path, |f| fill(f)).map_err(|e| write_error(path, e))
|
||||
}
|
||||
|
||||
/// The save commands' writer: preserves a filesystem location refusal as a typed error. Other
|
||||
@@ -358,7 +378,7 @@ pub fn write_save_file(path: &str, bytes: &[u8]) -> Result<()> {
|
||||
pub fn write_save_file_with(path: &str, fill: &mut dyn FnMut(&mut dyn std::io::Write) -> std::io::Result<()>) -> Result<()> {
|
||||
vectorcraft_doc::cancel::check()?;
|
||||
may_write(path)?;
|
||||
vectorcraft_format::write_atomic_with(std::path::Path::new(path), |f| fill(f)).map_err(|e| save_write_error(path, e))
|
||||
write_checked(path, |f| fill(f)).map_err(|e| save_write_error(path, e))
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
@@ -751,4 +771,43 @@ mod tests {
|
||||
assert_eq!(naming_in_error(EngineError::Other(raw.clone()), &file).to_string(), raw);
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
/// The second check of a checked write compares the open folder's real path as it is: a folder
|
||||
/// on that path replaced afterwards by a link into the write root does not make a place outside
|
||||
/// the root pass.
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn a_checked_write_compares_the_open_folder_without_looking_it_up_again() {
|
||||
let base = std::fs::canonicalize(std::env::temp_dir()).unwrap().join(format!("vc-access-real-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&base);
|
||||
let (root, out) = (base.join("root"), base.join("out"));
|
||||
std::fs::create_dir_all(&root).unwrap();
|
||||
std::fs::create_dir_all(out.join("x")).unwrap();
|
||||
let real = out.join("x/doc.svg");
|
||||
std::fs::remove_dir(out.join("x")).unwrap();
|
||||
std::os::unix::fs::symlink(&root, out.join("x")).unwrap();
|
||||
let roots = AutomationRoots::new(&[], &[root.as_path()]).unwrap();
|
||||
assert!(confine(roots.as_ref(), || crate::file_access::check_write_unrecorded(&real.to_string_lossy())).is_ok(), "looked up, it passes");
|
||||
let checked = confine(roots.as_ref(), || crate::file_access::check_write_real(&real));
|
||||
assert!(checked.is_err_and(|e| e.contains("outside the write root")));
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
/// A checked write through a link to a folder whose name is not valid UTF-8, inside the write
|
||||
/// root, is saved.
|
||||
#[cfg(target_os = "linux")]
|
||||
#[test]
|
||||
fn a_checked_write_saves_into_a_folder_whose_name_is_not_text() {
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
let base = std::fs::canonicalize(std::env::temp_dir()).unwrap().join(format!("vc-access-bytes-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&base);
|
||||
let bytes = base.join(std::ffi::OsStr::from_bytes(b"folder-\xff"));
|
||||
std::fs::create_dir_all(&bytes).unwrap();
|
||||
std::os::unix::fs::symlink(&bytes, base.join("text")).unwrap();
|
||||
let roots = AutomationRoots::new(&[], &[base.as_path()]).unwrap();
|
||||
let path = base.join("text/doc.svg").to_string_lossy().into_owned();
|
||||
confine(roots.as_ref(), || write_file(&path, b"new")).unwrap();
|
||||
assert_eq!(std::fs::read(bytes.join("doc.svg")).unwrap(), b"new");
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Export Document",
|
||||
[],
|
||||
None,
|
||||
"{path?, format?: svg|svgz|pdf|ai|png|jpg|webp|gif|png8|txt|dxf|eps|emf|wmf|hpgl|tiff|bmp|tga|psd|cmx|vectorcraft|template (default: from the path's extension, else png; png8 writes an indexed .png; ait, a .ait template, is written by file.saveAsTemplate; an exporter plug-in's format is plugin.<plug-in id>, which an extension only it lists picks too), params?: {…} (an exporter plug-in's parameters; missing ones take their defaults, see plugin.info), selectedOnly?: false (the selected objects alone, in the layers and groups that hold them; an object of a blend, envelope, repeat or intertwine on its own), includeArtboardFill?: true (raster, PDF, SVG and EPS draw each exported artboard's background color behind its art, a transparent background too; false leaves it out), artboard?: 0, artboards?: [i…], rect?: [x, y, width, height] (raster formats: that area of the page in points, y down, instead of an artboard; not with artboard, artboards, range or useArtboards), range?: \"1-3, 5\" | \"all\" (1-based; PDF and .ai write one page per artboard, default all; SVG writes one file per artboard, {stem}-{artboard}.svg; raster formats write one artboard), useArtboards?: true (raster: one file per chosen artboard, default all, {stem}-{artboard}.{ext}; pdf/ai: every page) | false (pdf/ai/raster: the bounds of the visible art; pdf/ai: of the layers the file draws, without editing data, with a warning, and ai refuses pdfCompatible: false; SVG has it as an SVG option), ppi?: number (raster formats: pixels per inch, stored in the file; wins over scale; without either, the document's raster effects resolution), scale?: number (pixels per point), background?: transparent|white|black|\"#rrggbb\" (jpg: white when transparent; #rrggbbaa and #rgba are refused here and in matte), antiAlias?: none|art (default)|type (text snapped to pixels), interlaced?: false (png, Adam7), embedIcc?: true (png: an sRGB chunk marks the colours as sRGB), quality?: 90 (jpg: 0–100), colorModel?: rgb|cmyk|gray (jpg), method?: baseline|optimized|progressive, scans?: 3 (3–5, progressive), embedIcc?: true, imageMap?: none|client|server (an HTML or NCSA map of the objects with a URL, written as <stem>.html / <stem>.map), colors?: 256 (gif/png8: 2–256), reduction?: perceptual|selective (default)|adaptive|web|blackWhite|gray, dither?: none|diffusion (default)|pattern|noise, ditherAmount?: 100, transparency?: true, transparencyDither?: none (default: pixels under half opacity become transparent)|diffusion|pattern|noise (with transparency: as document.exportForWeb), transparencyDitherAmount?: 100 (0–100: the diffusion transparency dither's strength), matte?: white|\"#rrggbb\"|none, interlaced?, lossless?: true (webp: every pixel kept exactly; false writes lossy WebP, a smaller file that loses some detail), quality?: 90 (webp with lossless: false: 0–100, higher keeps more detail in a larger file; more than 100 is refused), encoding?: utf8|utf16 (txt: the stories in stacking order, back to front, a thread once; utf16 with a byte order mark), lineEndings?: lf|crlf, selectionOnly?: false, svg?: {styling, outlineText, images, objectIds, decimals, minify, responsive, useArtboards, preserveEditing, metadata, fewerTspans, hiddenLayers, encoding, profile, embedFonts, variableData} (see document.formats), …the SVG options given flat instead, …the PDF options of document.exportPdf, …the DXF options of document.exportDxf (useArtboards: one drawing per artboard), …the EPS options of document.exportEps (useArtboards: one file per artboard, {stem}_{artboard}.eps, after a central {stem}.eps of the whole document when there are two or more and art shows; else the visible art), …emf and wmf write one picture of the artboard (useArtboards: true one file per chosen artboard, false the bounds of the visible art; EMF keeps curves, clipping, transparent images and gradients as images clipped to their shape; WMF flattens curves into polygons behind a placeable header; what a format leaves out comes back in warnings), …hpgl writes a plot of the artboard as pen moves for plotters and cutters (each visible path once along its line in plotter units; useArtboards: true one file per chosen artboard, false the bounds of the art it plots, without placed images, unpainted paths and art at 0% opacity), hpglVersion?: hpgl (default: IN, SP, PU, PD) | hpgl2 (also NP and PC pen colors, each pen's paths as one encoded polyline PE), curveTolerance?: 0.1 (points, 0.01 to 10), pens?: [\"#rrggbb\"…] (pen 1 first, up to 255; each path takes the nearest; default a pen per color in the order the art first draws in it, numbered alike in every file), origin?: bottomLeft (default) | center, sortPaths?: false (each pen's next path the nearest), insideFirst?: false (a path after the pen's paths that lie inside it), …cmx writes one file with a page for the artboard (useArtboards: true a page for each chosen artboard, false the bounds of the visible art; a layer for each
Line truncated
|
||||
"{path?, format?: svg|svgz|pdf|ai|png|jpg|webp|gif|png8|txt|dxf|eps|emf|wmf|hpgl|tiff|bmp|tga|psd|cmx|vectorcraft|template (default: from the path's extension, else png; png8 writes an indexed .png; ait, a .ait template, is written by file.saveAsTemplate; an exporter plug-in's format is plugin.<plug-in id>, which an extension only it lists picks too), params?: {…} (an exporter plug-in's parameters; missing ones take their defaults, see plugin.info), selectedOnly?: false (the selected objects alone, in the layers and groups that hold them; an object of a blend, envelope, repeat or intertwine on its own), includeArtboardFill?: true (raster, PDF, SVG and EPS draw each exported artboard's background color behind its art, a transparent background too; false leaves it out), artboard?: 0, artboards?: [i…], rect?: [x, y, width, height] (raster formats: that area of the page in points, y down, instead of an artboard; not with artboard, artboards, range or useArtboards), range?: \"1-3, 5\" | \"all\" (1-based; PDF and .ai write one page per artboard, default all; SVG writes one file per artboard, {stem}-{artboard}.svg; raster formats write one artboard), useArtboards?: true (raster: one file per chosen artboard, default all, {stem}-{artboard}.{ext}; pdf/ai: every page) | false (pdf/ai/raster: the bounds of the visible art; pdf/ai: of the layers the file draws, without editing data, with a warning, and ai refuses pdfCompatible: false; SVG has it as an SVG option), ppi?: number (raster formats: pixels per inch, stored in the file; wins over scale; without either, the document's raster effects resolution), scale?: number (pixels per point), background?: transparent|white|black|\"#rrggbb\" (jpg: white when transparent; #rrggbbaa and #rgba are refused here and in matte), antiAlias?: none|art (default)|type (text snapped to pixels), interlaced?: false (png, Adam7), embedIcc?: true (png: an sRGB chunk marks the colours as sRGB), quality?: 90 (jpg: 0–100), colorModel?: rgb|cmyk|gray (jpg), method?: baseline|optimized|progressive, scans?: 3 (3–5, progressive), embedIcc?: true, imageMap?: none|client|server (an HTML or NCSA map of the objects with a URL, written as <stem>.html / <stem>.map), colors?: 256 (gif/png8: 2–256), reduction?: perceptual|selective (default)|adaptive|web|blackWhite|gray, dither?: none|diffusion (default)|pattern|noise, ditherAmount?: 100, transparency?: true, transparencyDither?: none (default: pixels under half opacity become transparent)|diffusion|pattern|noise (with transparency: as document.exportForWeb), transparencyDitherAmount?: 100 (0–100: the diffusion transparency dither's strength), matte?: white|\"#rrggbb\"|none, interlaced?, lossless?: true (webp: every pixel kept exactly; false writes lossy WebP, a smaller file that loses some detail), quality?: 90 (webp with lossless: false: 0–100, higher keeps more detail in a larger file; more than 100 is refused), encoding?: utf8|utf16 (txt: the stories in stacking order, back to front, a thread once; utf16 with a byte order mark), lineEndings?: lf|crlf, selectionOnly?: false, svg?: {styling, outlineText, images, objectIds, decimals, minify, responsive, units, useArtboards, preserveEditing, metadata, fewerTspans, hiddenLayers, encoding, profile, embedFonts, variableData} (see document.formats), …the SVG options given flat instead, …the PDF options of document.exportPdf, …the DXF options of document.exportDxf (useArtboards: one drawing per artboard), …the EPS options of document.exportEps (useArtboards: one file per artboard, {stem}_{artboard}.eps, after a central {stem}.eps of the whole document when there are two or more and art shows; else the visible art), …emf and wmf write one picture of the artboard (useArtboards: true one file per chosen artboard, false the bounds of the visible art; EMF keeps curves, clipping, transparent images and gradients as images clipped to their shape; WMF flattens curves into polygons behind a placeable header; what a format leaves out comes back in warnings), …hpgl writes a plot of the artboard as pen moves for plotters and cutters (each visible path once along its line in plotter units; useArtboards: true one file per chosen artboard, false the bounds of the art it plots, without placed images, unpainted paths and art at 0% opacity), hpglVersion?: hpgl (default: IN, SP, PU, PD) | hpgl2 (also NP and PC pen colors, each pen's paths as one encoded polyline PE), curveTolerance?: 0.1 (points, 0.01 to 10), pens?: [\"#rrggbb\"…] (pen 1 first, up to 255; each path takes the nearest; default a pen per color in the order the art first draws in it, numbered alike in every file), origin?: bottomLeft (default) | center, sortPaths?: false (each pen's next path the nearest), insideFirst?: false (a path after the pen's paths that lie inside it), …cmx writes one file with a page for the artboard (useArtboards: true a page for each chosen artboard, false the bounds of the visible art; a layer f
Line truncated
|
||||
has_doc,
|
||||
export::export
|
||||
),
|
||||
@@ -54,7 +54,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Export for Screens",
|
||||
["File", "Export"],
|
||||
None,
|
||||
"{folder?, zip?: false (one .zip of every file, each deflated or stored, whichever is smaller: no folder → {name, dataBase64, bytes, files: [name…]}; with a folder it is written there → {path, bytes, files}), artboard?: index | artboards?: [index…] | range?: \"1-3\" (default all), assets?: [asset id…] (instead of artboards: each asset's art alone, cropped to its bounds and named after the asset; see assets.list), layers?: [layer id…] (instead of artboards: each layer's art alone, sublayers included, named after the layer), selection?: one|each (instead of artboards: the selected art as one file, or a file per selected object, named after it), fullDocument?: false (one file per format instead: a PDF of every artboard, other formats the bounds of all visible art, named after the document), includeBleed?: false (artboards grown by the document's bleed; a PDF page keeps the artboard as its TrimBox and puts its row's bleed around it once, the document's bleed when the row sets none and its preset gives none or 0), includeArtboardFill?: true (Include Artboard Fill: each artboard's background color behind its art; false leaves it out), pdfs?: multiple|single (Export PDFs As: with several artboards, single writes them as the pages of one PDF per PDF row, named after the document; refused with assets, layers or selection: each), exportPreset?: (a preset of document.exportPresets.list: its settings, under these params), subfolders?: false (each row's files in a sub-folder: its folder, else its size for raster (1x, 2x, 100w…) or its format (SVG, PDF)), folders?: none|rows (as subfolders)|format (a folder per extension: png, svg, pdf…)|item (a folder per artboard, asset, layer or object)|itemFormat (item/extension) (default: rows with subfolders or a preset, else none), name?: (a file name pattern instead of the item's name, with <filename> for the document, <name> for the artboard, asset, layer or object, <index> from 1, #### for the counter zero-padded to the run of #, <format>, <scale>, <suffix> (else the row's suffix ends the name), YYYYMMDD, YYYY-MM-DD, YYYY, <date>, <time>, <YYYY>, <MM>, <DD>, <hh>, <mm> and <ss>; a trailing .ext is dropped, as in `COMPANY-Logo-<filename>-####-YYYYMMDD`; different files it names alike get -2, -3…), counterStart?: 1, counterPer?: item (every file of an item has its number)|file, date?: YYYY-MM-DD (the date the pattern uses; default today, UTC), preset?: mobile (PNG 1x, 2x, 3x) | density (PNG 0.75x–4x in ldpi…xxxhdpi sub-folders) instead of formats (turns subfolders on), formats?: [{format: png|png8|jpg|webp|gif|tiff|bmp|tga|psd|svg|svgz|pdf|eps|ai|vectorcraft, scale?: 1 | \"2x\" | \"100w\" | \"100h\" | \"72ppi\", width?: px | height?: px | ppi? (raster only; width, then height, then ppi win over scale), suffix?: (raster default: @2x, @100w, @100h, none at 1x; vector formats drop size suffixes), folder?: (its sub-folder), quality?: (jpg 0–100; webp 0–100 with lossless: false), …the format's options (antiAlias, background, preset (pdf)…)}], settings?: {png|png8|jpg|webp|gif|tiff|bmp|tga|psd|svg|svgz|pdf|eps|ai|vectorcraft: {…options for every row of that format}} (rows' own options win), prefix?, antiAlias?: none|art|type (raster rows without their own), openLocation?: (remembered; the app shows the files after exporting)} one file per artboard and format (a PDF holds its artboard alone; artboards with the same name, in any case, get -2, -3…; an unnamed one is Artboard-N; a row whose file would take a name another row's file has, in any case, gets -2, -3… too, and identical rows write one file; row folders that differ only in case are one folder, spelled as the first row spells it) → {files: [path…]} (into the folder of exportPreset, outside the automation read roots: no ZIP path, and files relative to that folder); no folder → {files: [{name, dataBase64}]} (names include sub-folders: 2x/[email protected]); every reply has warnings: [the encoders' warnings for the files, each once: an image that couldn't be decoded, type written in the fallback font…]. eps, ai and vectorcraft rows write a document of the item alone (its one artboard). The params (but zip and assets) are remembered in the document (document.exportSettings; not an undo step). A key it doesn't take, a key no format takes in a format row or in settings, settings for a format it doesn't write, and an unknown key inside a PDF, EPS or SVG option's object, are refused; a key only another format takes in a row or in settings is not used, and warnings name it as given (formats[0].quality; a key in settings only when no row of that format reads it; not a key of an exportPreset). Under automation read roots, an svg or svgz row, and a row whose files carry the native document (vectorcraft, eps, ai but a version 7 file, a pdf with preserveEditing on that holds every artboard of the document it is written from), is refused, before the folder is made or any file is written, while t
Line truncated
|
||||
"{folder?, zip?: false (one .zip of every file, each deflated or stored, whichever is smaller: no folder → {name, dataBase64, bytes, files: [name…]}; with a folder it is written there → {path, bytes, files}), artboard?: index | artboards?: [index…] | range?: \"1-3\" (default all), assets?: [asset id…] (instead of artboards: each asset's art alone, cropped to its bounds and named after the asset; see assets.list), layers?: [layer id…] (instead of artboards: each layer's art alone, sublayers included, named after the layer), selection?: one|each (instead of artboards: the selected art as one file, or a file per selected object, named after it), fullDocument?: false (one file per format instead: a PDF of every artboard, other formats the bounds of all visible art, named after the document), includeBleed?: false (artboards grown by the document's bleed; a PDF page keeps the artboard as its TrimBox and puts its row's bleed around it once, the document's bleed when the row sets none and its preset gives none or 0; a native, .ai or EPS file of an artboard holds the grown artboard with a bleed of 0), includeArtboardFill?: true (Include Artboard Fill: each artboard's background color behind its art; false leaves it out), pdfs?: multiple|single (Export PDFs As: with several artboards, single writes them as the pages of one PDF per PDF row, named after the document; refused with assets, layers or selection: each), exportPreset?: (a preset of document.exportPresets.list: its settings, under these params), subfolders?: false (each row's files in a sub-folder: its folder, else its size for raster (1x, 2x, 100w…) or its format (SVG, PDF)), folders?: none|rows (as subfolders)|format (a folder per extension: png, svg, pdf…)|item (a folder per artboard, asset, layer or object)|itemFormat (item/extension) (default: rows with subfolders or a preset, else none), name?: (a file name pattern instead of the item's name, with <filename> for the document, <name> for the artboard, asset, layer or object, <index> from 1, #### for the counter zero-padded to the run of #, <format>, <scale>, <suffix> (else the row's suffix ends the name), YYYYMMDD, YYYY-MM-DD, YYYY, <date>, <time>, <YYYY>, <MM>, <DD>, <hh>, <mm> and <ss>; a trailing .ext is dropped, as in `COMPANY-Logo-<filename>-####-YYYYMMDD`; different files it names alike get -2, -3…), counterStart?: 1, counterPer?: item (every file of an item has its number)|file, date?: YYYY-MM-DD (the date the pattern uses; default today, UTC), preset?: mobile (PNG 1x, 2x, 3x) | density (PNG 0.75x–4x in ldpi…xxxhdpi sub-folders) instead of formats (turns subfolders on), formats?: [{format: png|png8|jpg|webp|gif|tiff|bmp|tga|psd|svg|svgz|pdf|eps|ai|vectorcraft, scale?: 1 | \"2x\" | \"100w\" | \"100h\" | \"72ppi\", width?: px | height?: px | ppi? (raster only; width, then height, then ppi win over scale), suffix?: (raster default: @2x, @100w, @100h, none at 1x; vector formats drop size suffixes), folder?: (its sub-folder), quality?: (jpg 0–100; webp 0–100 with lossless: false), …the format's options (antiAlias, background, preset (pdf)…)}], settings?: {png|png8|jpg|webp|gif|tiff|bmp|tga|psd|svg|svgz|pdf|eps|ai|vectorcraft: {…options for every row of that format}} (rows' own options win), prefix?, antiAlias?: none|art|type (raster rows without their own), openLocation?: (remembered; the app shows the files after exporting)} one file per artboard and format (a PDF holds its artboard alone; artboards with the same name, in any case, get -2, -3…; an unnamed one is Artboard-N; a row whose file would take a name another row's file has, in any case, gets -2, -3… too, and identical rows write one file; row folders that differ only in case are one folder, spelled as the first row spells it) → {files: [path…]} (into the folder of exportPreset, outside the automation read roots: no ZIP path, and files relative to that folder); no folder → {files: [{name, dataBase64}]} (names include sub-folders: 2x/[email protected]); every reply has warnings: [the encoders' warnings for the files, each once: an image that couldn't be decoded, type written in the fallback font…]. eps, ai and vectorcraft rows write a document of the item alone (its one artboard). The params (but zip and assets) are remembered in the document (document.exportSettings; not an undo step). A key it doesn't take, a key no format takes in a format row or in settings, settings for a format it doesn't write, and an unknown key inside a PDF, EPS or SVG option's object, are refused; a key only another format takes in a row or in settings is not used, and warnings name it as given (formats[0].quality; a key in settings only when no row of that format reads it; not a key of an exportPreset). Under automation read roots, an svg or svgz row, and a row whose files carry the native document (vectorcraft, eps, ai but a version 7 file, a pdf with preserveEditing on that holds every artboard of the document it is
Line truncated
|
||||
has_doc,
|
||||
screens::export_for_screens
|
||||
),
|
||||
|
||||
@@ -1131,23 +1131,29 @@ fn names_scripts(item: &Item, r: &Row, single: Option<&[usize]>) -> bool {
|
||||
|
||||
/// The document the file of `item` that row `r` writes carries when it carries one
|
||||
/// ([`names_scripts`]): Full Document's PDF of every artboard, the item's artboard alone for a
|
||||
/// native, `.ai` or EPS row ([`board_document`]), else the item's document.
|
||||
fn carried_document<'a>(item: &'a Item, r: &Row, single: Option<&[usize]>) -> std::borrow::Cow<'a, Document> {
|
||||
/// native, `.ai` or EPS row ([`board_document`]), else the item's document. `grown`: Include Bleed
|
||||
/// grew the artboards by the document's bleed.
|
||||
fn carried_document<'a>(item: &'a Item, r: &Row, single: Option<&[usize]>, grown: bool) -> std::borrow::Cow<'a, Document> {
|
||||
match (&item.every_artboard, r.format.id, single) {
|
||||
(Some(all), "pdf", None) => std::borrow::Cow::Borrowed(&**all),
|
||||
_ if r.whole_document() && item.artboard.is_some() => std::borrow::Cow::Owned(board_document(item)),
|
||||
_ if r.whole_document() && item.artboard.is_some() => std::borrow::Cow::Owned(board_document(item, grown)),
|
||||
_ => std::borrow::Cow::Borrowed(&*item.doc),
|
||||
}
|
||||
}
|
||||
|
||||
/// The document a native, `.ai` or EPS row writes for `item`'s artboard: that artboard alone, with
|
||||
/// its background color and the art on it, as Save's separateArtboards writes it (#3868).
|
||||
fn board_document(item: &Item) -> Document {
|
||||
/// its background color and the art on it, as Save's separateArtboards writes it (#3868). When
|
||||
/// Include Bleed grew the artboard (`grown`), the artboard already holds the bleed, so the document
|
||||
/// is written with a bleed of 0: opened again, its pages are not grown by the bleed a second time.
|
||||
fn board_document(item: &Item, grown: bool) -> Document {
|
||||
let mut d = single_artboard(&item.doc, item.region, &item.name);
|
||||
if let (Some(a), Some(from)) = (d.artboards.first_mut(), item.doc.artboards.get(item.artboard.unwrap_or(0))) {
|
||||
a.color = from.color;
|
||||
}
|
||||
super::save::keep_art_on(&mut d, item.region);
|
||||
if grown && item.every_artboard.is_none() {
|
||||
d.setup.bleed = [0.0; 4];
|
||||
}
|
||||
d
|
||||
}
|
||||
|
||||
@@ -1209,7 +1215,7 @@ pub(crate) fn export(s: &mut Session, p: &Value, asked: &Value) -> Result<Value>
|
||||
let all = item.every_artboard.is_some() && r.format.id == "pdf" && single.is_none();
|
||||
let board = item.artboard.filter(|_| !all && r.whole_document());
|
||||
if looked.insert((Arc::as_ptr(&item.doc) as usize, all, board))
|
||||
&& crate::cmd::links::names_hidden_file(&carried_document(item, r, single.as_deref()), base)
|
||||
&& crate::cmd::links::names_hidden_file(&carried_document(item, r, single.as_deref(), ungrown.is_some()), base)
|
||||
{
|
||||
return Err(bad(C, super::access::IMAGE_OUTSIDE));
|
||||
}
|
||||
@@ -1402,7 +1408,10 @@ fn encode_and_write(export: ScreenExport, writer: &mut dyn FnMut(&str, &[u8]) ->
|
||||
write(pdf_doc.unwrap_or(all), "pdf", &options)?
|
||||
} else if r.whole_document() && item.artboard.is_some() {
|
||||
let b = item.artboard.unwrap_or(0);
|
||||
let d = board_docs.entry((Arc::as_ptr(&item.doc) as usize, b)).or_insert_with(|| Arc::new(board_document(item))).clone();
|
||||
let d = board_docs
|
||||
.entry((Arc::as_ptr(&item.doc) as usize, b))
|
||||
.or_insert_with(|| Arc::new(board_document(item, pdf_doc.is_some())))
|
||||
.clone();
|
||||
let mut options = r.options_for(item.region, None)?;
|
||||
// An EPS page is the artboard, not its art's bounds: an artboard without art still writes.
|
||||
if r.format.id == "eps" {
|
||||
|
||||
@@ -50,6 +50,12 @@ pub const OPTIONS: &[FormatOption] = &[
|
||||
FormatOption { name: "decimals", ty: "integer", default: "3", description: "coordinate precision, 1–7 decimal places" },
|
||||
FormatOption { name: "minify", ty: "boolean", default: "false", description: "no XML declaration, indentation or line breaks" },
|
||||
FormatOption { name: "responsive", ty: "boolean", default: "false", description: "no width/height: the SVG scales to its container" },
|
||||
FormatOption {
|
||||
name: "units",
|
||||
ty: "string",
|
||||
default: "null",
|
||||
description: "override the document unit for width and height: px (bare numbers, one per point) | pt | mm | cm | in; omit to follow the document unit, not null (the viewBox stays in points; not with responsive)",
|
||||
},
|
||||
FormatOption {
|
||||
name: "preserveEditing",
|
||||
ty: "boolean",
|
||||
@@ -121,7 +127,7 @@ pub fn options_map(p: &Value) -> Result<Map<String, Value>, String> {
|
||||
let mut m = Map::new();
|
||||
let Some(o) = p.as_object() else { return Ok(m) };
|
||||
for opt in OPTIONS.iter().filter(|opt| opt.name != "svg") {
|
||||
if let Some(v) = o.get(opt.name).filter(|v| !v.is_null()) {
|
||||
if let Some(v) = o.get(opt.name).filter(|v| opt.name == "units" || !v.is_null()) {
|
||||
m.insert(opt.name.into(), v.clone());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1512,3 +1512,39 @@ fn each_piece_writes_its_own_native_document() {
|
||||
assert!(name.contains(&board), "{name} holds the artboard {board}");
|
||||
}
|
||||
}
|
||||
|
||||
/// With Include Bleed, a native, `.ai` or EPS file of an artboard holds the artboard grown by the
|
||||
/// bleed, and no bleed of its own: opened again, a PDF with the document's bleed has the same page
|
||||
/// as the export's own PDF row, not one grown by the bleed twice. A Full Document file keeps the
|
||||
/// document's bleed around its art's bounds, which Include Bleed doesn't grow.
|
||||
#[test]
|
||||
fn include_bleed_native_files_hold_the_bleed_once() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap();
|
||||
s.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 50, "height": 50})).unwrap();
|
||||
s.execute("document.setup", &json!({"bleed": 9})).unwrap();
|
||||
let r = export(&mut s, json!({"includeBleed": true, "artboard": 0, "formats": [{"format": "pdf"}]}));
|
||||
let [(_, pdf)] = &files(&r)[..] else { panic!("one PDF: {r}") };
|
||||
let [(media, bleed, ..)] = page_sizes(pdf)[..] else { panic!("one page") };
|
||||
let reopened = |name: &str, bytes: &[u8]| -> (Session, Vec<PageSizes>) {
|
||||
let mut t = Session::new();
|
||||
t.execute("document.open", &json!({"name": name, "dataBase64": vectorcraft_format::base64_encode(bytes)})).unwrap();
|
||||
let r = t.execute("document.exportPdf", &json!({"bleed": {"useDocument": true}, "preserveEditing": false})).unwrap();
|
||||
let pages = page_sizes(&b64(&r));
|
||||
(t, pages)
|
||||
};
|
||||
for format in ["vectorcraft", "ai", "eps"] {
|
||||
let r = export(&mut s, json!({"includeBleed": true, "artboard": 0, "formats": [{"format": format}]}));
|
||||
let [(name, bytes)] = &files(&r)[..] else { panic!("one {format} file: {r}") };
|
||||
let (t, pages) = reopened(name, bytes);
|
||||
let [(m, b, trim, _)] = pages[..] else { panic!("{format}: one page") };
|
||||
assert_eq!((m, b), (media, bleed), "{format}: the page of the PDF row");
|
||||
assert_eq!(trim, bleed, "{format}: the artboard holds the bleed");
|
||||
assert_eq!(t.doc().unwrap().doc.setup.bleed, [0.0; 4], "{format}: no second bleed");
|
||||
}
|
||||
// Full Document: the art's bounds, with the document's bleed around them.
|
||||
let r = export(&mut s, json!({"includeBleed": true, "fullDocument": true, "formats": [{"format": "vectorcraft"}]}));
|
||||
let [(name, bytes)] = &files(&r)[..] else { panic!("one file: {r}") };
|
||||
let (t, _) = reopened(name, bytes);
|
||||
assert_eq!(t.doc().unwrap().doc.setup.bleed, [9.0; 4]);
|
||||
}
|
||||
@@ -115,6 +115,10 @@ fn junk_options_are_rejected() {
|
||||
json!({"svg": "css"}),
|
||||
json!({"images": "inline"}),
|
||||
json!({"useArtboards": "yes"}),
|
||||
json!({"units": "furlong"}),
|
||||
json!({"units": 7}),
|
||||
json!({"units": null}),
|
||||
json!({"svg": {"units": null}}),
|
||||
] {
|
||||
let mut q = p.clone();
|
||||
q["format"] = json!("svg");
|
||||
@@ -124,6 +128,39 @@ fn junk_options_are_rejected() {
|
||||
assert!(s.execute("document.export", &json!({"format": "png", "styling": "fancy"})).is_ok());
|
||||
}
|
||||
|
||||
/// #4462: width and height carry the chosen unit (the document is 200 × 100 pt, the viewBox stays
|
||||
/// in points), px is today's bare numbers, and Responsive leaves the size out whatever the unit.
|
||||
#[test]
|
||||
fn svg_export_writes_width_height_with_the_requested_unit() {
|
||||
let mut s = session(1);
|
||||
let plain = svg(&mut s, json!({}));
|
||||
assert!(plain.contains(" width=\"200\" height=\"100\" viewBox=\"0 0 200 100\""), "{plain}");
|
||||
assert_eq!(svg(&mut s, json!({"units": "px"})), plain, "px keeps bare point coordinates");
|
||||
for unit in ["mm", "cm", "in", "pt"] {
|
||||
for decimals in [1, 3] {
|
||||
for p in [json!({"units": unit, "decimals": decimals}), json!({"svg": {"units": unit, "decimals": decimals}})] {
|
||||
let out = svg(&mut s, p);
|
||||
assert!(out.contains(&format!("{unit}\"")) && out.contains("viewBox=\"0 0 200 100\""), "{unit}:\n{out}");
|
||||
let back = vectorcraft_svg::import(&out).unwrap();
|
||||
let rect = back.artboards[0].rect;
|
||||
assert!((rect.width() - 200.0).abs() < 0.001 && (rect.height() - 100.0).abs() < 0.001, "{unit}: {rect:?}\n{out}");
|
||||
}
|
||||
}
|
||||
}
|
||||
let out = svg(&mut s, json!({"units": "mm", "responsive": true}));
|
||||
assert!(!out.contains("mm\"") && !out.contains("height=\"100\" viewBox") && out.contains("viewBox=\"0 0 200 100\""), "{out}");
|
||||
assert!(svg(&mut s, json!({"units": "mm", "decimals": 1})).contains("x=\"10.1\""), "coordinate precision is unchanged");
|
||||
// Omitted units retain main's document-unit save behavior, including serialized defaults.
|
||||
s.execute("document.setUnits", &json!({"units": "millimeters"})).unwrap();
|
||||
let defaults = serde_json::to_value(vectorcraft_svg::ExportOptions::default()).unwrap();
|
||||
assert!(svg(&mut s, json!({"svg": defaults})).contains("mm\""));
|
||||
for p in [json!({"units": "px"}), json!({"svg": {"units": "px"}})] {
|
||||
assert_eq!(svg(&mut s, p), plain, "explicit pixels override physical document units");
|
||||
}
|
||||
assert_eq!(svg(&mut s, json!({"units": "mm", "svg": {"units": "px"}})), plain, "nested units override flat units");
|
||||
assert_eq!(svg(&mut s, json!({"units": null, "svg": {"units": "px"}})), plain, "nested units override flat null");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn several_artboards_write_one_file_each() {
|
||||
let mut s = session(3);
|
||||
|
||||
@@ -104,8 +104,15 @@ fn bmp_options_reach_the_file() {
|
||||
assert_eq!(i32::from_le_bytes(flipped[22..26].try_into().unwrap()), -40, "top-down rows");
|
||||
let os2 = bmp(&mut s, json!({"fileFormat": "os2", "depth": 4}));
|
||||
assert_eq!(u32::from_le_bytes(os2[14..18].try_into().unwrap()), 12, "OS/2 core header");
|
||||
let gray = image::load_from_memory_with_format(&bmp(&mut s, json!({"colorModel": "gray", "depth": 8})), image::ImageFormat::Bmp).unwrap();
|
||||
assert!(gray.to_rgb8().pixels().all(|p| p[0] == p[1] && p[1] == p[2]));
|
||||
// A red square, whose gray is neither black nor white.
|
||||
let red = s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 10, "height": 40})).unwrap()["id"].clone();
|
||||
s.execute("paint.setFill", &json!({"ids": [red], "color": "#ff0000"})).unwrap();
|
||||
let gray =
|
||||
image::load_from_memory_with_format(&bmp(&mut s, json!({"colorModel": "gray", "depth": 8})), image::ImageFormat::Bmp).unwrap().to_rgb8();
|
||||
assert_eq!(gray.dimensions(), (60, 40));
|
||||
assert!(gray.pixels().all(|p| p[0] == p[1] && p[1] == p[2]));
|
||||
let [r, _, _] = gray.get_pixel(5, 20).0;
|
||||
assert!(r > 0 && r < 255, "red is a middle gray: {r}");
|
||||
for bad in [
|
||||
json!({"depth": 2}),
|
||||
json!({"depth": 24, "rle": true}),
|
||||
|
||||
@@ -30,19 +30,29 @@ impl Visitor for Names {
|
||||
}
|
||||
}
|
||||
|
||||
/// Reads every file, and waits on reading one until its channel sends or closes.
|
||||
struct Blocked(Mutex<mpsc::Receiver<()>>);
|
||||
/// Reads every file, says on its second channel that a read began, and waits on reading one until
|
||||
/// its first channel sends or closes.
|
||||
struct Blocked(Mutex<mpsc::Receiver<()>>, mpsc::Sender<()>);
|
||||
|
||||
impl Visitor for Blocked {
|
||||
fn wants(&self, _: &str) -> bool {
|
||||
true
|
||||
}
|
||||
fn items(&self, _: &Path) -> Vec<usize> {
|
||||
let _ = self.1.send(());
|
||||
let _ = self.0.lock().unwrap().recv();
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
/// A [`Blocked`] visitor with the sender that lets its reads end and the receiver that hears each
|
||||
/// read begin.
|
||||
fn blocked() -> (mpsc::Sender<()>, mpsc::Receiver<()>, Arc<dyn Visitor>) {
|
||||
let (go, wait_for_go) = mpsc::channel();
|
||||
let (entered, reading) = mpsc::channel();
|
||||
(go, reading, Arc::new(Blocked(Mutex::new(wait_for_go), entered)))
|
||||
}
|
||||
|
||||
/// A test's folder tree, removed with everything in it when dropped, also when the test panics,
|
||||
/// and also when the test locked a folder in it. A removal that fails (a walker still holding a
|
||||
/// file open) is ignored.
|
||||
@@ -316,29 +326,35 @@ fn the_search_ends_at_its_limits_and_when_stopped() {
|
||||
#[test]
|
||||
fn the_search_answers_at_its_deadline_while_a_walker_is_blocked() {
|
||||
let root = tree("blocked", &["f.ttf"]);
|
||||
let (tx, rx) = mpsc::channel();
|
||||
let (tx, reading, visitor) = blocked();
|
||||
let started = Instant::now();
|
||||
let s = begin(root.clone(), rules(&root), Limits { seconds: 0.2, ..Limits::default() }, 1, 1, Arc::new(Blocked(Mutex::new(rx))));
|
||||
std::thread::sleep(Duration::from_millis(300));
|
||||
let s = begin(root.clone(), rules(&root), Limits::default(), 1, 1, visitor);
|
||||
// The walker is blocked reading the file.
|
||||
assert!(reading.recv_timeout(WAIT).is_ok(), "the walker reads the file");
|
||||
assert_eq!((s.progress().state(), s.progress().read), ("searching", 1));
|
||||
s.expire();
|
||||
let p = s.progress();
|
||||
// The search ended when it answered, and it ran no longer than the test has waited.
|
||||
let waited = started.elapsed().as_secs_f64();
|
||||
assert_eq!((p.state(), p.stopped()), ("stopped", Some("time")), "{p:?}");
|
||||
assert!(p.seconds >= 0.2 && p.seconds <= waited, "{p:?}, {waited} s");
|
||||
let (tx2, rx2) = mpsc::channel();
|
||||
let s2 = begin(root.clone(), rules(&root), Limits::default(), 1, 1, Arc::new(Blocked(Mutex::new(rx2))));
|
||||
let until = Instant::now() + WAIT;
|
||||
while s2.progress().read == 0 && Instant::now() < until {
|
||||
std::thread::sleep(Duration::from_millis(2));
|
||||
}
|
||||
assert!(p.seconds <= waited, "{p:?}, {waited} s");
|
||||
assert_eq!(s.progress().seconds, p.seconds, "the time it ended at stays");
|
||||
// A limit of no seconds has run out as the search starts; a long one hasn't.
|
||||
let (_tx0, _, visitor) = blocked();
|
||||
let none = begin(root.clone(), rules(&root), Limits { seconds: 0.0, ..Limits::default() }, 1, 1, visitor);
|
||||
assert_eq!(none.progress().stopped(), Some("time"));
|
||||
let (tx2, reading2, visitor) = blocked();
|
||||
let s2 = begin(root.clone(), rules(&root), Limits::default(), 1, 1, visitor);
|
||||
assert!(reading2.recv_timeout(WAIT).is_ok(), "the walker reads the file");
|
||||
assert_eq!(s2.progress().state(), "searching");
|
||||
s2.stop();
|
||||
assert_eq!(s2.progress().stopped(), Some("stop"));
|
||||
drop((tx, tx2));
|
||||
}
|
||||
|
||||
/// Every file is item 0; reading the second file waits until the channel closes.
|
||||
struct SecondBlocks(Mutex<(usize, mpsc::Receiver<()>)>);
|
||||
/// Every file is item 0; reading the second file says so on the second channel, then waits until
|
||||
/// the first channel closes.
|
||||
struct SecondBlocks(Mutex<(usize, mpsc::Receiver<()>)>, mpsc::Sender<()>);
|
||||
|
||||
impl Visitor for SecondBlocks {
|
||||
fn wants(&self, _: &str) -> bool {
|
||||
@@ -348,6 +364,7 @@ impl Visitor for SecondBlocks {
|
||||
let mut read = self.0.lock().unwrap();
|
||||
read.0 += 1;
|
||||
if read.0 == 2 {
|
||||
let _ = self.1.send(());
|
||||
let _ = read.1.recv();
|
||||
}
|
||||
vec![0]
|
||||
@@ -360,11 +377,9 @@ impl Visitor for SecondBlocks {
|
||||
fn files_found_are_kept_as_they_are_read() {
|
||||
let root = tree("kept", &["a.ttf", "b.ttf", "c.ttf"]);
|
||||
let (tx, rx) = mpsc::channel();
|
||||
let s = begin(root.clone(), rules(&root), Limits::default(), 1, 2, Arc::new(SecondBlocks(Mutex::new((0, rx)))));
|
||||
let until = Instant::now() + WAIT;
|
||||
while s.progress().read < 2 && Instant::now() < until {
|
||||
std::thread::sleep(Duration::from_millis(2));
|
||||
}
|
||||
let (second, reading_second) = mpsc::channel();
|
||||
let s = begin(root.clone(), rules(&root), Limits::default(), 1, 2, Arc::new(SecondBlocks(Mutex::new((0, rx)), second)));
|
||||
assert!(reading_second.recv_timeout(WAIT).is_ok(), "the walker reads a second file");
|
||||
let p = s.progress();
|
||||
assert_eq!((p.state(), p.hits.len()), ("searching", 1), "{p:?}");
|
||||
s.stop();
|
||||
@@ -527,16 +542,12 @@ fn system_roots_and_homes_are_told_by_what_they_hold() {
|
||||
fn a_search_starts_with_the_threads_left_and_fails_when_none_is() {
|
||||
static POOL: Pool = Pool::new(3);
|
||||
let root = tree("pool", &["f.ttf"]);
|
||||
let blocked = || {
|
||||
let (tx, rx) = mpsc::channel();
|
||||
(tx, Arc::new(Blocked(Mutex::new(rx))) as Arc<dyn Visitor>)
|
||||
};
|
||||
let (tx_a, a) = blocked();
|
||||
let (tx_b, b) = blocked();
|
||||
let (tx_a, _, a) = blocked();
|
||||
let (tx_b, _, b) = blocked();
|
||||
let a = start_in(&POOL, root.clone(), Some(rules(&root)), Limits::default(), 2, 1, a).unwrap();
|
||||
let b = start_in(&POOL, root.clone(), Some(rules(&root)), Limits::default(), 4, 1, b).unwrap();
|
||||
assert_eq!(POOL.live(), 3);
|
||||
let (_, c) = blocked();
|
||||
let (_, _, c) = blocked();
|
||||
let c = start_in(&POOL, root.clone(), Some(rules(&root)), Limits::default(), 1, 1, c);
|
||||
assert_eq!(c.err().as_deref(), Some("the search couldn't start: try again in a moment"));
|
||||
drop((tx_a, tx_b));
|
||||
|
||||
@@ -238,12 +238,18 @@ impl Search {
|
||||
self.shared.finish(&mut w, End::Stopped);
|
||||
}
|
||||
|
||||
/// Move the search's deadline to now, as if its time had run out.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn expire(&self) {
|
||||
self.shared.deadline.store(0, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// Where the search stands. Past its deadline it has ended ([`End::Time`]), even while a walker
|
||||
/// is still waiting for a slow folder or file.
|
||||
pub fn progress(&self) -> Progress {
|
||||
let s = &self.shared;
|
||||
let mut w = s.lock();
|
||||
if w.end.is_none() && Instant::now() >= s.deadline {
|
||||
if w.end.is_none() && s.time_up() {
|
||||
s.finish(&mut w, End::Time);
|
||||
}
|
||||
Progress {
|
||||
@@ -310,7 +316,7 @@ pub(crate) fn start_in(
|
||||
entries: AtomicU64::new(0),
|
||||
read: AtomicU64::new(0),
|
||||
started,
|
||||
deadline: started + Duration::from_secs_f64(seconds),
|
||||
deadline: AtomicU64::new(u64::try_from(Duration::from_secs_f64(seconds).as_nanos()).unwrap_or(u64::MAX)),
|
||||
limits,
|
||||
items,
|
||||
given: rules,
|
||||
@@ -355,7 +361,8 @@ struct Shared {
|
||||
entries: AtomicU64,
|
||||
read: AtomicU64,
|
||||
started: Instant,
|
||||
deadline: Instant,
|
||||
/// Nanoseconds after `started` at which the search's time is up.
|
||||
deadline: AtomicU64,
|
||||
limits: Limits,
|
||||
items: usize,
|
||||
/// The rules given to [`start`], else this computer's, read by the first walker.
|
||||
@@ -419,7 +426,12 @@ impl Shared {
|
||||
|
||||
/// Whether to stop listing and reading: the search ended or its time is up.
|
||||
fn should_stop(&self) -> bool {
|
||||
self.stop.load(Ordering::Relaxed) || Instant::now() >= self.deadline
|
||||
self.stop.load(Ordering::Relaxed) || self.time_up()
|
||||
}
|
||||
|
||||
/// Whether the search's time is up: [`Shared::deadline`] nanoseconds passed since it started.
|
||||
fn time_up(&self) -> bool {
|
||||
u64::try_from(self.started.elapsed().as_nanos()).unwrap_or(u64::MAX) >= self.deadline.load(Ordering::Relaxed)
|
||||
}
|
||||
|
||||
/// Whether the folders waiting to be listed and `more` folders found in the folder being listed
|
||||
@@ -618,7 +630,7 @@ fn walker(s: &Shared) {
|
||||
if w.end.is_some() {
|
||||
return;
|
||||
}
|
||||
if Instant::now() >= s.deadline {
|
||||
if s.time_up() {
|
||||
s.finish(&mut w, End::Time);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2588,6 +2588,7 @@ fn a_line_series_draws_its_kept_stroke_on_the_line_and_its_kept_fill_on_the_mark
|
||||
s.execute("graph.setData", &json!({"rows": [[1, 2], [3, 4]]})).unwrap();
|
||||
let (drawn, others) = line_parts(&s, id);
|
||||
assert_eq!((drawn.appearance.fill_paint(), drawn.appearance.stroke_paint()), (Paint::None, red));
|
||||
assert!(!others.is_empty(), "the markers and the legend swatch are drawn");
|
||||
assert!(others.iter().all(|m| m.appearance.fill_paint() == blue), "{others:?}");
|
||||
}
|
||||
|
||||
@@ -4867,7 +4868,7 @@ fn blanks_read_back_as_null_and_year_header_rows_still_read_as_headers() {
|
||||
#[test]
|
||||
fn a_huge_ragged_grid_is_capped() {
|
||||
let g = GraphSpec { rows: vec![vec![0.0; vectorcraft_doc::MAX_GRAPH_SERIES + 10]; 3], ..GraphSpec::default() };
|
||||
assert!(g.cells().iter().all(|r| r.len() == vectorcraft_doc::MAX_GRAPH_SERIES));
|
||||
assert_eq!(g.cells().iter().map(Vec::len).collect::<Vec<_>>(), [vectorcraft_doc::MAX_GRAPH_SERIES; 3]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -6720,7 +6721,17 @@ fn designs_and_markers_survive_save_and_open() {
|
||||
d.graph_designs.push(vectorcraft_doc::GraphDesign { name: "Dot".into(), art: std::sync::Arc::new(dot) });
|
||||
let art = super::generate(&mut d, &g);
|
||||
let s0 = art.iter().find(|n| n.extras().series_index == Some(0)).unwrap();
|
||||
assert!(s0.children().unwrap().iter().all(|n| matches!(n.kind, NodeKind::Path { .. })));
|
||||
let marks = s0.children().unwrap();
|
||||
assert!(marks.iter().all(|n| matches!(n.kind, NodeKind::Path { .. })));
|
||||
assert_eq!(marks.iter().filter(|n| sized(n, 5.0)).count(), 1, "a default square at the one data point");
|
||||
}
|
||||
|
||||
/// Whether `n` is a square path `side` points across, drawn as the four corners of its bounds (a default point marker
|
||||
/// is 5, a default legend swatch 8).
|
||||
fn sized(n: &vectorcraft_doc::Node, side: f64) -> bool {
|
||||
let Some(b) = n.geometric_bounds() else { return false };
|
||||
let square = matches!(&n.kind, NodeKind::Path { path, .. } if *path == vectorcraft_geom::shapes::rectangle(b));
|
||||
square && (b.width() - side).abs() < 1e-6 && (b.height() - side).abs() < 1e-6
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -6773,7 +6784,11 @@ fn designs_too_big_for_a_graph_are_refused_and_drawn_as_squares() {
|
||||
let mut d = (*s.doc().unwrap().doc).clone();
|
||||
let art = super::generate(&mut d, &g);
|
||||
let s0 = art.iter().find(|n| n.extras().series_index == Some(0)).unwrap();
|
||||
assert!(s0.children().unwrap().iter().all(|n| matches!(n.kind, NodeKind::Path { .. })));
|
||||
let marks = s0.children().unwrap();
|
||||
assert!(marks.iter().all(|n| matches!(n.kind, NodeKind::Path { .. })));
|
||||
assert_eq!(marks.iter().filter(|n| sized(n, 5.0)).count(), 200, "a default square at each of the 200 points");
|
||||
let line = marks.iter().filter(|n| n.geometric_bounds().is_some_and(|b| b.width() > 100.0)).count();
|
||||
assert_eq!(line, 1, "the series line is drawn as well");
|
||||
// Too many objects for one design.
|
||||
let ids: Vec<u64> = (0..2001)
|
||||
.map(|i| s.execute("shape.rectangle", &json!({"x": i % 40, "y": i / 40, "width": 1, "height": 1})).unwrap()["id"].as_u64().unwrap())
|
||||
@@ -7157,7 +7172,16 @@ fn graph_column_params_are_checked_and_designs_too_big_are_drawn_plain() {
|
||||
let mut d = (*s.doc().unwrap().doc).clone();
|
||||
let art = super::generate(&mut d, &g);
|
||||
let s0 = art.iter().find(|n| n.extras().series_index == Some(0)).unwrap();
|
||||
assert!(s0.children().unwrap().iter().all(|n| matches!(n.kind, NodeKind::Path { .. })));
|
||||
let marks = s0.children().unwrap();
|
||||
assert!(marks.iter().all(|n| matches!(n.kind, NodeKind::Path { .. })));
|
||||
assert_eq!(marks.iter().filter(|n| sized(n, 8.0)).count(), 1, "a default square as the legend swatch");
|
||||
let columns: Vec<_> = marks.iter().filter(|n| !sized(n, 8.0)).collect();
|
||||
assert_eq!(columns.len(), 1, "one plain column for the one value");
|
||||
let bounds = columns[0].geometric_bounds();
|
||||
let height = bounds.map(|b| b.height());
|
||||
assert!(height.is_some_and(|h| (h - 140.0).abs() < 1e-6), "the column has the value's height: {height:?}");
|
||||
let rectangle = bounds.map(vectorcraft_geom::shapes::rectangle);
|
||||
assert!(matches!(&columns[0].kind, NodeKind::Path { path, .. } if Some(path) == rectangle.as_ref()), "the plain column is a rectangle");
|
||||
// Columns of 0 on a value axis from 10,000 to 10,001 run 2,000,000 points from the clamped zero line: a copy each
|
||||
// 0.1 is past the budget too.
|
||||
let far = one_series(&mut s, "column", &[0.0, 0.0]);
|
||||
@@ -7840,7 +7864,9 @@ fn the_legend_across_top_keeps_above_labels_over_the_plot() {
|
||||
let n = s.doc().unwrap().doc.node(col).unwrap().clone();
|
||||
let texts: Vec<_> = group(&n, "Legend").children().unwrap().iter().filter_map(|c| c.geometric_bounds()).collect();
|
||||
let last_row = texts.iter().map(|b| b.y0).fold(f64::MIN, f64::max);
|
||||
assert!(texts.iter().filter(|b| b.y0 < last_row - 1e-6).all(|b| b.x1 <= 400.0 + 1e-6), "{texts:?}");
|
||||
let above: Vec<_> = texts.iter().filter(|b| b.y0 < last_row - 1e-6).collect();
|
||||
assert!(!above.is_empty(), "the legend takes more than one row: {texts:?}");
|
||||
assert!(above.iter().all(|b| b.x1 <= 400.0 + 1e-6), "{texts:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -8024,6 +8050,7 @@ fn formatting_the_whole_graphs_text_survives_it_being_drawn_again() {
|
||||
s.execute("select.set", &json!({"ids": [id.0]})).unwrap();
|
||||
s.execute("text.setStyle", &json!({"size": 12})).unwrap();
|
||||
let looks = label_looks(&mut s, id);
|
||||
assert!(!looks.is_empty());
|
||||
assert!(looks.iter().all(|(_, size, _)| (*size - 12.0).abs() < 1e-6), "{looks:?}");
|
||||
let g = spec(&s, id);
|
||||
assert!(g.label_styles.values.is_some() && g.label_styles.categories.is_some() && g.label_styles.legend.is_some());
|
||||
@@ -9145,10 +9172,13 @@ fn line_look(n: &vectorcraft_doc::Node) -> (String, f64, f32) {
|
||||
(stroke, n.appearance.stroke_width(), n.opacity)
|
||||
}
|
||||
|
||||
/// The looks of graph `id`'s lines after it is drawn again.
|
||||
/// The looks of graph `id`'s lines after it is drawn again: more than three (a radar graph's
|
||||
/// three spokes come first, then its rings).
|
||||
fn redrawn_line_looks(s: &mut Session, id: NodeId) -> Vec<(String, f64, f32)> {
|
||||
s.execute("graph.setData", &json!({"id": id.0, "csv": ",2024,2025\nQ1,3,2\nQ2,5,4\nQ3,-1,6"})).unwrap();
|
||||
line_nodes(s, id).iter().map(line_look).collect()
|
||||
let looks: Vec<_> = line_nodes(s, id).iter().map(line_look).collect();
|
||||
assert!(looks.len() > 3, "the graph is drawn with its lines: {looks:?}");
|
||||
looks
|
||||
}
|
||||
|
||||
/// A stroke, a weight, no stroke or an opacity given to one axis line is kept for every axis line and tick mark when the
|
||||
|
||||
@@ -388,6 +388,7 @@ const EXCLUSIVE_KEYS: &[(&str, &str, &str)] = &[
|
||||
("addon.pathtools.cornerSet", "items", "ids"),
|
||||
("addon.pathtools.cornerRemove", "items", "ids"),
|
||||
("addon.pathtools.bridge", "radius", "gap"),
|
||||
("addon.pathtools.commonTangents", "radius", "gap"),
|
||||
("links.unembed", "id", "ids"),
|
||||
("links.unembed", "path", "folder"),
|
||||
];
|
||||
@@ -956,11 +957,10 @@ fn option_trees() -> Value {
|
||||
let mut trees = pdf_option_tree();
|
||||
if let Some(tree) = trees.as_object_mut() {
|
||||
tree.insert("flattener".into(), serde_json::to_value(super::flatten::FlattenOptions::default()).unwrap_or_default());
|
||||
let mut svg = serde_json::to_value(vectorcraft_svg::ExportOptions::default()).unwrap_or_default();
|
||||
if let Some(svg) = svg.as_object_mut() {
|
||||
svg.extend(super::fileio::ARTBOARD_PARAMS.iter().chain(&["useArtboards"]).map(|k| (k.to_string(), Value::Null)));
|
||||
}
|
||||
tree.insert("svg".into(), svg);
|
||||
// Serialized defaults omit optional overrides such as units; the registry lists every key.
|
||||
let svg = super::fileio::FORMATS.iter().find(|f| f.id == "svg").into_iter().flat_map(|f| f.options);
|
||||
let svg = svg.filter(|o| o.name != "svg").map(|o| (o.name.to_string(), Value::Null)).collect();
|
||||
tree.insert("svg".into(), Value::Object(svg));
|
||||
}
|
||||
trees
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Divide",
|
||||
["Window", "Pathfinder"],
|
||||
None,
|
||||
"{ids?: [id…] (selected first; default: the selection), precision?: pt 0.001..10, removeRedundantPoints?: bool, removeUnpainted?: bool (default: the Pathfinder Options, see object.pathfinder.options; the values used join the journal entry)} operate on the selected objects (back → front) → {ids}",
|
||||
"{ids?: [id…] (selected first; default: the selection), precision?: pt 0.001..10, removeRedundantPoints?: bool, removeUnpainted?: bool (default: the Pathfinder Options, see object.pathfinder.options; the values used join the journal entry)} operate on the selected objects (back → front). When open paths are among them, the command stops with an error and leaves the art unchanged if the paths are too many or too complex to map. This happens when the paths it maps, as it prepares them from the selection, have more than 65,536 segments, have more than 131,072 pieces once cut where they meet, or exceed the sweep's work budget, which counts pairs of segments with overlapping bounds. → {ids}",
|
||||
has_selection,
|
||||
|s, p| run_pf(s, p, PathfinderOp::Divide)
|
||||
),
|
||||
@@ -823,7 +823,8 @@ fn run_pf(s: &mut Session, p: &Value, op: PathfinderOp) -> Result<Value> {
|
||||
if shapes.iter().any(|s| s.path.subpaths.iter().any(|sp| sp.anchors.iter().any(|a| !(a.p.x.is_finite() && a.p.y.is_finite())))) {
|
||||
return Err(EngineError::Other("paths contain invalid coordinates".into()));
|
||||
}
|
||||
let mut results = po::pathfinder_with(op, &shapes, options.precision);
|
||||
let mut results = po::try_pathfinder_with(op, &shapes, options.precision)
|
||||
.map_err(|e| EngineError::Other(format!("{label}: {e} to cut with the open paths; select fewer paths")))?;
|
||||
if options.remove_unpainted && matches!(op, PathfinderOp::Divide | PathfinderOp::Outline) {
|
||||
// Pathfinder Options › Divide and Outline Will Remove Unpainted Artwork: the pieces
|
||||
// of objects with no fill (or only hidden ones) go.
|
||||
@@ -1562,6 +1563,12 @@ pub fn auto_simplify_level(s: &Session) -> Result<f64> {
|
||||
fn simplify(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
const C: &str = "object.path.simplify";
|
||||
let (auto, given_level, given_tolerance) = (switch_or(p, "auto", false, C)?, number_given(p, "level", C)?, length_given(p, "tolerance", C)?);
|
||||
if given_tolerance.is_some_and(|t| t < 0.0) {
|
||||
return Err(bad(C, "`tolerance` must be 0 or more"));
|
||||
}
|
||||
if given_level.is_some_and(|l| !(0.0..=100.0).contains(&l)) {
|
||||
return Err(bad(C, "`level` must be from 0 to 100"));
|
||||
}
|
||||
let corner_angle = number_given(p, "cornerAngle", C)?.unwrap_or(30.0).clamp(0.0, 180.0);
|
||||
let (straight_lines, whole) = (switch_or(p, "straightLines", false, C)?, switch_or(p, "wholePaths", false, C)?);
|
||||
// With auto, the slider's level is Auto-Simplify's for the selection's size; otherwise it is the level given.
|
||||
|
||||
@@ -758,12 +758,13 @@ pub(super) const ALLOWED: &[&str] = &[
|
||||
|
||||
/// Commands a plug-in may not call although no rule refuses them, in order: they change the
|
||||
/// preferences, a tool's options, a drag's state or the font names the whole app knows, list the
|
||||
/// fonts installed on the system as `text.fontList` does, run plug-ins again, or read a file and
|
||||
/// report where it is on disk.
|
||||
/// fonts installed on the system as `text.fontList` does, run plug-ins again, read a file and
|
||||
/// report where it is on disk, or edit text once per match with no limit on the matches in one call.
|
||||
pub(super) const DENIED: &[&str] = &[
|
||||
"addon.cleanup.splitText",
|
||||
"addon.pathtools.movePointsTogether",
|
||||
"addon.pen.nextSegment",
|
||||
"addon.type.numbers",
|
||||
"color.contrast",
|
||||
"effect.refreshDeferred",
|
||||
"graphicStyle.setOptions",
|
||||
|
||||
@@ -1753,6 +1753,29 @@ fn candidates(indexes: &[&RetypeIndex], path: &BezPath, part: bool, near: bool,
|
||||
if exact.is_empty() && near { indexes.iter().flat_map(|ix| painted(ix, ix.near_matches(path, tolerance), tolerance)).collect() } else { exact }
|
||||
}
|
||||
|
||||
/// Joins whole shape `pc`, whose matches `ms` are near ones in faces other than `l`'s alone, to line
|
||||
/// `l` by its near matches among the glyphs of `l`'s face in `indexes`: the 256 glyphs closest to a
|
||||
/// shape in proportion can all be glyphs of other faces drawn alike (a period, a dot). Those
|
||||
/// matches when the shape joins, `None` when it does not (`l` unchanged).
|
||||
fn join_in_line_face(l: &mut Line, pc: &Piece, ms: &[GlyphMatch], indexes: &[RetypeIndex], tolerance: f64) -> Option<Vec<GlyphMatch>> {
|
||||
let face = l.face.id();
|
||||
if ms.iter().any(|m| m.exact || m.face.id() == face) {
|
||||
return None;
|
||||
}
|
||||
let fill = pc.filled.then_some(pc.nonzero);
|
||||
let own: Vec<GlyphMatch> = indexes
|
||||
.iter()
|
||||
.flat_map(|ix| {
|
||||
let found = ix.near_matches_in(&pc.path, tolerance, face);
|
||||
match fill {
|
||||
Some(nonzero) => found.iter().filter_map(|m| ix.painted_agrees(m, &pc.path, nonzero, tolerance)).collect(),
|
||||
None => found,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
join(l, pc, &own).then_some(own)
|
||||
}
|
||||
|
||||
/// The parts of the shape `path` ([`parts`]: the whole shape, or the glyphs of its contour
|
||||
/// `groups`), each with its [`candidates`] in `indexes`; empty when it matches nothing. `fill` is
|
||||
/// as [`candidates`] takes it, and `once` is set when the shape paints its overlaps once, as
|
||||
@@ -1886,14 +1909,17 @@ fn retype(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
extra.push(f);
|
||||
}
|
||||
}
|
||||
if !extra.is_empty() {
|
||||
let indexes: Vec<RetypeIndex> = if extra.is_empty() {
|
||||
vec![index]
|
||||
} else {
|
||||
// Near matching spends an index's comparison budget, so with a tolerance the
|
||||
// candidates are indexed again for this pass.
|
||||
let first = if tolerance > 0.0 { build(cands) } else { index };
|
||||
let others: Vec<RetypeIndex> = extra.chunks(vectorcraft_text::retype::MAX_FACES).map(|g| build(g.to_vec())).collect();
|
||||
let all: Vec<&RetypeIndex> = std::iter::once(&first).chain(&others).collect();
|
||||
found = match_pieces(&pieces, &groups, &all, tolerance);
|
||||
}
|
||||
let mut all = vec![first];
|
||||
all.extend(extra.chunks(vectorcraft_text::retype::MAX_FACES).map(|g| build(g.to_vec())));
|
||||
found = match_pieces(&pieces, &groups, &all.iter().collect::<Vec<_>>(), tolerance);
|
||||
all
|
||||
};
|
||||
// The face most shapes match, so a glyph several fonts share is set in the same font as
|
||||
// the glyphs around it. Among faces that as many shapes match, the one whose glyphs fit
|
||||
// them closest in all (the least leftover distance summed over those shapes), so every
|
||||
@@ -1949,11 +1975,19 @@ fn retype(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
for ms in parts {
|
||||
// The part's candidates in the face most shapes fit (see `ranked`).
|
||||
let face = ms.iter().enumerate().max_by(ranked).map(|(_, m)| m.face.id());
|
||||
let cands: Vec<GlyphMatch> = ms.iter().filter(|m| Some(m.face.id()) == face).cloned().collect();
|
||||
let joined = match lines.last_mut() {
|
||||
let mut cands: Vec<GlyphMatch> = ms.iter().filter(|m| Some(m.face.id()) == face).cloned().collect();
|
||||
let mut joined = match lines.last_mut() {
|
||||
Some(l) if open => join(l, pc, &cands),
|
||||
_ => false,
|
||||
};
|
||||
if !joined
|
||||
&& open
|
||||
&& parts.len() == 1
|
||||
&& let Some(own) = lines.last_mut().and_then(|l| join_in_line_face(l, pc, ms, &indexes, tolerance))
|
||||
{
|
||||
joined = true;
|
||||
cands = own;
|
||||
}
|
||||
// A part that joined a line, perhaps as a mark, that is also another character, in
|
||||
// that face or else in the face most shapes fit of those it is a character in: the
|
||||
// character, should a split leave the part first on a line ([`verified`]). Kept by
|
||||
|
||||
@@ -149,6 +149,10 @@ fn of_two_versions_only_the_one_the_name_gives_is_listed() {
|
||||
db.add_font(named_copy(true, (FAMILY, "Regular", "Version 2.000", "VersiontestSans-Regular")).unwrap());
|
||||
assert_eq!(db.face(FAMILY, "Regular").unwrap().version, "Version 1.000");
|
||||
let mut s = session();
|
||||
// Live type in the family puts the font among those compared first. Added last, after the
|
||||
// bundled fonts and however many faces craft-fonts supplies, it can fall past the fonts
|
||||
// Retype compares (`MAX_FACES`).
|
||||
s.execute("text.create", &json!({"x": 40, "y": 300, "text": "live", "size": 40, "font": FAMILY, "style": "Regular"})).unwrap();
|
||||
let inter = outlined(&mut s, json!({"x": 40, "y": 100, "text": "Kg", "size": 40, "font": "Inter", "style": "Regular"}));
|
||||
s.execute("select.set", &json!({"ids": [inter]})).unwrap();
|
||||
let r = query(&mut s, json!({"count": 96}), &db);
|
||||
|
||||
@@ -102,10 +102,12 @@ fn a_mark_in_one_font_starts_its_line_as_another_fonts_character() {
|
||||
use vectorcraft_text::test_fonts::{SPACING_COMMA_FAMILY, spacing_comma_font};
|
||||
// The comma below of Source Sans 3 is only marks there, and a modifier letter in this face.
|
||||
vectorcraft_text::FontDb::global().add_font(spacing_comma_font().unwrap());
|
||||
// Named, so it is among the fonts compared first, however many faces are loaded before it.
|
||||
let fonts = json!([SPACING_COMMA_FAMILY]);
|
||||
let mut s = session();
|
||||
let g = outlined(&mut s, json!({"x": 40, "y": 100, "text": "\u{326}", "size": 40, "font": "Source Sans 3", "style": "Regular"}));
|
||||
s.execute("select.set", &json!({"ids": [g]})).unwrap();
|
||||
let r = s.execute("type.retype", &json!({})).unwrap();
|
||||
let r = s.execute("type.retype", &json!({"fonts": fonts})).unwrap();
|
||||
assert_eq!(r["texts"], json!(["\u{2bb}"]), "{r}");
|
||||
assert_eq!(r["fonts"][0]["family"], json!(SPACING_COMMA_FAMILY), "{r}");
|
||||
// After a base, it joins the line as the mark; moved off its base, the split leaves it first,
|
||||
@@ -115,7 +117,7 @@ fn a_mark_in_one_font_starts_its_line_as_another_fonts_character() {
|
||||
s.execute("select.set", &json!({"ids": [mark]})).unwrap();
|
||||
s.execute("object.move", &json!({"dx": 3, "dy": 0})).unwrap();
|
||||
s.execute("select.set", &json!({"ids": [g]})).unwrap();
|
||||
let r = s.execute("type.retype", &json!({})).unwrap();
|
||||
let r = s.execute("type.retype", &json!({"fonts": fonts})).unwrap();
|
||||
assert_eq!((&r["texts"], &r["unmatched"]), (&json!(["x", "\u{2bb}", "yz"]), &json!([])), "{r}");
|
||||
assert_eq!(r["fonts"][1]["family"], json!(SPACING_COMMA_FAMILY), "{r}");
|
||||
}
|
||||
@@ -1099,7 +1101,9 @@ fn lines_that_do_not_stack_as_a_paragraph_stay_apart() {
|
||||
s.execute("select.set", &json!({"ids": [a]})).unwrap();
|
||||
let r = s.execute("type.retype", &json!({})).unwrap();
|
||||
assert_eq!(r["texts"], json!(["Top", "Far", "Askew"]), "{r}");
|
||||
assert!(r["fonts"].as_array().unwrap().iter().all(|f| f["area"] == json!(false)), "{r}");
|
||||
let fonts = r["fonts"].as_array().unwrap();
|
||||
assert!(!fonts.is_empty(), "{r}");
|
||||
assert!(fonts.iter().all(|f| f["area"] == json!(false)), "{r}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1918,19 +1922,28 @@ fn lines_in(s: &Session, g: u64) -> Vec<super::Line> {
|
||||
lines_in_family(s, g, None)
|
||||
}
|
||||
|
||||
/// [`lines_in`] with the face of the first glyph's match in `family` when given.
|
||||
/// [`lines_in`] with the face of the first glyph's match in `family` when given. The family is
|
||||
/// compared first, as `type.retype`'s `fonts` puts it, so the faces loaded before it cannot leave it
|
||||
/// out of the fonts Retype compares.
|
||||
fn lines_in_family(s: &Session, g: u64, family: Option<&str>) -> Vec<super::Line> {
|
||||
let d = &s.doc().unwrap().doc;
|
||||
let (mut barrier, mut truncated, mut pieces) = (true, false, vec![]);
|
||||
super::collect(d.node(NodeId(g)).unwrap(), d.parent_of(NodeId(g)), 0, &mut barrier, &mut truncated, &mut pieces);
|
||||
let db = vectorcraft_text::FontDb::global();
|
||||
let wanted = pieces.iter().filter_map(|pc| vectorcraft_text::retype::shape_key(&pc.path)).collect();
|
||||
let index = super::RetypeIndex::build(db, super::candidate_faces(db, d, &[]), &wanted);
|
||||
let first = index.matches(&pieces[0].path);
|
||||
let face = first.iter().find(|m| family.is_none_or(|f| m.face.family == f)).unwrap_or(&first[0]).face.id();
|
||||
let fonts: Vec<String> = family.into_iter().map(str::to_string).collect();
|
||||
let index = super::RetypeIndex::build(db, super::candidate_faces(db, d, &fonts), &wanted);
|
||||
// Every match, as Retype reads them: the first MAX_CANDIDATES can all be faces drawn alike.
|
||||
let first = index.all_matches(&pieces[0].path);
|
||||
let face = match family {
|
||||
Some(f) => first.iter().find(|m| m.face.family == f).unwrap_or_else(|| panic!("the first glyph matches no glyph of {f}")),
|
||||
None => &first[0],
|
||||
}
|
||||
.face
|
||||
.id();
|
||||
let mut lines: Vec<super::Line> = vec![];
|
||||
for pc in &pieces {
|
||||
let cands: Vec<_> = index.matches(&pc.path).into_iter().filter(|m| m.face.id() == face).collect();
|
||||
let cands: Vec<_> = index.all_matches(&pc.path).into_iter().filter(|m| m.face.id() == face).collect();
|
||||
if !lines.last_mut().is_some_and(|l| super::join(l, pc, &cands)) {
|
||||
lines.extend(super::new_line(pc, &cands, 0.0));
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Run Script",
|
||||
[],
|
||||
None,
|
||||
"{path?: a script file (.js, .mjs or .jsx) | source?: the script's text (exactly one of the two), installed?: true or false (default false; true with a path that script.listInstalled gave: the file is read once, checked as File › Scripts checks it, and that text runs, its #include lines and $.evalFile reading in the folder that read found; a file that is no longer a listed script ends with \"the script is no longer in the Scripts folder\" and nothing runs), module?: true or false (default true for a path ending in .mjs, false otherwise; true runs the file or source as a .mjs file runs, as a module, and a source run this way imports no files), name?: the name errors and the report use (default: the script's #script line, else the path's file name, or \"script\"), args?: {…} (at most 1 MiB as JSON; vc.args in the script), answers?: [{kind: alert|confirm|prompt|window, value: \"ok\" (alert) | true or false (confirm) | text or null (prompt) | [{control, event: click} | {control, event: change, value: text, number, item index or null} | {event: close}] (window: the steps of one show(), control being a control's name, or the text of a control without a name)}] (for a run with nobody to ask: the answers to its dialogs, in order; at most 10000 and 1 MiB as JSON; refused in the app, where the person answers; an empty object is an empty list), actions?: [{set, name, steps: [{command, params?, step?: the step's place in the action, a whole number from 1 (default its place in the list)}]}] (the actions app.doScript(action, set, dialogs?) plays, matched by their exact names; a command.batch step gives its own steps; at most 4096 actions, 10000 steps an action, 100000 steps in all and 16 MiB as JSON; in the app, the Actions panel's actions with their included steps, which a caller's list replaces), maxFuel?: whole number from 1 to 100000000000 (instructions in all; default 1000000000)} run a JavaScript file against the open documents, through the vc object: vc.run(id, params) runs a command and returns its result, a failed command throws an error the script can catch and puts back the documents and the session state it changed, while any file it wrote stays written and is named; vc.document is a snapshot of the active document or null; vc.commands lists the commands a script may run; vc.log(value) adds to the report and the Script Console (script.console); $.write(...values) writes the values to the Script Console as String(value) gives them, and $.writeln(...values) does the same and ends the line; $.evalFile(path, timeout?) runs a file with the same globals and returns its last value (timeout, in milliseconds from 0, is taken and not waited on), $.fileName is the file of the code that reads it (the file being run for code that eval or Function compiled; empty for code compiled from a script given as text), $.includePath the #includepath list and $.engineName the engine's name (VectorCraft without #targetengine); alert(message[, title, errorIcon]), confirm(message[, noAsDflt, title]) and prompt(message, preset[, title]) open a dialog with a Stop button (default title \"Script Alert\"; message and preset as String(value) gives them; errorIcon and noAsDflt as Boolean(value) gives them; No is the default with noAsDflt): alert returns undefined, confirm true for Yes and false for No, prompt the field's text for OK and null for Cancel; in the app the run waits at the call for the person's answer and Stop ends it as script.stop does, a dialog cannot open inside a callback of a built-in, a getter, a conversion or a file $.evalFile runs and throws there (an #include file's code is the script's own and can), and a run with nobody to ask takes the next of answers, and ends when none is left or the next is for another kind of dialog, or when the script ends with answers unused; new Window(\"dialog\", title) builds a ScriptUI dialog with add(type, bounds, text or items or value, properties) for group, panel, statictext, edittext, button, checkbox, radiobutton, dropdownlist, listbox (one selection), slider and progressbar (a group takes properties third, or fourth after a third that is not an object, and a list may take them there with properties.items), at most 512 controls 16 deep, 1024 list items and 16 KiB a text (other types, palettes and windows throw that they are not available yet); new Window and add also take a resource string such as \"dialog { g: Group { b: Button { text: 'OK' } } }\" in place of the type, which adds each control it lists through add and sets it and each other value as the property of its name (properties gives the creation properties and a list's items its item texts; at most 1 MiB nested 64 deep, and a malformed one throws a SyntaxError); preferredSize, size, minimumSize and maximumSize start with width and height -1 (left to the layout), lists have find and remove, containers remove, radio buttons added one after another turn each other off, notify runs a click's or a change's handler
Line truncated
|
||||
"{path?: a script file (.js, .mjs or .jsx) | source?: the script's text (exactly one of the two), installed?: true or false (default false; true with a path that script.listInstalled gave: the file is read once, checked as File › Scripts checks it, and that text runs, its #include lines and $.evalFile reading in the folder that read found; a file that is no longer a listed script ends with \"the script is no longer in the Scripts folder\" and nothing runs), module?: true or false (default true for a path ending in .mjs, false otherwise; true runs the file or source as a .mjs file runs, as a module, and a source run this way imports no files), name?: the name errors and the report use (default: the script's #script line, else the path's file name, or \"script\"), args?: {…} (at most 1 MiB as JSON; vc.args in the script), answers?: [{kind: alert|confirm|prompt|window, value: \"ok\" (alert) | true or false (confirm) | text or null (prompt) | [{control, event: click} | {control, event: change, value: text, number, item index or null} | {event: close}] (window: the steps of one show(), control being a control's name, or the text of a control without a name)}] (for a run with nobody to ask: the answers to its dialogs, in order; at most 10000 and 1 MiB as JSON; refused in the app, where the person answers; an empty object is an empty list), actions?: [{set, name, steps: [{command, params?, step?: the step's place in the action, a whole number from 1 (default its place in the list)}]}] (the actions app.doScript(action, set, dialogs?) plays, matched by their exact names; a command.batch step gives its own steps; at most 4096 actions, 10000 steps an action, 100000 steps in all and 16 MiB as JSON; in the app, the Actions panel's actions with their included steps, which a caller's list replaces), maxFuel?: whole number from 1 to 100000000000 (instructions in all; default 1000000000)} run a JavaScript file against the open documents, through the vc object: vc.run(id, params) runs a command and returns its result, a failed command throws an error the script can catch and puts back the documents and the session state it changed, while any file it wrote stays written and is named; vc.document is a snapshot of the active document or null; vc.commands lists the commands a script may run; vc.log(value) adds to the report and the Script Console (script.console); $.write(...values) writes the values to the Script Console as String(value) gives them, and $.writeln(...values) does the same and ends the line; $.evalFile(path, timeout?) runs a file with the same globals and returns its last value (timeout, in milliseconds from 0, is taken and not waited on), an absolute path in a File's URI notation is read too, with escapes decoded and /c/... naming drive C: on Windows, $.fileName is the file of the code that reads it (the file being run for code that eval or Function compiled; empty for code compiled from a script given as text), $.includePath the #includepath list and $.engineName the engine's name (VectorCraft without #targetengine); alert(message[, title, errorIcon]), confirm(message[, noAsDflt, title]) and prompt(message, preset[, title]) open a dialog with a Stop button (default title \"Script Alert\"; message and preset as String(value) gives them; errorIcon and noAsDflt as Boolean(value) gives them; No is the default with noAsDflt): alert returns undefined, confirm true for Yes and false for No, prompt the field's text for OK and null for Cancel; in the app the run waits at the call for the person's answer and Stop ends it as script.stop does, a dialog cannot open inside a callback of a built-in, a getter, a conversion or a file $.evalFile runs and throws there (an #include file's code is the script's own and can), and a run with nobody to ask takes the next of answers, and ends when none is left or the next is for another kind of dialog, or when the script ends with answers unused; new Window(\"dialog\", title) builds a ScriptUI dialog with add(type, bounds, text or items or value, properties) for group, panel, statictext, edittext, button, checkbox, radiobutton, dropdownlist, listbox (one selection), slider and progressbar (a group takes properties third, or fourth after a third that is not an object, and a list may take them there with properties.items), at most 512 controls 16 deep, 1024 list items and 16 KiB a text (other types, palettes and windows throw that they are not available yet); new Window and add also take a resource string such as \"dialog { g: Group { b: Button { text: 'OK' } } }\" in place of the type, which adds each control it lists through add and sets it and each other value as the property of its name (properties gives the creation properties and a list's items its item texts; at most 1 MiB nested 64 deep, and a malformed one throws a SyntaxError); preferredSize, size, minimumSize and maximumSize start with width and height -1 (left to the layout), lists have find and remove, contai
Line truncated
|
||||
always,
|
||||
run
|
||||
),
|
||||
|
||||
@@ -12,6 +12,8 @@ use vectorcraft_doc::{Node, Scaling};
|
||||
|
||||
const CMD: &str = "object.stepAndRepeat";
|
||||
const MAX_CELLS: usize = 10_000;
|
||||
/// The most objects the copies may hold in all, counting every object inside each copy.
|
||||
const MAX_COPIED_OBJECTS: usize = 250_000;
|
||||
const EPS: f64 = 1e-9;
|
||||
|
||||
pub fn specs() -> Vec<CommandSpec> {
|
||||
@@ -20,7 +22,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Step and Repeat…",
|
||||
["Object", "Transform"],
|
||||
None,
|
||||
"{rows?: n (default 1), columns?: n (default 1), fill?: bool (rows and columns are as many as fit the sheet, ignoring `rows` and `columns`; the first copy goes to the sheet's top-left corner plus `margin`), sheet?: {x, y, width, height} (pt; default the artboard that holds the selection's center, else the first), margin?: pt (fill only, default 0, not negative), gap?: pt (between neighbors, both axes), gapX?: pt, gapY?: pt (default `gap`, default 0; measured between the bounds of `cutId`, else of the selection, not between centers; a negative gap overlaps neighbors and must be smaller than the width or height it is between), cutId?: id (a selected object whose geometric bounds measure the spacing and the 180° turn; default the selection), rotate?: \"none\"|\"columns\"|\"rows\" (turn every other column or row by 180° about its cell's center, the same clockwise or counter-clockwise; default none), patterns?: bool} copy the selection into a grid of cells, left to right and top to bottom, the first cell being the selection itself (moved to the sheet's corner with fill); copies of pixel-aligned objects stay on the pixel grid, so a fractional gap between them is rounded to it, and gaps of other objects are exact; a selection of several objects is grouped first, so that a cut contour stays with its artwork in every copy; one undo step; the copies are selected → {ids: [id…], rows, columns, count}",
|
||||
"{rows?: n (default 1), columns?: n (default 1), fill?: bool (rows and columns are as many as fit the sheet, ignoring `rows` and `columns`; the first copy goes to the sheet's top-left corner plus `margin`), sheet?: {x, y, width, height} (pt; default the artboard that holds the selection's center, else the first), margin?: pt (fill only, default 0, not negative), gap?: pt (between neighbors, both axes), gapX?: pt, gapY?: pt (default `gap`, default 0; measured between the bounds of `cutId`, else of the selection, not between centers; a negative gap overlaps neighbors and must be smaller than the width or height it is between), cutId?: id (a selected object whose geometric bounds measure the spacing and the 180° turn; default the selection), rotate?: \"none\"|\"columns\"|\"rows\" (turn every other column or row by 180° about its cell's center, the same clockwise or counter-clockwise; default none), patterns?: bool} copy the selection into a grid of cells, left to right and top to bottom, the first cell being the selection itself (moved to the sheet's corner with fill); copies of pixel-aligned objects stay on the pixel grid, so a fractional gap between them is rounded to it, and gaps of other objects are exact; a selection of several objects is grouped first, so that a cut contour stays with its artwork in every copy; a grid of more than 10,000 cells, or one whose new copies (every cell but the first) would hold more than 250,000 objects in all (the art of opacity masks and the group of a multi-object selection counted), is refused; one undo step; the copies are selected → {ids: [id…], rows, columns, count}",
|
||||
has_selection,
|
||||
step_and_repeat
|
||||
)]
|
||||
@@ -174,6 +176,12 @@ fn step_and_repeat(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if rows.saturating_mul(cols) > MAX_CELLS {
|
||||
return Err(bad(CMD, format!("more than {MAX_CELLS} copies")));
|
||||
}
|
||||
// Each copy holds every object of the selection, the art of opacity masks included, and the
|
||||
// group that a selection of several objects goes into.
|
||||
let objects = roots.iter().filter_map(|r| d.node(*r)).fold(usize::from(roots.len() > 1), |sum, n| sum.saturating_add(n.count_with_masks()));
|
||||
if objects.saturating_mul(rows * cols - 1) > MAX_COPIED_OBJECTS {
|
||||
return Err(bad(CMD, format!("the copies would hold more than {MAX_COPIED_OBJECTS} objects")));
|
||||
}
|
||||
let origin = anchor.map_or(Vec2::ZERO, |(sh, m)| Vec2::new(sh.x0 + m - b.x0, sh.y0 + m - b.y0));
|
||||
let cells = layout(w, h, gx, gy, rows, cols, alt);
|
||||
let center = b.center().to_vec2();
|
||||
|
||||
@@ -131,6 +131,21 @@ fn rejects_bad_params_and_a_selection_that_does_not_fit() {
|
||||
assert!(e.execute(CMD, &json!({})).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_a_grid_whose_copies_would_hold_too_many_objects() {
|
||||
let (mut s, _) = setup();
|
||||
for i in 1..25 {
|
||||
s.execute("shape.rectangle", &json!({"x": i, "y": 0, "width": 10, "height": 10})).unwrap();
|
||||
}
|
||||
s.execute("select.all", &json!({})).unwrap();
|
||||
let (count, steps) = (s.doc().unwrap().doc.node_count(), undo_steps(&s));
|
||||
// 25 objects and the group they go into, in each of 9,999 copies, are more than the limit,
|
||||
// though the cells are not.
|
||||
let e = s.execute(CMD, &json!({"rows": 100, "columns": 100})).unwrap_err();
|
||||
assert!(e.to_string().contains("objects"), "{e}");
|
||||
assert_eq!((s.doc().unwrap().doc.node_count(), undo_steps(&s)), (count, steps));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_a_negative_margin_and_gaps_that_fold_the_grid_back() {
|
||||
let (mut s, _) = setup();
|
||||
|
||||
@@ -115,7 +115,7 @@ fn make(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
let mut out = json!({ "ids": objects.iter().map(|i| i.0).collect::<Vec<_>>() });
|
||||
let mut wraps = false;
|
||||
vectorcraft_doc::text::wrap_sources(&s.doc()?.doc, |_, sources, _| wraps |= sources.iter().any(|n| objects.contains(&n.id)));
|
||||
vectorcraft_doc::text::wrap_source_objects(&s.doc()?.doc, |_, sources| wraps |= sources.iter().any(|n| objects.contains(&n.id)));
|
||||
if !wraps {
|
||||
out["warning"] = json!(NO_AREA_TYPE_BELOW);
|
||||
}
|
||||
|
||||
@@ -1854,9 +1854,12 @@ fn kana_style_and_roman_italics_are_character_features() {
|
||||
}
|
||||
assert_eq!(runs(&s), before);
|
||||
s.execute("text.setRangeStyle", &json!({"id": id, "featureChanges": ["-hkna", "-ital"]})).unwrap();
|
||||
let text = |s: &Session| runs(s).into_iter().map(|(t, _)| t).collect::<String>();
|
||||
assert_eq!(text(&s), "かなAB");
|
||||
assert!(runs(&s).iter().all(|(_, f)| f.is_empty()), "{:?}", runs(&s));
|
||||
s.execute("charStyle.new", &json!({"name": "Kana", "attrs": {"features": ["hkna", "ital"]}})).unwrap();
|
||||
s.execute("charStyle.apply", &json!({"name": "Kana", "id": id})).unwrap();
|
||||
assert_eq!(text(&s), "かなAB");
|
||||
assert!(runs(&s).iter().all(|(_, f)| *f == ["hkna", "ital"]), "{:?}", runs(&s));
|
||||
let e = s.execute("charStyle.new", &json!({"name": "Bad", "attrs": {"features": ["ital=2"]}})).unwrap_err().to_string();
|
||||
assert!(e.contains("unknown OpenType feature `ital=2`"), "{e}");
|
||||
|
||||
@@ -257,6 +257,7 @@ fn gaps_set_word_spacing_and_leading() {
|
||||
// The layout uses the gap as the Desired word spacing; the paragraph keeps its own.
|
||||
assert_eq!(t.para_at(0).justification.word_spacing, [80.0, 100.0, 133.0]);
|
||||
assert_eq!(t.layout_justification(t.para_at(0)).word_spacing, [80.0, 300.0, 300.0]);
|
||||
assert_eq!(t.plain_text(), "two words\nthree more words", "the runs hold the text");
|
||||
assert!(t.runs.iter().all(|r| (r.style.leading.unwrap() - r.style.size - 6.0).abs() < 1e-9), "{:?}", t.runs);
|
||||
assert_block(&t);
|
||||
assert!(size_at(&t, 0) < size_at(&plain, 0), "wider word spaces leave the letters less room");
|
||||
@@ -850,6 +851,7 @@ fn a_range_leading_change_with_block_on_moves_the_line_gap() {
|
||||
let t = text(&s, id);
|
||||
assert!((t.area.line_gap - 5.0).abs() < 1e-9, "line gap {}", t.area.line_gap);
|
||||
assert!(leading_at(&t, 4).is_some_and(|l| (l - second - 5.0).abs() < 1e-9), "{:?}", leading_at(&t, 4));
|
||||
assert_eq!(t.plain_text(), "BIG\na much longer second line\nmid one", "the runs hold the text");
|
||||
assert!(t.runs.iter().all(|r| r.style.leading.is_some_and(|l| (l - r.style.size - 5.0).abs() < 1e-9)), "every line spreads");
|
||||
// Reset Panel's form: the leading is set and Block keeps the line gap.
|
||||
s.execute("text.setRangeStyle", &json!({"id": id, "start": 4, "end": 10, "leading": "auto", "keepLineGap": true})).unwrap();
|
||||
|
||||
@@ -100,16 +100,9 @@ impl AutomationRoots {
|
||||
/// May the file or folder at `path` be read (or written)? It must lie inside one of the roots
|
||||
/// of that kind. `Err` says why not.
|
||||
pub fn check(&self, path: &str, access: Access) -> Result<(), String> {
|
||||
let roots = match access {
|
||||
Access::Read => &self.read,
|
||||
Access::Write => &self.write,
|
||||
};
|
||||
// The messages are spelled out whole, as the translation catalogs match them.
|
||||
let roots = self.of(access);
|
||||
if roots.is_empty() {
|
||||
return match access {
|
||||
Access::Read => Err(format!("automation filesystem access is not granted: read authority is absent: {path}")),
|
||||
Access::Write => Err(format!("automation filesystem access is not granted: write authority is absent: {path}")),
|
||||
};
|
||||
return Err(refused(roots, path, access));
|
||||
}
|
||||
// Resolving a path on another computer connects to it: unless a root is on a network
|
||||
// share, such a path is refused by its name before anything is looked up.
|
||||
@@ -120,12 +113,22 @@ impl AutomationRoots {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
let shown: Vec<String> = roots.iter().map(|r| r.shown.display().to_string()).collect();
|
||||
match (shown.as_slice(), access) {
|
||||
([root], Access::Read) => Err(format!("automation path rejected: outside the read root {root}: {path}")),
|
||||
([root], Access::Write) => Err(format!("automation path rejected: outside the write root {root}: {path}")),
|
||||
(_, Access::Read) => Err(format!("automation path rejected: outside the read roots {roots}: {path}", roots = shown.join(", "))),
|
||||
(_, Access::Write) => Err(format!("automation path rejected: outside the write roots {roots}: {path}", roots = shown.join(", "))),
|
||||
Err(refused(roots, path, access))
|
||||
}
|
||||
|
||||
/// [`AutomationRoots::check`] for `real`, a path whose links have been followed already: it is
|
||||
/// compared with the roots as it is, and not looked up again.
|
||||
#[cfg(unix)]
|
||||
pub(crate) fn check_real(&self, real: &Path, access: Access) -> Result<(), String> {
|
||||
let roots = self.of(access);
|
||||
if roots.iter().any(|r| inside(real, &r.resolved)) { Ok(()) } else { Err(refused(roots, &real.display().to_string(), access)) }
|
||||
}
|
||||
|
||||
/// The roots of the kind `access`.
|
||||
fn of(&self, access: Access) -> &[Root] {
|
||||
match access {
|
||||
Access::Read => &self.read,
|
||||
Access::Write => &self.write,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,6 +160,24 @@ impl AutomationRoots {
|
||||
}
|
||||
}
|
||||
|
||||
/// Why `path` is refused `access` under `roots`, the roots of that kind.
|
||||
fn refused(roots: &[Root], path: &str, access: Access) -> String {
|
||||
// The messages are spelled out whole, as the translation catalogs match them.
|
||||
if roots.is_empty() {
|
||||
return match access {
|
||||
Access::Read => format!("automation filesystem access is not granted: read authority is absent: {path}"),
|
||||
Access::Write => format!("automation filesystem access is not granted: write authority is absent: {path}"),
|
||||
};
|
||||
}
|
||||
let shown: Vec<String> = roots.iter().map(|r| r.shown.display().to_string()).collect();
|
||||
match (shown.as_slice(), access) {
|
||||
([root], Access::Read) => format!("automation path rejected: outside the read root {root}: {path}"),
|
||||
([root], Access::Write) => format!("automation path rejected: outside the write root {root}: {path}"),
|
||||
(_, Access::Read) => format!("automation path rejected: outside the read roots {roots}: {path}", roots = shown.join(", ")),
|
||||
(_, Access::Write) => format!("automation path rejected: outside the write roots {roots}: {path}", roots = shown.join(", ")),
|
||||
}
|
||||
}
|
||||
|
||||
/// Where the roots are in force on a thread ([`confine`], [`unconfined`]).
|
||||
#[derive(Clone, Debug)]
|
||||
enum Scope {
|
||||
@@ -371,18 +392,34 @@ impl ScriptGate {
|
||||
also.check(path, access)?;
|
||||
}
|
||||
let real = if ScriptScope::refused_by_name(Path::new(path)) { None } else { resolve(path).ok() };
|
||||
let allowed = real.is_some_and(|real| {
|
||||
let scoped = match access {
|
||||
Access::Read => self.read.allows(&real) || self.write.allows(&real),
|
||||
Access::Write => self.write.allows(&real),
|
||||
};
|
||||
// A read-only file is not written over, also where a rename could replace it.
|
||||
let read_only = matches!(access, Access::Write) && std::fs::metadata(&real).is_ok_and(|m| m.is_file() && m.permissions().readonly());
|
||||
let held = matches!(access, Access::Write) && self.held.contains(&real);
|
||||
let linked = matches!(access, Access::Read) && self.linked.has(&real) && !self.read.keeps_out(&real);
|
||||
!read_only && !held && (scoped || self.documents.iter().any(|d| resolve(d).is_ok_and(|d| d == real)) || linked)
|
||||
});
|
||||
if allowed { Ok(()) } else { Err(format!("Script file access denied: {path}")) }
|
||||
if real.is_some_and(|real| self.allows_real(&real, access)) { Ok(()) } else { Err(format!("Script file access denied: {path}")) }
|
||||
}
|
||||
|
||||
/// [`ScriptGate::check`] for `real`, a path whose links have been followed already: it is
|
||||
/// compared as it is, and not looked up again.
|
||||
#[cfg(unix)]
|
||||
pub(crate) fn check_real(&self, real: &Path, access: Access) -> Result<(), String> {
|
||||
if let Some(also) = &self.also {
|
||||
also.check_real(real, access)?;
|
||||
}
|
||||
if !ScriptScope::refused_by_name(real) && self.allows_real(real, access) {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(format!("Script file access denied: {}", real.display()))
|
||||
}
|
||||
}
|
||||
|
||||
/// May the place at the real path `real` be read (or written) through this gate alone?
|
||||
fn allows_real(&self, real: &Path, access: Access) -> bool {
|
||||
let scoped = match access {
|
||||
Access::Read => self.read.allows(real) || self.write.allows(real),
|
||||
Access::Write => self.write.allows(real),
|
||||
};
|
||||
// A read-only file is not written over, also where a rename could replace it.
|
||||
let read_only = matches!(access, Access::Write) && std::fs::metadata(real).is_ok_and(|m| m.is_file() && m.permissions().readonly());
|
||||
let held = matches!(access, Access::Write) && self.held.iter().any(|h| h == real);
|
||||
let linked = matches!(access, Access::Read) && self.linked.has(real) && !self.read.keeps_out(real);
|
||||
!read_only && !held && (scoped || self.documents.iter().any(|d| resolve(d).is_ok_and(|d| d == real)) || linked)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,8 +499,7 @@ pub fn is_path_key(key: &str) -> bool {
|
||||
/// May `path` be written here? Always, without roots in force and outside a script's command
|
||||
/// ([`with_script_gate`]).
|
||||
pub fn check_write(path: &str) -> Result<(), String> {
|
||||
current().map_or(Ok(()), |r| r.check(path, Access::Write))?;
|
||||
check_gate(path, Access::Write)?;
|
||||
check_write_unrecorded(path)?;
|
||||
WRITES.with(|w| {
|
||||
if let Some(paths) = w.borrow_mut().as_mut()
|
||||
&& !paths.iter().any(|(p, _)| p == path)
|
||||
@@ -474,6 +510,26 @@ pub fn check_write(path: &str) -> Result<(), String> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// [`check_write`] without recording `path` as written.
|
||||
pub(crate) fn check_write_unrecorded(path: &str) -> Result<(), String> {
|
||||
current().map_or(Ok(()), |r| r.check(path, Access::Write))?;
|
||||
check_gate(path, Access::Write)
|
||||
}
|
||||
|
||||
/// [`check_write_unrecorded`] for `real`, the path of a file in a folder whose links have been
|
||||
/// followed already (the folder a checked write has opened): it is compared as it is, so the folder
|
||||
/// is not looked up again by its path.
|
||||
#[cfg(unix)]
|
||||
pub(crate) fn check_write_real(real: &Path) -> Result<(), String> {
|
||||
current().map_or(Ok(()), |r| r.check_real(real, Access::Write))?;
|
||||
GATE.with(|g| g.borrow().clone()).map_or(Ok(()), |g| g.check_real(real, Access::Write))
|
||||
}
|
||||
|
||||
/// Whether a write here is checked: roots are in force, or a script's command runs.
|
||||
pub(crate) fn writes_checked() -> bool {
|
||||
current().is_some() || in_script_command()
|
||||
}
|
||||
|
||||
/// A file's modification time and length; `None` when there is no file at `path`.
|
||||
type Stamp = Option<(Option<std::time::SystemTime>, u64)>;
|
||||
|
||||
@@ -1200,6 +1256,7 @@ mod tests {
|
||||
fn a_script_gate_does_not_write_over_a_read_only_file() {
|
||||
let (base, _) = folders("gate-read-only");
|
||||
let out = base.join("out/kept.svg");
|
||||
let _cleanup = ReadOnlyFixture { file: out.clone(), folder: base.clone() };
|
||||
std::fs::write(&out, "<svg/>").unwrap();
|
||||
let gate = ScriptGate {
|
||||
read: ScriptScope::default(),
|
||||
@@ -1218,14 +1275,47 @@ mod tests {
|
||||
assert!(document_write(), "an open document's file is written");
|
||||
let mut perms = std::fs::metadata(&out).unwrap().permissions();
|
||||
perms.set_readonly(true);
|
||||
std::fs::set_permissions(&out, perms.clone()).unwrap();
|
||||
std::fs::set_permissions(&out, perms).unwrap();
|
||||
assert_eq!(check(&kept), (false, true), "a read-only file is read but not written");
|
||||
assert!(check(&fresh).0, "a new file next to it is written");
|
||||
assert!(!document_write(), "also when it is an open document's file");
|
||||
#[allow(clippy::permissions_set_readonly_false)]
|
||||
perms.set_readonly(false);
|
||||
std::fs::set_permissions(&out, perms).unwrap();
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
/// Makes `file` writable again and removes `folder` when the test ends, a failed assertion
|
||||
/// included: Windows does not delete a read-only file.
|
||||
struct ReadOnlyFixture {
|
||||
file: PathBuf,
|
||||
folder: PathBuf,
|
||||
}
|
||||
|
||||
impl Drop for ReadOnlyFixture {
|
||||
fn drop(&mut self) {
|
||||
if let Ok(meta) = std::fs::metadata(&self.file) {
|
||||
let mut perms = meta.permissions();
|
||||
#[allow(clippy::permissions_set_readonly_false)]
|
||||
perms.set_readonly(false);
|
||||
let _ = std::fs::set_permissions(&self.file, perms);
|
||||
}
|
||||
let _ = std::fs::remove_dir_all(&self.folder);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_read_only_fixture_is_removed_when_its_test_fails() {
|
||||
let (base, _) = folders("read-only-fixture");
|
||||
let file = base.join("out/locked.svg");
|
||||
std::fs::write(&file, "<svg/>").unwrap();
|
||||
let failed = std::panic::catch_unwind(|| {
|
||||
let _cleanup = ReadOnlyFixture { file: file.clone(), folder: base.clone() };
|
||||
let mut perms = std::fs::metadata(&file).unwrap().permissions();
|
||||
perms.set_readonly(true);
|
||||
std::fs::set_permissions(&file, perms).unwrap();
|
||||
assert!(std::fs::metadata(&file).unwrap().permissions().readonly(), "the fixture is read-only");
|
||||
panic!("a failed assertion");
|
||||
});
|
||||
let payload = failed.err().unwrap_or_else(|| panic!("the closure did not panic"));
|
||||
assert_eq!(payload.downcast_ref::<&str>(), Some(&"a failed assertion"), "the test's own panic, not a setup failure");
|
||||
assert!(!base.exists(), "{} is left", base.display());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1390,6 +1480,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
// test-lint: allow never-run Windows only; CI runs tests on Linux and FreeBSD
|
||||
#[test]
|
||||
fn windows_ignores_case_and_refuses_devices() {
|
||||
let (base, roots) = folders("case");
|
||||
@@ -1471,6 +1562,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
// test-lint: allow never-run Windows only; CI runs tests on Linux and FreeBSD
|
||||
#[test]
|
||||
fn windows_refuses_a_stream_inside_a_write_root() {
|
||||
let (base, roots) = folders("streams");
|
||||
|
||||
@@ -980,9 +980,16 @@ pub(super) fn after_kept_command(h: &Host) {
|
||||
/// selection cannot be put back, the edit is undone too. The points the run read of the item's
|
||||
/// paths stay valid through the change ([`paths::see_all_points`]).
|
||||
fn edit_item(h: &Host, item: Item, id: &str, params: &Value) -> std::result::Result<Data, HostError> {
|
||||
edit_item_with(h, item, |h| command(h, id, params))
|
||||
}
|
||||
|
||||
/// Runs `f` on the item's document as [`edit_item`] runs its command. `f` runs after the document
|
||||
/// is made active, so bounds it reads take in type that the switch measured again (in the
|
||||
/// document's own composite fonts, [`Session::set_active`]).
|
||||
fn edit_item_with<T>(h: &Host, item: Item, f: impl FnOnce(&Host) -> std::result::Result<T, HostError>) -> std::result::Result<T, HostError> {
|
||||
paths::see_all_points(h);
|
||||
let kept = h.dom.editing.replace(Some(item));
|
||||
let r = atomically(h, |h| on_doc(h, item.doc.uid, true, |h| command(h, id, params)));
|
||||
let r = atomically(h, |h| on_doc(h, item.doc.uid, true, f));
|
||||
h.dom.editing.set(kept);
|
||||
r
|
||||
}
|
||||
@@ -2567,14 +2574,18 @@ fn move_to(h: &Host, a: &[Data], x: Option<f64>, y: Option<f64>) -> Answer {
|
||||
let item = this_item(h, a)?;
|
||||
refuse_protected_edit(h, item)?;
|
||||
selection_ids(h, item.doc, arg(a, 0))?;
|
||||
let (Some(r), f) = item_rect(h, item, false)? else { return Ok(Data::Undefined) };
|
||||
let c = h.dom.coords.get();
|
||||
let now = f.to_script(c, Point::new(r.x0, r.y0));
|
||||
let to = f.to_document(c, [x.unwrap_or(now[0]), y.unwrap_or(now[1])]);
|
||||
let (dx, dy) = (to.x - r.x0, to.y - r.y0);
|
||||
if dx.abs() > 1e-9 || dy.abs() > 1e-9 {
|
||||
edit_item(h, item, "object.move", &json!({"ids": [item.id.0], "dx": dx, "dy": dy}))?;
|
||||
}
|
||||
// Measured once the document is active.
|
||||
edit_item_with(h, item, |h| {
|
||||
let (Some(r), f) = item_rect(h, item, false)? else { return Ok(()) };
|
||||
let c = h.dom.coords.get();
|
||||
let now = f.to_script(c, Point::new(r.x0, r.y0));
|
||||
let to = f.to_document(c, [x.unwrap_or(now[0]), y.unwrap_or(now[1])]);
|
||||
let (dx, dy) = (to.x - r.x0, to.y - r.y0);
|
||||
if dx.abs() > 1e-9 || dy.abs() > 1e-9 {
|
||||
command(h, "object.move", &json!({"ids": [item.id.0], "dx": dx, "dy": dy}))?;
|
||||
}
|
||||
Ok(())
|
||||
})?;
|
||||
Ok(Data::Undefined)
|
||||
}
|
||||
|
||||
@@ -2608,18 +2619,21 @@ fn resize(h: &Host, a: &[Data], width: bool) -> Answer {
|
||||
}
|
||||
refuse_protected_edit(h, item)?;
|
||||
selection_ids(h, item.doc, arg(a, 0))?;
|
||||
let (Some(r), _) = item_rect(h, item, false)? else { return Ok(Data::Undefined) };
|
||||
let now = if width { r.width() } else { r.height() };
|
||||
if now <= 0.0 {
|
||||
return Err(HostError::Error(format!("the object has no {what} to scale")));
|
||||
}
|
||||
if (now - size).abs() < 1e-9 {
|
||||
return Ok(Data::Undefined);
|
||||
}
|
||||
let pct = size / now * 100.0;
|
||||
let (sx, sy) = if width { (pct, 100.0) } else { (100.0, pct) };
|
||||
let p = json!({"ids": [item.id.0], "sx": sx, "sy": sy, "origin": [r.x0, r.y0], "basis": "page"});
|
||||
edit_item(h, item, "object.scale", &p)?;
|
||||
// Measured once the document is active, so the ratio applies to the bounds the scale works on.
|
||||
edit_item_with(h, item, |h| {
|
||||
let (Some(r), _) = item_rect(h, item, false)? else { return Ok(()) };
|
||||
let now = if width { r.width() } else { r.height() };
|
||||
if now <= 0.0 {
|
||||
return Err(HostError::Error(format!("the object has no {what} to scale")));
|
||||
}
|
||||
if (now - size).abs() < 1e-9 {
|
||||
return Ok(());
|
||||
}
|
||||
let pct = size / now * 100.0;
|
||||
let (sx, sy) = if width { (pct, 100.0) } else { (100.0, pct) };
|
||||
command(h, "object.scale", &json!({"ids": [item.id.0], "sx": sx, "sy": sy, "origin": [r.x0, r.y0], "basis": "page"}))?;
|
||||
Ok(())
|
||||
})?;
|
||||
Ok(Data::Undefined)
|
||||
}
|
||||
|
||||
|
||||
@@ -366,7 +366,12 @@ const AI_KEPT: &[(&str, Default)] = &[
|
||||
];
|
||||
|
||||
fn ai_starts() -> Vec<(&'static str, Data)> {
|
||||
vec![("compressed", Data::Bool(true)), ("pdfCompatible", Data::Bool(true)), ("embedICCProfile", Data::Bool(false))]
|
||||
vec![
|
||||
("compatibility", text("Compatibility.ILLUSTRATOR19")),
|
||||
("compressed", Data::Bool(true)),
|
||||
("pdfCompatible", Data::Bool(true)),
|
||||
("embedICCProfile", Data::Bool(false)),
|
||||
]
|
||||
}
|
||||
|
||||
fn eps_map(name: &str, d: &Data, p: &mut Map<String, Value>) -> std::result::Result<bool, HostError> {
|
||||
|
||||
@@ -1352,7 +1352,7 @@ fn encode(s: &str) -> String {
|
||||
}
|
||||
|
||||
/// `s` with its `%xx` escapes read as UTF-8 bytes; `s` as it is when they do not make UTF-8.
|
||||
fn decode(s: &str) -> String {
|
||||
pub(crate) fn decode(s: &str) -> String {
|
||||
let b = s.as_bytes();
|
||||
let mut out = Vec::with_capacity(b.len());
|
||||
let mut i = 0;
|
||||
|
||||
@@ -359,6 +359,32 @@ fn has_parent(p: &str) -> bool {
|
||||
p.split(['/', '\\']).any(|name| name == "..")
|
||||
}
|
||||
|
||||
/// The paths `value` can name in a `File`'s URI notation, as `File.parent` and `File.fullName` give
|
||||
/// them, other than `value` as written: on a platform that reads drive letters (`windows`), `/c/…`
|
||||
/// is the drive path `C:/…`, and on every platform `%20` and the other escapes are decoded. Only a
|
||||
/// path that starts with one `/` has them; `$.evalFile` tries them after `value` as written
|
||||
/// misses. A `//host/share` path, and a form with a `..` name, is left out.
|
||||
pub fn uri_forms(value: &str, windows: bool) -> Vec<String> {
|
||||
if !value.starts_with('/') || value.starts_with("//") {
|
||||
return Vec::new();
|
||||
}
|
||||
let drive = value.strip_prefix('/').filter(|_| windows && !value.starts_with("//")).and_then(|rest| {
|
||||
let (first, after) = rest.split_once('/').unwrap_or((rest, ""));
|
||||
let letter = first.as_bytes();
|
||||
(letter.len() == 1 && letter[0].is_ascii_alphabetic()).then(|| format!("{}:/{after}", letter[0].to_ascii_uppercase() as char))
|
||||
});
|
||||
let mut forms = Vec::new();
|
||||
for form in drive.iter().map(String::as_str).chain(drive.is_none().then_some(value)) {
|
||||
let decoded = crate::script::files::decode(form);
|
||||
for f in [decoded.as_str(), form] {
|
||||
if f != value && !has_parent(f) && !(windows && f.replace('\\', "/").starts_with("//")) && !forms.iter().any(|g| g == f) {
|
||||
forms.push(f.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
forms
|
||||
}
|
||||
|
||||
/// A real path as people read it.
|
||||
fn display(path: &Path) -> Arc<str> {
|
||||
Arc::from(crate::cmd::findfiles::plain(path.to_path_buf()).to_string_lossy().as_ref())
|
||||
@@ -575,13 +601,18 @@ impl Files {
|
||||
let refused = || (FailKind::Error, format!("script file read refused: {value}"));
|
||||
// A script given as text has no folder, and so no file it may read.
|
||||
let Some(dir) = dir.filter(|_| !has_parent(value)) else { return Err(refused()) };
|
||||
// Each candidate, and whether the scope's refusal passes it over.
|
||||
let mut candidates: Vec<(Option<PathBuf>, bool)> = vec![(Some(dir.join(path)), false)];
|
||||
// Each candidate, and whether the scope's refusal passes it over. The path as written comes
|
||||
// first; for `$.evalFile` only, when it misses, fails or is refused, the forms of a path in
|
||||
// URI notation are tried, and when none of them is read either, the error of the path as written stands.
|
||||
let forms = if search { Vec::new() } else { uri_forms(value, cfg!(windows)) };
|
||||
let mut literal_error = None;
|
||||
let mut candidates: Vec<(Option<PathBuf>, bool)> = vec![(Some(dir.join(path)), !forms.is_empty())];
|
||||
candidates.extend(forms.into_iter().map(|f| (Some(dir.join(f)), true)));
|
||||
if search && !path.is_absolute() {
|
||||
candidates.extend(self.include_path.iter().map(|p| ((!has_parent(p)).then(|| dir.join(p).join(path)), false)));
|
||||
candidates.extend(self.jsinclude.iter().filter(|p| p.is_absolute()).map(|p| (Some(p.join(path)), true)));
|
||||
}
|
||||
for (candidate, passed_over_when_refused) in candidates {
|
||||
for (i, (candidate, passed_over_when_refused)) in candidates.into_iter().enumerate() {
|
||||
let Some(candidate) = candidate else { return Err(refused()) };
|
||||
self.probes += 1;
|
||||
if self.probes > MAX_PROBES {
|
||||
@@ -590,12 +621,22 @@ impl Files {
|
||||
match self.scope.read(&candidate, crate::script::MAX_SOURCE_BYTES) {
|
||||
Ok(found) => return Ok(found),
|
||||
Err(ScriptRead::Missing) => {}
|
||||
Err(ScriptRead::Refused) if passed_over_when_refused => {}
|
||||
Err(ScriptRead::Refused) if passed_over_when_refused => {
|
||||
if i == 0 {
|
||||
literal_error = Some(refused());
|
||||
}
|
||||
}
|
||||
Err(ScriptRead::Refused) => return Err(refused()),
|
||||
Err(ScriptRead::TooLarge) => return Err((FailKind::Limit, format!("script file is too large: {value}"))),
|
||||
Err(ScriptRead::Failed(e)) if i == 0 && passed_over_when_refused => {
|
||||
literal_error = Some((FailKind::Error, format!("cannot read script file {value}: {e}")));
|
||||
}
|
||||
Err(ScriptRead::Failed(e)) => return Err((FailKind::Error, format!("cannot read script file {value}: {e}"))),
|
||||
}
|
||||
}
|
||||
if let Some(error) = literal_error {
|
||||
return Err(error);
|
||||
}
|
||||
Err((FailKind::Error, format!("include file not found: {value}")))
|
||||
}
|
||||
|
||||
|
||||
@@ -4500,11 +4500,14 @@ fn stale_current_layer_id_never_targets_a_reused_id() {
|
||||
s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap();
|
||||
let c = NodeId(s.execute("object.compoundPath.make", &json!({})).unwrap()["id"].as_u64().unwrap());
|
||||
assert_eq!(c, layer, "precondition: id reused");
|
||||
// Undo gives back the layer that was current before New Layer; a remembered id left over
|
||||
// from elsewhere still names the compound path now.
|
||||
s.doc_mut().unwrap().active_layer = Some(c);
|
||||
let d = rect(&mut s, 50.0, 50.0, 10.0, 10.0);
|
||||
s.execute("select.set", &json!({"ids": [d.0]})).unwrap();
|
||||
s.execute("object.arrange.sendToCurrentLayer", &json!({})).unwrap();
|
||||
let doc = &s.doc().unwrap().doc;
|
||||
assert!(doc.node(c).unwrap().children().unwrap().iter().all(|n| n.path_data().is_some()));
|
||||
assert_eq!(doc.node(c).unwrap().children().unwrap().len(), 2, "the compound path holds only the two rectangles it was made from");
|
||||
assert!(doc.parent_of(d).is_some_and(|p| doc.node(p).unwrap().is_layer()));
|
||||
// layer.delete without an id must not delete the compound path.
|
||||
s.execute("layer.delete", &json!({})).ok();
|
||||
|
||||
@@ -374,52 +374,6 @@ fn auto_height_in_columns_matches_the_full_search_when_lines_start_small() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Time typing at the start of a story of 5,000, 20,000 and 50,000 characters in Auto Size area
|
||||
/// type in 2 and 3 columns: 20 letters typed one at a time with the Type tool, with Auto Size as it
|
||||
/// runs and with `FULL_SEARCH` on (the columns laid out at every step of the bisection).
|
||||
/// Run with `cargo test --release -p vectorcraft-engine --lib auto_height_in_columns_typing_timing -- --ignored --nocapture`.
|
||||
#[test]
|
||||
#[ignore = "manual timing probe; wall-clock performance depends on machine load"]
|
||||
fn auto_height_in_columns_typing_timing() {
|
||||
use crate::cmd::typecmd::{COLUMN_LAYOUTS, FULL_SEARCH};
|
||||
const WORDS: &str = "The quick brown fox jumps over the lazy dog and keeps running far beyond the first frame of this story. ";
|
||||
let v = ViewInfo::default();
|
||||
for n in [5_000, 20_000, 50_000] {
|
||||
let story = format!("{}\n", WORDS.repeat(6).trim_end()).repeat(n / 600 + 1)[..n].to_string();
|
||||
for cols in [2, 3] {
|
||||
let mut row = format!("{n} characters in {cols} columns:");
|
||||
for full in [false, true] {
|
||||
FULL_SEARCH.with(|c| c.set(full));
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 4400, "height": 1200})).unwrap();
|
||||
let area = json!({"width": 500, "height": 100, "fit": "autoHeight"});
|
||||
let id = s.execute("text.create", &json!({"x": 20, "y": 20, "size": 9, "text": story, "area": area})).unwrap()["id"].clone();
|
||||
s.execute("select.set", &json!({"ids": [id]})).unwrap();
|
||||
s.execute("text.areaOptions", &json!({"columns": cols, "gutter": 12})).unwrap();
|
||||
s.select_tool("type", v).unwrap();
|
||||
for kind in [PointerKind::Down, PointerKind::Up] {
|
||||
s.pointer(&PointerEvent::new(kind, 21.0, 24.0), v).unwrap();
|
||||
}
|
||||
let layouts = COLUMN_LAYOUTS.with(std::cell::Cell::get);
|
||||
let mut ms: Vec<f64> = "abcdefghijklmnopqrst"
|
||||
.chars()
|
||||
.map(|ch| {
|
||||
let start = std::time::Instant::now();
|
||||
s.tool_text(&ch.to_string(), v).unwrap();
|
||||
start.elapsed().as_secs_f64() * 1000.0
|
||||
})
|
||||
.collect();
|
||||
let per_key = (COLUMN_LAYOUTS.with(std::cell::Cell::get) - layouts) as f64 / ms.len() as f64;
|
||||
ms.sort_by(f64::total_cmp);
|
||||
let how = if full { "every step laid out" } else { "Auto Size" };
|
||||
row += &format!(" {how} {:.1} ms a keystroke ({per_key:.1} column layouts);", ms[ms.len() / 2]);
|
||||
}
|
||||
FULL_SEARCH.with(|c| c.set(false));
|
||||
println!("{row}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shrink_text_round_trips_through_the_native_format() {
|
||||
let mut s = session();
|
||||
|
||||
@@ -553,7 +553,7 @@ fn reset_bounding_box_squares_the_objects_inside_a_group() {
|
||||
// The group and both members, in one step.
|
||||
assert_eq!(s.execute("object.resetBoundingBox", &json!({})).unwrap()["changed"], 3);
|
||||
assert_eq!(undo_len(&s), n + 1);
|
||||
assert!(object_angles(&s).iter().all(|a| *a == 0.0), "{:?}", object_angles(&s));
|
||||
assert_eq!(object_angles(&s), [0.0; 3], "the group and both members");
|
||||
s.execute("object.ungroup", &json!({})).unwrap();
|
||||
assert_eq!(selection_box(&s).angle, 0.0);
|
||||
assert_eq!(s.execute("object.resetBoundingBox", &json!({})).unwrap()["changed"], 0);
|
||||
@@ -709,9 +709,11 @@ fn reset_bounding_box_squares_every_box_rotate_bounding_box_turned() {
|
||||
let art = (anchors(&s, a), anchors(&s, c));
|
||||
// The group, the masked object, its mask's art and the other rectangle.
|
||||
assert_eq!(s.execute("object.rotateBoundingBox", &json!({"angle": 25})).unwrap()["changed"], 4);
|
||||
assert!(object_angles(&s).iter().all(|x| near(*x, 25.0)), "{:?}", object_angles(&s));
|
||||
let turned = object_angles(&s);
|
||||
assert_eq!(turned.len(), 4, "{turned:?}");
|
||||
assert!(turned.iter().all(|x| near(*x, 25.0)), "{turned:?}");
|
||||
assert_eq!(s.execute("object.resetBoundingBox", &json!({})).unwrap()["changed"], 4);
|
||||
assert!(object_angles(&s).iter().all(|x| *x == 0.0), "{:?}", object_angles(&s));
|
||||
assert_eq!(object_angles(&s), [0.0; 4]);
|
||||
assert_eq!((anchors(&s, a), anchors(&s, c)), art);
|
||||
}
|
||||
|
||||
|
||||
@@ -1247,10 +1247,13 @@ fn pasted_brushed_art_brings_the_patterns_its_brush_art_uses() {
|
||||
run(&mut s, "brush.apply", json!({"name": "Dotted Band", "ids": [line]}));
|
||||
run(&mut s, "select.set", json!({"ids": [line]}));
|
||||
run(&mut s, "edit.copy", json!({}));
|
||||
let (brush, dots) = (vectorcraft_brush::find(doc(&s), "Dotted Band"), doc(&s).pattern("Dots").cloned());
|
||||
run(&mut s, "file.new", json!({"width": 200, "height": 200}));
|
||||
assert_eq!((vectorcraft_brush::find(doc(&s), "Dotted Band"), doc(&s).pattern("Dots")), (None, None), "a new document has neither");
|
||||
run(&mut s, "edit.paste", json!({}));
|
||||
assert!(vectorcraft_brush::find(doc(&s), "Dotted Band").is_some());
|
||||
assert!(doc(&s).pattern("Dots").is_some(), "the brush's art is filled with it");
|
||||
assert_eq!(vectorcraft_brush::find(doc(&s), "Dotted Band"), brush);
|
||||
assert_eq!(doc(&s).pattern("Dots").cloned(), dots, "the brush's art is filled with it");
|
||||
assert!(dots.is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -2533,6 +2533,9 @@ fn shape_builder_erase_click_or_drag_from_inside_a_narrow_overlap_deletes_it() {
|
||||
assert_eq!(r["edges"].as_u64(), Some(0), "{points}: {r}");
|
||||
let d = &s.doc().unwrap().doc;
|
||||
let left: Vec<f64> = d.children(d.default_layer()).unwrap().iter().filter_map(|c| c.geometric_bounds()).map(|b| b.width()).collect();
|
||||
let erased = r["regions"].as_u64().unwrap();
|
||||
assert!((1..=3).contains(&erased), "{points}: {r}");
|
||||
assert_eq!(left.len() as u64, 3 - erased, "{points}: the regions not erased stay: {left:?}");
|
||||
assert!(left.iter().all(|w| *w > 2.0), "{points}: no strip is left: {left:?}");
|
||||
}
|
||||
}
|
||||
@@ -4583,6 +4586,7 @@ fn live_paint_group_default_clears_the_faces_and_gives_the_edges_a_thin_black_st
|
||||
s.execute("paint.setStroke", &json!({"color": "#0000ff"})).unwrap();
|
||||
s.execute("paint.default", &json!({})).unwrap();
|
||||
let (faces, edges) = part_looks(&s, g);
|
||||
assert_eq!((faces.len(), edges.len() >= 4), (3, true), "{}", edges.len());
|
||||
assert!(faces.iter().all(|f| f.fill_paint().is_none() && f.stroke_paint().is_none()));
|
||||
assert!(edges.iter().all(|e| e.stroke_paint() == Paint::solid(Color::BLACK) && e.stroke_width() == 0.5 && e.fill_paint().is_none()));
|
||||
assert_eq!(sources_looks(&s, g), sources0);
|
||||
@@ -4627,6 +4631,7 @@ fn live_paint_group_invert_recolors_the_faces_fill() {
|
||||
let (_, edges0) = part_looks(&s, g);
|
||||
s.execute("paint.invert", &json!({"stroke": false})).unwrap();
|
||||
let (faces, edges) = part_looks(&s, g);
|
||||
assert_eq!((faces.len(), edges.len() >= 4), (3, true), "{}", edges.len());
|
||||
assert!(faces.iter().all(|f| f.fill_paint() == Paint::solid(Color::rgb(0.0, 1.0, 1.0))));
|
||||
assert_eq!(edges, edges0);
|
||||
assert_eq!(sources_looks(&s, g), sources0);
|
||||
@@ -4634,12 +4639,14 @@ fn live_paint_group_invert_recolors_the_faces_fill() {
|
||||
s.execute("paint.invert", &json!({"stroke": true, "target": "contents"})).unwrap();
|
||||
let (faces1, edges1) = part_looks(&s, g);
|
||||
assert_eq!(faces1, faces);
|
||||
assert_eq!(edges1.len(), edges.len());
|
||||
assert!(edges1.iter().all(|e| e.stroke_paint() == Paint::solid(Color::WHITE)));
|
||||
assert_eq!(sources_looks(&s, g), sources0);
|
||||
// A gradient edit of the fill goes to the faces only.
|
||||
s.execute("paint.setFill", &json!({"gradient": {}})).unwrap();
|
||||
s.execute("paint.editGradient", &json!({"stroke": false, "angle": 45})).unwrap();
|
||||
let (faces2, edges2) = part_looks(&s, g);
|
||||
assert_eq!(faces2.len(), 3);
|
||||
assert!(faces2.iter().all(|f| matches!(f.fill_paint(), Paint::Gradient(_))));
|
||||
assert_eq!(edges2, edges1, "edges take no fill gradient");
|
||||
assert_eq!(sources_looks(&s, g), sources0);
|
||||
@@ -4674,7 +4681,9 @@ fn live_paint_group_gradient_vector_and_freeform_edits_change_its_faces() {
|
||||
assert_eq!(sources_looks(&s, g), sources0);
|
||||
s.execute("paint.setFill", &json!({"gradient": {"kind": "freeform"}})).unwrap();
|
||||
s.execute("paint.freeform.addPoint", &json!({"stroke": false, "at": [25, 50], "color": "#00ff00"})).unwrap();
|
||||
assert!(part_looks(&s, g).0.iter().all(|f| matches!(f.fill_paint(), Paint::Gradient(gr) if gr.freeform.is_some())));
|
||||
let faces_now = part_looks(&s, g).0;
|
||||
assert_eq!(faces_now.len(), face_ids.len());
|
||||
assert!(faces_now.iter().all(|f| matches!(f.fill_paint(), Paint::Gradient(gr) if gr.freeform.is_some())));
|
||||
assert_eq!(part_looks(&s, g).1, edges0);
|
||||
assert_eq!(sources_looks(&s, g), sources0);
|
||||
}
|
||||
@@ -4944,16 +4953,19 @@ fn live_paint_group_contents_edits_follow_the_group_rule() {
|
||||
let sources0 = sources_looks(&s, g);
|
||||
s.execute("appearance.addFill", &json!({"target": "contents"})).unwrap();
|
||||
let (faces1, edges1) = part_looks(&s, g);
|
||||
assert_eq!((faces0.len(), faces1.len(), edges0.len() >= 4), (3, 3, true), "{}", edges0.len());
|
||||
assert!(faces1.iter().zip(&faces0).all(|(f, f0)| f.items.len() == f0.items.len() + 1), "every face takes a new fill");
|
||||
assert_eq!(edges1, edges0, "edges take no new fill");
|
||||
s.execute("appearance.addStroke", &json!({"target": "contents"})).unwrap();
|
||||
let (faces2, edges2) = part_looks(&s, g);
|
||||
assert_eq!(faces2, faces1, "faces take no new stroke");
|
||||
assert_eq!(edges2.len(), edges1.len());
|
||||
assert!(edges2.iter().zip(&edges1).all(|(e, e0)| e.items.len() == e0.items.len() + 1), "every edge takes a new stroke");
|
||||
// A stroke row edit of the contents reaches the edges, not the faces.
|
||||
s.execute("stroke.set", &json!({"target": "contents", "item": 0, "weight": 7})).unwrap();
|
||||
let (faces3, edges3) = part_looks(&s, g);
|
||||
assert_eq!(faces3, faces2, "faces keep their rows");
|
||||
assert_eq!(edges3.len(), edges2.len());
|
||||
assert!(edges3.iter().all(|e| e.stroke_at(Some(0)).map(|st| st.width) == Some(7.0)), "every edge's stroke row takes the weight");
|
||||
s.execute("appearance.clear", &json!({"target": "contents"})).unwrap();
|
||||
assert_eq!(sources_looks(&s, g), sources0, "the hidden source paths keep their appearance");
|
||||
@@ -5203,6 +5215,7 @@ fn live_paint_group_contents_take_a_graphic_style_by_kind() {
|
||||
s.execute("graphicStyle.apply", &json!({"name": "Both", "target": "contents", "add": add})).unwrap();
|
||||
assert!(parts_hold_their_kind(&s, g), "add {add}: faces hold fills and edges strokes");
|
||||
let (faces, edges) = part_looks(&s, g);
|
||||
assert_eq!((faces.len(), edges.len() >= 4), (3, true), "add {add}: {}", edges.len());
|
||||
assert!(faces.iter().all(|a| a.items.iter().any(|it| *it.paint() == red)), "add {add}: each face takes the style's fill");
|
||||
assert!(edges.iter().all(|a| a.items.iter().any(|it| *it.paint() == blue)), "add {add}: each edge takes the style's stroke");
|
||||
let n = node(&s, g);
|
||||
@@ -6199,6 +6212,7 @@ fn live_paint_bucket_edge_double_click_after_filling_a_face_paints_the_joined_ed
|
||||
let black = Paint::solid(Color::rgb(0.0, 0.0, 0.0));
|
||||
let green = Paint::solid(Color::from_hex("#00ff00").unwrap());
|
||||
let all = edges_in(&s, g, Rect::new(-1.0, -1.0, 101.0, 51.0));
|
||||
assert!(all.len() >= 3, "the outline and the shared edge: {all:?}");
|
||||
paint_parts(&mut s, &all, &black, &[(a, black.clone()), (b, black.clone())]);
|
||||
let v = ViewInfo::default();
|
||||
s.select_tool("livePaintBucket", v).unwrap();
|
||||
@@ -9217,16 +9231,23 @@ fn image_trace_refuses_an_unknown_setting() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Every preset's settings, as imageTrace.presets lists them, trace when passed back whole.
|
||||
/// A preset's settings, as imageTrace.presets lists them, trace when passed back whole, and the
|
||||
/// trace keeps them: a preset with an enhanced version, both ways, and a preset without one.
|
||||
#[test]
|
||||
fn image_trace_takes_every_preset_back_as_params() {
|
||||
fn image_trace_takes_a_preset_back_as_params() {
|
||||
let list = session().execute("imageTrace.presets", &json!({})).unwrap();
|
||||
for preset in list["presets"].as_array().unwrap() {
|
||||
for params in [&preset["params"], &preset["enhanced"]].into_iter().filter(|p| !p.is_null()) {
|
||||
let mut s = session();
|
||||
image_doc(&mut s);
|
||||
let r = s.execute("imageTrace.make", &json!({"preset": preset["name"], "params": params}));
|
||||
assert!(r.is_ok(), "{}: {r:?}", preset["name"]);
|
||||
let preset = |name: &str| list["presets"].as_array().unwrap().iter().find(|p| p["name"] == name).unwrap().clone();
|
||||
let (six, flat) = (preset("6 Colors"), preset("Flat Logo"));
|
||||
for (name, params) in [("6 Colors", &six["params"]), ("6 Colors", &six["enhanced"]), ("Flat Logo", &flat["params"])] {
|
||||
let mut s = session();
|
||||
image_doc(&mut s);
|
||||
let r = s.execute("imageTrace.make", &json!({"preset": name, "params": params})).unwrap();
|
||||
let stored = node(&s, NodeId(r["id"].as_u64().unwrap())).extras().trace.clone().unwrap();
|
||||
assert_eq!(stored["preset"], name);
|
||||
let given = params.as_object().unwrap();
|
||||
assert!(given.len() > 1, "{name}: {params}");
|
||||
for (key, value) in given {
|
||||
assert_eq!(&stored["params"][key], value, "{name}: `{key}` is kept");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,5 +87,10 @@ fn nothing_is_cancelled_outside_a_scope() {
|
||||
token.cancel();
|
||||
// The token only counts for work run under it, on its thread.
|
||||
let mut s = session(1);
|
||||
assert!(s.execute("document.exportPdf", &json!({})).is_ok());
|
||||
let r = cancel::scope(&token, None, || s.execute("document.exportPdf", &json!({})));
|
||||
assert!(matches!(r, Err(EngineError::Cancelled)), "under the token: {r:?}");
|
||||
let r = s.execute("document.exportPdf", &json!({})).unwrap();
|
||||
let bytes = vectorcraft_format::base64_decode(r["dataBase64"].as_str().unwrap()).unwrap();
|
||||
assert!(bytes.starts_with(b"%PDF-"), "outside it the whole file is written");
|
||||
assert!(bytes.ends_with(b"%%EOF"), "to its end");
|
||||
}
|
||||
@@ -155,5 +155,7 @@ fn type_as_a_clipping_path_paints_its_characters() {
|
||||
let p = paint(&s);
|
||||
assert!(p.stroke.is_none());
|
||||
let NodeKind::Text(fill) = &p.fill.expect("the characters' fill paints").kind else { panic!("type") };
|
||||
assert!(fill.runs.iter().all(|r| r.style.fill.color().is_some() && r.style.stroke.is_none()));
|
||||
assert_eq!(fill.plain_text(), "Clip");
|
||||
let blue = vectorcraft_color::Color::from_hex("#0000ff");
|
||||
assert!(!fill.runs.is_empty() && fill.runs.iter().all(|r| r.style.fill.color() == blue && r.style.stroke.is_none()), "{:?}", fill.runs);
|
||||
}
|
||||
@@ -1160,9 +1160,10 @@ fn a_blend_mode_over_art_of_several_colors_has_no_one_answer() {
|
||||
assert!((ratio(&r) - 21.0).abs() < 1e-3, "white minus white is black: {r}");
|
||||
}
|
||||
|
||||
/// A Difference square over a white square in a 50 % group that isolates its blending, over the
|
||||
/// edge between black and white art: the square blends only with the white inside the group, so
|
||||
/// A Difference square over a 50 % white square in a 50 % group that isolates its blending, over
|
||||
/// the edge between black and white art: the square blends only with the white inside the group, so
|
||||
/// the art of two colors outside it, which the group draws over in Normal mode, leaves one answer.
|
||||
/// Without isolation the blend also reaches that art, and there is no one answer.
|
||||
#[test]
|
||||
fn a_blend_mode_inside_an_isolating_group_answers_over_art_of_several_colors() {
|
||||
let mut s = session();
|
||||
@@ -1177,14 +1178,33 @@ fn a_blend_mode_inside_an_isolating_group_answers_over_art_of_several_colors() {
|
||||
let back = id(s.execute("shape.rectangle", &json!({"x": 60, "y": 60, "width": 80, "height": 80})).unwrap());
|
||||
s.execute("paint.setFill", &json!({"color": "#ffffff"})).unwrap();
|
||||
s.execute("paint.setStroke", &json!({"none": true})).unwrap();
|
||||
// Translucent, so that a blend that is not isolated also reaches the art behind the group.
|
||||
s.execute("transparency.set", &json!({"opacity": 50})).unwrap();
|
||||
let square = id(s.execute("shape.rectangle", &json!({"x": 70, "y": 70, "width": 60, "height": 60})).unwrap());
|
||||
s.execute("paint.setStroke", &json!({"none": true})).unwrap();
|
||||
s.execute("paint.setFill", &json!({"color": "#ffffff"})).unwrap();
|
||||
s.execute("transparency.set", &json!({"blend": "difference"})).unwrap();
|
||||
s.execute("object.group", &json!({"ids": [back, square]})).unwrap();
|
||||
let group = id(s.execute("object.group", &json!({"ids": [back, square]})).unwrap());
|
||||
s.execute("transparency.set", &json!({"opacity": 50, "isolate": true})).unwrap();
|
||||
s.execute("select.set", &json!({"ids": [square]})).unwrap();
|
||||
s.execute("color.contrast", &json!({})).unwrap();
|
||||
let r = s.execute("color.contrast", &json!({})).unwrap();
|
||||
let isolated = ratio(&r);
|
||||
assert!(isolated > 1.0, "{r}");
|
||||
assert!(r["against"].as_str().is_some_and(|h| vectorcraft_color::Color::from_hex(h).is_some()), "{r}");
|
||||
// Without isolation the square also blends with the black and white art, so there is no one answer.
|
||||
let set_isolate = |s: &mut Session, on: bool| {
|
||||
s.execute("select.set", &json!({"ids": [group]})).unwrap();
|
||||
s.execute("transparency.set", &json!({"isolate": on})).unwrap();
|
||||
s.execute("select.set", &json!({"ids": [square]})).unwrap();
|
||||
};
|
||||
set_isolate(&mut s, false);
|
||||
let e = s.execute("color.contrast", &json!({})).unwrap_err().to_string();
|
||||
assert!(e.contains("is not one color where it is read"), "{e}");
|
||||
set_isolate(&mut s, true);
|
||||
// The Difference mode is applied: in Normal mode the same square gives another answer.
|
||||
s.execute("transparency.set", &json!({"blend": "normal"})).unwrap();
|
||||
let normal = ratio(&s.execute("color.contrast", &json!({})).unwrap());
|
||||
assert!((isolated - normal).abs() > 0.1, "difference {isolated} against normal {normal}");
|
||||
}
|
||||
|
||||
/// With a fill of None, what a pick would be measured against is still read: the Color Wheel's
|
||||
|
||||
@@ -739,7 +739,9 @@ fn separations_preview_compares_the_visible_plates_as_a_set() {
|
||||
assert_eq!(sep(&mut s, json!({"plates": ["Cyan", "Magenta", "Yellow", "Black"]})), all, "every plate in plate order");
|
||||
sep(&mut s, json!({"plates": ["Cyan", "Cyan"]}));
|
||||
let r = s.execute("view.separationsPreview", &json!({"toggle": "Cyan"})).unwrap();
|
||||
assert!(r["plates"].as_array().unwrap().iter().all(|p| p["visible"] == false), "{r}");
|
||||
let plates = r["plates"].as_array().unwrap();
|
||||
assert_eq!(plates.len(), 4, "{r}");
|
||||
assert!(plates.iter().all(|p| p["visible"] == false), "{r}");
|
||||
}
|
||||
|
||||
/// Each plate's visibility in a `view.separationsPreview` or `color.plates` reply, in plate order.
|
||||
|
||||
@@ -345,7 +345,9 @@ fn constrain_angle_turns_the_new_objects_bounding_box() {
|
||||
let id =
|
||||
NodeId(s.execute("shape.polarGrid", &json!({"x": 0, "y": 0, "width": 40, "height": 20, "rotation": -30})).unwrap()["id"].as_u64().unwrap());
|
||||
let n = s.doc().unwrap().doc.node(id).unwrap().clone();
|
||||
assert!(n.children().unwrap().iter().all(|c| close(c.bbox_angle, 30.0)));
|
||||
let lines = n.children().unwrap();
|
||||
assert!(lines.len() > 1, "{}", lines.len());
|
||||
assert!(lines.iter().all(|c| close(c.bbox_angle, 30.0)));
|
||||
s.execute("text.create", &json!({"x": 10, "y": 20, "text": "Hi", "rotation": -30})).unwrap();
|
||||
assert!(close(selection_rotation(&s), 30.0));
|
||||
s.execute("text.create", &json!({"x": 10, "y": 20, "text": "Hi"})).unwrap();
|
||||
|
||||
@@ -1350,7 +1350,9 @@ fn a_stroke_on_a_picked_type_object_without_a_weight_draws() {
|
||||
s.execute("paint.setStroke", &json!({"color": "#ff0000"})).unwrap();
|
||||
let part = s.doc().unwrap().selected_symbol_part().unwrap();
|
||||
let NodeKind::Text(tx) = &part.kind else { panic!("type: {part:?}") };
|
||||
assert!(tx.runs.iter().all(|r| r.style.stroke_width == 1.0 && !r.style.stroke.is_none()), "{:?}", tx.runs);
|
||||
assert_eq!(tx.plain_text(), "Hi");
|
||||
let red = Paint::solid(vectorcraft_color::Color::from_hex("#ff0000").unwrap());
|
||||
assert!(!tx.runs.is_empty() && tx.runs.iter().all(|r| r.style.stroke_width == 1.0 && r.style.stroke == red), "{:?}", tx.runs);
|
||||
}
|
||||
|
||||
/// The colors the Fill and Stroke proxies show, as `paint.proxies` replies them.
|
||||
|
||||
Loaded 100 of 322 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user