Merge main into fix/rotate-reference-point-drag

This commit is contained in:
dotCooCoo committed 2026-12-05 21:24:05 -08:00
commit 225db3568d
56 files changed
+949 -1363

No files matched your search

Generated
+93 -92
View File
@@ -1256,7 +1256,7 @@ dependencies = [
[[package]]
name = "craft"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-automation",
"craft-behavior",
@@ -1298,7 +1298,7 @@ dependencies = [
[[package]]
name = "craft-affinity"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"crc32fast",
"flate2",
@@ -1319,7 +1319,7 @@ dependencies = [
[[package]]
name = "craft-appkit"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"block2 0.6.2",
"objc2 0.6.5",
@@ -1331,7 +1331,7 @@ dependencies = [
[[package]]
name = "craft-atomic"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"rustix 1.1.6",
]
@@ -1339,7 +1339,7 @@ dependencies = [
[[package]]
name = "craft-automation"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"base64 0.23.1",
"craft-behavior",
@@ -1364,7 +1364,7 @@ dependencies = [
[[package]]
name = "craft-behavior"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"accesskit",
"bitflags 2.13.2",
@@ -1383,7 +1383,7 @@ dependencies = [
[[package]]
name = "craft-browse"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-behavior",
"craft-docpath",
@@ -1401,7 +1401,7 @@ dependencies = [
[[package]]
name = "craft-cdr"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-codepage",
"crc32fast",
@@ -1411,7 +1411,7 @@ dependencies = [
[[package]]
name = "craft-cloud-ui"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"egui",
]
@@ -1419,7 +1419,7 @@ dependencies = [
[[package]]
name = "craft-cms"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"md-5",
"rayon",
@@ -1428,12 +1428,12 @@ dependencies = [
[[package]]
name = "craft-codepage"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
[[package]]
name = "craft-color-ui"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-behavior",
"craft-cms",
@@ -1453,7 +1453,7 @@ dependencies = [
[[package]]
name = "craft-control"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-ai-agents",
"craft-atomic",
@@ -1469,7 +1469,7 @@ dependencies = [
[[package]]
name = "craft-control-protocol"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"getrandom 0.3.4",
"serde_json",
@@ -1479,7 +1479,7 @@ dependencies = [
[[package]]
name = "craft-dds"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"rayon",
]
@@ -1487,7 +1487,7 @@ dependencies = [
[[package]]
name = "craft-dialogs"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"block2 0.6.2",
"craft-appkit",
@@ -1513,7 +1513,7 @@ dependencies = [
[[package]]
name = "craft-doc"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"blake3",
"craft-ecproj-format",
@@ -1529,7 +1529,7 @@ dependencies = [
[[package]]
name = "craft-docpath"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"serde",
]
@@ -1537,7 +1537,7 @@ dependencies = [
[[package]]
name = "craft-draw"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-behavior",
"craft-color-ui",
@@ -1556,7 +1556,7 @@ dependencies = [
[[package]]
name = "craft-dwg"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"acadrust",
"craft-dxf",
@@ -1566,7 +1566,7 @@ dependencies = [
[[package]]
name = "craft-dxf"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-codepage",
"encoding_rs",
@@ -1578,7 +1578,7 @@ dependencies = [
[[package]]
name = "craft-ecproj-format"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"serde",
"serde_json",
@@ -1588,12 +1588,12 @@ dependencies = [
[[package]]
name = "craft-eps"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
[[package]]
name = "craft-flags"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-atomic",
"dirs",
@@ -1603,7 +1603,7 @@ dependencies = [
[[package]]
name = "craft-font-catalog"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"fontique",
"harfrust 0.13.3",
@@ -1618,7 +1618,7 @@ dependencies = [
[[package]]
name = "craft-font-manager"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-behavior",
"craft-font-catalog",
@@ -1637,7 +1637,7 @@ dependencies = [
[[package]]
name = "craft-font-os-windows"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"windows-registry",
"windows-sys 0.61.2",
@@ -1646,7 +1646,7 @@ dependencies = [
[[package]]
name = "craft-font-store"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"cap-primitives",
"craft-atomic",
@@ -1669,12 +1669,12 @@ dependencies = [
[[package]]
name = "craft-fonts-build"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
[[package]]
name = "craft-gif"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"gif",
]
@@ -1682,7 +1682,7 @@ dependencies = [
[[package]]
name = "craft-gzip"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"flate2",
]
@@ -1690,7 +1690,7 @@ dependencies = [
[[package]]
name = "craft-host"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"bitflags 2.13.2",
"craft-i18n",
@@ -1703,7 +1703,7 @@ dependencies = [
[[package]]
name = "craft-i18n"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"brotli 9.1.3",
"brotli-decompressor 6.3.2",
@@ -1733,7 +1733,7 @@ dependencies = [
[[package]]
name = "craft-image-codecs"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-dds",
"craft-jpeg",
@@ -1760,7 +1760,7 @@ dependencies = [
[[package]]
name = "craft-imaging"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-behavior",
"craft-color-ui",
@@ -1778,7 +1778,7 @@ dependencies = [
[[package]]
name = "craft-jpeg"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"thiserror 2.0.21",
]
@@ -1786,7 +1786,7 @@ dependencies = [
[[package]]
name = "craft-jxl"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"brotli-decompressor 5.0.3",
"jixel",
@@ -1797,7 +1797,7 @@ dependencies = [
[[package]]
name = "craft-keymap"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-host",
"craft-i18n",
@@ -1812,7 +1812,7 @@ dependencies = [
[[package]]
name = "craft-layers"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-behavior",
"craft-i18n",
@@ -1826,7 +1826,7 @@ dependencies = [
[[package]]
name = "craft-menu"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-behavior",
"craft-host",
@@ -1844,7 +1844,7 @@ dependencies = [
[[package]]
name = "craft-metadata"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"brotli-decompressor 6.3.2",
"chrono",
@@ -1856,7 +1856,7 @@ dependencies = [
[[package]]
name = "craft-metafile"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"encoding_rs",
"image",
@@ -1867,7 +1867,7 @@ dependencies = [
[[package]]
name = "craft-mime"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"chrono",
"craft-codepage",
@@ -1877,7 +1877,7 @@ dependencies = [
[[package]]
name = "craft-nightly"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"uds_windows",
"winsafe",
@@ -1886,7 +1886,7 @@ dependencies = [
[[package]]
name = "craft-pages"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-behavior",
"craft-keymap",
@@ -1902,7 +1902,7 @@ dependencies = [
[[package]]
name = "craft-pbr"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-texture",
"thiserror 2.0.21",
@@ -1911,7 +1911,7 @@ dependencies = [
[[package]]
name = "craft-pcraft-format"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"flate2",
"serde",
@@ -1922,7 +1922,7 @@ dependencies = [
[[package]]
name = "craft-pdf"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"hayro-interpret",
"hayro-syntax",
@@ -1934,7 +1934,7 @@ dependencies = [
[[package]]
name = "craft-platform"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"async-channel",
"async-io",
@@ -1968,7 +1968,7 @@ dependencies = [
[[package]]
name = "craft-plotter"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"kurbo 0.13.1",
"thiserror 2.0.21",
@@ -1977,7 +1977,7 @@ dependencies = [
[[package]]
name = "craft-print"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2001,7 +2001,7 @@ dependencies = [
[[package]]
name = "craft-proof"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"log",
"miniz_oxide 0.9.1",
@@ -2012,7 +2012,7 @@ dependencies = [
[[package]]
name = "craft-ps"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-eps",
"flate2",
@@ -2026,7 +2026,7 @@ dependencies = [
[[package]]
name = "craft-psd"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"encoding_rs",
"flate2",
@@ -2037,7 +2037,7 @@ dependencies = [
[[package]]
name = "craft-quit"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"dispatch2",
"egui",
@@ -2050,7 +2050,7 @@ dependencies = [
[[package]]
name = "craft-raster3d"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"rayon",
"thiserror 2.0.21",
@@ -2059,7 +2059,7 @@ dependencies = [
[[package]]
name = "craft-review"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"base64 0.23.1",
"craft-behavior",
@@ -2078,7 +2078,7 @@ dependencies = [
[[package]]
name = "craft-settings"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-atomic",
"craft-host",
@@ -2095,7 +2095,7 @@ dependencies = [
[[package]]
name = "craft-stream-codecs"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"fax",
"hayro-ccitt",
@@ -2106,7 +2106,7 @@ dependencies = [
[[package]]
name = "craft-svg"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-image-codecs",
"craft-xml",
@@ -2127,7 +2127,7 @@ dependencies = [
[[package]]
name = "craft-table"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-behavior",
"craft-keymap",
@@ -2139,7 +2139,7 @@ dependencies = [
[[package]]
name = "craft-text"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-behavior",
"craft-font-manager",
@@ -2164,7 +2164,7 @@ dependencies = [
[[package]]
name = "craft-texture"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"thiserror 2.0.21",
]
@@ -2172,7 +2172,7 @@ dependencies = [
[[package]]
name = "craft-theme"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"bitflags 2.13.2",
"craft-tracked",
@@ -2187,7 +2187,7 @@ dependencies = [
[[package]]
name = "craft-theme-store"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-atomic",
"craft-behavior",
@@ -2202,7 +2202,7 @@ dependencies = [
[[package]]
name = "craft-tiff"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"serde",
"thiserror 2.0.21",
@@ -2212,7 +2212,7 @@ dependencies = [
[[package]]
name = "craft-time"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"serde",
"thiserror 2.0.21",
@@ -2221,7 +2221,7 @@ dependencies = [
[[package]]
name = "craft-timeline"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-behavior",
"craft-keymap",
@@ -2236,12 +2236,12 @@ dependencies = [
[[package]]
name = "craft-tracked"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
[[package]]
name = "craft-ui"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-cloud-ui",
"craft-ui-canvas",
@@ -2255,7 +2255,7 @@ dependencies = [
[[package]]
name = "craft-ui-canvas"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-behavior",
"craft-font-catalog",
@@ -2272,7 +2272,7 @@ dependencies = [
[[package]]
name = "craft-ui-contract"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"accesskit",
"craft-behavior",
@@ -2310,7 +2310,7 @@ dependencies = [
[[package]]
name = "craft-ui-macros"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"proc-macro-crate",
"proc-macro2",
@@ -2321,7 +2321,7 @@ dependencies = [
[[package]]
name = "craft-ui-panels"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2339,7 +2339,7 @@ dependencies = [
[[package]]
name = "craft-ui-patterns"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2360,7 +2360,7 @@ dependencies = [
[[package]]
name = "craft-ui-shell"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2381,7 +2381,7 @@ dependencies = [
[[package]]
name = "craft-ui-widgets"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2401,7 +2401,7 @@ dependencies = [
[[package]]
name = "craft-update"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"base64 0.22.1",
"chrono",
@@ -2433,7 +2433,7 @@ dependencies = [
[[package]]
name = "craft-vectorcraft-format"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"flate2",
"serde",
@@ -2444,7 +2444,7 @@ dependencies = [
[[package]]
name = "craft-wayland"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"raw-window-handle",
"wayland-backend",
@@ -2454,7 +2454,7 @@ dependencies = [
[[package]]
name = "craft-web-api"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"js-sys",
"serde_json",
@@ -2465,7 +2465,7 @@ dependencies = [
[[package]]
name = "craft-win32"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"winsafe",
]
@@ -2473,7 +2473,7 @@ dependencies = [
[[package]]
name = "craft-window"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"craft-appkit",
"craft-atomic",
@@ -2505,7 +2505,7 @@ dependencies = [
[[package]]
name = "craft-xml"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"quick-xml 0.41.0",
"serde",
@@ -3864,7 +3864,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a"
[[package]]
name = "hayro-cmap"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"brotli 8.0.4",
"hayro-postscript",
@@ -3873,7 +3873,7 @@ dependencies = [
[[package]]
name = "hayro-interpret"
version = "0.7.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"bitflags 2.13.2",
"hayro-cmap",
@@ -3891,7 +3891,7 @@ dependencies = [
[[package]]
name = "hayro-jbig2"
version = "0.3.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"fearless_simd",
"hayro-ccitt",
@@ -3909,12 +3909,12 @@ dependencies = [
[[package]]
name = "hayro-postscript"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
[[package]]
name = "hayro-syntax"
version = "0.7.2"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"flate2",
"hayro-ccitt",
@@ -4937,7 +4937,7 @@ dependencies = [
[[package]]
name = "krilla"
version = "0.8.2"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"base64 0.22.1",
"bumpalo",
@@ -5094,7 +5094,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4"
[[package]]
name = "linesweeper"
version = "0.5.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"arrayvec",
"kurbo 0.13.1",
@@ -7700,7 +7700,7 @@ dependencies = [
[[package]]
name = "skrifa"
version = "0.44.0"
source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97"
source = "git+https://github.com/storytold/craft-libs?rev=6b67abe4b3deead5a1437dc6987a85b35afd40f6#6b67abe4b3deead5a1437dc6987a85b35afd40f6"
dependencies = [
"bytemuck",
"read-fonts 0.41.0",
@@ -9304,6 +9304,7 @@ dependencies = [
"vectorcraft-doc",
"vectorcraft-geom 0.25.1",
"vello_cpu",
"windows-registry",
"write-fonts",
]
+43 -43
View File
@@ -10,62 +10,62 @@ license = "MIT OR Apache-2.0"
rust-version = "1.95"
[workspace.dependencies]
craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97", default-features = false, features = ["interpret", "write"] }
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6", default-features = false, features = ["interpret", "write"] }
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
# Language packs: the Craft apps' shared font store installs them (#4936).
craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
# 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 = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
# `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile.
craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97", features = ["pcraft-pixels"] }
craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6", features = ["pcraft-pixels"] }
# Native Affinity documents (craft-libs#914).
craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
# Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778).
craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
# SVG parsing, limits, SVGZ and writer (craft-libs#778).
craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97", features = ["tree"] }
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6", features = ["tree"] }
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
# Digits typed in any script in numeric fields (`vectorcraft_doc::units`).
craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
# EPS container, previews, ASCII85 and DSC comments (craft-libs#778).
craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
# DXF tags, reader and writer (craft-libs#778, #926, #927).
craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
# DWG to DXF bytes, in a child process on desktop builds (acadrust 0.6.6, MPL-2.0, unmodified).
craft-dwg = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-dwg = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
# The DWG reader and writer craft-dwg uses, at the rev craft-libs pins (its Cargo.toml). Tests only: it writes the
# R12, R13 and R14 DWG files that craft-dwg's writer, 2000 and later, does not.
acadrust = { git = "https://github.com/storytold/acadrust.git", rev = "468b9d8e317755209020d5d3f2f1c8a76210c47f" }
# WMF, EMF and EMF+ reader (craft-libs#778).
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97", default-features = false, features = ["read", "write"] }
craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6", default-features = false, features = ["read", "write"] }
craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
# The metallic-roughness BRDF and environment light the 3D effects' Roughness and Metallic shade with.
craft-pbr = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-pbr = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
# The CPU rasterizer that draws a 3D effect's Render Settings › Rendered image: depth-buffered triangles, shadow maps.
craft-raster3d = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-raster3d = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
# 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 = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
# 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 = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
# Nightly profile isolation, launch protocol, and security fence.
craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
# internal
vectorcraft-geom = { path = "crates/geom" }
vectorcraft-color = { path = "crates/color" }
@@ -205,15 +205,15 @@ lto = "thin"
codegen-units = 1
[patch.crates-io]
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
krilla = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
krilla = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
# skrifa 0.44 (epaint, glifo, usvg) with the automatic hinter's long blue-zone exit (craft-libs vendor/skrifa).
skrifa = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" }
skrifa = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6" }
ecolor = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" }
emath = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" }
epaint = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" }
+1 -1
View File
@@ -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 = "138ce9929ea48d055c797f61c042a3c407427d97", version = "0.1.0" }
craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "6b67abe4b3deead5a1437dc6987a85b35afd40f6", version = "0.1.0" }
wasm-bindgen = "0.2"
serde_json = { workspace = true }
-115
View File
@@ -1,115 +0,0 @@
//! Block definitions and INSERT entities for the DXF writer.
//!
//! Temporary: `craft_dxf::drawing` at the pinned craft-libs revision writes only the model and
//! paper space blocks. storytold/craft-libs#5381 adds `Block`, `Drawing::blocks` and
//! `Codes::insert`; once it merges and the pin moves past it, this module is removed and
//! `scene.rs` uses those instead. Until then [`write`] adds the user blocks to the file that
//! `Drawing::write` returns, with the same group codes #5381 writes.
use craft_dxf::drawing::{Codes, Drawing, Handle, fixed};
/// A block definition: entities written once, which INSERT entities place ([`insert`]). Its base
/// point is the origin.
#[derive(Clone, Debug)]
pub struct Block {
pub name: String,
/// The handle of its BLOCK_RECORD (from R13), which owns its entities.
pub record: Handle,
/// The handles of its BLOCK and ENDBLK records.
pub begin: Handle,
pub end: Handle,
/// The entities' group codes, written with `record` as their owner.
pub entities: String,
}
/// The start of an object: its type, and from R13 its handle, owner and first subclass.
fn object(c: &mut Codes, kind: &str, h: Handle, owner: Handle, subclass: &str) {
c.raw(0, kind);
if c.v.handles() {
c.handle(5, h);
c.handle(330, owner);
c.raw(100, subclass);
}
}
/// An INSERT entity owned by `owner` on `layer` that places block `block` at the origin, unscaled
/// and unrotated. It has no color of its own (ByLayer).
pub fn insert(c: &mut Codes, h: Handle, owner: Handle, layer: &str, block: &str) {
object(c, "INSERT", h, owner, "AcDbEntity");
c.str(8, layer);
if c.v.handles() {
c.raw(100, "AcDbBlockReference");
}
c.str(2, block);
c.xyz(10, 0.0, 0.0);
}
/// The whole file of `d` with `blocks` written after the model and paper space blocks.
pub fn write(d: Drawing, blocks: &[Block]) -> String {
let v = d.version;
let out = d.write();
if blocks.is_empty() {
return out;
}
let mut defs = Codes::new(v);
for b in blocks {
object(&mut defs, "BLOCK", b.begin, b.record, "AcDbEntity");
defs.raw(8, "0");
if v.handles() {
defs.raw(100, "AcDbBlockBegin");
}
defs.str(2, &b.name);
defs.int(70, 0);
defs.xyz(10, 0.0, 0.0);
defs.str(3, &b.name);
defs.raw(1, "");
defs.append(&b.entities);
object(&mut defs, "ENDBLK", b.end, b.record, "AcDbEntity");
defs.raw(8, "0");
if v.handles() {
defs.raw(100, "AcDbBlockEnd");
}
}
let defs = defs.into_string();
if !v.handles() {
// R12 has no model and paper space blocks: its BLOCKS section holds the user blocks only.
let at = " 0\nSECTION\n 2\nENTITIES\n";
return match out.find(at) {
Some(i) => format!("{} 0\nSECTION\n 2\nBLOCKS\n{defs} 0\nENDSEC\n{}", &out[..i], &out[i..]),
None => out,
};
}
let mut records = Codes::new(v);
for b in blocks {
object(&mut records, "BLOCK_RECORD", b.record, fixed::BLOCK_RECORD_TABLE, "AcDbSymbolTableRecord");
records.raw(100, "AcDbBlockTableRecord");
records.str(2, &b.name);
if v.r2000() {
records.handle(340, Handle(0));
records.int(70, 0);
records.int(280, 1);
records.int(281, 0);
}
}
let records = records.into_string();
let (Some(table), Some(blocks_at)) = (out.find(" 0\nTABLE\n 2\nBLOCK_RECORD\n"), out.find(" 0\nSECTION\n 2\nBLOCKS\n")) else {
return out;
};
let count = " 70\n2\n";
let (Some(c), Some(t_end), Some(b_end)) = (
out[table..].find(count).map(|i| table + i),
out[table..].find(" 0\nENDTAB\n").map(|i| table + i),
out[blocks_at..].find(" 0\nENDSEC\n").map(|i| blocks_at + i),
) else {
return out;
};
let mut s = String::with_capacity(out.len() + records.len() + defs.len());
s.push_str(&out[..c]);
s.push_str(&format!(" 70\n{}\n", 2 + blocks.len()));
s.push_str(&out[c + count.len()..t_end]);
s.push_str(&records);
s.push_str(&out[t_end..b_end]);
s.push_str(&defs);
s.push_str(&out[b_end..]);
s
}
+2 -2
View File
@@ -19,10 +19,10 @@
//! - `curve`: bulges, arcs, ellipses and NURBS as Bézier paths.
//! - `hatch`: pattern hatches' lines and gradient hatches' fills.
//! - `text`: text values to plain text.
//! - `acis`: a region's solid-modeler data as its outline.
//! - `build`: items to the document.
//!
//! A region's solid-modeler data becomes its outline in `craft_dxf::acis`.
mod acis;
mod build;
mod curve;
mod entity;
-779
View File
@@ -1,779 +0,0 @@
//! The solid-modeler data of a REGION as a filled outline: each face's loops of edges, in world x
//! and y (drawing units). The data comes as text (DXF before 2013, ciphered or not) or binary
//! (DXF 2013 and later keep it in the ACDSDATA section).
//!
//! The model is a list of records pointing at each other: a body holds lumps, a lump shells, a
//! shell faces, a face loops, a loop a ring of coedges. Each coedge uses an edge (forward or
//! reversed), and each edge runs between two vertices along a line, an ellipse or a spline. A
//! curve of any other kind comes in as a straight line between its vertices.
//!
//! The REGION groups are in the DXF Reference
//! (<https://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-644BF0F0-FD79-4C5E-AD5A-0053FCC5A5A4>); which
//! DXF versions hold text and which binary data is in <https://ezdxf.mozman.at/docs/acis.html>.
use std::collections::HashMap;
use kurbo::{BezPath, ParamCurve, ParamCurveArclen, ParamCurveNearest, PathSeg};
use vectorcraft_geom::{Affine, Point};
use super::curve;
/// The most bytes of one region's data read.
pub(crate) const MAX_BYTES: usize = 16 << 20;
/// The most records one region's outline may visit: bodies, lumps, shells, faces and coedges
/// (a loop counts as one at least).
const MAX_VISITS: usize = 1_000_000;
/// The first bytes of binary data: ACIS's, or ASM's (DXF 2018 writes either).
const BINARY_MAGIC: [&[u8]; 2] = [b"ACIS BinaryFile", b"ASM BinaryFile4"];
/// From this version on, every record starts with its attribute, a history number and one more
/// pointer; before it, with its attribute alone.
const LONG_HEADER_VERSION: u32 = 700;
type P3 = [f64; 3];
/// A B-spline: degree, knots, control points, weights (none: all 1).
type Spline = (usize, Vec<f64>, Vec<P3>, Option<Vec<f64>>);
/// One value of a record.
#[derive(Clone, Debug, PartialEq)]
enum Tok {
Ptr(i64),
Num(f64),
Word(String),
/// `forward` (false) or `reversed` (true).
Sense(bool),
Open,
Close,
}
/// A record: its type (`body`, `plane-surface`…) and its values after the ones every record
/// starts with.
#[derive(Debug)]
struct Rec {
kind: String,
toks: Vec<Tok>,
}
impl Rec {
/// The type `base` or one derived from it (`tedge-edge` is an edge).
fn is(&self, base: &str) -> bool {
self.kind == base || self.kind.strip_suffix(base).is_some_and(|k| k.ends_with('-'))
}
/// The `n`th pointer (-1: none).
fn ptr(&self, n: usize) -> i64 {
self.toks.iter().filter_map(|t| if let Tok::Ptr(p) = t { Some(*p) } else { None }).nth(n).unwrap_or(-1)
}
/// The sense right after the `n`th pointer: true when reversed (old files write 1).
fn sense_after(&self, n: usize) -> Option<bool> {
let mut ptrs = 0;
for t in &self.toks {
if ptrs > n {
return match t {
Tok::Sense(r) => Some(*r),
Tok::Num(v) if v.is_finite() => Some(*v != 0.0),
_ => None,
};
}
if matches!(t, Tok::Ptr(_)) {
ptrs += 1;
}
}
None
}
/// The numbers, in order.
fn nums(&self) -> Vec<f64> {
self.toks.iter().filter_map(|t| if let Tok::Num(v) = t { Some(*v) } else { None }).collect()
}
}
/// The records of one body, and how pointers find them.
struct Model {
recs: Vec<Rec>,
/// Record number by index, when the records carry their own.
at: HashMap<i64, usize>,
}
impl Model {
fn get(&self, p: i64) -> Option<&Rec> {
if p < 0 {
return None;
}
if self.at.is_empty() { self.recs.get(usize::try_from(p).ok()?) } else { self.recs.get(*self.at.get(&p)?) }
}
/// The record `p` points at when it is of type `base`.
fn get_is(&self, p: i64, base: &str) -> Option<&Rec> {
self.get(p).filter(|r| r.is(base))
}
/// The records of type `base` from `first` along their `next` pointer (pointer `next`), each
/// once. Missing records, wrong types and cycles outside coedge rings set `broken`.
fn chain(&self, first: i64, base: &str, next: usize, broken: &mut bool) -> Vec<&Rec> {
let mut out = vec![];
let mut seen = std::collections::HashSet::new();
let mut p = first;
while p >= 0 {
if !seen.insert(p) {
*broken |= base != "coedge";
break;
}
let Some(r) = self.get_is(p, base) else {
*broken = true;
break;
};
out.push(r);
p = r.ptr(next);
}
out
}
}
/// A region's outline: its faces' loops, closed; `approximated` when an edge of a curve type
/// this reader doesn't draw came in as a straight line; `broken` when a topology chain breaks
/// off or a loop's ring of coedges doesn't come back to its first; `ambiguous` when an edge's
/// endpoint lies on separate parts of its curve.
#[derive(Debug)]
pub(crate) struct Outline {
pub path: BezPath,
pub approximated: bool,
pub broken: bool,
pub ambiguous: bool,
}
/// Text data, ciphered as DXF writes it or not.
pub(crate) fn from_text(text: &str) -> Option<Outline> {
if text.len() > MAX_BYTES {
return None;
}
let plain;
let text = if text.trim_start().starts_with(|c: char| c.is_ascii_digit()) {
text
} else {
plain = decipher(text);
&plain
};
outline(&sat_model(text)?)
}
/// Binary data.
pub(crate) fn from_binary(bytes: &[u8]) -> Option<Outline> {
if bytes.len() > MAX_BYTES {
return None;
}
outline(&sab_model(bytes)?)
}
/// DXF's cipher of text data undone: each printable character is mapped back, and the space
/// written after a mapped `A` (a caret, which DXF reads as a control code) is dropped.
fn decipher(s: &str) -> String {
let mut out = String::with_capacity(s.len());
let mut chars = s.chars().peekable();
while let Some(c) = chars.next() {
out.push(match c {
' ' | '\n' | '\r' | '\t' => c,
'@'..='_' => char::from(159 - c as u8),
c if c.is_ascii() && !c.is_ascii_control() => char::from(c as u8 ^ 0x5F),
c => c,
});
if c == '^' && chars.peek() == Some(&' ') {
chars.next();
}
}
out
}
/// How many values every record starts with in data of `version`.
fn header_len(version: u32) -> usize {
if version >= LONG_HEADER_VERSION { 3 } else { 1 }
}
/// A text value as a value.
fn sat_tok(w: &str) -> Tok {
match w {
"{" => Tok::Open,
"}" => Tok::Close,
"forward" | "forward_v" => Tok::Sense(false),
"reversed" | "reversed_v" => Tok::Sense(true),
_ => {
if let Some(p) = w.strip_prefix('$').and_then(|p| p.parse::<i64>().ok()) {
return Tok::Ptr(p);
}
match w.parse::<f64>() {
Ok(v) if v.is_finite() => Tok::Num(v),
_ => Tok::Word(w.to_string()),
}
}
}
}
/// Does this line start a record (`[-<index>] <type> $<attribute> …`)?
fn starts_record(line: &str) -> bool {
let mut words = line.split_whitespace();
let first = words.next().unwrap_or_default();
let (kind, next) = if first.starts_with('-') && first[1..].parse::<u64>().is_ok() {
(words.next().unwrap_or_default(), words.next().unwrap_or_default())
} else {
(first, words.next().unwrap_or_default())
};
kind.starts_with(|c: char| c.is_ascii_alphabetic()) && next.starts_with('$')
}
/// Text data's records: a version line, product and tolerance lines, then records ending in `#`.
fn sat_model(text: &str) -> Option<Model> {
let version = text.split_whitespace().next()?.parse::<f64>().ok().filter(|v| v.is_finite() && *v >= 0.0)? as u32;
let skip = header_len(version);
let mut offset = text.find('\n')? + 1;
let start = loop {
let rest = text.get(offset..)?;
let line = rest.split('\n').next().unwrap_or_default();
if starts_record(line) {
break offset;
}
offset += line.len() + 1;
};
let body = text.get(start..)?;
let (mut recs, mut at) = (Vec::new(), HashMap::new());
let mut cur: Vec<Tok> = vec![];
let (mut kind, mut index): (Option<String>, Option<i64>) = (None, None);
let mut i = 0;
let b = body.as_bytes();
while i < b.len() {
if b[i].is_ascii_whitespace() {
i += 1;
continue;
}
let end = b[i..].iter().position(u8::is_ascii_whitespace).map_or(b.len(), |n| i + n);
let word = body.get(i..end)?;
i = end;
// A counted string: `@<n>`, a space, then n bytes.
if let Some(n) = word.strip_prefix('@').and_then(|n| n.parse::<usize>().ok()) {
let from = (i + 1).min(b.len());
let to = from.checked_add(n)?.min(b.len());
cur.push(Tok::Word(body.get(from..to)?.to_string()));
i = to;
continue;
}
let (word, ends) = match word.strip_suffix('#') {
Some(w) => (w, true),
None => (word, false),
};
if !word.is_empty() {
match &kind {
None if index.is_none() && word.starts_with('-') && word[1..].parse::<i64>().is_ok() => {
index = word[1..].parse().ok();
}
None => {
if word.starts_with("End-of-") || word.starts_with("Begin-of-") {
break;
}
kind = Some(word.to_string());
}
Some(_) => cur.push(sat_tok(word)),
}
}
if ends {
let toks = cur.split_off(skip.min(cur.len()));
cur.clear();
if let Some(n) = index.take() {
at.insert(n, recs.len());
}
recs.push(Rec { kind: kind.take().unwrap_or_default(), toks });
}
}
Some(Model { recs, at })
}
/// Reads binary data's little-endian values.
struct Bytes<'b> {
b: &'b [u8],
i: usize,
}
impl Bytes<'_> {
fn take(&mut self, n: usize) -> Option<&[u8]> {
let s = self.b.get(self.i..self.i.checked_add(n)?)?;
self.i += n;
Some(s)
}
fn u8(&mut self) -> Option<u8> {
self.take(1).map(|s| s[0])
}
fn i16(&mut self) -> Option<f64> {
self.take(2).map(|s| f64::from(i16::from_le_bytes([s[0], s[1]])))
}
fn u16(&mut self) -> Option<usize> {
self.take(2).map(|s| usize::from(u16::from_le_bytes([s[0], s[1]])))
}
fn i32(&mut self) -> Option<i32> {
self.take(4).map(|s| i32::from_le_bytes([s[0], s[1], s[2], s[3]]))
}
fn u32(&mut self) -> Option<u32> {
self.take(4).map(|s| u32::from_le_bytes([s[0], s[1], s[2], s[3]]))
}
fn f64(&mut self) -> Option<f64> {
let s = self.take(8)?;
Some(f64::from_le_bytes([s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7]]))
}
fn text(&mut self, n: usize) -> Option<String> {
self.take(n).map(|s| String::from_utf8_lossy(s).into_owned())
}
}
/// Binary data's records: the magic, four numbers (version first), product and tolerance values,
/// then records of tagged values, each type name made of its parts.
fn sab_model(b: &[u8]) -> Option<Model> {
let mut r = Bytes { b: BINARY_MAGIC.iter().find_map(|m| b.strip_prefix(*m))?, i: 0 };
let version = r.u32()?;
r.take(12)?;
let skip = header_len(version);
let mut recs = vec![];
let (mut parts, mut kind, mut cur): (Vec<String>, Option<String>, Vec<Tok>) = (vec![], None, vec![]);
while r.i < r.b.len() {
let tag = r.u8()?;
let tok = match tag {
0x02 => Tok::Num(f64::from(i8::from_le_bytes([r.u8()?]))),
0x03 => Tok::Num(r.i16()?),
0x04 | 0x15 => Tok::Num(f64::from(r.i32()?)),
0x05 => Tok::Num(f64::from(f32::from_le_bytes(r.take(4)?.try_into().ok()?))),
0x06 | 0x17 => Tok::Num(r.f64()?),
0x07 => {
let n = usize::from(r.u8()?);
Tok::Word(r.text(n)?)
}
0x08 => {
let n = r.u16()?;
Tok::Word(r.text(n)?)
}
0x09 | 0x12 => {
let n = usize::try_from(r.u32()?).ok()?;
Tok::Word(r.text(n)?)
}
0x0A => Tok::Sense(true),
0x0B => Tok::Sense(false),
0x0C => Tok::Ptr(i64::from(r.i32()?)),
0x0D | 0x0E => {
let n = usize::from(r.u8()?);
let name = r.text(n)?;
if kind.is_some() {
Tok::Word(name)
} else {
parts.push(name);
if tag == 0x0D {
let k = parts.join("-");
parts.clear();
if k.starts_with("End-of-") || k.starts_with("Begin-of-") {
break;
}
kind = Some(k);
}
continue;
}
}
0x0F => Tok::Open,
0x10 => Tok::Close,
0x11 => {
if let Some(k) = kind.take() {
let toks = cur.split_off(skip.min(cur.len()));
recs.push(Rec { kind: k, toks });
}
cur.clear();
continue;
}
0x13 | 0x14 => {
for _ in 0..3 {
cur.push(Tok::Num(r.f64()?));
}
continue;
}
0x16 => {
for _ in 0..2 {
cur.push(Tok::Num(r.f64()?));
}
continue;
}
_ => return None,
};
// Values before the first record are the header's.
if kind.is_some() {
cur.push(tok);
}
}
Some(Model { recs, at: HashMap::new() })
}
/// A body's placement: `p · m · scale + t`.
#[derive(Clone, Copy)]
struct Xf {
m: [P3; 3],
scale: f64,
t: P3,
}
impl Xf {
const IDENTITY: Xf = Xf { m: [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]], scale: 1.0, t: [0.0; 3] };
/// A `transform` record's: nine matrix numbers row by row, the translation, the scale.
fn read(r: &Rec) -> Option<Xf> {
let n: Vec<f64> = r.toks.iter().map_while(|t| if let Tok::Num(v) = t { Some(*v) } else { None }).collect();
if n.iter().any(|v| !v.is_finite()) {
return None;
}
let v = |i: usize| n.get(i).copied();
let row = |i: usize| Some([v(i)?, v(i + 1)?, v(i + 2)?]);
let scale = v(12)?;
Some(Xf { m: [row(0)?, row(3)?, row(6)?], t: row(9)?, scale })
}
fn vector(&self, p: P3) -> P3 {
let [a, b, c] = self.m;
std::array::from_fn(|i| (p[0] * a[i] + p[1] * b[i] + p[2] * c[i]) * self.scale)
}
fn point(&self, p: P3) -> P3 {
let v = self.vector(p);
std::array::from_fn(|i| v[i] + self.t[i])
}
}
/// Seen from above: x and y.
fn flat(p: P3) -> Point {
Point::new(p[0], p[1])
}
fn sub(a: P3, b: P3) -> P3 {
[a[0] - b[0], a[1] - b[1], a[2] - b[2]]
}
fn dot(a: P3, b: P3) -> f64 {
a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
}
fn cross(a: P3, b: P3) -> P3 {
[a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]
}
fn p3(n: &[f64], i: usize) -> Option<P3> {
Some([*n.get(i)?, *n.get(i + 1)?, *n.get(i + 2)?])
}
/// Endpoints farther apart than rounding at their coordinate size allows.
fn endpoints_apart(a: Point, b: Point) -> bool {
a.distance(b) > 1e-6 * (1.0 + a.x.hypot(a.y).max(b.x.hypot(b.y)))
}
/// Every face's loops of every body, as one path (filled even-odd).
fn outline(m: &Model) -> Option<Outline> {
let mut o = Outline { path: BezPath::new(), approximated: false, broken: false, ambiguous: false };
// Records visited at every level together: chains shared between records are walked again
// each time.
let mut visits = 0usize;
let mut spend = |n: usize| {
visits = visits.saturating_add(n.max(1));
(visits <= MAX_VISITS).then_some(())
};
for body in m.recs.iter().filter(|r| r.is("body")) {
spend(1)?;
let xf = if body.ptr(2) == -1 { Xf::IDENTITY } else { Xf::read(m.get_is(body.ptr(2), "transform")?)? };
for lump in m.chain(body.ptr(0), "lump", 0, &mut o.broken) {
spend(1)?;
for shell in m.chain(lump.ptr(1), "shell", 0, &mut o.broken) {
spend(1)?;
for face in m.chain(shell.ptr(2), "face", 0, &mut o.broken) {
spend(1)?;
for lp in m.chain(face.ptr(1), "loop", 0, &mut o.broken) {
let ring = m.chain(lp.ptr(1), "coedge", 0, &mut o.broken);
spend(ring.len())?;
let complete = ring.last().is_some_and(|c| c.ptr(0) == lp.ptr(1));
o.broken |= !complete;
let mut bp = BezPath::new();
for c in ring {
let edge = m.get_is(c.ptr(3), "edge")?;
let (seg, ambiguous) = edge_path(m, edge, c.sense_after(3)?, &xf, &mut o.approximated)?;
o.ambiguous |= ambiguous;
if let (Some(end), Some(start)) =
(bp.elements().last().and_then(|e| e.end_point()), seg.elements().first().and_then(|e| e.end_point()))
{
o.broken |= endpoints_apart(end, start);
}
super::entity::append(&mut bp, &seg);
if o.path.elements().len().saturating_add(bp.elements().len()) > super::build::MAX_ELEMENTS {
return None;
}
}
if !bp.elements().is_empty() {
if complete
&& let (Some(end), Some(start)) =
(bp.elements().last().and_then(|e| e.end_point()), bp.elements().first().and_then(|e| e.end_point()))
{
o.broken |= endpoints_apart(end, start);
}
// A loop of one curve ending where it starts is split in two: as one
// segment, its start and end would become one anchor.
if let [seg] = bp.segments().collect::<Vec<_>>()[..]
&& !matches!(seg, PathSeg::Line(_))
{
let (a, b) = seg.subdivide();
bp = BezPath::from_path_segments([a, b].into_iter());
}
bp.close_path();
if o.path.elements().len().saturating_add(bp.elements().len()) > super::build::MAX_ELEMENTS {
return None;
}
o.path.extend(bp);
}
}
}
}
}
}
let ok = !o.path.elements().is_empty() && curve::bounds(&o.path).is_some();
ok.then_some(o)
}
/// A vertex's position.
fn vertex(m: &Model, p: i64) -> Option<P3> {
let v = m.get_is(p, "vertex")?;
let n = m.get_is(v.ptr(1), "point")?.nums();
p3(&n, 0).filter(|p| p.iter().all(|c| c.is_finite()))
}
/// The edge as a coedge runs it (`reversed`: from its end vertex to its start), from the first
/// point.
fn edge_path(m: &Model, edge: &Rec, reversed: bool, xf: &Xf, approximated: &mut bool) -> Option<(BezPath, bool)> {
let (sv, ev) = (vertex(m, edge.ptr(0))?, vertex(m, edge.ptr(1))?);
let closed = edge.ptr(0) == edge.ptr(1);
let (from, to) = if reversed { (ev, sv) } else { (sv, ev) };
// Against the curve's own direction?
let back = edge.sense_after(3)? != reversed;
let drawn = match m.get(edge.ptr(3)) {
// Only -1 means the edge has no curve.
None => {
*approximated |= edge.ptr(3) != -1;
None
}
Some(c) if c.is("straight-curve") => None,
Some(c) => {
let bp = if c.is("ellipse-curve") {
ellipse(c, from, to, closed, back, xf).map(|bp| (bp, false))
} else if c.is("intcurve-curve") {
spline(c, from, to, closed, back, xf)
} else {
None
};
*approximated |= bp.is_none();
bp
}
};
if let Some(bp) = drawn {
return Some(bp);
}
let mut bp = BezPath::new();
bp.move_to(flat(xf.point(from)));
bp.line_to(flat(xf.point(to)));
Some((bp, false))
}
/// An `ellipse-curve` (centre, normal, major axis, ratio) from `from` to `to`; the whole curve
/// when the edge starts and ends at one vertex. It runs counter-clockwise about its normal,
/// clockwise when `back`.
fn ellipse(c: &Rec, from: P3, to: P3, closed: bool, back: bool, xf: &Xf) -> Option<BezPath> {
let n = c.nums();
let (centre, normal, major, ratio) = (p3(&n, 0)?, p3(&n, 3)?, p3(&n, 6)?, *n.get(9)?);
let len = dot(normal, normal).sqrt();
if !(len > 1e-12 && ratio > 0.0 && ratio.is_finite() && dot(major, major) > 1e-24) {
return None;
}
let minor = cross(normal, major).map(|v| v / len * ratio);
let angle = |p: P3| {
let d = sub(p, centre);
(dot(d, minor) / dot(minor, minor)).atan2(dot(d, major) / dot(major, major))
};
let (a, b) = (angle(from), angle(to));
let tau = std::f64::consts::TAU;
let sweep = match (closed, back) {
(true, false) => tau,
(true, true) => -tau,
(false, false) => (b - a).rem_euclid(tau),
(false, true) => -(a - b).rem_euclid(tau),
};
let (o, u, v) = (flat(xf.point(centre)), flat(xf.vector(major)), flat(xf.vector(minor)));
curve::ellipse(Affine::new([u.x, u.y, v.x, v.y, o.x, o.y]), a, sweep)
}
/// An `intcurve-curve`'s B-spline (`nubs`, or `nurbs` with weights): degree, form, the knots
/// with their multiplicities (without the end knots, or with them), the control points.
fn bspline(toks: &[Tok]) -> Option<Spline> {
let at = toks.iter().position(|t| matches!(t, Tok::Word(w) if matches!(w.as_str(), "nubs" | "nurbs" | "nullbs")))?;
let rational = match &toks[at] {
Tok::Word(w) if w == "nurbs" => true,
Tok::Word(w) if w == "nubs" => false,
_ => return None,
};
let num = |i: usize| if let Some(Tok::Num(v)) = toks.get(i) { Some(*v) } else { None };
let degree = num(at + 1).filter(|d| (1.0..=32.0).contains(d))? as usize;
let count = num(at + 3).filter(|n| *n >= 1.0 && *n <= toks.len() as f64)? as usize;
let mut knots = vec![];
let mut i = at + 4;
for _ in 0..count {
let (k, mult) = (num(i)?, num(i + 1)?);
if !(mult >= 1.0 && mult <= (degree + 1) as f64) {
return None;
}
knots.extend(std::iter::repeat_n(k, mult as usize));
i += 2;
}
let stride = if rational { 4 } else { 3 };
let values: Vec<f64> = toks[i.min(toks.len())..].iter().map_while(|t| if let Tok::Num(v) = t { Some(*v) } else { None }).collect();
let available = values.len() / stride;
// The data leaves out the first and last knots; data that keeps them has two points fewer.
let short = (knots.len() + 1).checked_sub(degree)?;
let n = if available >= short {
let (first, last) = (*knots.first()?, *knots.last()?);
knots.insert(0, first);
knots.push(last);
short
} else {
knots.len().checked_sub(degree + 1)?
};
if n == 0 || n > available {
return None;
}
let pts = values.chunks(stride).take(n).map(|c| [c[0], c[1], c[2]]).collect();
let weights = rational.then(|| values.chunks(stride).take(n).map(|c| c[3]).collect());
Some((degree, knots, pts, weights))
}
/// The distinct parameters of a cubic's self-intersection, when both lie on the curve.
fn cubic_crossing(cubic: kurbo::CubicBez) -> Option<(f64, f64)> {
let b = (cubic.p1 - cubic.p0) * 3.0;
let c = (cubic.p2 - cubic.p1) * 3.0 - b;
let d = (cubic.p3 - cubic.p0) - b - c;
let det = c.cross(d);
if det == 0.0 {
return None;
}
// Dividing P(s) - P(t) by s - t gives b + c*u + d*(u*u - v) = 0,
// where u = s + t and v = s*t.
let u = -b.cross(d) / det;
let v = u * u - b.cross(c) / det;
let discriminant = u * u - 4.0 * v;
if !discriminant.is_finite() || discriminant <= 0.0 {
return None;
}
let root = discriminant.sqrt();
let (s, t) = ((u - root) * 0.5, (u + root) * 0.5);
(0.0 <= s && s < t && t <= 1.0).then_some((s, t))
}
/// An `intcurve-curve` from `from` to `to` (the part of its spline between them), the whole
/// ring when the edge starts and ends at one vertex; also whether trimming is ambiguous.
fn spline(c: &Rec, from: P3, to: P3, closed: bool, back: bool, xf: &Xf) -> Option<(BezPath, bool)> {
// The curve's own sense comes before its data.
let open = c.toks.iter().position(|t| *t == Tok::Open)?;
let curve_back = c.toks[..open].contains(&Tok::Sense(true));
let (degree, knots, pts, weights) = bspline(&c.toks[open..])?;
let ctrl: Vec<Point> = pts.into_iter().map(|p| flat(xf.point(p))).collect();
let full = curve::nurbs(degree, &knots, &ctrl, weights.as_deref())?;
let back = back != curve_back;
let segs: Vec<PathSeg> = full.segments().collect();
let (first, last) = (segs.first()?.start(), segs.last()?.end());
let ring = first.distance(last) <= 1e-9 * (1.0 + first.to_vec2().hypot());
let mut lengths = vec![0.0];
for s in &segs {
lengths.push(lengths.last()? + s.arclen(1e-9));
}
let total = *lengths.last()?;
let at = |p: P3| {
let p = flat(xf.point(p));
let near: Vec<_> = segs.iter().enumerate().map(|(i, s)| (s.nearest(p, 1e-9), i)).collect();
let (n, i) = near.iter().min_by(|a, b| a.0.distance_sq.total_cmp(&b.0.distance_sq))?;
let along = |i: usize, t: f64| lengths[i] + segs[i].subsegment(0.0..t).arclen(1e-9);
let tolerance = 1e-6 * (1.0 + p.x.hypot(p.y));
let mut locations: Vec<_> =
near.iter().filter(|(n, i)| !endpoints_apart(p, segs[*i].eval(n.t))).map(|(n, i)| (*i as f64 + n.t, along(*i, n.t))).collect();
for (i, s) in segs.iter().enumerate() {
if let PathSeg::Cubic(cubic) = s
&& let Some((a, b)) = cubic_crossing(*cubic)
&& !endpoints_apart(p, cubic.eval(a))
{
locations.extend([a, b].map(|t| (i as f64 + t, along(i, t))));
}
}
// Nearby ends at a segment joint, or at a closed curve's seam, are one location.
locations.sort_by(|a, b| a.0.total_cmp(&b.0));
locations.dedup_by(|a, b| (a.1 - b.1).abs() <= 4.0 * tolerance);
if ring && locations.len() > 1 && (total - (locations.last()?.1 - locations.first()?.1)).abs() <= 4.0 * tolerance {
locations.pop();
}
Some((*i as f64 + n.t, locations))
};
let mut ambiguous = false;
let part = if closed && ring {
let (_, locations) = at(from)?;
ambiguous = locations.len() > 1;
full
} else {
let bounds = if closed {
let (_, locations) = at(from)?;
if let [a, b] = locations.as_slice() {
Some((a.0, b.0))
} else {
ambiguous = true;
None
}
} else {
let ((ga, a), (gb, b)) = (at(from)?, at(to)?);
ambiguous = a.len() > 1 || b.len() > 1;
Some((ga, gb))
};
if let Some((ga, gb)) = bounds {
let (lo, hi) = if back { (gb, ga) } else { (ga, gb) };
let pieces = if lo <= hi || !ring {
piece(&segs, lo.min(hi), hi.max(lo))
} else {
[piece(&segs, lo, segs.len() as f64), piece(&segs, 0.0, hi)].concat()
};
if pieces.is_empty() {
return None;
}
BezPath::from_path_segments(pieces.into_iter())
} else {
full
}
};
Some((if back { part.reverse_subpaths() } else { part }, ambiguous))
}
/// The parts of `segs` from `lo` to `hi`, counted in segments (2.5: halfway along the third).
fn piece(segs: &[PathSeg], lo: f64, hi: f64) -> Vec<PathSeg> {
let mut out = vec![];
for (i, s) in segs.iter().enumerate() {
let (t0, t1) = ((lo - i as f64).max(0.0), (hi - i as f64).min(1.0));
if t1 > t0 {
out.push(s.subsegment(t0..t1));
}
}
out
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn cubic_crossings_have_two_distinct_parameters() {
let cubic = kurbo::CubicBez::new((36.0, -18.0), (-28.0, 26.0), (-28.0, -26.0), (36.0, 18.0));
let (s, t) = cubic_crossing(cubic).unwrap();
assert!((s - 0.25).abs() < 1e-12 && (t - 0.75).abs() < 1e-12, "{s}, {t}");
let plain = kurbo::CubicBez::new((0.0, 0.0), (30.0, 50.0), (70.0, -50.0), (100.0, 0.0));
assert!(cubic_crossing(plain).is_none());
}
#[test]
fn deciphering_maps_each_character_back_and_drops_the_caret_space() {
// "Ab@_ 7#" ciphered: A→^ (and a space), b→=, @→_, _→@, 7→h, #→|.
assert_eq!(decipher("^ =_@ h|"), "Ab@_ 7#");
}
}
+8 -21
View File
@@ -8,9 +8,10 @@ use kurbo::{BezPath, ParamCurve, ParamCurveDeriv, PathEl, PathSeg, Shape};
use vectorcraft_doc::Justify;
use vectorcraft_geom::{Affine, Point, Vec2};
use craft_dxf::acis;
use craft_dxf::model::{self, EntityRecord, Groups, HatchEdge, HatchPath};
use super::acis;
use super::build::MAX_ELEMENTS;
use super::curve::{self, Vertex};
use super::hatch::{self, Grad, NoPattern};
use super::reader::{aci_paper, point};
@@ -478,26 +479,12 @@ impl Converter {
/// A region as a filled path: its solid-modeler data as text in groups 1 (a line each) and 3
/// (the rest of a long line), or, from DXF 2013 on, binary data kept by handle.
fn region(&mut self, e: &EntityRecord<'_>) -> Option<Geom> {
let g = e.groups();
let own = g.subclass("AcDbModelerGeometry");
let tags = if own.0.is_empty() { g.0 } else { own.0 };
let mut text = String::new();
for t in tags {
match t.code {
1 => {
if !text.is_empty() {
text.push('\n');
}
text.push_str(t.str_ref().unwrap_or_default());
}
3 => text.push_str(t.str_ref().unwrap_or_default()),
_ => {}
}
if text.len() > acis::MAX_BYTES {
return None;
}
}
let outline = if text.trim().is_empty() { acis::from_binary(self.regions.get(&e.record().handle()?)?) } else { acis::from_text(&text) }?;
let text = acis::text_data(e)?;
let outline = if text.trim().is_empty() {
acis::from_binary(self.regions.get(&e.record().handle()?)?, MAX_ELEMENTS)
} else {
acis::from_text(&text, MAX_ELEMENTS)
}?;
if outline.approximated {
self.warn(REGION_CURVES);
}
+2 -65
View File
@@ -1,7 +1,7 @@
//! What the import uses of a drawing, from `craft_dxf::model`: header variables; the layer,
//! linetype and text style tables; the blocks; the entities; the layouts; the image files.
use std::collections::{HashMap, HashSet};
use std::collections::HashMap;
use std::rc::Rc;
use craft_dxf::model::{self, EntityRecord};
@@ -132,7 +132,7 @@ impl<'a> Drawing<'a> {
d.images.entry(h).or_insert(ImageFile { path: def.file, size: def.size });
}
}
d.regions = Rc::new(region_data(&doc));
d.regions = Rc::new(craft_dxf::acis::binary_data(&doc));
for b in doc.blocks {
if b.name.is_empty() {
continue;
@@ -169,69 +169,6 @@ impl<'a> Drawing<'a> {
}
}
/// The binary data of each region in the ACDSDATA section: an `ACDSRECORD` names its entity's
/// handle (320), then holds the bytes (310 chunks) after `2 ASM_Data`, their count in 94.
fn region_data(doc: &model::Document<'_>) -> HashMap<u64, Vec<u8>> {
let records = doc.entities.iter().chain(doc.blocks.iter().flat_map(|b| &b.entities));
let wanted: HashSet<u64> = records.filter(|e| e.kind == "REGION").filter_map(|e| e.record().handle()).collect();
let mut out = HashMap::new();
if wanted.is_empty() {
return out;
}
for section in doc.other_sections.iter().filter(|s| s.name.eq_ignore_ascii_case("ACDSDATA")) {
for r in model::records(section.tags).into_iter().filter(|r| r.kind == "ACDSRECORD") {
let Some(handle) = r.tags.iter().find(|t| t.code == 320).and_then(|t| model::parse_handle(&t.str())) else { continue };
if !wanted.contains(&handle) || out.contains_key(&handle) {
continue;
}
let Some(at) = r.tags.iter().position(|t| t.code == 2 && t.str_ref().is_some_and(|s| s.trim() == "ASM_Data")) else { continue };
let data = r.tags.get(at + 1..).unwrap_or_default();
let size = data.iter().find(|t| t.code == 94).and_then(|t| usize::try_from(t.i64()).ok());
let mut bytes = Vec::new();
let mut whole = true;
for t in data.iter().filter(|t| t.code == 310) {
whole = hex_bytes(t.str_ref().unwrap_or_default().trim(), &mut bytes);
if !whole || bytes.len() > super::acis::MAX_BYTES {
break;
}
}
if !whole {
continue;
}
if let Some(bytes) = sized_region(bytes, size, super::acis::MAX_BYTES) {
out.insert(handle, bytes);
}
}
}
out
}
/// A region's `bytes` cut to its declared `size`, or `None` when the record declares more bytes
/// than it holds (the data was cut short or damaged) or the data is longer than `limit`.
pub(super) fn sized_region(mut bytes: Vec<u8>, size: Option<usize>, limit: usize) -> Option<Vec<u8>> {
match size {
Some(n) if n <= bytes.len() => bytes.truncate(n),
Some(_) => return None,
None => {}
}
(bytes.len() <= limit).then_some(bytes)
}
/// Hex digits' bytes, two digits each, onto `out`. False when `hex` has a character that is not
/// a hex digit or an odd number of digits.
pub(super) fn hex_bytes(hex: &str, out: &mut Vec<u8>) -> bool {
let digit = |c: u8| (c as char).to_digit(16).and_then(|d| u8::try_from(d).ok());
let (pairs, rest) = hex.as_bytes().as_chunks::<2>();
if !rest.is_empty() {
return false;
}
for pair in pairs {
let (Some(hi), Some(lo)) = (digit(pair[0]), digit(pair[1])) else { return false };
out.push(hi << 4 | lo);
}
true
}
pub(crate) fn point(p: model::Point) -> Point {
Point::new(p[0], p[1])
}
-14
View File
@@ -327,20 +327,6 @@ fn binary_data_in_the_acdsdata_section_reads_alike() {
short[7].1 = (bytes.len() + 1).to_string();
let r = import(&drawing("AC1032", &e, &short), &points()).unwrap();
assert!(r.warnings.iter().any(|w| w.contains("1 REGION")), "{:?}", r.warnings);
// A chunk with an odd number of digits or a character that is not a hex digit fails to read.
let mut out = Vec::new();
assert!(super::reader::hex_bytes("0aFf", &mut out));
assert_eq!(out, [0x0A, 0xFF]);
for hex in ["0aF", "0aZZ", "0 aF"] {
assert!(!super::reader::hex_bytes(hex, &mut Vec::new()), "{hex}");
}
// Data longer than the limit is left out, unless its declared size cuts it within the limit.
let sized = |len: usize, size: Option<usize>| super::reader::sized_region(vec![7; len], size, 8).map(|b| b.len());
assert_eq!(sized(10, None), None);
assert_eq!(sized(10, Some(9)), None);
assert_eq!(sized(10, Some(11)), None);
assert_eq!(sized(10, Some(5)), Some(5));
assert_eq!(sized(8, None), Some(8));
}
/// A drawing the export writes (R2000, millimetres) with a region added to its entities.
-2
View File
@@ -27,8 +27,6 @@
#![doc(test(attr(deny(unsafe_code))))]
mod aci;
// Temporary until storytold/craft-libs#5381 merges and the craft-libs pin moves past it.
mod blocks_compat;
pub mod dwg;
#[cfg(test)]
mod expansion_test;
+4 -11
View File
@@ -15,9 +15,7 @@ use vectorcraft_geom::{Affine, BezPath, FillRule, PathData, Point, Rect, Vec2};
use crate::aci::nearest_aci;
use crate::{CAP_HEIGHT, ColorDepth, DxfImage, DxfOptions, DxfOutput, MAX_NEST, Preserve, RasterFormat};
// Block and the INSERT writer come from craft-libs#5381 once it merges; see `blocks_compat`.
use crate::blocks_compat::Block;
use craft_dxf::drawing::{Codes, Drawing, EntityStyle, Handle, ImageDef, Layer, LineType, STANDARD_STYLE, fixed};
use craft_dxf::drawing::{Block, Codes, Drawing, EntityStyle, Handle, ImageDef, Layer, LineType, STANDARD_STYLE, fixed};
/// Curves are flattened to within this distance (points) where DXF needs straight segments
/// (hatch boundaries, R12 polylines).
@@ -597,7 +595,7 @@ impl<'a> Scene<'a> {
linetypes: self.linetypes,
styles: self.styles,
images: self.images,
blocks: Vec::new(),
blocks: self.blocks,
entities: self.e.into_string(),
extents: self.extents.unwrap_or(limits),
limits,
@@ -605,12 +603,7 @@ impl<'a> Scene<'a> {
metric: matches!(self.o.unit, Unit::Millimeters | Unit::Centimeters | Unit::Meters),
next: self.next,
};
DxfOutput {
bytes: crate::blocks_compat::write(drawing, &self.blocks).into_bytes(),
images: self.files,
warnings: self.warnings,
setting_notes: self.setting_notes,
}
DxfOutput { bytes: drawing.write().into_bytes(), images: self.files, warnings: self.warnings, setting_notes: self.setting_notes }
}
/// Note `w`, once, about something of the document that the drawing leaves out or that reaches
@@ -789,7 +782,7 @@ impl<'a> Scene<'a> {
let base = symbol_name(n.name.as_deref().unwrap_or_default(), long);
let base = if base.is_empty() { symbol_name("Group", long) } else { base };
let name = self.block_names.unique(&base, if long { 255 } else { 31 });
crate::blocks_compat::insert(&mut self.e, insert, self.owner, &self.layer, &name);
self.e.insert(insert, self.owner, &self.layer, &name);
self.blocks.push(Block { name, record, begin, end, entities });
}
+4 -4
View File
@@ -241,28 +241,28 @@ pub fn effect_catalog() -> Vec<EffectInfo> {
REVOLVE,
"Revolve…",
&["Effect", "3D and Materials"],
"{angle: degrees (0..360, 360), offset: pt (0..100000, 0), edge: left|right, rotationX: degrees (0), rotationY: degrees (0), rotationZ: degrees (0), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), perspective: % (0..100; the earlier form, read as the perspectiveAngle that shows the same view), segments: integer (8..128, 64), shade: bool (true), lightColor: #rrggbb (white, #ffffff; legacy directional light color), lights: null or array of 1..10 objects (color: #rrggbb, intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, softness: % 0..100, behind: bool; overrides the single-light fields; ambient is shared), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 80), lightSoftness: % (0..100, 0; how far round the object the light reaches, and how much it blurs the shadow), ambient: % (0..200, 25; Ambient Light), lightAzimuth: degrees (the earlier form: with lightElevation, read as the lightRotation, lightHeight and lightBehind of the same light), lightElevation: degrees (the earlier form, with lightAzimuth), shadow: bool (false; in the shaded faces the first light casts a shadow, black at 50% times the art's opacity, hard-edged at the first light's softness 0 and blurred above it; with render mode rendered, every light with an intensity above 0 casts shadows in the image), shadowPosition: behind|below (behind; behind: on a plane square to the view, below: on the floor under the object, turned with it), shadowDistance: % (0..100, 0; how far the plane is from the object, as a share of its largest size), shadowBounds: % (10..400, 100; how far the plane reaches: at 100 it is four times the object's largest size across), cap: bool (true: solid, closing circular ends of open profiles and a partial sweep's cut sides; false: hollow), expandVisibleOnly: bool (true, trim covered opaque solid surfaces only on Expand Appearance; surfaces with graphics keep every face), graphics: array of 0..64 objects ([]; the 3D and Materials panel's Graphics on the swept side, see threeD.mapGraphic: symbol: name of a document symbol, face: front (the side), x: pt (0; the offset of the graphic's center from the middle of the side, around the axis: the angle times the profile's distance from the axis at that point), y: pt (0; along the profile, toward its lower end), scale: % (1..10000, 100), rotation: degrees (-360..360, 0; counterclockwise); wrapped around the side at its own size, so it reaches farther around where the profile comes nearer the axis, shaded with it and drawn only where the side's outside faces the viewer; a full turn cuts it at the back; nothing on the caps), material: object ({roughness: 1, metallic: 0}; the 3D and Materials panel's Materials › Properties: roughness: 0..1 (1; lower values give a smaller, brighter highlight), metallic: 0..1 (0; higher values tint the reflected light with the paint and darken the diffuse light); a key left out keeps its default, and any other key or value is an error; the default draws as before), render: object ({mode: shaded}; mode: shaded|wireframe|rendered, wireframe draws the edges of the faces the effect draws, each once, stroked 0.5 pt black with round joins, with no fill, shadow or graphics, whatever the opacity of the fills, strokes and group members, while the effect stays live; the stroke is VectorCraft's own; rendered draws the solid as one image with a depth buffer, lit by every light; with shadow on, every light with an intensity above 0 casts shadows on the solid and on the shadow plane in the image, and with it off none does; it draws the shaded faces when the image can't be made or a later geometry effect reshapes paths but leaves images unchanged; quality: low|medium|high (medium; 1, 2 x 2 or 3 x 3 samples a pixel, VectorCraft's own), resolution: null or ppi 1..2400 (null: Document Raster Effects Settings), background: transparent|white (transparent); any other key or value is an error)}. Shaded surfaces use smooth vector gradients automatically; intersecting profiles use approximate painter visibility.",
"{angle: degrees (0..360, 360), offset: pt (0..100000, 0), edge: left|right, rotationX: degrees (0), rotationY: degrees (0), rotationZ: degrees (0), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), perspective: % (0..100; the earlier form, read as the perspectiveAngle that shows the same view), segments: integer (8..128, 64), shade: bool (true), lightColor: #rrggbb (white, #ffffff; legacy directional light color), lights: null or array of 1..10 objects (color: #rrggbb, intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, softness: % 0..100, behind: bool; overrides the single-light fields; ambient is shared), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 80), lightSoftness: % (0..100, 0; how far round the object the light reaches, and how much it blurs the shadow), ambient: % (0..200, 25; Ambient Light), lightAzimuth: degrees (the earlier form: with lightElevation, read as the lightRotation, lightHeight and lightBehind of the same light), lightElevation: degrees (the earlier form, with lightAzimuth), shadow: bool (false; in the shaded faces the first light casts a shadow, black at 50% times the art's opacity, hard-edged at the first light's softness 0 and blurred above it; with render mode rendered, every light with an intensity above 0 casts shadows in the image), shadowPosition: behind|below (behind; behind: on a plane square to the view, below: on the floor under the object, turned with it), shadowDistance: % (0..100, 0; how far the plane is from the object, as a share of its largest size), shadowBounds: % (10..400, 100; how far the plane reaches: at 100 it is four times the object's largest size across), cap: bool (true: solid, closing circular ends of open profiles and a partial sweep's cut sides; false: hollow), expandVisibleOnly: bool (true, trim covered opaque solid surfaces only on Expand Appearance; surfaces with graphics keep every face), graphics: array of 0..64 objects ([]; the 3D and Materials panel's Graphics on the swept side, see threeD.mapGraphic: symbol: name of a document symbol, face: front (the side), x: pt (0; the offset of the graphic's center from the middle of the side, around the axis: the angle times the profile's distance from the axis at that point), y: pt (0; along the profile, toward its lower end), scale: % (1..10000, 100), rotation: degrees (-360..360, 0; counterclockwise); wrapped around the side at its own size, so it reaches farther around where the profile comes nearer the axis, shaded with it and drawn only where the side's outside faces the viewer; a full turn cuts it at the back; nothing on the caps), material: object ({roughness: 1, metallic: 0}; the 3D and Materials panel's Materials › Properties: roughness: 0..1 (1; lower values give a smaller, brighter highlight), metallic: 0..1 (0; higher values tint the reflected light with the paint and darken the diffuse light); a key left out keeps its default, and any other key or value is an error; the default draws as before), render: object ({mode: shaded}; mode: shaded|wireframe|rendered, wireframe draws the edges of the faces the effect draws, each once, stroked 0.5 pt black with round joins, with no fill, shadow or graphics, whatever the opacity of the fills, strokes and group members, while the effect stays live; the stroke is VectorCraft's own; rendered draws the solid as one image with a depth buffer, lit by every light; with shadow on, every light with an intensity above 0 casts shadows on the solid and on the shadow plane in the image, and with it off none does; it draws the shaded faces when the image can't be made or a later geometry effect reshapes paths but leaves images unchanged; quality: low|medium|high (medium; 1, 2 x 2 or 3 x 3 samples a pixel, VectorCraft's own), resolution: null or ppi 1..2400 (null: Document Raster Effects Settings), background: transparent|white (transparent), colorModel: document|grayscale|bitmap (document: RGB pixels in every document, which a CMYK document's PDF export converts as it converts raster effect images; grayscale: the Rec. 709 luma of each pixel; bitmap: two pixel values, black and white with background white, or black and transparent with background transparent, where a dark pixel at least half covered is black; applied after the background; grayscale and bitmap images are stored as 8-bit gray PNGs, with alpha unless every pixel is opaque); any other key or value is an error)}. Shaded surfaces use smooth vector gradients automatically; intersecting profiles use approximate painter visibility.",
json!({"angle":360.0,"offset":0.0,"edge":"left","rotationX":0.0,"rotationY":0.0,"rotationZ":0.0,"perspectiveAngle":0.0,"segments":64,"shade":true,"lightColor":"#ffffff","lights":null,"lightRotation":125.26438968275465,"lightHeight":30.0,"lightBehind":false,"lightIntensity":80.0,"lightSoftness":0.0,"ambient":25.0,"shadow":false,"shadowPosition":"behind","shadowDistance":0.0,"shadowBounds":100.0,"cap":true,"expandVisibleOnly":true,"graphics":[],"material":{"roughness":1.0,"metallic":0.0},"render":{"mode":"shaded"}}),
),
g(
EXTRUDE,
"Extrude & Bevel…",
&["Effect", "3D and Materials"],
"{depth: pt (0..2000, 50), twist: degrees (0..360, 0; the back turned against the front), taper: % (1..100, 100; the back's size), cap: bool (true: solid; false: hollow), bevel: none|classic|rounded|cove|step|ogee (none; or custom, a bevel of the user's own drawn by bevelProfile), bevelWidth: pt (0..1000, 4), bevelHeight: pt (0..1000, 4), bevelRepeat: integer (1..32, 1), bevelSpace: % (0..90, 0; flat between repeats), bevelInside: bool (false: added around the shape; true: carved into it), bevelBothSides: bool (false), bevelName: string (a custom bevel's name), bevelProfile: [[x, y], …] (a custom bevel's 2 to 64 points, shares 0..1 of the width and height from [0, 0] at the cap's edge to [1, 1] at the side wall, joined by straight lines; effect.apply and effect.setParams also take bevel {custom: name}, a bevel of the bevels file (threeD.bevels.list), and store it as bevel custom with its bevelName and bevelProfile), rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), perspective: % (0..100; the earlier form, read as the perspectiveAngle that shows the same view), shade: bool (true), lightColor: #rrggbb (white, #ffffff; legacy directional light color), lights: null or array of 1..10 objects (color: #rrggbb, intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, softness: % 0..100, behind: bool; overrides the single-light fields; ambient is shared), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 80), lightSoftness: % (0..100, 0; how far round the object the light reaches, and how much it blurs the shadow), ambient: % (0..200, 25; Ambient Light), lightAzimuth: degrees (the earlier form: with lightElevation, read as the lightRotation, lightHeight and lightBehind of the same light), lightElevation: degrees (the earlier form, with lightAzimuth), shadow: bool (false; in the shaded faces the first light casts a shadow, black at 50% times the art's opacity, hard-edged at the first light's softness 0 and blurred above it; with render mode rendered, every light with an intensity above 0 casts shadows in the image), shadowPosition: behind|below (behind; behind: on a plane square to the view, below: on the floor under the object, turned with it), shadowDistance: % (0..100, 0; how far the plane is from the object, as a share of its largest size), shadowBounds: % (10..400, 100; how far the plane reaches: at 100 it is four times the object's largest size across), graphics: array of 0..64 objects ([]; the 3D and Materials panel's Graphics on the caps and the side, see threeD.mapGraphic: symbol: name of a document symbol, face: front|back|side (front; the back reads left to right as seen from behind; side is the walls and bevels), x: pt (0; the offset of the graphic's center from the center of the object's bounds, in the face's own plane; on the side from the middle of the side unrolled flat, along the outline, clockwise from its top), y: pt (0; on the side from the front toward the back), scale: % (1..10000, 100; of the symbol's own size), rotation: degrees (-360..360, 0; counterclockwise); drawn turned, foreshortened and shaded with the face and clipped to it: on a cap of a solid object only, and on the side of a solid or hollow object wrapped around it and drawn only where its outside faces the viewer), material: object ({roughness: 1, metallic: 0}; as Revolve's), render: object ({mode: shaded}; mode: shaded|wireframe|rendered, quality, resolution and background, as Revolve's)}. The front face is the art, extruded backwards about the centre of its bounds; painted with the top fill (else the top stroke).",
"{depth: pt (0..2000, 50), twist: degrees (0..360, 0; the back turned against the front), taper: % (1..100, 100; the back's size), cap: bool (true: solid; false: hollow), bevel: none|classic|rounded|cove|step|ogee (none; or custom, a bevel of the user's own drawn by bevelProfile), bevelWidth: pt (0..1000, 4), bevelHeight: pt (0..1000, 4), bevelRepeat: integer (1..32, 1), bevelSpace: % (0..90, 0; flat between repeats), bevelInside: bool (false: added around the shape; true: carved into it), bevelBothSides: bool (false), bevelName: string (a custom bevel's name), bevelProfile: [[x, y], …] (a custom bevel's 2 to 64 points, shares 0..1 of the width and height from [0, 0] at the cap's edge to [1, 1] at the side wall, joined by straight lines; effect.apply and effect.setParams also take bevel {custom: name}, a bevel of the bevels file (threeD.bevels.list), and store it as bevel custom with its bevelName and bevelProfile), rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), perspective: % (0..100; the earlier form, read as the perspectiveAngle that shows the same view), shade: bool (true), lightColor: #rrggbb (white, #ffffff; legacy directional light color), lights: null or array of 1..10 objects (color: #rrggbb, intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, softness: % 0..100, behind: bool; overrides the single-light fields; ambient is shared), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 80), lightSoftness: % (0..100, 0; how far round the object the light reaches, and how much it blurs the shadow), ambient: % (0..200, 25; Ambient Light), lightAzimuth: degrees (the earlier form: with lightElevation, read as the lightRotation, lightHeight and lightBehind of the same light), lightElevation: degrees (the earlier form, with lightAzimuth), shadow: bool (false; in the shaded faces the first light casts a shadow, black at 50% times the art's opacity, hard-edged at the first light's softness 0 and blurred above it; with render mode rendered, every light with an intensity above 0 casts shadows in the image), shadowPosition: behind|below (behind; behind: on a plane square to the view, below: on the floor under the object, turned with it), shadowDistance: % (0..100, 0; how far the plane is from the object, as a share of its largest size), shadowBounds: % (10..400, 100; how far the plane reaches: at 100 it is four times the object's largest size across), graphics: array of 0..64 objects ([]; the 3D and Materials panel's Graphics on the caps and the side, see threeD.mapGraphic: symbol: name of a document symbol, face: front|back|side (front; the back reads left to right as seen from behind; side is the walls and bevels), x: pt (0; the offset of the graphic's center from the center of the object's bounds, in the face's own plane; on the side from the middle of the side unrolled flat, along the outline, clockwise from its top), y: pt (0; on the side from the front toward the back), scale: % (1..10000, 100; of the symbol's own size), rotation: degrees (-360..360, 0; counterclockwise); drawn turned, foreshortened and shaded with the face and clipped to it: on a cap of a solid object only, and on the side of a solid or hollow object wrapped around it and drawn only where its outside faces the viewer), material: object ({roughness: 1, metallic: 0}; as Revolve's), render: object ({mode: shaded}; mode: shaded|wireframe|rendered, quality, resolution, background and colorModel, as Revolve's)}. The front face is the art, extruded backwards about the centre of its bounds; painted with the top fill (else the top stroke).",
json!({"depth":50.0,"twist":0.0,"taper":100.0,"cap":true,"bevel":"none","bevelWidth":4.0,"bevelHeight":4.0,"bevelRepeat":1,"bevelSpace":0.0,"bevelInside":false,"bevelBothSides":false,"rotationX":-21.88,"rotationY":-23.4,"rotationZ":9.06,"perspectiveAngle":0.0,"shade":true,"lightColor":"#ffffff","lights":null,"lightRotation":125.26438968275465,"lightHeight":30.0,"lightBehind":false,"lightIntensity":80.0,"lightSoftness":0.0,"ambient":25.0,"shadow":false,"shadowPosition":"behind","shadowDistance":0.0,"shadowBounds":100.0,"graphics":[],"material":{"roughness":1.0,"metallic":0.0},"render":{"mode":"shaded"}}),
),
g(
INFLATE,
"Inflate…",
&["Effect", "3D and Materials"],
"{depth: pt (0..2000, 0; flat depth between front and back), twist: degrees (0..360, 0; the back turned against the front), taper: % (1..100, 100; the back's size), cap: bool (true: solid; false: no back, a shell open behind), volume: % (0..100, 50; 50 rounds the edge like a half sphere), bothSides: bool (false: flat back), rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), perspective: % (0..100; the earlier form, read as the perspectiveAngle that shows the same view), shade: bool (true), lightColor: #rrggbb (white, #ffffff; legacy directional light color), lights: null or array of 1..10 objects (color: #rrggbb, intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, softness: % 0..100, behind: bool; overrides the single-light fields; ambient is shared), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 80), lightSoftness: % (0..100, 0; how far round the object the light reaches, and how much it blurs the shadow), ambient: % (0..200, 25; Ambient Light), lightAzimuth: degrees (the earlier form: with lightElevation, read as the lightRotation, lightHeight and lightBehind of the same light), lightElevation: degrees (the earlier form, with lightAzimuth), shadow: bool (false; in the shaded faces the first light casts a shadow, black at 50% times the art's opacity, hard-edged at the first light's softness 0 and blurred above it; with render mode rendered, every light with an intensity above 0 casts shadows in the image), shadowPosition: behind|below (behind; behind: on a plane square to the view, below: on the floor under the object, turned with it), shadowDistance: % (0..100, 0; how far the plane is from the object, as a share of its largest size), shadowBounds: % (10..400, 100; how far the plane reaches: at 100 it is four times the object's largest size across), graphics: array of 0..64 objects ([]; the 3D and Materials panel's Graphics on the puffed front and back, see threeD.mapGraphic: symbol: name of a document symbol, face: front|back (front; the back reads left to right as seen from behind and takes graphics with bothSides and cap on), x: pt (0; the offset of the graphic's center from the center of the object's bounds, in the art's plane), y: pt (0), scale: % (1..10000, 100; of the symbol's own size), rotation: degrees (-360..360, 0; counterclockwise); carried straight out from the art's plane onto the puffed face, twist and taper turning and shrinking the back's with it, shaded with the surface and drawn only where its outside faces the viewer), material: object ({roughness: 1, metallic: 0}; as Revolve's), render: object ({mode: shaded}; mode: shaded|wireframe|rendered, quality, resolution and background, as Revolve's)}. Painted with the top fill (else the top stroke).",
"{depth: pt (0..2000, 0; flat depth between front and back), twist: degrees (0..360, 0; the back turned against the front), taper: % (1..100, 100; the back's size), cap: bool (true: solid; false: no back, a shell open behind), volume: % (0..100, 50; 50 rounds the edge like a half sphere), bothSides: bool (false: flat back), rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), perspective: % (0..100; the earlier form, read as the perspectiveAngle that shows the same view), shade: bool (true), lightColor: #rrggbb (white, #ffffff; legacy directional light color), lights: null or array of 1..10 objects (color: #rrggbb, intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, softness: % 0..100, behind: bool; overrides the single-light fields; ambient is shared), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 80), lightSoftness: % (0..100, 0; how far round the object the light reaches, and how much it blurs the shadow), ambient: % (0..200, 25; Ambient Light), lightAzimuth: degrees (the earlier form: with lightElevation, read as the lightRotation, lightHeight and lightBehind of the same light), lightElevation: degrees (the earlier form, with lightAzimuth), shadow: bool (false; in the shaded faces the first light casts a shadow, black at 50% times the art's opacity, hard-edged at the first light's softness 0 and blurred above it; with render mode rendered, every light with an intensity above 0 casts shadows in the image), shadowPosition: behind|below (behind; behind: on a plane square to the view, below: on the floor under the object, turned with it), shadowDistance: % (0..100, 0; how far the plane is from the object, as a share of its largest size), shadowBounds: % (10..400, 100; how far the plane reaches: at 100 it is four times the object's largest size across), graphics: array of 0..64 objects ([]; the 3D and Materials panel's Graphics on the puffed front and back, see threeD.mapGraphic: symbol: name of a document symbol, face: front|back (front; the back reads left to right as seen from behind and takes graphics with bothSides and cap on), x: pt (0; the offset of the graphic's center from the center of the object's bounds, in the art's plane), y: pt (0), scale: % (1..10000, 100; of the symbol's own size), rotation: degrees (-360..360, 0; counterclockwise); carried straight out from the art's plane onto the puffed face, twist and taper turning and shrinking the back's with it, shaded with the surface and drawn only where its outside faces the viewer), material: object ({roughness: 1, metallic: 0}; as Revolve's), render: object ({mode: shaded}; mode: shaded|wireframe|rendered, quality, resolution, background and colorModel, as Revolve's)}. Painted with the top fill (else the top stroke).",
json!({"depth":0.0,"twist":0.0,"taper":100.0,"cap":true,"volume":50.0,"bothSides":false,"rotationX":-21.88,"rotationY":-23.4,"rotationZ":9.06,"perspectiveAngle":0.0,"shade":true,"lightColor":"#ffffff","lights":null,"lightRotation":125.26438968275465,"lightHeight":30.0,"lightBehind":false,"lightIntensity":80.0,"lightSoftness":0.0,"ambient":25.0,"shadow":false,"shadowPosition":"behind","shadowDistance":0.0,"shadowBounds":100.0,"graphics":[],"material":{"roughness":1.0,"metallic":0.0},"render":{"mode":"shaded"}}),
),
g(
ROTATE,
"Rotate…",
&["Effect", "3D and Materials"],
"{rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), perspective: % (0..100; the earlier form, read as the perspectiveAngle that shows the same view), shade: bool (true), lightColor: #rrggbb (white, #ffffff; legacy directional light color), lights: null or array of 1..10 objects (color: #rrggbb, intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, softness: % 0..100, behind: bool; overrides the single-light fields; ambient is shared), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 80), lightSoftness: % (0..100, 0; how far round the object the light reaches, and how much it blurs the shadow), ambient: % (0..200, 25; Ambient Light), lightAzimuth: degrees (the earlier form: with lightElevation, read as the lightRotation, lightHeight and lightBehind of the same light), lightElevation: degrees (the earlier form, with lightAzimuth), shadow: bool (false; in the shaded faces the first light casts a shadow, black at 50% times the art's opacity, hard-edged at the first light's softness 0 and blurred above it; with render mode rendered, every light with an intensity above 0 casts shadows in the image), shadowPosition: behind|below (behind; behind: on a plane square to the view, below: on the floor under the object, turned with it), shadowDistance: % (0..100, 0; how far the plane is from the object, as a share of its largest size), shadowBounds: % (10..400, 100; how far the plane reaches: at 100 it is four times the object's largest size across), graphics: array of 0..64 objects ([]; the 3D and Materials panel's Graphics on the plane, as Extrude & Bevel's, with face front only), material: object ({roughness: 1, metallic: 0}; as Revolve's), render: object ({mode: shaded}; mode: shaded|wireframe|rendered, quality, resolution and background, as Revolve's; rendered mode checks the paint of every fill and stroke)}. Turns the flat art in 3D about the centre of its bounds; every fill and stroke keeps its paint, shaded as one plane.",
"{rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), perspective: % (0..100; the earlier form, read as the perspectiveAngle that shows the same view), shade: bool (true), lightColor: #rrggbb (white, #ffffff; legacy directional light color), lights: null or array of 1..10 objects (color: #rrggbb, intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, softness: % 0..100, behind: bool; overrides the single-light fields; ambient is shared), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 80), lightSoftness: % (0..100, 0; how far round the object the light reaches, and how much it blurs the shadow), ambient: % (0..200, 25; Ambient Light), lightAzimuth: degrees (the earlier form: with lightElevation, read as the lightRotation, lightHeight and lightBehind of the same light), lightElevation: degrees (the earlier form, with lightAzimuth), shadow: bool (false; in the shaded faces the first light casts a shadow, black at 50% times the art's opacity, hard-edged at the first light's softness 0 and blurred above it; with render mode rendered, every light with an intensity above 0 casts shadows in the image), shadowPosition: behind|below (behind; behind: on a plane square to the view, below: on the floor under the object, turned with it), shadowDistance: % (0..100, 0; how far the plane is from the object, as a share of its largest size), shadowBounds: % (10..400, 100; how far the plane reaches: at 100 it is four times the object's largest size across), graphics: array of 0..64 objects ([]; the 3D and Materials panel's Graphics on the plane, as Extrude & Bevel's, with face front only), material: object ({roughness: 1, metallic: 0}; as Revolve's), render: object ({mode: shaded}; mode: shaded|wireframe|rendered, quality, resolution, background and colorModel, as Revolve's; rendered mode checks the paint of every fill and stroke)}. Turns the flat art in 3D about the centre of its bounds; every fill and stroke keeps its paint, shaded as one plane.",
json!({"rotationX":-21.88,"rotationY":-23.4,"rotationZ":9.06,"perspectiveAngle":0.0,"shade":true,"lightColor":"#ffffff","lights":null,"lightRotation":125.26438968275465,"lightHeight":30.0,"lightBehind":false,"lightIntensity":80.0,"lightSoftness":0.0,"ambient":25.0,"shadow":false,"shadowPosition":"behind","shadowDistance":0.0,"shadowBounds":100.0,"graphics":[],"material":{"roughness":1.0,"metallic":0.0},"render":{"mode":"shaded"}}),
),
g(
+3 -3
View File
@@ -102,9 +102,9 @@ pub use revolve::{
pub use solids::rendered::{rendered_warning, three_d_bounds_art_in};
pub use solids::{
BEVEL_NAME, BEVEL_PROFILE, CLASSIC_EXTRUDE, CLASSIC_ROTATE, EXTRUDE, GRAPHICS, GraphicFrame, INFLATE, MATERIAL, MAX_GRAPHICS, MappedGraphic,
MeshGraphics, RENDER, RENDER_BACKGROUNDS, RENDER_MODES, RENDER_QUALITIES, ROTATE, ROTATE_SURFACES, ROTATION_PRESETS, RenderSettings,
SHADING_COLORS, SOLIDS, SolidMesh, THREE_D_TYPES, classic_extrude_options, classic_shading, extrude_options, graphic_bounds, graphic_frame,
graphic_symbols, has_solid, inflate_options, is_classic_three_d, is_three_d, mapped_graphics, mesh_graphics_art, missing_symbol,
MeshGraphics, RENDER, RENDER_BACKGROUNDS, RENDER_COLOR_MODELS, RENDER_MODES, RENDER_QUALITIES, ROTATE, ROTATE_SURFACES, ROTATION_PRESETS,
RenderSettings, SHADING_COLORS, SOLIDS, SolidMesh, THREE_D_TYPES, classic_extrude_options, classic_shading, extrude_options, graphic_bounds,
graphic_frame, graphic_symbols, has_solid, inflate_options, is_classic_three_d, is_three_d, mapped_graphics, mesh_graphics_art, missing_symbol,
names_graphic_symbol, rename_graphic_symbol, rename_graphic_symbol_in, render_settings, rendered, renders_image, renders_wireframe, solid_art,
solid_art_drawn_in, solid_art_in, takes_graphics, three_d_meshes, three_d_meshes_in, three_d_meshes_of, three_d_meshes_of_in, three_d_params_as,
three_d_wireframe_in, validate_solid, validate_solid_in, validate_three_d, validate_three_d_at, validate_three_d_at_in, validate_three_d_in,
+2 -2
View File
@@ -42,8 +42,8 @@ pub(crate) mod shadow;
pub(crate) mod wireframe;
pub use wireframe::{
RENDER, RENDER_BACKGROUNDS, RENDER_MODES, RENDER_QUALITIES, RenderSettings, render_settings, renders_image, renders_wireframe,
three_d_wireframe_in,
RENDER, RENDER_BACKGROUNDS, RENDER_COLOR_MODELS, RENDER_MODES, RENDER_QUALITIES, RenderSettings, render_settings, renders_image,
renders_wireframe, three_d_wireframe_in,
};
pub mod rendered;
+45 -9
View File
@@ -7,7 +7,7 @@ use std::io::Cursor;
use std::sync::Arc;
use craft_raster3d::{Limits, Scene, Vertex, srgb_to_linear, try_encode, try_render_cpu, try_shadow_maps};
use vectorcraft_doc::{ImageBlob, ImageObject, Node, NodeId, NodeKind};
use vectorcraft_doc::{ImageBlob, ImageObject, Node, NodeId, NodeKind, RasterColorModel};
use vectorcraft_geom::{Affine, Rect};
use vectorcraft_three_d::{Light, MeshProjection};
@@ -149,7 +149,8 @@ pub(crate) fn with_receiver(
}
/// A rendered image: `cols` × `rows` straight-alpha sRGB RGBA8 pixels covering `rect` on the page,
/// made with `samples` × `samples` samples a pixel.
/// made with `samples` × `samples` samples a pixel. `gray` when the color model is Grayscale or
/// Bitmap: every pixel's red, green and blue are equal, and the image is stored as a gray PNG.
#[derive(Clone, Debug, PartialEq)]
pub struct Rendered {
pub rect: Rect,
@@ -157,6 +158,7 @@ pub struct Rendered {
pub rows: u32,
pub samples: u32,
pub pixels: Vec<u8>,
pub gray: bool,
}
/// The margin, as a share of the depth range, the solids' nearest and farthest points keep from the
@@ -197,12 +199,33 @@ pub fn render(
.iter()
.flat_map(|p| {
let p = if settings.white { [p[0] + 1.0 - p[3], p[1] + 1.0 - p[3], p[2] + 1.0 - p[3], 1.0] } else { *p };
let a = p[3].clamp(0.0, 1.0);
let straight = |c: f32| if a > 0.0 { (c / a).clamp(0.0, 1.0) } else { 0.0 };
[straight(p[0]), straight(p[1]), straight(p[2]), a].map(|c| (c * 255.0).round() as u8)
color_model_pixel(p, settings.color_model, settings.white)
})
.collect();
Ok(Rendered { rect, cols, rows, samples: k, pixels })
Ok(Rendered { rect, cols, rows, samples: k, pixels, gray: settings.color_model != RasterColorModel::Document })
}
/// Premultiplied sRGB float pixel `p` as a straight RGBA8 pixel in color model `model`, `white`
/// when `p` is already on the white background. Grayscale and Bitmap map the straight color before
/// the coverage is rounded, so an edge pixel takes the gray or the black or white of the surface it
/// covers. Bitmap on a transparent background is black and transparent: a dark pixel at least half
/// covered is opaque black, and every other pixel is transparent.
fn color_model_pixel(p: [f32; 4], model: RasterColorModel, white: bool) -> [u8; 4] {
let a = p[3].clamp(0.0, 1.0);
let straight = |c: f32| if a > 0.0 { (c / a).clamp(0.0, 1.0) } else { 0.0 };
if model == RasterColorModel::Document {
return [straight(p[0]), straight(p[1]), straight(p[2]), a].map(|c| (c * 255.0).round() as u8);
}
let alpha = (a * 255.0).round() as u8;
if alpha == 0 {
return [0; 4];
}
let luma = 0.2126 * straight(p[0]) + 0.7152 * straight(p[1]) + 0.0722 * straight(p[2]);
if model == RasterColorModel::Bitmap && !white {
return if alpha >= 128 && luma < 0.5 { [0, 0, 0, 255] } else { [0; 4] };
}
let gray = if model == RasterColorModel::Bitmap { if luma < 0.5 { 0 } else { 255 } } else { (luma * 255.0).round() as u8 };
[gray, gray, gray, alpha]
}
#[cfg(test)]
@@ -585,11 +608,23 @@ pub fn image_node(id: NodeId, image: &Rendered) -> Option<Arc<Node>> {
Some(Arc::new(Node::new(id, NodeKind::Image(Box::new(image_object(image)?)))))
}
/// `image` as an image object holding its pixels as a PNG; `None` when it can't be encoded.
/// `image` as an image object holding its pixels as a PNG: RGBA, or for a [`Rendered::gray`] image
/// gray, with alpha unless every pixel is opaque. `None` when it can't be encoded.
fn image_object(image: &Rendered) -> Option<ImageObject> {
let raw = image::RgbaImage::from_raw(image.cols, image.rows, image.pixels.clone())?;
let mut png = vec![];
raw.write_to(&mut Cursor::new(&mut png), image::ImageFormat::Png).ok()?;
let mut out = Cursor::new(&mut png);
if image.gray {
let pixels = image.pixels.as_chunks::<4>().0;
if pixels.iter().all(|p| p[3] == 255) {
let levels = pixels.iter().map(|p| p[0]).collect();
image::GrayImage::from_raw(image.cols, image.rows, levels)?.write_to(&mut out, image::ImageFormat::Png).ok()?;
} else {
let gray_alpha = pixels.iter().flat_map(|p| [p[0], p[3]]).collect();
image::GrayAlphaImage::from_raw(image.cols, image.rows, gray_alpha)?.write_to(&mut out, image::ImageFormat::Png).ok()?;
}
} else {
image::RgbaImage::from_raw(image.cols, image.rows, image.pixels.clone())?.write_to(&mut out, image::ImageFormat::Png).ok()?;
}
let blob = ImageBlob::png(png);
let cell = image.rect.width() / f64::from(image.cols);
Some(ImageObject {
@@ -728,6 +763,7 @@ fn image_key(meshes: &[SolidMesh], lighting: &Lighting, settings: RenderSettings
.into_iter()
.for_each(&mut f);
[settings.quality as f64, settings.resolution.unwrap_or(f64::NAN), f64::from(u8::from(settings.white)), ppi].into_iter().for_each(&mut f);
settings.color_model.id().hash(&mut h);
for m in meshes {
m.mesh.triangles.hash(&mut h);
}
+125 -3
View File
@@ -62,7 +62,8 @@ fn scene_of(n: &Node) -> (Vec<SolidMesh>, Lighting) {
(crate::three_d_meshes(n).unwrap(), lighting(&fx.id, &p))
}
const MEDIUM: RenderSettings = RenderSettings { quality: 1, resolution: None, white: false };
const MEDIUM: RenderSettings =
RenderSettings { quality: 1, resolution: None, white: false, color_model: vectorcraft_doc::RasterColorModel::Document };
const FOUR: [&str; 4] = [super::super::EXTRUDE, crate::REVOLVE, super::super::INFLATE, super::super::ROTATE];
@@ -447,6 +448,127 @@ fn the_background_is_white_or_clear() {
assert!(corners(&white).contains(&[255; 4]), "{:?}", corners(&white));
}
#[test]
fn color_model_maps_straight_color_before_rounding_coverage() {
let dark = 127.0 / 255.0;
let edge = [dark * 0.25, dark * 0.25, dark * 0.25, 0.25];
assert_eq!(color_model_pixel(edge, RasterColorModel::Grayscale, false), [127, 127, 127, 64]);
// Over white, every pixel is opaque, so Bitmap needs no rounding of the coverage.
for (model, white) in [(RasterColorModel::Grayscale, false), (RasterColorModel::Grayscale, true), (RasterColorModel::Bitmap, true)] {
assert_eq!(color_model_pixel([0.0; 4], model, white), [0; 4]);
for rgb in [[127, 127, 127], [128, 128, 128], [255, 0, 0], [0, 255, 0], [0, 0, 255]] {
let mut expected = [rgb[0], rgb[1], rgb[2], 255];
vectorcraft_doc::RasterEffectsSettings { color_model: model, ..Default::default() }.finish_pixels(&mut expected);
let p = [f32::from(rgb[0]) / 255.0, f32::from(rgb[1]) / 255.0, f32::from(rgb[2]) / 255.0, 1.0];
assert_eq!(color_model_pixel(p, model, white), expected, "{model:?}, white {white}: {rgb:?}");
}
}
}
/// Bitmap on a transparent background makes a black and transparent image: a dark pixel at least
/// half covered is opaque black, and a light pixel or one less than half covered is transparent.
#[test]
fn bitmap_on_a_transparent_background_is_black_and_transparent() {
let bitmap = |p| color_model_pixel(p, RasterColorModel::Bitmap, false);
assert_eq!(bitmap([1.0, 1.0, 1.0, 1.0]), [0; 4], "white is transparent");
assert_eq!(bitmap([0.0, 0.0, 0.0, 1.0]), [0, 0, 0, 255]);
assert_eq!(bitmap([1.0, 0.0, 0.0, 1.0]), [0, 0, 0, 255], "red is dark");
assert_eq!(bitmap([0.0, 1.0, 0.0, 1.0]), [0; 4], "green is light");
assert_eq!(bitmap([0.0, 0.0, 0.0, 0.5]), [0, 0, 0, 255], "a half-covered black pixel is opaque black");
let dark = 127.0 / 255.0;
assert_eq!(bitmap([dark * 0.25, dark * 0.25, dark * 0.25, 0.25]), [0; 4], "a dark pixel a quarter covered is transparent");
assert_eq!(bitmap([0.5, 0.5, 0.5, 0.5]), [0; 4], "a half-covered white pixel is transparent");
assert_eq!(bitmap([0.0; 4]), [0; 4]);
// A pale solid's light pixels are transparent and its dark ones black.
let pale = solid_square(super::super::EXTRUDE, Color::rgb(0.9, 0.9, 0.7), json!({}));
let (meshes, lighting) = scene_of(&pale);
let at = |color_model| render(&meshes, &lighting, RenderSettings { color_model, ..MEDIUM }, 72.0, false, &Limits::default()).unwrap().pixels;
let (color, bitmap) = (at(RasterColorModel::Document), at(RasterColorModel::Bitmap));
let mut clear = 0;
for (c, b) in color.chunks(4).zip(bitmap.chunks(4)) {
assert!(b == [0, 0, 0, 255] || b == [0; 4], "bitmap pixel {b:?} is black or transparent");
let luma = 0.2126 * f64::from(c[0]) + 0.7152 * f64::from(c[1]) + 0.0722 * f64::from(c[2]);
if c[3] == 255 && luma > 130.0 {
assert_eq!(b, [0; 4], "a light pixel {c:?} is transparent");
clear += 1;
} else if c[3] == 255 && luma < 125.0 {
assert_eq!(b, [0, 0, 0, 255], "a dark pixel {c:?} is black");
}
}
assert!(clear > 0, "the pale solid has light pixels");
}
/// Grayscale gives each pixel the Rec. 709 luma of the pixel the document's color mode gives, and
/// Bitmap makes each pixel black or white over a white background and black or transparent on a
/// transparent one. The effect's `colorModel` sets the model, and a new model makes a new image.
#[test]
fn the_color_model_makes_gray_or_black_and_white_pixels() {
use vectorcraft_doc::RasterColorModel;
let n = solid_square(super::super::EXTRUDE, Color::rgb(0.2, 0.5, 0.8), json!({}));
let (meshes, lighting) = scene_of(&n);
let at = |color_model, white| {
render(&meshes, &lighting, RenderSettings { color_model, white, ..MEDIUM }, 72.0, false, &Limits::default()).unwrap().pixels
};
for white in [false, true] {
let (color, gray, bitmap) =
(at(RasterColorModel::Document, white), at(RasterColorModel::Grayscale, white), at(RasterColorModel::Bitmap, white));
assert_eq!((color.len(), gray.len(), bitmap.len()), (color.len(), color.len(), color.len()));
let (mut colored, mut blacks, mut whites) = (0, 0, 0);
for ((c, g), b) in color.chunks(4).zip(gray.chunks(4)).zip(bitmap.chunks(4)) {
assert_eq!(g[3], c[3], "white {white}: grayscale keeps each pixel's coverage");
assert!(g[0] == g[1] && g[1] == g[2], "white {white}: grayscale pixel {g:?}");
if white {
assert_eq!(b[3], c[3], "white {white}: bitmap keeps each pixel's coverage");
} else {
assert!(b == [0, 0, 0, 255] || b == [0; 4], "on a transparent background bitmap pixel {b:?} is black or transparent");
}
if c[3] == 255 {
let luma = 0.2126 * f64::from(c[0]) + 0.7152 * f64::from(c[1]) + 0.0722 * f64::from(c[2]);
assert!((f64::from(g[0]) - luma).abs() <= 1.0, "white {white}: gray {g:?} for {c:?}, luma {luma}");
assert!(b[..3] == [0; 3] || b[..3] == [255; 3], "white {white}: bitmap pixel {b:?}");
blacks += usize::from(b == [0, 0, 0, 255]);
whites += usize::from(b == [255; 4]);
}
colored += usize::from(c[0] != c[1] || c[1] != c[2]);
}
assert!(colored > 0, "white {white}: the document's color mode keeps the paint's color");
// Over white, the background is white and the blue solid has dark pixels. On a transparent
// background nothing is white.
assert!(blacks > 0 && (whites > 0) == white, "white {white}: bitmap gives {blacks} black and {whites} white pixels");
}
// Grayscale and Bitmap images are stored as gray PNGs, and the document's color mode as RGBA.
for (color_model, kinds) in [
(RasterColorModel::Document, [image::ColorType::Rgba8, image::ColorType::Rgba8]),
(RasterColorModel::Grayscale, [image::ColorType::La8, image::ColorType::L8]),
(RasterColorModel::Bitmap, [image::ColorType::La8, image::ColorType::L8]),
] {
for (white, kind) in [false, true].into_iter().zip(kinds) {
let image = render(&meshes, &lighting, RenderSettings { color_model, white, ..MEDIUM }, 72.0, false, &Limits::default()).unwrap();
let object = image_object(&image).unwrap();
let blob = object.pixels.unwrap();
let decoded = image::load_from_memory(&blob.bytes).unwrap();
assert_eq!(decoded.color(), kind, "{color_model:?}, white {white}");
assert_eq!(decoded.to_rgba8().into_raw(), image.pixels, "{color_model:?}, white {white}: the PNG holds the pixels");
}
}
let settings = |model: &str| crate::render_settings(super::super::EXTRUDE, &json!({"render": {"mode": "rendered", "colorModel": model}}));
assert_eq!(settings("bitmap").map(|s| s.color_model), Some(RasterColorModel::Bitmap));
assert_eq!(settings("grayscale").map(|s| s.color_model), Some(RasterColorModel::Grayscale));
assert_eq!(settings("document").map(|s| s.color_model), Some(RasterColorModel::Document));
let default = crate::render_settings(super::super::EXTRUDE, &json!({"render": {"mode": "rendered"}}));
assert_eq!(default.map(|s| s.color_model), Some(RasterColorModel::Document), "the document's color mode is the default");
assert_eq!(settings("rgb"), None, "a model outside the three draws shaded");
let count = || RASTERIZATIONS.with(|count| count.get());
let doc = vectorcraft_doc::Document::new(400.0, 400.0);
let mut lit = solid_square(super::super::EXTRUDE, Color::rgb(0.2, 0.5, 0.8), json!({"render": {"mode": "rendered", "quality": "low"}}));
let draw = |n: &Node| images(&super::super::solid_art_drawn_in(Some(&doc), n).unwrap()).len();
assert_eq!(draw(&lit), 1);
let start = count();
lit.appearance.effects[0].params["render"]["colorModel"] = json!("grayscale");
assert_eq!(draw(&lit), 1);
assert_eq!(count(), start + 1, "a new color model makes a new image");
}
/// A mesh without a projection, or meshes with different ones, can't be placed: the image is refused.
#[test]
fn meshes_without_one_projection_are_refused() {
@@ -1203,7 +1325,7 @@ fn a_medium_render_stays_within_its_work_bound() {
let mut n = Node::path(NodeId(1), PathData::from_bezpath(&b), Appearance::basic(Paint::solid(Color::rgb(0.2, 0.5, 0.8)), Paint::None, 0.0));
n.appearance.effects.push(crate::new_effect(super::super::EXTRUDE, &json!({"render": {"mode": "rendered", "resolution": 300}})).unwrap());
let (meshes, lighting) = scene_of(&n);
let settings = RenderSettings { quality: 1, resolution: Some(300.0), white: false };
let settings = RenderSettings { quality: 1, resolution: Some(300.0), ..MEDIUM };
let m = measure(&meshes, &lighting, settings, 72.0, false, &Limits::default()).unwrap();
assert_eq!(m.samples, 2);
let samples = u64::from(m.cols) * u64::from(m.rows) * 4;
@@ -1245,7 +1367,7 @@ fn edge_values_render_or_are_refused() {
meshes[0].mesh.triangles.push([first[0], first[0], first[1]]);
assert!(render(&meshes, &lighting, MEDIUM, 72.0, false, &Limits::default()).is_ok(), "zero-area triangle");
for resolution in [1.0, 2400.0] {
let settings = RenderSettings { quality: 0, resolution: Some(resolution), white: false };
let settings = RenderSettings { quality: 0, resolution: Some(resolution), ..MEDIUM };
let image = render(&meshes, &lighting, settings, 72.0, false, &Limits::default()).unwrap();
assert!(image.cols >= 1 && image.rows >= 1, "{resolution} ppi");
}
+21 -6
View File
@@ -6,7 +6,7 @@ use std::sync::Arc;
use serde_json::Value;
use vectorcraft_doc::color::{Color, Paint};
use vectorcraft_doc::{Appearance, AppearanceItem, Document, Effect, FillLayer, LineJoin, Node, NodeId, StrokeLayer};
use vectorcraft_doc::{Appearance, AppearanceItem, Document, Effect, FillLayer, LineJoin, Node, NodeId, RasterColorModel, StrokeLayer};
use vectorcraft_geom::{Anchor, CubicBez, PathData, Point, SubPath};
use vectorcraft_three_d::Facet;
@@ -21,8 +21,8 @@ use crate::{GeomContext, is_geometry};
pub(crate) const MAX_WIRE_EDGES: usize = 1_000_000;
/// The parameter that holds a 3D effect's render settings: an object whose `mode` is one of
/// [`RENDER_MODES`], with the rendered image's `quality` ([`RENDER_QUALITIES`]), `resolution` and
/// `background` ([`RENDER_BACKGROUNDS`]).
/// [`RENDER_MODES`], with the rendered image's `quality` ([`RENDER_QUALITIES`]), `resolution`,
/// `background` ([`RENDER_BACKGROUNDS`]) and `colorModel` ([`RENDER_COLOR_MODELS`]).
pub const RENDER: &str = "render";
/// The render modes of a 3D effect: `shaded` draws the lit faces, `wireframe` the edges of every
@@ -37,6 +37,11 @@ pub const RENDER_QUALITIES: [&str; 3] = ["low", "medium", "high"];
/// What the rendered image shows where no surface is: nothing, or white.
pub const RENDER_BACKGROUNDS: [&str; 2] = ["transparent", "white"];
/// The color models of the rendered image, the ids of [`RasterColorModel`]: RGB pixels in every
/// document, grayscale, or two pixel values, black and white on a white background and black and
/// transparent on a transparent one.
pub const RENDER_COLOR_MODELS: [&str; 3] = ["document", "grayscale", "bitmap"];
/// The index in [`RENDER_QUALITIES`] of the quality a `render` without one takes (VectorCraft's own
/// default).
const DEFAULT_QUALITY: usize = 1;
@@ -51,6 +56,8 @@ pub struct RenderSettings {
/// A white background, which makes the image opaque; otherwise it is transparent where no
/// surface or shadow is.
pub white: bool,
/// The image's color model, applied after the background.
pub color_model: RasterColorModel,
}
impl RenderSettings {
@@ -73,6 +80,11 @@ pub fn render_settings(id: &str, p: &Value) -> Option<RenderSettings> {
quality: quality.unwrap_or(DEFAULT_QUALITY),
resolution: render.get("resolution").and_then(Value::as_f64),
white: render.get("background").and_then(Value::as_str) == Some("white"),
color_model: render
.get("colorModel")
.and_then(Value::as_str)
.and_then(|m| RasterColorModel::ALL.into_iter().find(|c| c.id() == m))
.unwrap_or_default(),
})
}
@@ -83,7 +95,8 @@ pub fn renders_image(fx: &Effect) -> bool {
/// The message a `render` that breaks the rules of [`validate_render`] is refused with.
const RENDER_RULES: &str = "`render` must be an object holding only mode (shaded, wireframe or rendered), quality (low, medium or high), \
resolution (null or a number from 1 to 2400) and background (transparent or white)";
resolution (null or a number from 1 to 2400), background (transparent or white) and colorModel \
(document, grayscale or bitmap)";
/// Check one `render` value against [`RENDER_RULES`].
fn check_render(render: &Value) -> Result<(), String> {
@@ -93,6 +106,7 @@ fn check_render(render: &Value) -> Result<(), String> {
"mode" => one_of(value, &RENDER_MODES),
"quality" => one_of(value, &RENDER_QUALITIES),
"background" => one_of(value, &RENDER_BACKGROUNDS),
"colorModel" => one_of(value, &RENDER_COLOR_MODELS),
"resolution" => value.is_null() || value.as_f64().is_some_and(|r| (1.0..=2400.0).contains(&r)),
_ => false,
})
@@ -124,8 +138,9 @@ pub(crate) fn wireframe_params(id: &str, p: &Value) -> bool {
/// Check the render settings in 3D effect `id`'s parameters `p`: `render`, when given to one of the
/// effects in [`TAKES_RENDER`], is an object that holds only `mode` (one of [`RENDER_MODES`]),
/// `quality` (one of [`RENDER_QUALITIES`]), `resolution` (`null`, or a number from 1 to 2400 pixels
/// per inch) and `background` (one of [`RENDER_BACKGROUNDS`]). A key left out takes its default:
/// `shaded`, `medium`, the document's raster effects resolution and `transparent`. The 3D (Classic)
/// per inch), `background` (one of [`RENDER_BACKGROUNDS`]) and `colorModel` (one of
/// [`RENDER_COLOR_MODELS`]). A key left out takes its default: `shaded`, `medium`, the document's
/// raster effects resolution, `transparent` and `document`. The 3D (Classic)
/// effects refuse it as a parameter they do not take.
pub(crate) fn validate_render(id: &str, p: &Value) -> Result<(), String> {
let Some(render) = p.get(RENDER).filter(|_| TAKES_RENDER.contains(&id)) else { return Ok(()) };
+11 -3
View File
@@ -419,8 +419,9 @@ fn expanding_a_revolve_in_wireframe_mode_gives_the_edges() {
}
/// `render` is checked before an edit: an object holding only `mode` (shaded, wireframe or
/// rendered), `quality` (low, medium or high), `resolution` (null or 1 to 2400) and `background`
/// (transparent or white), and only on the panel's four effects.
/// rendered), `quality` (low, medium or high), `resolution` (null or 1 to 2400), `background`
/// (transparent or white) and `colorModel` (document, grayscale or bitmap), and only on the panel's
/// four effects.
#[test]
fn render_settings_are_validated() {
for id in WIRE {
@@ -434,6 +435,9 @@ fn render_settings_are_validated() {
json!({"render": {"mode": "rendered", "quality": "low", "resolution": null, "background": "transparent"}}),
json!({"render": {"resolution": 1}}),
json!({"render": {"resolution": 2400}}),
json!({"render": {"mode": "rendered", "colorModel": "document"}}),
json!({"render": {"mode": "rendered", "colorModel": "grayscale"}}),
json!({"render": {"colorModel": "bitmap"}}),
] {
assert_eq!(crate::validate_three_d_params(id, &good), Ok(()), "{id} {good}");
}
@@ -448,12 +452,16 @@ fn render_settings_are_validated() {
json!({"render": {"mode": "rendered", "resolution": "300"}}),
json!({"render": {"mode": "rendered", "background": "black"}}),
json!({"render": {"mode": "rendered", "samples": 4}}),
json!({"render": {"mode": "rendered", "colorModel": "rgb"}}),
json!({"render": {"mode": "rendered", "colorModel": "Grayscale"}}),
json!({"render": {"mode": "rendered", "colorModel": null}}),
json!({"render": {"mode": "rendered", "colorModel": 1}}),
] {
let e = crate::validate_three_d_params(id, &bad).unwrap_err();
assert_eq!(
e,
"`render` must be an object holding only mode (shaded, wireframe or rendered), quality (low, medium or high), resolution (null \
or a number from 1 to 2400) and background (transparent or white)",
or a number from 1 to 2400), background (transparent or white) and colorModel (document, grayscale or bitmap)",
"{id} {bad}"
);
}
-5
View File
@@ -17,11 +17,6 @@ bundled-fonts = ["vectorcraft-text/bundled-fonts"]
# feature still recognizes the files and refuses them with a message. The apps list it beside
# `bundled-fonts`.
heif = ["dep:heic-rs", "dep:rayon"]
# Binary CGM files open and place. Off until the craft-metafile CGM reader (craft-libs#5410) merges
# and the workspace pins it; the build fails with this feature on before then. Without it, `.cgm`
# is not listed as readable or placeable anywhere. Turning it on also needs `cgm` in
# `UNASSOCIATED_EXTS` (`src/cmd/fileio/formats.rs`).
cgm = ["vectorcraft-metafile/cgm"]
[dependencies]
craft-codepage = { workspace = true }
+1 -2
View File
@@ -247,8 +247,7 @@ mod tests_svgimport;
#[cfg(test)]
mod tests_eps;
// The CGM reader waits on craft-libs#5410 (the `cgm` feature).
#[cfg(all(test, feature = "cgm"))]
#[cfg(test)]
mod tests_cgm;
#[cfg(test)]
mod tests_dwgimport;
+4 -8
View File
@@ -588,8 +588,7 @@ pub const FORMATS: &[Format] = &[
options: metafile::OPTIONS,
},
// Binary Computer Graphics Metafiles, read by `vectorcraft_metafile::import_cgm` into paths,
// type and images. Behind the `cgm` feature until craft-libs#5410 merges.
#[cfg(feature = "cgm")]
// type and images.
reader("cgm", "CGM", &["cgm"], "image/cgm", false),
// Layered raster `.pcraft` documents, read by `pcraftread` as one image: the full-size
// composite, the layers combined, or the preview with a note. Exports don't write them.
@@ -664,7 +663,6 @@ pub const OPEN_EXTS: &[&str] = &[
"pct",
"pic",
"pict",
#[cfg(feature = "cgm")]
"cgm",
"plt",
"hpgl",
@@ -691,12 +689,11 @@ pub const OPEN_EXTS: &[&str] = &[
/// names of PNG, BMP and JPEG files (File › Open and Place still read them all). On Linux the desktop
/// entry's EPS and JPEG types (shared-mime-info's) also cover `.epsf` and `.jpe`, so file managers
/// offer VectorCraft for them.
/// The packaging declares no type for HP-GL plot files, PICT pictures, layered raster `.pcraft`
/// documents or DWG drawings (`.dwg`, `.dws` and `.dwt`) either. CGM files are added here
/// when the `cgm` feature is turned on (craft-libs#5410).
/// The packaging declares no type for HP-GL plot files, PICT pictures, CGM files, layered raster
/// `.pcraft` documents or DWG drawings (`.dwg`, `.dws` and `.dwt`) either.
pub const UNASSOCIATED_EXTS: &[&str] = &[
"psd", "pdd", "psb", "epsf", "ps", "pns", "dib", "rle", "jpe", "tga", "vda", "icb", "vst", "pcx", "pxr", "jpf", "jpx", "jp2", "j2k", "j2c",
"jpc", "heic", "heif", "jxl", "cdr", "cdt", "cmx", "plt", "hpgl", "hgl", "hpg", "pct", "pic", "pict", "pcraft", "dwg", "dws", "dwt",
"jpc", "heic", "heif", "jxl", "cdr", "cdt", "cmx", "plt", "hpgl", "hgl", "hpg", "pct", "pic", "pict", "cgm", "pcraft", "dwg", "dws", "dwt",
];
/// The extension that picks each writable format when exporting (the format's first; PNG-8 shares
@@ -783,7 +780,6 @@ pub const PLACE_EXTS: &[&str] = &[
"pct",
"pic",
"pict",
#[cfg(feature = "cgm")]
"cgm",
"plt",
"hpgl",
+5 -5
View File
@@ -26,8 +26,8 @@ pub const OPTIONS: &[FormatOption] = &[
FormatOption {
name: "version",
ty: "integer",
default: "4",
description: "the format version to write: 4 (current), or 3, 2 or 1 for older VectorCraft versions (1 and 2 are never compressed; newer features they don't know are lost there)",
default: "5",
description: "the format version to write: 5 (current), or 4, 3, 2 or 1 for older VectorCraft versions (1 and 2 are never compressed; newer features they don't know are lost there)",
},
FormatOption {
name: "preview",
@@ -202,7 +202,7 @@ pub(super) fn encode(cmd: &str, f: &Format, doc: &Document, p: &Value) -> Result
pub(super) fn encode_to(cmd: &str, f: &Format, doc: &Document, p: &Value, w: impl std::io::Write) -> Result<()> {
let (mut so, extras) = save_options(cmd, f, doc, p)?;
// Include Linked Files keeps placed documents' files; older versions get their art.
let full = if so.include_linked || so.version < vectorcraft_format::VERSION {
let full = if so.include_linked || so.version < vectorcraft_format::PLACED_SINCE {
crate::cmd::place::document::full_documents(doc).0
} else {
std::borrow::Cow::Borrowed(doc)
@@ -223,7 +223,7 @@ pub(super) fn encode_to(cmd: &str, f: &Format, doc: &Document, p: &Value, w: imp
}
drop(drawn);
let native = match full {
Cow::Owned(full) if so.include_linked && so.version >= vectorcraft_format::VERSION => {
Cow::Owned(full) if so.include_linked && so.version >= vectorcraft_format::PLACED_SINCE => {
// Include available bytes without replacing missing, relinkable placed objects.
let mut original = doc.clone();
original.images = full.images;
@@ -242,7 +242,7 @@ pub(super) fn encode_to(cmd: &str, f: &Format, doc: &Document, p: &Value, w: imp
/// groups of their art for older versions.
fn rounded(doc: &Document, version: u32, decimals: u8) -> Document {
let mut d = doc.clone();
if version < vectorcraft_format::VERSION {
if version < vectorcraft_format::PLACED_SINCE {
vectorcraft_format::placed_as_groups(&mut d);
}
d.round_geometry(decimals.min(vectorcraft_format::MAX_PRECISION));
@@ -476,7 +476,7 @@ fn placed_carried_fonts_survive_break_link_and_older_version_save() {
assert_eq!(embedded["embedded"], json!([id.0]), "{embedded}");
assert_eq!(glyphs(&s).1, 1);
}
let version = if break_link { vectorcraft_format::VERSION } else { vectorcraft_format::VERSION - 1 };
let version = if break_link { vectorcraft_format::VERSION } else { vectorcraft_format::PLACED_SINCE - 1 };
let saved = s.execute("document.serialize", &json!({"format": "vectorcraft", "version": version, "preview": false})).unwrap();
let reopened = s.execute("document.open", &json!({"name": "placed-font.vectorcraft", "dataBase64": saved["dataBase64"]})).unwrap();
assert!(reopened["warnings"].as_array().unwrap().is_empty(), "{reopened}");
+61
View File
@@ -284,6 +284,67 @@ fn image_widths(bytes: &[u8]) -> Vec<u32> {
out
}
/// `render.colorModel` outside document, grayscale and bitmap is refused before the document
/// changes. A valid one is saved with the effect and read back, and Grayscale gives the image
/// Expand Appearance leaves gray pixels, stored as a gray PNG.
#[test]
fn a_rendered_3d_color_model_is_checked_saved_and_drawn() {
let mut s = rendered_square(&[]);
let object = |s: &Session| {
let mut found = None;
for l in &s.doc().unwrap().doc.layers {
l.walk(&mut |n| {
if n.appearance.effects.iter().any(|e| e.id == "threeD.extrude") {
found = Some(n.clone());
}
});
}
found.unwrap()
};
let before = object(&s);
let undo = s.doc().unwrap().history.undo.len();
for bad in [json!("sepia"), json!("rgb"), json!(null), json!(2)] {
let params = json!({"index": 0, "item": null, "params": {"render": {"mode": "rendered", "colorModel": bad}}});
let e = s.execute("effect.setParams", &params).unwrap_err().to_string();
assert!(e.contains("colorModel (document, grayscale or bitmap)"), "{bad}: {e}");
}
assert_eq!(object(&s), before, "a refused color model leaves the object unchanged");
assert_eq!(s.doc().unwrap().history.undo.len(), undo);
run(
&mut s,
"effect.setParams",
json!({"index": 0, "item": null, "params": {"render": {"mode": "rendered", "quality": "low", "colorModel": "grayscale"}}}),
);
let back = vectorcraft_format::load(&vectorcraft_format::save(&s.doc().unwrap().doc, false)).unwrap();
let mut models = vec![];
for l in &back.layers {
l.walk(&mut |n| {
for e in n.appearance.effects.iter().filter(|e| e.id == "threeD.extrude") {
models.push(vectorcraft_render::effects::render_settings(&e.id, &e.params).map(|r| r.color_model));
}
});
}
assert_eq!(models, vec![Some(vectorcraft_doc::RasterColorModel::Grayscale)], "the saved file keeps the color model");
run(&mut s, "effect.expandAppearance", json!({}));
let doc = &s.doc().unwrap().doc;
let mut keys = vec![];
for l in &doc.layers {
l.walk(&mut |n| {
if let vectorcraft_doc::NodeKind::Image(im) = &n.kind {
keys.push(im.key.clone());
}
});
}
assert_eq!(keys.len(), 1, "{keys:?}");
let decoded = image::load_from_memory(&doc.images[&keys[0]].bytes).unwrap();
assert!(matches!(decoded.color(), image::ColorType::L8 | image::ColorType::La8), "a gray image is stored gray: {:?}", decoded.color());
let pixels = decoded.to_rgba8();
let opaque = pixels.pixels().filter(|p| p[3] == 255).count();
assert!(opaque > 0, "the image covers the solid");
let colored: Vec<_> = pixels.pixels().filter(|p| p[3] > 0 && !(p[0] == p[1] && p[1] == p[2])).take(4).collect();
assert!(colored.is_empty(), "pixels with color in a grayscale image: {colored:?}");
}
/// PDF and SVG export write one image for a rendered 3D object, and Expand Appearance leaves one
/// embedded image of the same size in pixels that covers the object.
#[test]
+3 -1
View File
@@ -1507,7 +1507,7 @@ fn saved_for_older_apps_placed_documents_in_brush_art_become_their_art() {
n
};
let prefix = vectorcraft_doc::placed_document::RESOURCE_PREFIX;
let older = vectorcraft_format::VERSION - 1;
let older = vectorcraft_format::PLACED_SINCE - 1;
let old =
vectorcraft_format::load(&decode(&s.execute("document.serialize", &json!({"format": "vectorcraft", "version": older})).unwrap())).unwrap();
assert_eq!(placed_in_brushes(&old), 0, "{}", old.unknown[vectorcraft_brush::DOC_KEY]);
@@ -1519,6 +1519,8 @@ fn saved_for_older_apps_placed_documents_in_brush_art_become_their_art() {
let current = vectorcraft_format::load(&decode(&s.execute("document.serialize", &json!({"format": "vectorcraft"})).unwrap())).unwrap();
assert_eq!(placed_in_brushes(&current), 2, "the current version keeps them placed");
assert!(current.symbols.iter().all(|s| !s.name.starts_with(prefix)));
let v4 = vectorcraft_format::load(&decode(&s.execute("document.serialize", &json!({"format": "vectorcraft", "version": 4})).unwrap())).unwrap();
assert_eq!(placed_in_brushes(&v4), 2, "version 4 keeps them placed too");
// With a precision, the preview shows the brushes' art as the file holds it, rounded.
let file = decode(&s.execute("file.saveCopy", &json!({"version": older, "precision": 0, "preview": true})).unwrap());
let saved = vectorcraft_format::load(&file).unwrap();
-8
View File
@@ -4161,10 +4161,7 @@ proptest! {
// ---------- Binary CGM files: opened and placed ----------
// The CGM reader waits on craft-libs#5410: everything here is behind the `cgm` feature.
/// One CGM element, in the long form past 30 bytes, padded to an even length.
#[cfg(feature = "cgm")]
fn cgm_el(class: u16, id: u16, data: &[u8]) -> Vec<u8> {
let mut b = Vec::new();
if data.len() < 31 {
@@ -4181,7 +4178,6 @@ fn cgm_el(class: u16, id: u16, data: &[u8]) -> Vec<u8> {
}
/// A metafile of one picture holding `body`.
#[cfg(feature = "cgm")]
fn cgm_of(body: &[(u16, u16, Vec<u8>)]) -> Vec<u8> {
let mut b = cgm_el(0, 1, b"\x01x");
b.extend(cgm_el(1, 1, &be16(&[3])));
@@ -4198,7 +4194,6 @@ fn cgm_of(body: &[(u16, u16, Vec<u8>)]) -> Vec<u8> {
}
/// A picture with lines, shapes, arcs, a figure, markers, text, a cell array and a clip.
#[cfg(feature = "cgm")]
fn cgm_sample() -> Vec<u8> {
cgm_of(&[
(5, 34, vec![8, 10, 20, 30, 40, 50, 60]),
@@ -4232,7 +4227,6 @@ fn cgm_sample() -> Vec<u8> {
}
/// The sample the mutations start from opens with art, type and an image.
#[cfg(feature = "cgm")]
#[test]
fn the_cgm_sample_opens() {
let l = vectorcraft_engine::cmd::fileio::load("x.cgm", &cgm_sample()).unwrap();
@@ -4249,14 +4243,12 @@ fn the_cgm_sample_opens() {
/// CGM elements VectorCraft reads, and some it skips: the class in the high byte, the id in the
/// low one.
#[cfg(feature = "cgm")]
const CGM_ELEMENTS: [u16; 44] = [
0x0008, 0x0009, 0x0103, 0x0104, 0x0105, 0x0107, 0x010A, 0x010C, 0x010D, 0x0113, 0x0201, 0x0202, 0x0203, 0x0207, 0x0301, 0x0302, 0x0305, 0x0306,
0x030A, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407, 0x0408, 0x0409, 0x040B, 0x040C, 0x040D, 0x040F, 0x0411, 0x0412, 0x0414, 0x0418,
0x041A, 0x0503, 0x0504, 0x050F, 0x0510, 0x0512, 0x0522, 0x0801,
];
#[cfg(feature = "cgm")]
proptest! {
#![proptest_config(config())]
+38 -23
View File
@@ -33,9 +33,9 @@
//! The document has a version of its own (`document.version`, [`vectorcraft_doc::FORMAT_VERSION`]),
//! which readers do not check. A version 2 document's Twist effects turn clockwise for a positive
//! angle. A version 1 document's Twist angles are negated when it opens, unless the file is of
//! [`VERSION`] and its `generator` is VectorCraft 0.21.0 or later, which turned them clockwise
//! already; [`save_with`] writes a version 1 document with them negated back for an older file
//! version ([`vectorcraft_doc::twist`]).
//! [`PLACED_SINCE`] or later and its `generator` is VectorCraft 0.21.0 or later, which turned them
//! clockwise already; [`save_with`] writes a version 1 document with them negated back for a file
//! version older than [`PLACED_SINCE`] ([`vectorcraft_doc::twist`]).
#![forbid(unsafe_code)]
#![doc(test(attr(forbid(unsafe_code))))]
@@ -64,11 +64,16 @@ use craft_gzip::Gz;
pub use craft_vectorcraft_format::base64::{decode as base64_decode, decoded_len as base64_decoded_len, encode as base64_encode};
use craft_vectorcraft_format::stream::{FileHeader, Indent, KeyScan, write_file_json};
pub use craft_vectorcraft_format::{
BLOB_MAGIC, COMPRESSED_SINCE, EXTENSION, ICC_MIME, INLINE_MAX, LEGACY_EXTENSION, MIN_VERSION, PREVIEW_MAX, VERSION, is_compressed, json_part,
sniff,
BLOB_MAGIC, COMPRESSED_SINCE, EXTENSION, ICC_MIME, INLINE_MAX, LEGACY_EXTENSION, LIVE_STAR_SINCE, MIN_VERSION, PREVIEW_MAX, VERSION,
is_compressed, json_part, sniff,
};
use stream::Out;
/// The first version whose files keep placed documents, Color Halftone's Max Radius in pixels and
/// Twist angles as they are. A save for an older version writes placed documents as the art they
/// show, the radius in points and Twist angles negated back, as apps of those versions read them.
pub const PLACED_SINCE: u32 = 4;
/// Most bytes the JSON of a compressed file may unpack to (a guard against decompression bombs,
/// as are [`MAX_BLOB`] and [`MAX_BLOBS`]). A compressed save refuses a document past any of them,
/// so every file VectorCraft writes reads back. On wasm32 the cap is a quarter of the native
@@ -252,7 +257,7 @@ fn body(doc: &Document, o: &SaveOptions) -> Result<Body, FormatError> {
// resources. Otherwise resources only exporting adds are never saved. The images and placed
// documents in the stored brushes' art count as those in the layers do.
let linked = with_brush_art(&mut d, |d| {
if version < VERSION {
if version < PLACED_SINCE {
placed_as_groups(d);
} else {
d.drop_placed_resources();
@@ -268,15 +273,15 @@ fn body(doc: &Document, o: &SaveOptions) -> Result<Body, FormatError> {
if version < 3 {
d.store_legacy_color_profiles();
}
// Apps before this one's version take Color Halftone's Max Radius in points (#3260), and
// predate 0.21.0, turning Twist the other way. The radii first: their conversion runs only on
// a document of version 3 or later, and the Twist one then marks it version 1.
if version < VERSION {
// Apps before version 4 take Color Halftone's Max Radius in points (#3260), and predate
// 0.21.0, turning Twist the other way. The radii first: their conversion runs only on a
// document of version 3 or later, and the Twist one then marks it version 1.
if version < PLACED_SINCE {
d.halftone_radii_to_points();
d.store_legacy_twist_angles();
}
// Older apps don't know live stars: they get the outline a star draws as a plain path.
if version < VERSION {
if version < LIVE_STAR_SINCE {
d.live_stars_to_paths();
}
let v1 = if version == 1 {
@@ -309,7 +314,7 @@ pub fn with_brush_art<T>(d: &mut Document, f: impl FnOnce(&mut Document) -> T) -
/// Every placed document in `d`'s art, the art of its stored brushes included, replaced by a group
/// of the art it shows, with the resources that art uses, as a save for a version older than
/// [`VERSION`] writes it. Without a placed document, the resources only exporting adds are dropped
/// [`PLACED_SINCE`] writes it. Without a placed document, the resources only exporting adds are dropped
/// ([`Document::drop_placed_resources`]).
pub fn placed_as_groups(d: &mut Document) {
with_brush_art(d, |d| {
@@ -576,7 +581,7 @@ fn load_unpacked(file: unpack::Unpacked<'_>, max_nodes: usize, max_values: usize
// version): its Twist angles turned the other way. The app that wrote it is read from the JSON
// before the data after it is taken; the walk's depth is bounded by the JSON reader's nesting
// limit.
let current_file = f.version >= VERSION;
let current_file = f.version >= PLACED_SINCE;
f.document.migrate_twist_angles(|| current_file && vectorcraft_doc::twist::written_clockwise(generator(file.json()).as_deref()));
// The bytes after the JSON, read in one pass: the images' first, then the profiles'.
let entries: Vec<[u64; 2]> = f.images.values().chain(f.profiles.values()).filter_map(|i| i.blob).collect();
@@ -1128,7 +1133,8 @@ mod tests {
}
}
}
assert_eq!(checked, 20);
// Four for each version, and two compressed for each version from 3.
assert_eq!(checked, 4 * (VERSION - MIN_VERSION + 1) + 2 * (VERSION - COMPRESSED_SINCE + 1));
}
/// Files are read through the crate's `Contents` with the messages VectorCraft gave before,
@@ -1148,7 +1154,10 @@ mod tests {
let doc = v["document"].to_string();
let file = |format: &str, version: u32| format!(r#"{{"format":"{format}","version":{version},"document":{doc}}}"#);
assert_eq!(message(&file("svg", 4)).as_deref(), Some("not a VectorCraft file: format is `svg`"));
assert_eq!(message(&file("vectorcraft", 9)).as_deref(), Some("file version 9 is newer than this VectorCraft supports (4)"));
assert_eq!(
message(&file("vectorcraft", 9)).as_deref(),
Some(format!("file version 9 is newer than this VectorCraft supports ({VERSION})").as_str())
);
// A document that does not read is reported first, as before.
assert!(
message(r#"{"format":"vectorcraft","version":9,"document":7}"#).is_some_and(|m| m.starts_with("not a VectorCraft file: invalid type"))
@@ -1188,15 +1197,16 @@ mod tests {
let old = load(&save(&d, false)).unwrap();
assert_eq!(old.version, vectorcraft_doc::FORMAT_VERSION);
assert!((radius(&old) - 8.0 * ppi / 72.0).abs() < 1e-9, "8 pt at {ppi} ppi: {}", radius(&old));
// Saved for an older app, in every older version: the radius in points, which opens
// here in pixels again.
// Saved for an older app, in every version before 4: the radius in points, which opens
// here in pixels again. Version 4 and later keep it in pixels.
let px = radius(&old);
for version in MIN_VERSION..VERSION {
for version in MIN_VERSION..=VERSION {
let bytes = save_with(&old, &SaveOptions { version, ..SaveOptions::default() }).unwrap();
let json = String::from_utf8(unpack::Unpacked::new(&bytes).unwrap().json().to_vec()).unwrap();
let at = json.find("\"maxRadius\":").unwrap() + "\"maxRadius\":".len();
let saved: f64 = json[at..].split([',', '}']).next().unwrap().trim().parse().unwrap();
assert!((saved - 8.0).abs() < 1e-9, "{ppi} ppi, version {version} holds 8 pt: {saved}");
let want = if version < 4 { 8.0 } else { px };
assert!((saved - want).abs() < 1e-9, "{ppi} ppi, version {version} holds {want}: {saved}");
let back = load(&bytes).unwrap();
assert!((radius(&back) - px).abs() < 1e-9, "{ppi} ppi, version {version}: {}", radius(&back));
}
@@ -1410,15 +1420,20 @@ mod tests {
let again = load(&save(&old, false)).unwrap();
assert_eq!((again.version, angle(&again)), (now, Some(-30.0)), "saved again, it is the current version");
// Saved for an older file version (apps before 0.21.0): version 1 with the angle negated
// back, whatever the generator, and it reopens as it was.
for version in MIN_VERSION..VERSION {
// back, whatever the generator, and it reopens as it was. Version 4 and later keep it.
for version in MIN_VERSION..=VERSION {
let bytes = save_with(&d, &SaveOptions { version, ..SaveOptions::default() }).unwrap();
let v: serde_json::Value = serde_json::from_slice(&bytes).unwrap();
assert_eq!(v["document"]["version"], 1, "file version {version}");
assert!(String::from_utf8_lossy(&bytes).contains(r#""angle":-30.0"#), "file version {version}");
let (document, saved) = if version < 4 { (1, r#""angle":-30.0"#) } else { (now, r#""angle":30.0"#) };
assert_eq!(v["document"]["version"], document, "file version {version}");
assert!(String::from_utf8_lossy(&bytes).contains(saved), "file version {version}");
let back = load(&bytes).unwrap();
assert_eq!((back.version, angle(&back)), (now, Some(30.0)), "file version {version}");
}
// A version 4 file from 0.21.0 or later turned its version 1 document's angles already.
let mut v4: serde_json::Value = serde_json::from_slice(&current).unwrap();
(v4["version"], v4["document"]["version"], v4["generator"]) = (4.into(), 1.into(), "VectorCraft 0.25.2".into());
assert_eq!(angle(&load(&serde_json::to_vec(&v4).unwrap()).unwrap()), Some(30.0));
}
#[test]
+2 -2
View File
@@ -6,7 +6,7 @@ use std::sync::Arc;
use serde_json::Value;
use vectorcraft_doc::{Document, ImageBlob, ImageObject, Node, NodeKind};
use vectorcraft_format::{BLOB_MAGIC, FormatError, INLINE_MAX, SaveOptions, load, load_file, pdf_content, save_with};
use vectorcraft_format::{BLOB_MAGIC, FormatError, INLINE_MAX, SaveOptions, VERSION, load, load_file, pdf_content, save_with};
use vectorcraft_geom::Affine;
/// A document showing image `key` of `len` bytes.
@@ -48,7 +48,7 @@ fn small_files_stay_plain_json_and_older_versions_inline() {
let small = save_with(&doc_with_image("small", 100), &SaveOptions::default()).unwrap();
assert!(!has_tail(&small));
let v: Value = serde_json::from_slice(&small).unwrap();
assert_eq!(v["version"], 4);
assert_eq!(v["version"], VERSION);
let big = doc_with_image("big", INLINE_MAX + 10);
let v3 = save_with(&big, &SaveOptions { version: 3, ..SaveOptions::default() }).unwrap();
assert!(!has_tail(&v3), "version 3 keeps everything in the JSON");
+1 -1
View File
@@ -136,7 +136,7 @@ proptest! {
without_live_stars(&mut older);
for o in [SaveOptions { compress: true, ..SaveOptions::default() }, SaveOptions { version: 2, ..SaveOptions::default() }, SaveOptions { version: 1, pretty: true, ..SaveOptions::default() }] {
let back = load(&save_with(&d, &o).unwrap()).unwrap();
let want = if o.version < vectorcraft_format::VERSION { &older } else { &want };
let want = if o.version < vectorcraft_format::LIVE_STAR_SINCE { &older } else { &want };
prop_assert!(json_approx_eq(&doc_json(&back), want, 1e-12), "{:?} differs", o);
}
}
-5
View File
@@ -8,11 +8,6 @@ description = "VectorCraft metafiles: EMF, WMF and QuickDraw PICT export and EMF
[lints]
workspace = true
[features]
# The binary CGM reader (`import_cgm`). Off until the craft-metafile CGM reader (craft-libs#5410)
# merges and the workspace pins it; without it, `is_cgm` is false and `import_cgm` is refused.
cgm = []
[dependencies]
vectorcraft-geom = { workspace = true }
vectorcraft-color = { workspace = true }
+5 -3
View File
@@ -95,12 +95,9 @@ pub(crate) fn import_pict(bytes: &[u8]) -> Result<crate::Picture, String> {
}
/// The longer side of a CGM picture without a metric scale, points (8 inches).
#[cfg(feature = "cgm")]
const CGM_SIDE: f64 = 576.0;
/// Read the first picture of a binary CGM (ISO/IEC 8632-3) through `craft_metafile`.
/// `craft_metafile::parse_cgm` comes with craft-libs#5410, so this waits on the `cgm` feature.
#[cfg(feature = "cgm")]
pub(crate) fn import_cgm(bytes: &[u8]) -> Result<crate::Picture, String> {
let cgm = craft_metafile::parse_cgm(bytes, CGM_SIDE).map_err(|e| e.to_string())?;
let n = cgm.notes;
@@ -113,6 +110,11 @@ pub(crate) fn import_cgm(bytes: &[u8]) -> Result<crate::Picture, String> {
(n.restricted_text, "restricted text was set at its character height without fitting it to its box"),
(n.character_spacing, "character spacing was not applied"),
(n.text_cut, "text past 16,384 characters in one string was cut"),
(n.fonts_cut, "fonts past the first 256 of the font list were not read: their text uses the default font"),
(n.append_attributes, "appended text that followed a change to the text's look was set as its text began"),
(n.text_alignment, "text with continuous alignment was aligned left or on its baseline"),
(n.marker_types, "markers of types other than dot, plus, asterisk, circle and cross were drawn as plus signs"),
(n.unsupported_char_set, "text in a character set other than ASCII, Latin-1, UTF-8 and UTF-16 was read as Latin-1"),
];
p.warnings.extend(notes.iter().filter(|(on, _)| *on).map(|(_, w)| (*w).to_string()));
if n.damaged_elements > 0 {
+6 -22
View File
@@ -255,33 +255,17 @@ pub fn import_pict(bytes: &[u8]) -> Result<Picture, String> {
Ok(p)
}
/// Do `bytes` start like a binary CGM: BEGIN METAFILE, then METAFILE VERSION? Always false
/// without the `cgm` feature (craft-libs#5410).
/// Do `bytes` start like a binary CGM: BEGIN METAFILE, then METAFILE VERSION?
pub fn is_cgm(bytes: &[u8]) -> bool {
#[cfg(feature = "cgm")]
return craft_metafile::is_cgm(bytes);
#[cfg(not(feature = "cgm"))]
{
let _ = bytes;
false
}
craft_metafile::is_cgm(bytes)
}
/// Read the first picture of a binary Computer Graphics Metafile (CGM, ISO/IEC 8632-3) into a
/// document whose one artboard is the picture's VDC extent. Without the `cgm` feature
/// (craft-libs#5410), every file is refused.
/// document whose one artboard is the picture's VDC extent.
pub fn import_cgm(bytes: &[u8]) -> Result<Picture, String> {
#[cfg(feature = "cgm")]
{
let mut p = import::import_cgm(bytes)?;
p.document.limit_depth_noting(&mut p.warnings);
Ok(p)
}
#[cfg(not(feature = "cgm"))]
{
let _ = bytes;
Err("CGM files can't be read in this build".to_string())
}
let mut p = import::import_cgm(bytes)?;
p.document.limit_depth_noting(&mut p.warnings);
Ok(p)
}
#[cfg(test)]
-2
View File
@@ -11,8 +11,6 @@ use vectorcraft_geom::{Affine, PathData, Point, Rect, shapes};
use crate::*;
// The CGM reader waits on craft-libs#5410 (the `cgm` feature).
#[cfg(feature = "cgm")]
mod cgm;
mod import;
mod pict;
+11
View File
@@ -313,6 +313,17 @@ fn what_the_reader_left_out_or_set_differently_is_warned_about() {
assert!(p.warnings.iter().any(|w| w == "character spacing was not applied"), "{:?}", p.warnings);
assert!(p.warnings.iter().any(|w| w == "2 drawing elements cut short or describing no shape were left out"), "{:?}", p.warnings);
assert_eq!(paths(&p.document).len(), 1);
// Continuous horizontal alignment before a text, and a marker type past cross before a marker.
let bytes = cgm(
&[],
&[extent()],
&[el(5, 18, &be(&[4, 0, 0, 0, 0, 0])), el(4, 4, &[be(&[100, 100, 1]), s("x")].concat()), el(5, 6, &be(&[6])), el(4, 3, &be(&[100, 100]))],
);
let p = import_cgm(&bytes).unwrap();
assert!(p.warnings.iter().any(|w| w == "text with continuous alignment was aligned left or on its baseline"), "{:?}", p.warnings);
let markers = "markers of types other than dot, plus, asterisk, circle and cross were drawn as plus signs";
assert!(p.warnings.iter().any(|w| w == markers), "{:?}", p.warnings);
}
#[test]
+6
View File
@@ -48,6 +48,12 @@ write-fonts = "0.48"
# The craft-fonts face types of the tables `build.rs` writes (`CRAFT_FONTS`, and `SERVED_FONTS` on the web).
craft-fonts-build = { workspace = true }
[target.'cfg(windows)'.dependencies]
# The fonts registered in the registry, compared by the font database's change check while the
# font catalog's own check leaves them out (src/fontdb/dirs.rs); MIT OR Apache-2.0, already in the
# build through the font catalog.
windows-registry = "0.6"
[build-dependencies]
# Embeds the craft-fonts faces (`Embed::write`) and, for the web, writes the served ones (`Embed::serve`).
craft-fonts-build = { workspace = true }
+5 -1
View File
@@ -46,12 +46,13 @@ use cache::GlyphCache;
use cache::{CanonicalNames, GlyphColours, GlyphImages};
pub use composite::{CompositeCoverage, LentCompositeFonts};
use craft::font_catalog::Catalog;
pub use db::FontWatch;
pub use dirs::{
PlatformFontFiles, app_font_dir, set_app_font_dir, set_platform_font_files, set_platform_font_files_complete, set_user_font_dirs,
set_user_font_dirs_confined, system_font_dirs, user_font_dirs,
};
#[cfg(test)]
pub(crate) use dirs::{sfnt_of, uses_font_service};
pub(crate) use dirs::{REGISTERED_IN_TESTS, sfnt_of, uses_font_service};
use face::Instances;
pub(crate) use face::PathAlignHeights;
pub use face::{FALLBACK_FAMILY, FontFace, IcfMargins, OutlineFormat};
@@ -103,6 +104,9 @@ pub struct FontDb {
/// never depends on what ran before them. It also holds the bundled faces, added when the
/// database is made and read from the binary in place.
catalog: Arc<Catalog>,
/// The registry's fonts as the catalog's last scan saw them, when the catalog does not compare
/// them itself ([`FontDb::installed_fonts_changed`]).
registered: Option<Arc<dirs::RegisteredFonts>>,
/// Fonts files carried for their type ([`vectorcraft_doc::FileFonts`]): apart from the faces,
/// so no family name, font menu, fallback or PostScript name lookup finds them.
pub(super) file_faces: RwLock<FileFaces>,
+65 -11
View File
@@ -4,7 +4,7 @@ use super::build::make_face;
use super::cache::{CanonicalNames, GlyphCache};
#[cfg(not(target_arch = "wasm32"))]
use super::dirs::confined_font_dirs;
use super::dirs::system_catalog;
use super::dirs::{RegisteredFonts, system_catalog};
use super::face::{BUNDLED, FontBytes, FontFace, Instances};
#[cfg(not(target_arch = "wasm32"))]
use super::names::SysFallback;
@@ -32,14 +32,14 @@ impl FontDb {
/// A database holding the bundled fonts, whose system font scan reads `font_dirs` (folders,
/// read with their subfolders, and font files) and nothing else.
pub fn with_font_dirs(font_dirs: Vec<PathBuf>) -> Self {
Self::new(font_dirs_catalog(font_dirs))
Self::new((font_dirs_catalog(font_dirs), None))
}
/// [`FontDb::with_font_dirs`] whose every scan also calls `lister` before it reads a folder,
/// for tests that hold a scan until they let it go on.
#[cfg(test)]
pub(crate) fn with_font_dirs_and_lister(font_dirs: Vec<PathBuf>, lister: craft::font_catalog::Lister) -> Self {
Self::new(font_dirs_catalog(font_dirs).with_lister(lister))
Self::new((font_dirs_catalog(font_dirs).with_lister(lister), None))
}
/// Same scan paths as [`FontDb::global`] (platform lister and font folders), for tests.
@@ -48,7 +48,15 @@ impl FontDb {
Self::new(system_catalog())
}
fn new(catalog: Catalog) -> Self {
/// [`FontDb::for_system_scan_test`] as with a complete platform lister
/// ([`super::set_platform_font_files_complete`]): the scan does not ask the platform's font service.
/// Its lister lists no platform files, so another test's process-wide lister does not change what it scans.
#[cfg(test)]
pub(crate) fn for_complete_lister_scan_test() -> Self {
Self::new(super::dirs::system_catalog_with(false, Vec::new))
}
fn new((catalog, registered): (Catalog, Option<Arc<RegisteredFonts>>)) -> Self {
#[cfg(not(target_arch = "wasm32"))]
catalog.set_confined_dirs(confined_font_dirs());
let mut faces = Vec::new();
@@ -70,6 +78,7 @@ impl FontDb {
images: Mutex::new(GlyphCache::default()),
colours: Mutex::new(GlyphCache::default()),
catalog: Arc::new(catalog),
registered,
file_faces: RwLock::new(super::FileFaces::default()),
canonical_cache: Mutex::new(CanonicalNames::new()),
#[cfg(not(target_arch = "wasm32"))]
@@ -414,16 +423,61 @@ impl FontDb {
}
/// Whether fonts were installed or removed since the last scan (a font folder it read
/// changed, or a new one is to be read), for [`FontDb::load_system_fonts`] to catalog them.
/// Costs a look at each folder the scan read, not a scan. `false` before the first scan and on
/// wasm.
/// changed, a new one is to be read, or on Windows the registry's font list changed), for
/// [`FontDb::load_system_fonts`] to catalog them. Costs a look at each folder the scan read,
/// not a scan. `false` before the first scan and on wasm.
pub fn installed_fonts_changed(&self) -> bool {
#[cfg(not(target_arch = "wasm32"))]
{
self.catalog.installed_fonts_changed()
}
let folders = self.catalog.installed_fonts_changed();
#[cfg(target_arch = "wasm32")]
false
let folders = false;
// No catalog leaves the registry to the database on wasm, where the font service is on.
folders || (self.catalog.is_ready() && self.registered.as_ref().is_some_and(|r| r.changed()))
}
/// Rescans the catalog when [`FontDb::installed_fonts_changed`] says so, registry included.
/// Returns whether it rescanned. One look of [`FontDb::watch`].
#[cfg(not(target_arch = "wasm32"))]
pub(crate) fn rescan_if_installed_fonts_changed(&self) -> bool {
let changed = self.installed_fonts_changed();
if changed {
self.catalog().rescan();
}
changed
}
/// Looks for installed and removed fonts every `interval` on a thread of its own, with
/// [`FontDb::installed_fonts_changed`], which also compares the registry's fonts when the
/// catalog's own check leaves them out. When they changed, it rescans the catalog and calls
/// `on_change`. Stops when the returned [`FontWatch`] is dropped.
#[cfg(not(target_arch = "wasm32"))]
pub fn watch(&'static self, interval: std::time::Duration, on_change: impl Fn() + Send + 'static) -> FontWatch {
let stop = Arc::new(std::sync::atomic::AtomicBool::new(false));
let flag = Arc::clone(&stop);
let _ = std::thread::Builder::new().name("font-db-watch".into()).spawn(move || {
loop {
std::thread::sleep(interval);
if flag.load(Ordering::Relaxed) {
return;
}
if self.rescan_if_installed_fonts_changed() {
on_change();
}
}
});
FontWatch { stop }
}
}
/// Stops a `FontDb::watch` when dropped.
#[must_use = "dropping a FontWatch stops it"]
pub struct FontWatch {
stop: Arc<std::sync::atomic::AtomicBool>,
}
impl Drop for FontWatch {
fn drop(&mut self) {
self.stop.store(true, Ordering::Relaxed);
}
}
+81 -4
View File
@@ -91,11 +91,88 @@ pub(crate) fn uses_font_service() -> bool {
/// The catalog of [`FontDb::global`]: the platform's font folders, the platform's font service
/// ([`uses_font_service`]), the font store, VectorCraft's own folders ([`app_dirs`]) and the files
/// [`set_platform_font_files`] lists.
pub(super) fn system_catalog() -> Catalog {
let catalog = Catalog::new(FontEnv::from_process()).with_font_service(uses_font_service()).with_lister(Arc::new(platform_font_files));
/// [`set_platform_font_files`] lists, with the registry's fonts its own change check leaves out.
pub(super) fn system_catalog() -> (Catalog, Option<Arc<RegisteredFonts>>) {
system_catalog_with(uses_font_service(), platform_font_files)
}
/// [`system_catalog`], asking the platform's font service when `service` and reading the files
/// `platform` lists. Without the service the catalog neither reads nor compares the fonts the
/// Windows registry lists, so its lister adds them to the scan and the database compares them
/// ([`RegisteredFonts`]).
pub(super) fn system_catalog_with(service: bool, platform: fn() -> Vec<PathBuf>) -> (Catalog, Option<Arc<RegisteredFonts>>) {
let registered = (!service).then(|| Arc::new(RegisteredFonts::default()));
let seen = registered.clone();
let lister = move || {
let mut files = platform();
if let Some(seen) = &seen {
files.extend(seen.record());
}
files
};
let catalog = Catalog::new(FontEnv::from_process()).with_font_service(service).with_lister(Arc::new(lister));
catalog.set_app_dirs(app_dirs());
catalog
(catalog, registered)
}
/// The font files the Windows registry lists by full path, as the last scan of a catalog whose
/// font service is off read them. That catalog does not compare them, so without this a font
/// registered from a folder no scan has read waits for a manual rescan. Remove it once the pinned
/// font catalog has `Catalog::with_registry` (storytold/craft-libs#5676) and [`system_catalog_with`]
/// turns that on.
#[derive(Default)]
pub(super) struct RegisteredFonts(super::Mutex<Option<Vec<PathBuf>>>);
impl RegisteredFonts {
/// Note the registry's list for the scan that is starting, and return it for the scan to read.
fn record(&self) -> Vec<PathBuf> {
let now = registered_font_files();
*self.0.lock().unwrap_or_else(std::sync::PoisonError::into_inner) = Some(now.clone());
now
}
/// Whether the registry's list changed since the last scan noted it: `false` before one. The
/// registry is read before the lock is taken, so a scan's [`RegisteredFonts::record`] does not
/// wait for the read.
pub(super) fn changed(&self) -> bool {
let now = registered_font_files();
self.0.lock().unwrap_or_else(std::sync::PoisonError::into_inner).as_ref().is_some_and(|seen| *seen != now)
}
}
#[cfg(test)]
thread_local! {
/// What [`registered_font_files`] gives on this thread in tests, in place of the registry.
pub(crate) static REGISTERED_IN_TESTS: std::cell::RefCell<Option<Vec<PathBuf>>> = const { std::cell::RefCell::new(None) };
}
/// The full paths the registry lists for the machine's and the current user's fonts, sorted and
/// each once, as the font catalog reads them. Bare file names (files in the Windows font folder)
/// are left out: the scan reads that folder. Empty elsewhere than on Windows.
fn registered_font_files() -> Vec<PathBuf> {
#[cfg(test)]
if let Some(files) = REGISTERED_IN_TESTS.with_borrow(Clone::clone) {
return files;
}
#[cfg(windows)]
{
const MAX_REGISTERED: usize = 1 << 16;
const KEY: &str = r"Software\Microsoft\Windows NT\CurrentVersion\Fonts";
use windows_registry::{CURRENT_USER, LOCAL_MACHINE};
let mut files: Vec<PathBuf> = [LOCAL_MACHINE, CURRENT_USER]
.into_iter()
.filter_map(|root| root.open(KEY).ok())
.flat_map(|key| key.values().map(|vs| vs.filter_map(|(_, v)| String::try_from(v).ok()).collect::<Vec<_>>()).unwrap_or_default())
.take(MAX_REGISTERED)
.map(PathBuf::from)
.filter(|p| p.is_absolute())
.collect();
files.sort();
files.dedup();
files
}
#[cfg(not(windows))]
Vec::new()
}
/// The folders VectorCraft adds to the platform's: its own Fonts folder ([`set_app_font_dir`]),
+1
View File
@@ -45,6 +45,7 @@ pub use features::{
EXTRA_FEATURES, LIGATURE_TRACKING_LIMITS, MAX_FEATURE_VALUE, MAX_STYLE_FEATURES, OtFeatures, explicit_ligatures, ligatures_suppressed_by,
};
pub use file_font::{FILE_FONT_UPEM, FileFontInfo, FileGlyph, MAX_FILE_GLYPHS, build_file_font};
pub use fontdb::FontWatch;
pub use fontdb::{
CompositeCoverage, FALLBACK_FAMILY, FontClass, FontDb, FontFace, FontLikeness, FontMatch, FontTraits, GENERIC_FAMILIES, GlyphAlternate,
GlyphCategory, GlyphCategoryKind, GlyphOrigin, IcfMargins, InstalledFace, JoiningPosition, LentCompositeFonts, MAX_FILE_FACES, OutlineFormat,
+40
View File
@@ -785,6 +785,46 @@ fn fonts_the_platform_lists_outside_the_font_folders_are_cataloged() {
assert_eq!(dirs.iter().filter(|d| **d == file).count(), 1, "{dirs:?}");
}
/// With a complete platform lister the catalog does not compare the fonts the Windows registry
/// lists, so the database does: a font registered from a folder no scan has read is a change, and
/// the scan that follows catalogs it and notes it.
#[test]
fn a_font_registered_since_the_scan_is_a_change_with_a_complete_lister() {
use crate::fontdb::REGISTERED_IN_TESTS;
REGISTERED_IN_TESTS.set(Some(Vec::new()));
let db = FontDb::for_complete_lister_scan_test();
assert!(!db.installed_fonts_changed(), "nothing to compare with before the first scan");
db.load_system_fonts();
assert!(!db.installed_fonts_changed());
let registered = std::env::temp_dir().join(format!("vc-sysfonts-{}-registered", std::process::id())).join("Registered.ttf");
std::fs::create_dir_all(registered.parent().unwrap()).unwrap();
std::fs::write(&registered, renamed_to("SourceSans3-Regular.ttf", "Registry Sans")).unwrap();
REGISTERED_IN_TESTS.set(Some(vec![registered.clone()]));
assert!(db.installed_fonts_changed(), "a font registered since the scan");
db.load_system_fonts();
assert_eq!(db.styles("Registry Sans"), ["Regular"], "the scan reads the font the registry lists");
assert!(!db.installed_fonts_changed(), "the scan noted the registered font");
REGISTERED_IN_TESTS.set(None);
let _ = std::fs::remove_dir_all(registered.parent().unwrap());
}
/// Each look of the font watch (`FontDb::watch`) uses the database's check, so a font registered
/// from a folder no scan has read rescans while the catalog's own check sees no change.
#[test]
fn the_font_watch_rescans_for_a_font_registered_since_the_scan() {
use crate::fontdb::REGISTERED_IN_TESTS;
REGISTERED_IN_TESTS.set(Some(Vec::new()));
let db = FontDb::for_complete_lister_scan_test();
db.load_system_fonts();
assert!(!db.rescan_if_installed_fonts_changed(), "nothing changed since the scan");
let registered = std::env::temp_dir().join(format!("vc-sysfonts-{}-watched", std::process::id())).join("Registered.ttf");
REGISTERED_IN_TESTS.set(Some(vec![registered]));
assert!(!db.catalog().installed_fonts_changed(), "the catalog's own check leaves the registry out");
assert!(db.rescan_if_installed_fonts_changed(), "a font registered since the scan");
assert!(!db.installed_fonts_changed(), "the watch's rescan noted the registered font");
REGISTERED_IN_TESTS.set(None);
}
#[test]
fn a_resource_fork_gives_up_its_font_files() {
let (regular, bold) = (renamed("SourceSans3-Regular.ttf"), renamed("SourceSans3-Bold.ttf"));
-1
View File
@@ -168,7 +168,6 @@ impl VectorcraftApp {
hover_object: None,
grab: None,
carry_target: None,
removed_press: false,
last_drag: None,
escaped_press: false,
pressed_at: None,
+5 -4
View File
@@ -17,9 +17,10 @@ impl VectorcraftApp {
// PLAN: hub-w1 calls `watch_fonts` once in `VectorcraftApp::new` (beside `scan_in_background`, app.rs:49) and `follow_fonts` once per frame in `tick` (app.rs:354-359), adds the fields `font_watch: Option<craft::font_catalog::Watch>` and `fonts_seen: u64` (lib.rs:280-285), makes `FONT_INSTALL_POLL` a `Duration` (state.rs:1585) and drops the `WindowFocused` refresh (app/input.rs:210).
impl VectorcraftApp {
/// Fonts installed or removed while the app runs are listed without Refresh Font List: the
/// font catalog looks at the font folders every [`FONT_INSTALL_POLL`] on a thread of its own
/// (asking the platform for the fonts font services loaded meanwhile takes tens of milliseconds
/// on Windows, #579), rescans only when they changed, and wakes the app for
/// font database looks at the font folders, and on Windows the registry's font list, every
/// [`FONT_INSTALL_POLL`] on a thread of its own (asking the platform for the fonts font services
/// loaded meanwhile takes tens of milliseconds on Windows, #579), rescans only when they
/// changed, and wakes the app for
/// [`Self::follow_fonts`]. Called once, at start; the watch stops with the app. Not on wasm,
/// which has no installed fonts.
///
@@ -28,7 +29,7 @@ impl VectorcraftApp {
#[cfg(not(target_arch = "wasm32"))]
{
let (ctx, changed) = (ctx.clone(), std::sync::Arc::clone(&self.fonts_changed));
let watch = vectorcraft_text::FontDb::global().catalog().watch(crate::state::FONT_INSTALL_POLL, move |_| {
let watch = vectorcraft_text::FontDb::global().watch(crate::state::FONT_INSTALL_POLL, move || {
changed.store(true, std::sync::atomic::Ordering::Release);
ctx.request_repaint();
});
-3
View File
@@ -123,9 +123,6 @@ pub struct CanvasCache {
/// The uid of the document a tab rest showed while art carried off the canvas waits over it: only its canvas takes
/// the art, so a target closed or left by other means carries nothing (`canvas::drops`).
pub carry_target: Option<u64>,
/// The tool host ended the tool's press with a `Removed` cancel in this pass: the canvas was hidden for a pass, as
/// when art carried off it rests on another document's tab and comes back (`tool_adapter::resume_carry`).
pub removed_press: bool,
/// The last drag the tool was sent and the screen point it was at: when the view scrolls under the held
/// pointer, the drag goes on at that point in the scrolled view.
pub last_drag: Option<(egui::Pos2, vectorcraft_tools::PointerEvent)>,
+50 -14
View File
@@ -682,6 +682,29 @@ struct MeshKey {
pixels_per_point: f32,
options: egui::epaint::TessellationOptions,
look: MarkLook,
/// [`Joins`] of the paint, or none under a fade.
joins: Option<Joins>,
}
/// When a mark's fill and its edge are one shape, as `BezierOverlay`'s kept mesh joins them: the edge is opaque and
/// wider than `thin_line`, the widest stroke egui tessellates as a translucent ridge (0.9 of the feathering, in points).
/// Under a fade (a painter opacity below 1) the overlay keeps them two shapes, so the fill shows through the edge.
#[derive(Clone, Copy, Debug, PartialEq)]
struct Joins {
thin_line: f32,
}
impl Joins {
/// The joins of a painter at `opacity` with `options` at `pixels_per_point`.
fn of(opacity: f32, options: &egui::epaint::TessellationOptions, pixels_per_point: f32) -> Option<Self> {
let thin_line = if options.feathering { 0.9 * (options.feathering_size_in_pixels * (1.0 / pixels_per_point)) } else { 0.0 };
(opacity >= 1.0).then_some(Self { thin_line })
}
/// Whether a fill and then `edge` around the same square or circle are one shape.
fn join(joins: Option<Self>, edge: Stroke) -> bool {
joins.is_some_and(|joins| edge.color.is_opaque() && edge.width > joins.thin_line)
}
}
/// The anchor marks tessellated as one mesh, and what they were tessellated from.
@@ -865,19 +888,21 @@ impl Component for AnchorMarks<'_> {
reach: style.reach,
};
let painter = ui.content_painter(cx);
let (pixels_per_point, options) = (painter.pixels_per_point(), painter.painter.ctx().tessellation_options(|options| *options));
let key = MeshKey {
marks: self.key,
view: space.view,
rect: cx.rect,
clip: painter.painter.clip_rect(),
pixels_per_point: painter.pixels_per_point(),
options: painter.painter.ctx().tessellation_options(|options| *options),
pixels_per_point,
options,
look,
joins: Joins::of(painter.painter.opacity(), &options, pixels_per_point),
};
let shapes = || {
let mut shapes = Vec::new();
for set in mark_sets(self.anchors) {
mark_shapes(&mut shapes, &set, &space.view, cx.rect, &look);
mark_shapes(&mut shapes, &set, &space.view, cx.rect, &look, key.joins);
}
shapes
};
@@ -955,8 +980,9 @@ fn mark_sides(options: &PathOptionsSettings, look: &MarkLook) -> [f32; 2] {
}
/// The egui shapes `BezierOverlay` paints for `set` under `BezierTool::Anchors`, in its order: every outline, the
/// selected segment, then the anchors and handles near `rect`, then the handles of the other paths' selected anchors.
fn mark_shapes(out: &mut Vec<Shape>, set: &MarkSet<'_>, view: &CanvasView, rect: Rect, look: &MarkLook) {
/// selected segment, then the anchors and handles near `rect`, then the handles of the other paths' selected anchors
/// that reach near `rect`. An anchor's or a handle end's fill and edge are one shape under `joins`.
fn mark_shapes(out: &mut Vec<Shape>, set: &MarkSet<'_>, view: &CanvasView, rect: Rect, look: &MarkLook, joins: Option<Joins>) {
let options = set.options;
let option_color = options.color.map(|[r, g, b]| Color32::from(Srgba::rgb(f32::from(r) / 255.0, f32::from(g) / 255.0, f32::from(b) / 255.0)));
let path_color = |path: &EditPath| path.color.map(Color32::from);
@@ -1006,14 +1032,18 @@ fn mark_shapes(out: &mut Vec<Shape>, set: &MarkSet<'_>, view: &CanvasView, rect:
MarkFill::Path => color.unwrap_or(look.line),
};
let edge = Stroke::new(look.thin, color.unwrap_or(look.edge));
if circle {
let radius = side / 2.0;
out.push(Shape::Circle(egui::epaint::CircleShape { center: at, radius, fill, stroke: Stroke::NONE }));
out.push(Shape::Circle(egui::epaint::CircleShape { center: at, radius, fill: Color32::TRANSPARENT, stroke: edge }));
let shape = |fill: Color32, stroke: Stroke| {
if circle {
Shape::Circle(egui::epaint::CircleShape { center: at, radius: side / 2.0, fill, stroke })
} else {
Shape::Rect(egui::epaint::RectShape::new(Rect::from_center_size(at, egui::Vec2::splat(side)), 0.0, fill, stroke, StrokeKind::Inside))
}
};
if Joins::join(joins, edge) {
out.push(shape(fill, edge));
} else {
let square = Rect::from_center_size(at, egui::Vec2::splat(side));
out.push(Shape::Rect(egui::epaint::RectShape::new(square, 0.0, fill, Stroke::NONE, StrokeKind::Inside)));
out.push(Shape::Rect(egui::epaint::RectShape::new(square, 0.0, Color32::TRANSPARENT, edge, StrokeKind::Inside)));
out.push(shape(fill, Stroke::NONE));
out.push(shape(Color32::TRANSPARENT, edge));
}
};
// A direction handle: its line from the anchor, then its end.
@@ -1046,7 +1076,10 @@ fn mark_shapes(out: &mut Vec<Shape>, set: &MarkSet<'_>, view: &CanvasView, rect:
if circles || set.handles == HandlesShown::All {
return;
}
// The handles of anchors selected in paths other than the edited one.
// The handles of anchors selected in paths other than the edited one whose end is near `rect`, or whose line from
// the anchor may cross it. Near is the reach, or the half side and edge of the largest handle end and one point for
// its feathered edge when that is further.
let near = rect.expand(look.reach.max(look.anchor.max(look.large) / 2.0 + look.thin + 1.0));
let edited = set.selection.path.map_or(0, |_| set.selection.anchors.len());
for path in set.paths {
if set.selection.path == Some(path.key) || !selected.listed.contains(&path.key) {
@@ -1055,7 +1088,10 @@ fn mark_shapes(out: &mut Vec<Shape>, set: &MarkSet<'_>, view: &CanvasView, rect:
let own = PathSelection::new(Some(path.key), Vec::new(), None);
let listed = |key: u64, knot: KnotRef| selected.others.contains(&(key, knot));
for (_, knot, end) in handles_of(std::slice::from_ref(path), &own, listed, selected.others_len + edited, set.handles, view) {
handle(out, path, knot, end);
let reaches = near.contains(end) || path.knot(knot).is_some_and(|k| Rect::from_two_pos(view.to_screen(k.anchor), end).intersects(near));
if reaches {
handle(out, path, knot, end);
}
}
}
}
@@ -1132,6 +1132,16 @@ fn the_anchor_marks_paint_what_the_bezier_overlay_paints() {
}
});
app.session.active_mut().unwrap().selection.segments.clear();
// Another path's selected anchors far off the canvas: their handles, ends and lines both off it, are left out.
let far = id_of(&app.run("path.create", json!({"d": "M-3000 -3000 C-2900 -3100 -2800 -3100 -2700 -3000"})).unwrap());
app.run("select.anchors", json!({"id": curve.0, "anchors": [[0, 1]], "mode": "set"})).unwrap();
app.run("select.anchors", json!({"id": far.0, "anchors": [[0, 0], [0, 1]], "mode": "add"})).unwrap();
compare(&mut app, "handles of another path off the canvas", &|anchors| {
assert!(
anchors.selection.others.iter().any(|(key, knots)| !knots.is_empty() && anchors.paths.iter().any(|p| p.key == *key)),
"another path's anchors are selected"
);
});
app.run("select.set", json!({"ids": [curve.0]})).unwrap();
app.select_tool("curvature");
compare(&mut app, "the Curvature tool", &same);
@@ -1439,6 +1449,7 @@ fn kept_at_one_pixel_per_point() -> KeptMesh {
pixels_per_point: 1.0,
options: egui::epaint::TessellationOptions::default(),
look,
joins: Joins::of(1.0, &egui::epaint::TessellationOptions::default(), 1.0),
},
mesh: Arc::new(egui::Mesh::default()),
moved: [0.0; 2],
-33
View File
@@ -1,9 +1,7 @@
//! The document tool as the framework's `CanvasTool`: the pointer and key calls of the tool host go to the engine
//! session, and what the session asks of the UI is applied here.
use std::any::Any;
use std::cell::{Cell, RefCell, RefMut};
use std::sync::Arc;
use craft::behavior::{CancelReason, CanvasView, Cursor, PointerKind as Device, PressPhase};
use craft::keymap::{Chord, Key};
@@ -12,9 +10,6 @@ use craft::ui::canvas::{
Autoscroll, CanvasTool, Momentary, MomentaryShift, ToolAction, ToolClaims, ToolContext, ToolHost, ToolHostResponse, ToolKey, ToolPass,
ToolPointer,
};
use craft::ui::contract::DragPreview;
use craft::ui::runtime::drag;
use craft::ui::runtime::env::Env;
use serde_json::json;
use vectorcraft_engine::ViewInfo;
use vectorcraft_geom::Point;
@@ -453,9 +448,6 @@ impl CanvasTool for SessionTool<'_> {
fn cancel(&mut self, reason: CancelReason, cx: &mut ToolContext<'_>) {
self.send_samples();
let mut app = self.app();
if reason == CancelReason::Removed {
app.canvas.removed_press = true;
}
if app.ui.screen_mode == 3 {
// The tool had no press of Presentation Mode's.
app.canvas.last_drag = None;
@@ -712,8 +704,6 @@ pub(crate) fn run(app: &mut VectorcraftApp, ui: &mut Ui, pass: &ToolPass) -> Too
app.canvas.keys_at = Some(ui.input(|i| i.time));
}
let view_info = app.view_info();
let carry = carried_session(ui.ctx());
app.canvas.removed_press = false;
let mut picked = ToolHostResponse::default();
let mut response = if crate::dialogs::recolor::edit_tab::with_theme_pick(app, |app, tool| picked = host_run(app, ui, pass, tool)) {
picked
@@ -747,7 +737,6 @@ pub(crate) fn run(app: &mut VectorcraftApp, ui: &mut Ui, pass: &ToolPass) -> Too
drop(tool);
response
};
resume_carry(app, ui, pass, carry);
// The framework ends a press at Escape; the engine's tool still takes the release that ends it.
if app.canvas.escaped_press && !ui.input(|i| i.pointer.primary_down()) {
app.canvas.escaped_press = false;
@@ -796,28 +785,6 @@ pub(crate) fn run(app: &mut VectorcraftApp, ui: &mut Ui, pass: &ToolPass) -> Too
response
}
/// The art a move carries off the canvas and what the panels see of it, while that drag session runs.
type Carry = (Arc<super::drops::CarriedArt>, Arc<crate::panel_drag::PanelDrag>);
/// The drag session of art carried off the canvas, when one runs.
fn carried_session(ctx: &egui::Context) -> Option<Carry> {
Some((drag::active::<super::drops::CarriedArt>(ctx)?, drag::active::<crate::panel_drag::PanelDrag>(ctx)?))
}
/// Starts the drag session `carry` again when the tool host ended it in this pass with the press's `Removed` cancel
/// while the button is still held. The canvas was hidden for a pass, as when the art rests on another document's tab
/// and comes back, and the release then drops the art where it lands.
// Workaround: storytold/craft-libs#5281 keeps the session running; remove this with the pin bump that takes it.
fn resume_carry(app: &mut VectorcraftApp, ui: &Ui, pass: &ToolPass, carry: Option<Carry>) {
let removed = std::mem::take(&mut app.canvas.removed_press);
let Some((art, panel)) = carry else { return };
if !removed || drag::active::<super::drops::CarriedArt>(ui.ctx()).is_some() || !ui.input(|i| i.pointer.primary_down()) {
return;
}
let also: Arc<dyn Any + Send + Sync> = panel;
drag::start(ui.ctx(), pass.id, &Env::of(ui).view(), art, vec![also], DragPreview::None);
}
fn host_run_session(tool: &mut SessionTool<'_>, ui: &Ui, pass: &ToolPass) -> ToolHostResponse {
let mut app = tool.app();
// The host borrows the tool and the app both through the cell, one call at a time.
+3 -2
View File
@@ -482,8 +482,9 @@ impl craft::behavior::ItemSource<usize> for Boards {
}
/// The native versions VectorCraft writes, newest first, each with the first release that reads
/// it (the format version each release tag writes: 2 in 0.1, 3 from 0.2, 4 from 0.8).
const NATIVE_VERSIONS: [(u32, &str); 4] = [(4, "0.8"), (3, "0.2"), (2, "0.1"), (1, "0.1")];
/// it (the format version each release tag writes: 2 in 0.1, 3 from 0.2, 4 from 0.8, 5 from the
/// release after 0.25.2).
const NATIVE_VERSIONS: [(u32, &str); 5] = [(5, "0.25.3"), (4, "0.8"), (3, "0.2"), (2, "0.1"), (1, "0.1")];
/// The native version the dialog will write (the current one unless chosen).
fn native_version_of(fields: &DialogFields) -> u32 {
+2 -2
View File
@@ -250,8 +250,8 @@ pub struct VectorcraftApp {
pub(crate) original_editor: original_editor::Draft,
/// The screen colour picker: the pick in progress and where its colour goes.
pub(crate) screen_pick: craft::color_ui::ui::ScreenPick,
/// The font catalog's watch for fonts installed or removed while the app runs.
pub(crate) font_watch: Option<craft::font_catalog::Watch>,
/// The font database's watch for fonts installed or removed while the app runs.
pub(crate) font_watch: Option<vectorcraft_text::FontWatch>,
/// Set by [`Self::font_watch`] when it found fonts installed or removed, until the documents' fonts are scanned
/// again for them.
pub(crate) fonts_changed: std::sync::Arc<std::sync::atomic::AtomicBool>,
+4 -3
View File
@@ -1578,13 +1578,14 @@ fn layers_and_swatches(app: &mut VectorcraftApp, ui: &mut egui::Ui) {
crate::panels::swatches::show(app, ui);
}
/// The texture of the icon drawn inside `rect`.
fn icon_texture(shapes: &[egui::Shape], rect: egui::Rect) -> egui::TextureId {
/// The texture of the icon drawn inside `rect`, and the part of it the icon shows: icons share packed atlas pages.
fn icon_texture(shapes: &[egui::Shape], rect: egui::Rect) -> (egui::TextureId, egui::Rect) {
shapes
.iter()
.find_map(|shape| match shape {
egui::Shape::Mesh(mesh) if mesh.texture_id != egui::TextureId::default() && rect.contains_rect(mesh.calc_bounds()) => {
Some(mesh.texture_id)
let uv: Vec<egui::Pos2> = mesh.vertices.iter().map(|v| v.uv).collect();
Some((mesh.texture_id, egui::Rect::from_points(&uv)))
}
_ => None,
})
@@ -2169,3 +2169,72 @@ fn raster_settings_sets_resolution_and_background() {
assert_eq!(render_of(&panel.app(), id)["resolution"], Value::Null, "{id}");
}
}
/// Raster Settings… shows Color as RGB (in a CMYK document too, since the image is made in RGB),
/// Grayscale or Bitmap. OK sets the picked model on every object in one undo step; a model the
/// objects hold differently opens blank and stays as each object has it.
#[test]
fn raster_settings_sets_the_color_model() {
use craft::ui::contract::Role;
use craft::ui::dialog::dialog_id;
use craft::ui::patterns::form_dialogs::HostedParamDialog;
use crate::tests::panel_harness::Panel;
let (app, a, b) = two_renders();
let mut panel = Panel::new(app, show_with_dialogs);
panel.frame();
let (id, ctx) = (dialog_id(super::raster::KIND), panel.ctx().clone());
let is_open = |panel: &Panel| panel.app().dialogs().is_some_and(|d| d.with(|host| host.get_mut_by_id::<HostedParamDialog>(id).is_some()));
let set = |panel: &Panel, key: &str, value: Value| panel.app().dialogs().unwrap().with(|host| host.set_json_field(&ctx, id, key, value)).unwrap();
let ok = |panel: &mut Panel| {
panel.app().dialogs().unwrap().with(|host| host.confirm_by_id(&ctx, id));
panel.frame();
panel.frame();
};
let open = |panel: &mut Panel| {
panel.click("Render Settings");
panel.click("Raster Settings…");
panel.frame();
assert!(is_open(panel));
};
open(&mut panel);
assert_eq!(panel.value_role("Color", Role::COMBO_BOX).as_deref(), Some("RGB"), "both objects take the document's color mode");
let history = undo_len(&panel.app());
set(&panel, "colorModel", json!("grayscale"));
ok(&mut panel);
assert!(!is_open(&panel));
assert_eq!(undo_len(&panel.app()), history + 1, "OK is one undo step for the selection");
for id in [a, b] {
assert_eq!(render_of(&panel.app(), id)["colorModel"], "grayscale", "{id}");
}
open(&mut panel);
assert_eq!(panel.value_role("Color", Role::COMBO_BOX).as_deref(), Some("Grayscale"));
ok(&mut panel);
assert_eq!(undo_len(&panel.app()), history + 1, "OK with what every object holds records no undo step");
panel.app().run("select.set", json!({"ids": [b]})).unwrap();
let mut bitmap = render_of(&panel.app(), b);
bitmap["colorModel"] = json!("bitmap");
panel.app().run("effect.setParams", json!({"index": 0, "item": null, "params": {"render": bitmap}})).unwrap();
panel.app().run("select.set", json!({"ids": [b, a]})).unwrap();
panel.frame();
open(&mut panel);
let shown = panel.value_role("Color", Role::COMBO_BOX).unwrap_or_default();
assert!(!["RGB", "Grayscale", "Bitmap"].contains(&shown.as_str()), "a mixed color model shows {shown:?}");
let history = undo_len(&panel.app());
set(&panel, "background", json!("transparent"));
ok(&mut panel);
assert_eq!(undo_len(&panel.app()), history + 1);
assert_eq!(render_of(&panel.app(), a)["colorModel"], "grayscale", "a blank color model stays as each object has it");
assert_eq!(render_of(&panel.app(), b)["colorModel"], "bitmap");
panel.app().run("file.documentColorMode", json!({"mode": "cmyk"})).unwrap();
panel.frame();
open(&mut panel);
set(&panel, "colorModel", json!("document"));
panel.frame();
assert_eq!(panel.value_role("Color", Role::COMBO_BOX).as_deref(), Some("RGB"), "the image is made in RGB in a CMYK document");
ok(&mut panel);
for id in [a, b] {
assert_eq!(render_of(&panel.app(), id)["colorModel"], "document", "{id}");
}
}
+1
View File
@@ -550,6 +550,7 @@ fn render_value(render: &Map<String, Value>, key: &str) -> Value {
"mode" => json!("shaded"),
"quality" => json!("medium"),
"background" => json!("transparent"),
"colorModel" => json!("document"),
_ => Value::Null,
})
}
+46 -13
View File
@@ -1,9 +1,10 @@
//! Render Settings › Raster Settings…: the resolution and background of the rendered image of each
//! selected object's 3D effect.
//! Render Settings › Raster Settings…: the resolution, background and color model of the rendered
//! image of each selected object's 3D effect.
//!
//! Fields: `document` (Use Document Raster Effects Resolution), `resolution` (1 to 2400 ppi) and
//! `background` (`transparent` or `white`). A field the selected objects hold differently opens
//! blank, and OK leaves it as each object has it. OK runs one `effect.setParams` over the objects
//! Fields: `document` (Use Document Raster Effects Resolution), `resolution` (1 to 2400 ppi),
//! `background` (`transparent` or `white`) and `colorModel` (`document`, shown as RGB, the image it
//! makes in every document; `grayscale` or `bitmap`). A field the selected objects hold differently
//! opens blank, and OK leaves it as each object has it. OK runs one `effect.setParams` over the objects
//! selected when the dialog opened, one undo step, which records none when every object already
//! holds what it sets. While another document is the active one, or after the document was
//! reverted or had an Undo, Redo or canceled edit, OK keeps the dialog open with the reason.
@@ -54,6 +55,11 @@ pub(crate) fn open(app: &mut VectorcraftApp) -> Result<(), String> {
Some(b) => fields.set("background", FieldValue::Text(b.clone())),
None => fields.set_mixed("background"),
}
let color_model = shared_render(&renders, "colorModel").as_ref().and_then(Value::as_str).map(str::to_owned);
match &color_model {
Some(m) => fields.set("colorModel", FieldValue::Text(m.clone())),
None => fields.set_mixed("colorModel"),
}
let ctx = app.ui_ctx.clone().ok_or("no window")?;
let dialog = HostedParamDialog::new(&ctx, KIND, fields, |fields| dialog().values(Bind::bound(fields)));
let (doc, targets) = app
@@ -71,7 +77,7 @@ pub(crate) fn open(app: &mut VectorcraftApp) -> Result<(), String> {
(Some((st.uid, st.reverts, st.history_restores)), targets)
})
.unwrap_or_default();
let opened = Opened { document, resolution: opening, background, doc, targets };
let opened = Opened { document, resolution: opening, background, color_model, doc, targets };
open_held(app, dialog, move |app, answer| ok(app, answer, &opened)).ok_or("no window")?;
Ok(())
}
@@ -84,12 +90,19 @@ fn opening_resolution(resolutions: &[Option<f64>], ppi: f64) -> Option<f64> {
effective.all(|r| r == first).then_some(first)
}
/// The dialog over its rows.
/// The dialog over its rows. Color's `document` shows as RGB in every document: the image is made in
/// RGB, and a CMYK document's PDF export converts it as it converts raster effect images.
fn dialog<'a>() -> ParamDialog<'a> {
let backgrounds = vec![("transparent".to_owned(), tl!("Transparent").into()), ("white".to_owned(), tl!("White").into())];
let models = vec![
("document".to_owned(), tl!("RGB").into()),
("grayscale".to_owned(), tl!("Grayscale").into()),
("bitmap".to_owned(), tl!("Bitmap").into()),
];
let params = vec![
Param::new("document", tl!("Use Document Raster Effects Resolution"), ParamKind::bool(true)),
Param::number("resolution", tl!("Resolution (ppi):"), 72.0, 1.0, 0).bounds(Some(1.0), Some(2400.0)).enabled_when("document", false),
Param::new("colorModel", tl!("Color:"), ParamKind::choice(models, None)),
Param::new("background", tl!("Background:"), ParamKind::radio(backgrounds, None)),
];
ParamDialog::new(KIND, tl!("Raster Settings"), params)
@@ -101,6 +114,7 @@ struct Opened {
document: Option<bool>,
resolution: Option<f64>,
background: Option<String>,
color_model: Option<String>,
/// The document the dialog opened on: its uid, and its revert count and history restore count (Undo, Redo or a canceled edit) then.
doc: Option<(u64, u64, u64)>,
/// The selected objects whose render settings the dialog opened on, as they were then: OK sets
@@ -135,6 +149,9 @@ fn edited(f: &DialogFields, opened: &Opened) -> Result<Map<String, Value>, Strin
if let Some(background) = f.text("background").filter(|b| opened.background.as_deref() != Some(*b)) {
render.insert("background".into(), json!(background));
}
if let Some(model) = f.text("colorModel").filter(|m| opened.color_model.as_deref() != Some(*m)) {
render.insert("colorModel".into(), json!(model));
}
Ok(render)
}
@@ -226,12 +243,12 @@ mod tests {
/// resolution sets nothing and a changed one sets it.
#[test]
fn ok_needs_a_resolution_and_keeps_blank_fields() {
let on = Opened { document: Some(true), resolution: Some(72.0), background: Some("transparent".into()), doc: None, targets: vec![] };
let on = Opened { document: Some(true), resolution: Some(72.0), background: Some("transparent".into()), ..opened() };
assert_eq!(edited(&fields(&[("document", FieldValue::Bool(false))]), &on), Err(NO_RESOLUTION.to_string()));
let own = Opened { document: Some(false), resolution: None, background: Some("transparent".into()), doc: None, targets: vec![] };
let own = Opened { document: Some(false), resolution: None, background: Some("transparent".into()), ..opened() };
let kept = edited(&fields(&[("document", FieldValue::Bool(false)), ("background", FieldValue::Text("white".into()))]), &own).unwrap();
assert_eq!(kept, Map::from_iter([("background".to_string(), json!("white"))]));
let mixed = Opened { document: None, resolution: Some(150.0), background: None, doc: None, targets: vec![] };
let mixed = Opened { document: None, resolution: Some(150.0), ..opened() };
assert_eq!(edited(&fields(&[("resolution", FieldValue::Number(150.0))]), &mixed), Ok(Map::new()));
let changed = edited(&fields(&[("resolution", FieldValue::Number(200.0))]), &mixed).unwrap();
assert_eq!(changed.get("resolution").and_then(Value::as_f64), Some(200.0));
@@ -243,14 +260,21 @@ mod tests {
/// mixed one sets it.
#[test]
fn ok_on_unchanged_values_sets_nothing() {
let on = Opened { document: Some(true), resolution: Some(72.0), background: Some("transparent".into()), doc: None, targets: vec![] };
let on = Opened {
document: Some(true),
resolution: Some(72.0),
background: Some("transparent".into()),
color_model: Some("document".into()),
..opened()
};
let unchanged = fields(&[
("document", FieldValue::Bool(true)),
("resolution", FieldValue::Number(72.0)),
("background", FieldValue::Text("transparent".into())),
("colorModel", FieldValue::Text("document".into())),
]);
assert_eq!(edited(&unchanged, &on), Ok(Map::new()));
let own = Opened { document: Some(false), resolution: Some(150.0), background: Some("transparent".into()), doc: None, targets: vec![] };
let own = Opened { document: Some(false), resolution: Some(150.0), background: Some("transparent".into()), ..opened() };
let kept = fields(&[("document", FieldValue::Bool(false)), ("resolution", FieldValue::Number(150.0))]);
assert_eq!(edited(&kept, &own), Ok(Map::new()));
let raised = edited(&fields(&[("document", FieldValue::Bool(false)), ("resolution", FieldValue::Number(200.0))]), &own).unwrap();
@@ -259,8 +283,17 @@ mod tests {
assert_eq!(switched, Map::from_iter([("resolution".to_string(), Value::Null)]));
let white = edited(&fields(&[("background", FieldValue::Text("white".into()))]), &on).unwrap();
assert_eq!(white, Map::from_iter([("background".to_string(), json!("white"))]));
let mixed = Opened { document: Some(true), resolution: Some(72.0), background: None, doc: None, targets: vec![] };
let mixed = Opened { document: Some(true), resolution: Some(72.0), ..opened() };
let picked = edited(&fields(&[("background", FieldValue::Text("transparent".into()))]), &mixed).unwrap();
assert_eq!(picked, Map::from_iter([("background".to_string(), json!("transparent"))]));
let gray = edited(&fields(&[("colorModel", FieldValue::Text("grayscale".into()))]), &on).unwrap();
assert_eq!(gray, Map::from_iter([("colorModel".to_string(), json!("grayscale"))]));
let model = edited(&fields(&[("colorModel", FieldValue::Text("document".into()))]), &mixed).unwrap();
assert_eq!(model, Map::from_iter([("colorModel".to_string(), json!("document"))]), "a model picked over a mixed one sets it");
}
/// The values a dialog opened blank on, with no document or objects.
fn opened() -> Opened {
Opened { document: None, resolution: None, background: None, color_model: None, doc: None, targets: vec![] }
}
}
+41 -6
View File
@@ -880,8 +880,8 @@ ends the wait, so the sampler can be shown again. The BSDs and headless sessions
| `invoke_menu` | `{command, params?}` | Invokes a menu item by command id. UI commands such as `view.*` and `window.*` are in `command_list` with `ui: true`; running them needs the desktop app (`--connect`). The app refuses `attributes.openUrl`, `file.export.svg.browser`, `file.saveForWeb.browser` and `file.showPackage` for every control and MCP request, since each opens another app, so the headless error for them does not suggest `--connect`. |
| `open_panel` | `{panel}` | Remote only. `panel` is a panel id (`layers`, `swatches`, `colorGuide`, …, as `window.panel` takes) or its display label (`"Color Guide"`), in any case. |
| `screenshot` | `{path?, scale?, artboard?, window?, max_side?, traceViews?}` | Returns MCP image content (`image/png`, base64) plus a text block. Renders the artboard with the pixels of a PNG `export` with `background: "white"` at the same scale; `traceViews:true` draws Image Trace objects in the view set with `imageTrace.setView`, as in the app's window; `window:true` captures the app window (remote only), as `ui_screenshot` does, and `max_side` (1–4096, window captures only) scales the returned image down as described for `ui_screenshot`. With `path` the backend (the headless session or the app) writes the PNG there too; a window capture written there keeps its full size with `max_side`. An app that does not send the image back writes a window capture without `path` to a file in a new folder inside the system's temporary folder (on Unix only the user can open it); the server reads the file and then removes the folder, also when the capture or the read fails. |
| `open_file` | `{path, importer?, params?}` | Opens any readable file as a new active document: `.vectorcraft`/`.drawcraft`, `.vctemplate`, `.svg`/`.svgz`, `.pdf`/`.ai`, `.ait`, `.eps`/`.epsf`, `.ps`, `.dxf`, `.emf`, `.wmf`, PICT (`.pct`/`.pic`/`.pict`, and a version 2 picture of any extension), HP-GL (`.plt`/`.hpgl`/`.hgl`/`.hpg`, and a file of an extension no other format reads that starts with plotter instructions), PNG (`.png`/`.pns`), JPEG (`.jpg`/`.jpeg`/`.jpe`), GIF, WebP, TIFF, BMP (`.bmp`/`.dib`/`.rle`), Targa (`.tga`/`.vda`/`.icb`/`.vst`), PCX, Pixar (`.pxr`), JPEG 2000 (`.jpf`/`.jpx`/`.jp2`/`.j2k`/`.j2c`/`.jpc`), HEIC/HEIF (`.heic`/`.heif`), JPEG XL (`.jxl`), PSD (`.psd`/`.pdd`)/PSB (an image opens as a document of its pixel size; a PSD or PSB file with its layers as layers, or as its merged image through `run_command document.open` with `layers: false`; a JPEG XL file as its first frame), CDR drawings of versions 1 to 27 (`.cdr`, `.cdt`), CMX files with 32-bit coordinates (`.cmx`), layered raster `.pcraft` documents (as one image at the canvas size; a warning says when only the smaller preview could be read), DWG drawings (`.dwg`, `.dws`, `.dwt`). Templates (`.vctemplate`, `.ait`, `.cdt`, `.dwt`) open as a new untitled document. A text, RTF or Word file (`.txt`, `.rtf`, `.docx`, `.doc`) opens as a new letter-size document named after the file, its text area type 36 pt inside the artboard as `file.place` sets it; `run_command document.open` with `text` gives a `.txt` file's Text Import Options, and Save asks for a name. A `.txt` file without text, and an RTF file that ends inside a group, are refused and open nothing. A file with one of those extensions that starts with a PDF header or an Affinity signature opens as that format instead. PDF, `.ai` and SVG files saved with Preserve Editing reopen as the document they carry. The reply is `document.open`'s: its `warnings` say what didn't come in as it was (an EPS whose PostScript can't be read opens as its preview, and the warning names the PostScript error, the operator and the procedure). A file of an extension only an installed importer plug-in lists opens with that importer ([Plug-ins](#plug-ins)); `importer: "plugin.<id>"` opens the file with the importer it names, which must list the file's extension, also one a built-in format reads (in the app, as File › Open With does), and `params` gives that importer's parameters (their defaults when omitted). `run_command document.formats` lists the formats. |
| `save_file` | `{path?, compress?, version?, preview?, precision?, options?}` | Runs `document.save`: the document's own file in its own format (native `.vectorcraft` unless it was opened from or saved as SVG, PDF or a restorable `.ai`; then `warnings` say what that format loses). A path's extension picks the format (`.vectorcraft`, `.vctemplate`, `.pdf`, `.svg`, `.svgz`, `.ai`: a PDF carrying the native document, which reopens editable; `.eps`: by default one file whose bounding box fits the visible art, the first artboard when no art shows; `options.useArtboards: true` makes the chosen artboard the page and, with two or more chosen, the file at the path is the central file of the visible art and each artboard is also written to `<name>_<artboard>.eps` beside it, listed in the reply's `files`). For a native file, `compress: true` gzips it (default: the `useCompression` preference, Preferences › File Handling › Use Compression), `version` (1 to 4) writes it for an older VectorCraft (1 and 2 are never compressed, and `version: 2` with `compress: true` is an error; versions 1 to 3 get each live star as a plain path of its outline, without its point count and ratio), `preview: true` embeds a PNG of the first artboard, and `precision` (0 to 9) rounds path anchors and handles to that many decimal places for that save only (colors, transforms and type stay exact). `options` passes the format's save options as `run_command document.formats` lists them. When `compress`, `version`, `preview` or `precision` is given both at the top level and in `options` with different values, the call is an error (`` `compress: true` and `options.compress: false` disagree: give the option once ``) and nothing is written. A key in `options` that no save format takes is an error, and nothing is written (see Parameter keys). The save drops each option the written format doesn't read. The reply's `warnings` then name each such option given (for example `` `compress` was not used: SVG files don't read it `` for an `.svg` path, and `` `options.preview` was not used: … `` for a key in `options`; a PDF-compatible `.ai` file reads `compress` but not `version`, `preview`, `precision`, `outlineText`, `hiddenObjects`, `transparentImages` or `preserveEditing`, and a legacy `.ai` file reads only its own options). For a `.ai` file, these warnings name the kind of `.ai` written: a legacy .ai (version 7) for `aiVersion: "7"`, a non-PDF-compatible .ai for `pdfCompatible: false`, and a PDF-compatible .ai otherwise, including a save that reuses the options the document was last saved with. `run_command document.save` and the other save commands refuse any option given beside the path and in `options` with different values, and give the same warnings for each key given beside the path or in `options` that the file doesn't read. The headless session and the app receive the same `app.save` params, and the app is also sent `wait: true`: the call returns once the file is written, or with the error (such as a path outside the write root), even with Background Save on. When the save asks first (the question before replacing a file that opened with losses, or on macOS and Linux the file dialog for an untitled document without `path`), the reply is `{pending}` or `"cancelled"` as before, and the save that runs after the answer uses the Background Save preference. Location refusals return `READ_ONLY_LOCATION: <reason>` without a fallback panel for automation; see [Save location errors](#save-location-errors). In the desktop app, a save that runs in the background shows in the progress window after 0.4 s with a moving bar. `file.cancelSave` stops every such save before it replaces its file → `{cancelled: n}`: the file stays as it was, and the document keeps its file and format and stays modified. A save whose file was already being replaced finishes and is reported as saved. `file.saveInBackground` closes the window while the saves go on → `{hidden: n}`. |
| `open_file` | `{path, importer?, params?}` | Opens any readable file as a new active document: `.vectorcraft`/`.drawcraft`, `.vctemplate`, `.svg`/`.svgz`, `.pdf`/`.ai`, `.ait`, `.eps`/`.epsf`, `.ps`, `.dxf`, `.emf`, `.wmf`, PICT (`.pct`/`.pic`/`.pict`, and a version 2 picture of any extension), binary CGM (`.cgm`, and a binary CGM of any extension), HP-GL (`.plt`/`.hpgl`/`.hgl`/`.hpg`, and a file of an extension no other format reads that starts with plotter instructions), PNG (`.png`/`.pns`), JPEG (`.jpg`/`.jpeg`/`.jpe`), GIF, WebP, TIFF, BMP (`.bmp`/`.dib`/`.rle`), Targa (`.tga`/`.vda`/`.icb`/`.vst`), PCX, Pixar (`.pxr`), JPEG 2000 (`.jpf`/`.jpx`/`.jp2`/`.j2k`/`.j2c`/`.jpc`), HEIC/HEIF (`.heic`/`.heif`), JPEG XL (`.jxl`), PSD (`.psd`/`.pdd`)/PSB (an image opens as a document of its pixel size; a PSD or PSB file with its layers as layers, or as its merged image through `run_command document.open` with `layers: false`; a JPEG XL file as its first frame), CDR drawings of versions 1 to 27 (`.cdr`, `.cdt`), CMX files with 32-bit coordinates (`.cmx`), layered raster `.pcraft` documents (as one image at the canvas size; a warning says when only the smaller preview could be read), DWG drawings (`.dwg`, `.dws`, `.dwt`). Templates (`.vctemplate`, `.ait`, `.cdt`, `.dwt`) open as a new untitled document. A text, RTF or Word file (`.txt`, `.rtf`, `.docx`, `.doc`) opens as a new letter-size document named after the file, its text area type 36 pt inside the artboard as `file.place` sets it; `run_command document.open` with `text` gives a `.txt` file's Text Import Options, and Save asks for a name. A `.txt` file without text, and an RTF file that ends inside a group, are refused and open nothing. A file with one of those extensions that starts with a PDF header or an Affinity signature opens as that format instead. PDF, `.ai` and SVG files saved with Preserve Editing reopen as the document they carry. The reply is `document.open`'s: its `warnings` say what didn't come in as it was (an EPS whose PostScript can't be read opens as its preview, and the warning names the PostScript error, the operator and the procedure). A file of an extension only an installed importer plug-in lists opens with that importer ([Plug-ins](#plug-ins)); `importer: "plugin.<id>"` opens the file with the importer it names, which must list the file's extension, also one a built-in format reads (in the app, as File › Open With does), and `params` gives that importer's parameters (their defaults when omitted). `run_command document.formats` lists the formats. |
| `save_file` | `{path?, compress?, version?, preview?, precision?, options?}` | Runs `document.save`: the document's own file in its own format (native `.vectorcraft` unless it was opened from or saved as SVG, PDF or a restorable `.ai`; then `warnings` say what that format loses). A path's extension picks the format (`.vectorcraft`, `.vctemplate`, `.pdf`, `.svg`, `.svgz`, `.ai`: a PDF carrying the native document, which reopens editable; `.eps`: by default one file whose bounding box fits the visible art, the first artboard when no art shows; `options.useArtboards: true` makes the chosen artboard the page and, with two or more chosen, the file at the path is the central file of the visible art and each artboard is also written to `<name>_<artboard>.eps` beside it, listed in the reply's `files`). For a native file, `compress: true` gzips it (default: the `useCompression` preference, Preferences › File Handling › Use Compression), `version` (1 to 5) writes it for an older VectorCraft (1 and 2 are never compressed, and `version: 2` with `compress: true` is an error; versions 1 to 4 get each live star as a plain path of its outline, without its point count and ratio, and versions 1 to 3 get placed documents as the art they show), `preview: true` embeds a PNG of the first artboard, and `precision` (0 to 9) rounds path anchors and handles to that many decimal places for that save only (colors, transforms and type stay exact). `options` passes the format's save options as `run_command document.formats` lists them. When `compress`, `version`, `preview` or `precision` is given both at the top level and in `options` with different values, the call is an error (`` `compress: true` and `options.compress: false` disagree: give the option once ``) and nothing is written. A key in `options` that no save format takes is an error, and nothing is written (see Parameter keys). The save drops each option the written format doesn't read. The reply's `warnings` then name each such option given (for example `` `compress` was not used: SVG files don't read it `` for an `.svg` path, and `` `options.preview` was not used: … `` for a key in `options`; a PDF-compatible `.ai` file reads `compress` but not `version`, `preview`, `precision`, `outlineText`, `hiddenObjects`, `transparentImages` or `preserveEditing`, and a legacy `.ai` file reads only its own options). For a `.ai` file, these warnings name the kind of `.ai` written: a legacy .ai (version 7) for `aiVersion: "7"`, a non-PDF-compatible .ai for `pdfCompatible: false`, and a PDF-compatible .ai otherwise, including a save that reuses the options the document was last saved with. `run_command document.save` and the other save commands refuse any option given beside the path and in `options` with different values, and give the same warnings for each key given beside the path or in `options` that the file doesn't read. The headless session and the app receive the same `app.save` params, and the app is also sent `wait: true`: the call returns once the file is written, or with the error (such as a path outside the write root), even with Background Save on. When the save asks first (the question before replacing a file that opened with losses, or on macOS and Linux the file dialog for an untitled document without `path`), the reply is `{pending}` or `"cancelled"` as before, and the save that runs after the answer uses the Background Save preference. Location refusals return `READ_ONLY_LOCATION: <reason>` without a fallback panel for automation; see [Save location errors](#save-location-errors). In the desktop app, a save that runs in the background shows in the progress window after 0.4 s with a moving bar. `file.cancelSave` stops every such save before it replaces its file → `{cancelled: n}`: the file stays as it was, and the document keeps its file and format and stays modified. A save whose file was already being replaced finishes and is reported as saved. `file.saveInBackground` closes the window while the saves go on → `{hidden: n}`. |
| `export` | `{path?, format?, scale?, artboard?, range?, selection?, outlineText?, options?}` | `svg`, `svgz`, `pdf`, `ai` (the PDF-compatible `.ai` that Save writes, which carries the document when every artboard is written in order), `eps`, `dxf`, `emf`, `wmf`, `pict` (a QuickDraw `.pct` picture), `hpgl` (a `.plt` plot file for plotters and cutters), `png`, `jpg`, `webp`, `gif`, `png8` (an indexed `.png`), `tiff`, `bmp`, `tga`, `psd` (layered), `txt` (the document's text), `vectorcraft` or `template` (a native template). The tool's `format` enum and `document.formats` list them, generated from the engine's format table. When `format` is omitted, it comes from the path's extension. PDF and `.ai` write one page per artboard: all of them, or `artboard` (0-based) / `range` (`"1-3, 5"`, 1-based). SVG and SVGZ write one file per chosen artboard. EPS writes one file of the visible art; with `artboard`, `range`, `options.artboards` or `options: {"useArtboards": true}` it writes one file per chosen artboard, after a central file of the visible art when there are two or more, and `useArtboards: false` keeps the one file. Rasters, DXF, EMF, WMF, PICT and HP-GL write one artboard, or one file per chosen artboard with `options: {"useArtboards": true}`. Rasters also take `options: {"rect": [x, y, width, height]}` (page points, y down): that area of the page at the given `ppi`/`scale`, without an artboard and without changing the document; it is refused with `artboard`, `artboards`, `range` or `useArtboards`, with a non-positive or non-finite size, and for non-raster formats. `options` carries more format options (e.g. `{"quality": 80}` for JPEG). `selection: true` exports the selected objects cropped to their bounds (the reply adds their `bounds`, and reports `format` and the encoder's `warnings` as a whole-document export does); `outlineText: true` writes SVG text as paths. Template layers are left out, live effects are kept, and exporting `vectorcraft` never changes the document's path. Without `path` the bytes come back as `dataBase64`. Both backends run the same `document.export` call. |
| `add_text` | `{text, x?, y?, width?, height?, fit?, fitMinPercent?, path?, mode?, pathEffect?, size?, font?, color?, justify?, vertical?}` | Point type at (x, y) (`justify`: `left`, `center` or `right` starts, centres or ends each line on x); area type with `width`/`height` (`fit`: `none`, `autoHeight`, `shrinkText`, as `text.areaOptions`); or `path` + `mode` (`area`/`onPath`) to flow text in or along a path, with `pathEffect` for type on a path (`rainbow`, `skew`, `3dRibbon`, `stairStep`, `gravity`; SVG export writes type on a path with any effect other than `rainbow` as outlines, with a warning). An invalid effect is rejected before editing. `justify` (also `auto`, `justifyAll`) aligns the paragraphs of every kind, as `text.setStyle` does later. `vertical: true` uses the existing vertical writing mode for every kind (default `false`, horizontal). Returns `{id}`, with `overflow: true` when the text doesn't fit its frame or path. |
| `apply_effect` | `{effect?, params?, ids?}` | Appends a live effect. Without `effect`, returns the effect catalogue with parameters and defaults. |
@@ -7637,8 +7637,15 @@ it is for a solid past its limits. In rendered mode the effect draws its solid a
by every light. With `shadow` and `shade` both on, every light with an intensity above 0 casts shadows on the solid and on the
effect's shadow plane, drawn in the image; with either off, none does. `render` then also takes
`quality` (`"low"`, `"medium"` or `"high"`: 1, 2 × 2 or 3 × 3 samples a pixel, default `"medium"`, VectorCraft's own
values), `resolution` (`null` for Document Raster Effects Settings › Resolution, the default, or 1..2400 ppi) and
`background` (`"transparent"`, the default, or `"white"`). A quality whose samples would pass 16,777,216 pixels
values), `resolution` (`null` for Document Raster Effects Settings › Resolution, the default, or 1..2400 ppi),
`background` (`"transparent"`, the default, or `"white"`) and `colorModel` (`"document"`, the default, for RGB
pixels in every document; `"grayscale"` for the Rec. 709 luma of each pixel; or `"bitmap"` for an image with two
pixel values). The color model applies after the background. Grayscale leaves each pixel's transparency as it is.
Bitmap makes each pixel black or white with `"white"`, and black or transparent with `"transparent"`, where a dark
pixel at least half covered is black and every other pixel is transparent. In a CMYK document the `"document"` image
is made in RGB and is converted as raster effect images are when a PDF export converts colors; Grayscale and Bitmap
images are stored as 8-bit gray PNGs, with an 8-bit alpha channel unless every pixel is opaque. A quality whose
samples would pass 16,777,216 pixels
takes fewer, and an image past that limit at one sample a pixel draws the shaded faces. The shaded faces are also
drawn for a scene past the renderer's limits on triangles, vertices, lights or work, for a mesh point at or behind
the eye, for solids painted with a gradient, a pattern, graphics, an
@@ -7656,9 +7663,10 @@ limits, so art too complex for the shaded surface does not refuse the wireframe.
```json
{"name":"run_command","arguments":{"command":"effect.setParams","params":{"index":0,"item":null,"params":{"render":{"mode":"wireframe"}}}}}
{"name":"run_command","arguments":{"command":"effect.setParams","params":{"index":0,"item":null,"params":{"render":{"mode":"rendered","quality":"high","background":"white"}}}}}
{"name":"run_command","arguments":{"command":"effect.setParams","params":{"index":0,"item":null,"params":{"render":{"mode":"rendered","colorModel":"grayscale"}}}}}
```
The 3D and Materials panel's Render Settings › Raster Settings dialog sets resolution and background on the objects
The 3D and Materials panel's Render Settings › Raster Settings dialog sets resolution, color model and background on the objects
selected when the dialog opened. OK applies the changes in one undo step and records nothing when nothing changes.
When there are changes to apply, OK keeps the dialog open with the reason while its document is not active, after it was reverted or had an Undo,
a Redo or a canceled edit that put back an earlier state, if one of those objects was changed, deleted, locked or hidden, or while another edit is in progress.
@@ -13045,7 +13053,8 @@ error that says to save as DXF. `.dws` drawing standards files and `.dwt` templa
`dws` or `dwt` answers with a hint to export DWG or DXF. Web builds and FreeBSD on 64-bit ARM have no DWG decoder:
there `document.formats` lists `dwg` and `dwt` as not readable, File › Open, File › Place and `openExtensions` list
`.dwg`, `.dws` and `.dwt` only for an installed importer plug-in that reads them, and a DWG drawing opens or places only
through such a plug-in. PICT files open and place (see PICT import), and PICT export writes them.
through such a plug-in. PICT files open and place (see PICT import), and PICT export writes them. CGM files open and
place (see CGM import) but can't be written.
```json
{"name":"run_command","arguments":{"command":"document.exportDxf","params":{"path":"/tmp/plan.dxf","version":"2013","unit":"mm","scale":10,"preserve":"editability"}}}
@@ -13731,6 +13740,32 @@ the frame within 16-bit coordinates. The writer follows the opcodes and data lay
{"name":"run_command","arguments":{"command":"document.export","params":{"format":"pict","useArtboards":true,"path":"/tmp/icons.pct"}}}
```
## CGM import
`document.open` and `file.place` read the first picture of a binary Computer Graphics Metafile (ISO/IEC 8632-3,
`.cgm`) into one artboard, the picture's VDC extent, and one layer. A binary CGM also opens by its content under any
name. A picture with a metric scale keeps its size; one without it is scaled so that its longer side is 576 pt
(8 inches). The extent's first corner is the picture's bottom left, so an extent that starts at the top left turns the
picture over.
- Lines, polylines, rectangles, polygons and polygon sets, circles, ellipses and their arcs become paths, in the order
the picture draws them, with their line width, color, type, caps and joins. Filled shapes are outlined only while
edges are visible, and a polygon set leaves out its hidden edges. A figure fills its lines as one shape.
- Text becomes point type at its character height. Markers are drawn at their points.
- Cell arrays, packed or run-length encoded, become images.
- The clip rectangle clips what follows it.
`file.place` places the picture as one group clipped to its frame. What isn't read as the file describes it comes back
in `warnings`, once each: hatch, pattern and interpolated fills (filled with their fill color), more than one picture,
colors in a CIE color model (read as RGB), text set to run left, up or down, restricted text, character spacing, text
past 16,384 characters in one string, fonts past the first 256 of the font list, appended text after a change to the
text's look, continuous text alignment, marker types other than dot, plus, asterisk, circle and cross (drawn as plus
signs), text in a character set other than ASCII, Latin-1, UTF-8 and UTF-16 (read as Latin-1), and drawing elements cut
short or describing no shape. A picture cut short keeps what came before it with a warning. A file that is not a CGM is
refused with "not a CGM file", a clear-text CGM with a message that only binary CGM files are read, and a metafile
without a picture with "the CGM file holds no picture". CGM can't be written: `document.export` to it is refused with
"CGM files can be opened but not written".
## HP-GL import
`document.open` and `file.place` read HP-GL/2 plot files (`.plt`, `.hpgl`, `.hgl`, `.hpg`) into one layer, with the
+1
View File
@@ -745,6 +745,7 @@ since 2026-10-01.
- 3D and Materials › Render Settings › Rendered: `render: {mode: "rendered"}` with `quality`, `resolution` and `background` draws the solid of Extrude & Bevel, Revolve, Inflate and Rotate as one depth-buffered image lit by every light (Revolve on a group draws every member's surface in one image, and Revolve on a fill or stroke draws that surface's own image), with shadow maps while Shading and Shadows are both on; solids painted with a gradient, a pattern, graphics, an opacity below 100% or a blending mode other than Normal, a later geometry effect that reshapes paths only, and an image past the renderer's limits draw the shaded faces instead, with a warning ([three-d.md](three-d.md#3d-and-materials-panel)); `crates/effects/src/solids/rendered/tests.rs` and `crates/ui-egui/src/panels/tests_three_d.rs` cover it. Scores and hours unchanged.
- 3D and Materials › Materials › Properties: Roughness and Metallic sliders set `material: {roughness, metallic}` on Extrude & Bevel, Revolve, Inflate and Rotate; with Shading on and outside Wireframe mode, any material other than the default (1 and 0) is shaded with craft-pbr's glTF 2.0 metallic-roughness BRDF, its highlight screened over each face; in every mode glTF exports write both factors, and USD exports write roughness and write metallic only when it is not the default 0 ([three-d.md](three-d.md#material-properties)); `crates/three-d/src/material.rs`, `crates/effects/src/solids/tests_material.rs`, `crates/engine/src/cmd/fileio/mesh3d/tests.rs` and `crates/ui-egui/src/panels/tests_three_d.rs` cover it. Scores and hours unchanged.
- 3D and Materials › Export 3D Object: the panel's button adds the selected objects that have a 3D effect to Asset Export as 3D assets (`assets.add3D`), one undo step and none when each is an asset already, selects their assets and shows the Asset Export panel ([three-d.md](three-d.md#3d-and-materials-panel)); `panels::three_d::tests::{export_3d_object_adds_the_selected_3d_objects_to_asset_export, export_3d_object_leaves_out_a_3d_object_inside_another}` cover it. Scores and hours unchanged.
- 3D and Materials › Render Settings › Raster Settings › Color: `render.colorModel` (`document`, `grayscale` or `bitmap`) on Extrude & Bevel, Revolve, Inflate and Rotate makes the rendered image in RGB, in gray, or with two pixel values, after the background. With a white background, each Bitmap pixel is black or white. With a transparent background, a dark pixel at least half covered is black and every other pixel is transparent. Grayscale and Bitmap images are stored as 8-bit gray PNGs, with an 8-bit alpha channel unless every pixel is opaque. Any other value is refused, the setting is saved with the effect, and the Raster Settings dialog's Color row sets it on every selected object in one undo step ([three-d.md](three-d.md#3d-and-materials-panel)); `the_color_model_makes_gray_or_black_and_white_pixels`, `bitmap_on_a_transparent_background_is_black_and_transparent`, `render_settings_are_validated`, `a_rendered_3d_color_model_is_checked_saved_and_drawn` and `raster_settings_sets_the_color_model` cover it. Scores and hours unchanged.
- 3D effects on clipping groups, blends and symbol instances (#6140, #5725): every 3D type builds from the art the object shows (the art inside the clipping path, the blend's keys and steps, the symbol's art where the instance places it), alone or in a group, on the canvas, in exports, Object › Rasterize and `assets.add3D`; an image is refused with a pointer to Object › Image Trace › Make. `crates/effects/src/solids/tests_sources.rs`, `crates/engine/src/cmd/effectcmd/three_d_source_tests.rs` and `fx::tests::a_symbol_instance_a_blend_and_a_clipping_group_draw_their_solids` cover it. Scores and estimates unchanged.
- 3D effects, images a clip hides: an image in a clipping group is left out of the solid when its transformed frame lies wholly outside the area every clipping path around it fills together, holes included, instead of when only the boxes miss; an image the clips show part of is still refused ([the help page](https://helpx.adobe.com/illustrator/using/clipping-masks.html) on clipping paths hiding everything outside their shape; the omission rule is VectorCraft's own). `solids::tests_sources::an_image_inside_a_clips_box_but_outside_its_shape_is_left_out` covers it. Scores and estimates unchanged.
+15 -2
View File
@@ -68,11 +68,24 @@ pages describe it.
off, no light casts a shadow. Low takes one sample a pixel, Medium 2 × 2 and High 3 × 3 (VectorCraft's own
values), at the effect's `resolution` or, without one, at Document Raster Effects Settings › Resolution.
**Render Settings › Raster Settings…** sets Use Document Raster Effects Resolution, Resolution (1 to 2400 ppi) and
Background (Transparent or White). OK sets the objects selected when the dialog opened in one undo step.
Background (Transparent or White), and Color: RGB, Grayscale or Bitmap (`colorModel`: `document`, the default,
`grayscale` or `bitmap`). Both apply after the background. Grayscale gives each pixel the Rec. 709 luma of its
color and keeps its transparency. Bitmap makes an image with two pixel values: with a White background each pixel
is black or white, and with a Transparent background each pixel is black or transparent, where a dark pixel at
least half covered is black and every other pixel is transparent. RGB is shown in every document because the image
is made in RGB: in a CMYK document, PDF
export converts it as it converts raster effect images, keeping RGB or converting to CMYK by the export's color
conversion, and Expand Appearance embeds it in RGB. Grayscale and Bitmap images are stored as 8-bit gray PNGs,
with an 8-bit alpha channel unless every pixel is opaque. OK sets the objects selected when the dialog opened in
one undo step.
When nothing changed, OK closes the dialog and records nothing. When there are changes to apply, OK keeps the
dialog open with the reason while its document is not active, after it was reverted or had an Undo,
a Redo or a canceled edit that put back an earlier state, if one of those objects was changed, deleted, locked or hidden, or while another edit is in progress.
The Render 3D vector artwork page describes Raster Settings changing the resolution and background. A setting
The Render 3D vector artwork page describes Raster Settings changing the resolution, color and background, and
the public
[Rasterization options](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/apply-filter-effects/rasterization-options.html)
page lists the color models of a rasterized image as the document's RGB or CMYK, Grayscale and Bitmap, and
describes a Bitmap image as black and white or black and transparent by the Background setting. A setting
the selected objects hold differently opens blank and is left as each object has it; Rendered and the qualities
show unchecked for such a selection.
The selection box, Use Preview Bounds, Align, hit testing and snapping measure the shaded faces, and the image is
+1 -1
View File
@@ -5,7 +5,7 @@ use std::process::Command;
use serde_json::Value;
const REV: &str = "138ce9929ea48d055c797f61c042a3c407427d97";
const REV: &str = "6b67abe4b3deead5a1437dc6987a85b35afd40f6";
const PACKAGES: &[(&str, &str, &str)] = &[
("craft-pdf", "0.1.0", REV),
("krilla", "0.8.2", REV),