mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-29 01:34:37 +01:00
Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts: # crates/engine/src/assets/library_swap.rs # crates/engine/src/assets/library_swap/tests.rs # docs/components-parity.md
This commit is contained in:
commit
6162bb1ab3
24 files changed
+855
-61
No files matched your search
+6
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
**Stage: alpha** · next: beta, ~26 points and ~162–292 h away (one Opus 5.5 agent; ~33–67 h wall-clock with 5 agents)
|
||||
|
||||
> **Last reviewed:** 2026-11-15 · **Last updated:** 2026-11-19 · **Change:** minor (mind maps from the toolbar and the keyboard: Shapes ▸ Mind map places one with a click, Cmd/Ctrl+Enter adds a child and Shift+Cmd/Ctrl+Enter a sibling, Tab goes to the next sibling (#2226); code blocks, first step: a dark panel of monospace text as tall as its lines, in one of 16 languages (`board.codeBlock`, `board.setLanguage`, #2237); library analytics count insertions and detachments of styles and variables; web builds with craft-fonts embed Noto Sans Arabic by default so Persian and Arabic text draws without extra build flags (#1902); the browser build uses team libraries and plugin directories on a server; CLI post-parse errors escape terminal controls in paths and failure text; M6 `.fig` export writes text on a path (#2323), list spacing, hanging punctuation and lists, vertical trim (#2305), vector region paints (#2302), image adjustments (#2297) and a page's prototype background (#2326); M8 Tidy up keeps a row's or column's order and sizes and evens the gaps, rounds the gap, tidies overlapping rows and grids along their longer axis, and raises a negative gap so no layer reaches the one two before it, as measured in Figma (#2319); a polygon's or star's Count handle and a double-click on a layer's icon (zoom, range anchor) follow Figma; Tab while renaming moves only the rename and wraps from the last layer; Align is unavailable for a layer in an auto layout frame's flow; the Scale tool pivots on the opposite handle and starts its origin at the centre; Paste over selection puts the copies just above the selected layer; Crop from the image fill's menu crops with a drag (#2307); M10 code export writes every colour and gradient fill in paint order for CSS, SwiftUI, Compose and Flutter (#2271), CSS as one layered background; 24 pt icon buttons draw 16 pt glyphs (#2227, #2238); M5 marquee selection follows Figma's measured rules and Select layer lists locked layers with a padlock (#1560); M7 the Design panel shows the page's variable modes with nothing selected (#2215); M12 mind maps in a section or frame without a place centre on the view, stickies take a Small–Huge text-size menu, and M9 `.jam` shapes with text import as native board shapes (#1808); M4 a boolean group's corner radius rounds its result (#2222), Flatten bakes a point's corner radius into its path (#2195) and loops close through a joining segment (#1951); library links survive moving or cloning the project folder (#2132); renaming a variable group to a path with `/` nests it (#2353); SVG import, widget images, batches and grids take bounded work, and a host's server key is never sent over plain `ws://` to another machine (#1923); CI prefetches dependencies for Sonar coverage and runs Harden-Runner on every job; releases FigCraft v0.18.0 and v0.18.1 (Flatpak update fix); readiness estimates unchanged) · **Target:** Figma Design (desktop app 126.10.7)
|
||||
> **Last reviewed:** 2026-11-15 · **Last updated:** 2026-11-19 · **Change:** minor (CLI scales reject repeated x suffixes; CLI help and docs name the first non-divider page as the default for export and render; invalid browser-page server endpoints are ignored before they replace the sharing default; the browser crate docs no longer repeat an obsolete same-computer-only live-session restriction; document HTTP(S) links without a host are refused before opening; mind maps from the toolbar and the keyboard: Shapes ▸ Mind map places one with a click, Cmd/Ctrl+Enter adds a child and Shift+Cmd/Ctrl+Enter a sibling, Tab goes to the next sibling (#2226); code blocks, first step: a dark panel of monospace text as tall as its lines, in one of 16 languages (`board.codeBlock`, `board.setLanguage`, #2237); library analytics count insertions and detachments of styles and variables; web builds with craft-fonts embed Noto Sans Arabic by default so Persian and Arabic text draws without extra build flags (#1902); the browser build uses team libraries and plugin directories on a server; CLI post-parse errors escape terminal controls in paths and failure text; M6 `.fig` export writes text on a path (#2323), list spacing, hanging punctuation and lists, vertical trim (#2305), vector region paints (#2302), image adjustments (#2297) and a page's prototype background (#2326); M8 Tidy up keeps a row's or column's order and sizes and evens the gaps, rounds the gap, tidies overlapping rows and grids along their longer axis, and raises a negative gap so no layer reaches the one two before it, as measured in Figma (#2319); a polygon's or star's Count handle and a double-click on a layer's icon (zoom, range anchor) follow Figma; Tab while renaming moves only the rename and wraps from the last layer; Align is unavailable for a layer in an auto layout frame's flow; the Scale tool pivots on the opposite handle and starts its origin at the centre; Paste over selection puts the copies just above the selected layer; Crop from the image fill's menu crops with a drag (#2307); M10 code export writes every colour and gradient fill in paint order for CSS, SwiftUI, Compose and Flutter (#2271), CSS as one layered background; 24 pt icon buttons draw 16 pt glyphs (#2227, #2238); M5 marquee selection follows Figma's measured rules and Select layer lists locked layers with a padlock (#1560); M7 the Design panel shows the page's variable modes with nothing selected (#2215); M12 mind maps in a section or frame without a place centre on the view, stickies take a Small–Huge text-size menu, and M9 `.jam` shapes with text import as native board shapes (#1808); M4 a boolean group's corner radius rounds its result (#2222), Flatten bakes a point's corner radius into its path (#2195) and loops close through a joining segment (#1951); library links survive moving or cloning the project folder (#2132); renaming a variable group to a path with `/` nests it (#2353); SVG import, widget images, batches and grids take bounded work, and a host's server key is never sent over plain `ws://` to another machine (#1923); CI prefetches dependencies for Sonar coverage and runs Harden-Runner on every job; releases FigCraft v0.18.0 and v0.18.1 (Flatpak update fix); readiness estimates unchanged) · **Target:** Figma Design (desktop app 126.10.7)
|
||||
|
||||
FigCraft is a clean-room, open-source, pure-Rust reimplementation of the Figma design workflow,
|
||||
native on macOS, Windows, Linux and FreeBSD and in the browser, fully drivable by agents through
|
||||
@@ -368,6 +368,7 @@ Ranked; detail and milestones in [`docs/roadmap.md`](docs/roadmap.md).
|
||||
|---|---|---|
|
||||
| 2026-11-26 | minor | #1396, craft-contrib#95: `figcraft-cli` follows RFC-0018. The CLI is a library with `run(args, out, err)` (`main` is a thin wrapper), failures are typed errors (exit 1, usage errors exit 2), output goes through the caller's writers, a closed stdout is quiet, `-V` works after subcommands, `FIGCRAFT_NO_SYSTEM_FONTS` and `FIGCRAFT_SERVER_KEY` are declared on `--no-system-fonts` and `plugin publish --key`, the packages install the man pages and Bash, Zsh and Fish completions (Linux and FreeBSD). Changed behaviour: `convert`/`run` refuse an output that is the input unless `--in-place` is given (it needs `--in`/`--out`); `export -o` and `render -o` refuse the file they read; `plugin publish` accepts `--key`; a blank `FIGCRAFT_NO_SYSTEM_FONTS` counts as unset and an unrecognised value is a usage error. Tests in `apps/figcraft-cli/tests/it/rfc18.rs`. Numbers unchanged |
|
||||
| 2026-11-24 | minor | M7: New York, Apple's serif that macOS installs as the hidden `.New York`, is found and listed under its public name (it was a missing font). Numbers unchanged. |
|
||||
| 2026-11-15 | patch | Removed the obsolete duplicate live-session bullet from the browser crate docs; the existing server publishing and remote wss guidance remains authoritative. Runtime behavior unchanged. |
|
||||
| 2026-11-18 | minor | M8: design context for AI agents. `inspect.designContext` and the MCP tool `design_context` read the selection (or `ids`, or a `scope`) in one call: a tree where each layer keeps apart `explicit` values, `derived` ones layout worked out and `unsupported` ones with no direct CSS equivalent, joined with the variables (every mode's stored and resolved value), styles, components, fonts and assets it uses, and what the design leaves `missing`. A connected instance gives its code instead of its layers, and a result that wouldn't fit the client asks for fewer layers. Numbers unchanged |
|
||||
| 2026-11-19 | minor | M8: Code Connect for agents. A link can name its source file, what variant values are called in code (Primary becomes `primary` in the snippet) and notes, in the Inspect tab, `codeConnect.set` and `figcraft.connect.json`. `codeConnect.list` and the MCP tool `component_mappings` say which code component each design component is, and whether its source file exists; `sync_mappings` imports and exports a repository's file. `codeConnect.export {path}` keeps the file's other keys and the links of components the design doesn't have, so several designs can share one file. Numbers unchanged |
|
||||
| 2026-11-18 | minor | M3, gap 10: library analytics count insertions and detachments of styles and variables. Applying one, or copying or duplicating content that uses it, inserts it; the Detach button detaches it; an instance counts as its component alone. Show usage and `library.usage` give them per style and variable over the chosen period. Modes aren't counted. Numbers unchanged. Tests: `library_asset_counts_tests`, `library_assets_tests`. |
|
||||
@@ -377,6 +378,10 @@ Ranked; detail and milestones in [`docs/roadmap.md`](docs/roadmap.md).
|
||||
| 2026-11-10 | minor | M12, #2226 (step 2 of 4): mind maps in the UI. The Shapes flyout ends in a mind map tool (`tool.mindMap`): a click places a map with the first node's text starting there and types in it. Cmd/Ctrl+Enter adds a child of the selected or edited node (`board.mindMapAdd`), Shift+Cmd/Ctrl+Enter its next sibling (`board.nextSticky` on a node), both typing on; Tab and Shift+Tab walk a node's siblings in the map's order (`select.next`, `select.previous`). The bar over the selection colours a node's text (`board.setColor`) and shows a branch the connector's controls without the line types. Tests: `board_mindmap_tests` (four more), `board_ui_tests` (five more). Breadth ~47% → ~48%, ready ~29% → ~30%. |
|
||||
| 2026-11-15 | patch | CLI usage and operation failures escape terminal controls in paths and error text, using the same printable-text rule as info and script diagnostics; exit codes and ordinary quotes and paths stay unchanged. |
|
||||
| 2026-11-10 | minor | Experimental `.fig` export preserves set-variable, set-variable-mode and conditional prototype actions (#2210). |
|
||||
| 2026-11-15 | patch | Document HTTP(S) links without a host are refused before opening; regressions retain valid query, fragment, IPv6 and mail links. |
|
||||
| 2026-11-15 | patch | The browser ignores a page server meta tag with an invalid host, port or path, using the same endpoint parser as sharing; valid local, IPv6 and reverse-proxy addresses keep their spelling. |
|
||||
| 2026-11-15 | patch | CLI export and render help and docs name the existing first non-divider page default, including the all-divider fallback and explicit page selection. Behavior unchanged. |
|
||||
| 2026-11-15 | patch | CLI export and render reject repeated scale suffixes such as `2xx` as usage errors (exit 2); numeric values and one optional `x` suffix retain the existing limits. |
|
||||
| 2026-11-10 | minor | M4, #2222: a boolean group takes a corner radius that rounds every sharp corner of its result. Numbers unchanged |
|
||||
| 2026-11-10 | minor | M12, #2226 (step 1 of 4): mind maps in the document and engine. `board.mindMap` places a first node with three children on curved branches and `board.mindMapAdd` adds a child or a sibling; the normalize pass lays a touched map out again from its first node (88 between columns, 48 between siblings, stacks centred on their parents). No toolbar entry yet; numbers unchanged. |
|
||||
| 2026-11-07 | patch | M10, #1902: web builds with craft-fonts embed Noto Sans Arabic Regular by default, so Persian and Arabic text has a fallback without `FIGCRAFT_EMBED_SCRIPTS=Arab`; required web builds reject catalogs without that face. Web faces are compressed losslessly at build time and restored once at runtime to keep the default catalog within the WASM size budget. A decode failure logs the unavailable face once; a compiler regression checks generated catalog initialization. Additional scripts remain opt-in. Exact Iran Sans appearance still needs the installed font through supported browsers' local font access. Numbers unchanged. |
|
||||
|
||||
@@ -102,7 +102,7 @@ pub struct ExportArgs {
|
||||
pub format: Option<String>,
|
||||
#[command(flatten)]
|
||||
pub scale: ScaleArg,
|
||||
/// The page to export (default the first)
|
||||
/// The page to export (default the first non-divider page)
|
||||
#[arg(long, value_name = "NAME")]
|
||||
pub page: Option<String>,
|
||||
/// The layer to export, by id (12 or 0:12) or name
|
||||
@@ -171,7 +171,7 @@ pub struct RenderArgs {
|
||||
pub out: String,
|
||||
#[command(flatten)]
|
||||
pub scale: ScaleArg,
|
||||
/// The page to render (default the first)
|
||||
/// The page to render (default the first non-divider page)
|
||||
#[arg(long, value_name = "NAME")]
|
||||
pub page: Option<String>,
|
||||
#[command(flatten)]
|
||||
@@ -306,7 +306,7 @@ enum ValueError {
|
||||
}
|
||||
|
||||
fn scale(s: &str) -> Result<f64, ValueError> {
|
||||
s.trim_end_matches('x').parse::<f64>().ok().filter(|v| v.is_finite() && *v > 0.0 && *v <= 64.0).ok_or(ValueError::Scale)
|
||||
s.strip_suffix('x').unwrap_or(s).parse::<f64>().ok().filter(|v| v.is_finite() && *v > 0.0 && *v <= 64.0).ok_or(ValueError::Scale)
|
||||
}
|
||||
|
||||
/// `FIGCRAFT_NO_SYSTEM_FONTS`: the usual boolean spellings; an empty value is unset (RFC-0018 rule 1.7).
|
||||
@@ -525,6 +525,13 @@ mod tests {
|
||||
assert!(try_parse(&["commands"]).is_ok_and(|cli| !cli.no_system_fonts));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scale_accepts_numbers_and_one_optional_suffix() {
|
||||
for (value, want) in [("0.5", 0.5), ("0.5x", 0.5), ("2", 2.0), ("2x", 2.0), ("64", 64.0), ("64x", 64.0)] {
|
||||
assert_eq!(super::scale(value).ok(), Some(want), "{value}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bad_arguments_are_usage_errors() {
|
||||
use ErrorKind::{
|
||||
@@ -543,6 +550,8 @@ mod tests {
|
||||
(&["export", "a", "-o", "b", "--scale", "0"], ValueValidation),
|
||||
(&["export", "a", "-o", "b", "--scale", "-3"], ValueValidation),
|
||||
(&["export", "a", "-o", "b", "--scale", "65"], ValueValidation),
|
||||
(&["export", "a", "-o", "b", "--scale", "2xx"], ValueValidation),
|
||||
(&["render", "a", "-o", "b", "--scale", "2xxx"], ValueValidation),
|
||||
(&["export", "a", "-o", "b", "--bleed", "lots"], ValueValidation),
|
||||
(&["export", "a", "-o", "b", "--bleed", "3in"], ValueValidation),
|
||||
(&["export", "a", "-o", "b", "--vd-compat", "sloppy"], ValueValidation),
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
//! - host mode: `?host=parent` (a same-origin page embedding FigCraft in an `<iframe>`) or
|
||||
//! `data-host="page"` on the canvas (the page's own document) hands the page the app's files
|
||||
//! instead of downloading them and reports unsaved changes (`host`);
|
||||
//! - live sessions: it joins sessions a desktop app hosts (File ▸ Join live session…) but can't
|
||||
//! host one. A page served over `https://` can only reach sessions on the same computer
|
||||
//!
|
||||
//! URL query flags: `?webgl` forces the WebGL2 backend instead of WebGPU; `?control` installs
|
||||
//! `window.figcraft`, the page's control channel (`api.rs`), which is off without it; `?host=parent`
|
||||
|
||||
@@ -22,7 +22,14 @@ pub fn join_link(fragment: &str) -> Option<&str> {
|
||||
pub fn page_server(content: &str) -> Option<String> {
|
||||
let c = content.trim();
|
||||
let scheme = c.starts_with("wss://") || c.starts_with("ws://");
|
||||
(scheme && c.len() <= 512 && !c.contains(|ch: char| ch.is_whitespace() || ch.is_control() || ch == '?' || ch == '#')).then(|| c.to_string())
|
||||
// Invalid metadata must not replace a usable default with an endpoint sharing cannot reach.
|
||||
(scheme
|
||||
&& c.len() <= 512
|
||||
&& !c.contains(|ch: char| ch.is_whitespace() || ch.is_control() || ch == '?' || ch == '#')
|
||||
// Endpoint parsing strips pasted-link delimiters; metadata must retain its spelling.
|
||||
&& !c.ends_with(['<', '>', '"', '\''])
|
||||
&& figcraft_collab_net::Endpoint::parse(c).is_ok())
|
||||
.then(|| c.to_string())
|
||||
}
|
||||
|
||||
/// Whether `search` (`location.search`, with or without its `?`) has a `control` entry (`?control`,
|
||||
|
||||
@@ -49,3 +49,36 @@ fn a_page_names_its_own_server_without_a_key() {
|
||||
assert_eq!(page_server(bad), None, "{bad:?} is ignored");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_page_ignores_invalid_server_endpoints() {
|
||||
for bad in [
|
||||
"ws://",
|
||||
"wss://",
|
||||
"wss:///figcraft/",
|
||||
"wss://:443/",
|
||||
"wss://figcraft.example:0/",
|
||||
"wss://figcraft.example:65536/",
|
||||
"wss://figcraft.example:port/",
|
||||
"wss://[::1/",
|
||||
"wss://figcraft.example/a@b/",
|
||||
] {
|
||||
assert_eq!(page_server(bad), None, "{bad:?} must not replace the default server");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_page_preserves_valid_server_endpoint_spelling() {
|
||||
for server in ["ws://localhost:47900/", "wss://figcraft.example/figcraft/", "wss://[::1]:47900/figcraft/"] {
|
||||
assert_eq!(page_server(server).as_deref(), Some(server), "{server}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_page_rejects_server_delimiters_that_endpoint_parsing_would_strip() {
|
||||
for suffix in ["'", "\"", "<", ">", "\"'>"] {
|
||||
let server = format!("wss://figcraft.example/{suffix}");
|
||||
assert!(figcraft_collab_net::Endpoint::parse(&server).is_ok(), "the parser cleans {server:?}");
|
||||
assert_eq!(page_server(&server), None, "{server:?} must not replace the default server");
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,11 @@ pub struct Swapped {
|
||||
pub styles: usize,
|
||||
pub variables: usize,
|
||||
pub unmatched: Vec<String>,
|
||||
/// The old library's copies the swap removed because nothing in the document used them before
|
||||
/// it (an imported component no instance shows, a variable nothing binds), named as in
|
||||
/// `unmatched`. Copies that went because what used them moved to the other library aren't
|
||||
/// listed.
|
||||
pub dropped: Vec<String>,
|
||||
/// Nothing of the old library is used any more: it was removed from the document.
|
||||
pub removed: bool,
|
||||
}
|
||||
@@ -70,6 +75,32 @@ fn match_components(doc: &Document, records: &[ImportedComponent], m: &LibraryMa
|
||||
pairs
|
||||
}
|
||||
|
||||
/// `from`'s copies in `doc`, each by its local id with its name as [`Swapped::dropped`] gives it.
|
||||
fn copies_of(doc: &Document, from: &str) -> Vec<(String, String)> {
|
||||
let libs = &doc.libraries;
|
||||
let coll_name = |id: &str| doc.variables.collection_by_id(id).map(|c| c.name.clone()).unwrap_or_default();
|
||||
let components = libs
|
||||
.components
|
||||
.iter()
|
||||
.filter(|r| r.library == from)
|
||||
.map(|r| (format!("node {}", r.root.0), format!("component {}", doc.node(r.root).map(|n| n.name.as_str()).unwrap_or_default())));
|
||||
let styles = libs
|
||||
.styles
|
||||
.iter()
|
||||
.filter(|r| r.library == from)
|
||||
.map(|r| (format!("style {}", r.local), format!("style {}", doc.style(&r.local).map(|st| st.name.as_str()).unwrap_or_default())));
|
||||
let variables = libs.variables.iter().filter(|r| r.library == from).map(|r| {
|
||||
let name = doc.variables.get_by_id(&r.local).map(|v| format!("{}/{}", coll_name(&v.collection), v.name)).unwrap_or_default();
|
||||
(format!("variable {}", r.local), format!("variable {name}"))
|
||||
});
|
||||
let collections = libs
|
||||
.collections
|
||||
.iter()
|
||||
.filter(|r| r.library == from)
|
||||
.map(|r| (format!("collection {}", r.local), format!("collection {}", coll_name(&r.local))));
|
||||
components.chain(styles).chain(variables).chain(collections).collect()
|
||||
}
|
||||
|
||||
/// A layer's explicit modes after a swap: a mode of A's collection becomes B's mode of the same
|
||||
/// name (`colls`: A's collection → B's, and A's mode ids → B's), and stays as well while that
|
||||
/// collection still has a variable on A (`still_a`). A mode the layer already chose of B's
|
||||
@@ -106,9 +137,13 @@ pub fn swap_library(doc: &mut Document, from: &str, to: &PublishedLibrary) -> Re
|
||||
if m.id == from {
|
||||
return Err(EngineError::Other("that is the same library".into()));
|
||||
}
|
||||
// Only what the document uses counts (copies nothing uses any more go first).
|
||||
// Only what the document uses counts: copies nothing uses any more go first, and are listed
|
||||
// (#2569). Those the final prune takes were in use, by what moved to B.
|
||||
let before = copies_of(doc, from);
|
||||
prune(doc, from)?;
|
||||
let mut out = Swapped::default();
|
||||
let kept: BTreeSet<String> = copies_of(doc, from).into_iter().map(|(id, _)| id).collect();
|
||||
out.dropped = before.into_iter().filter(|(id, _)| !kept.contains(id)).map(|(_, name)| name).collect();
|
||||
let store = doc.library_store();
|
||||
let outside = |d: &Document, id: NodeId| store.is_none_or(|s| d.page_of(id) != Some(s));
|
||||
|
||||
|
||||
@@ -203,6 +203,41 @@ fn swap_repoints_colour_calculations() {
|
||||
assert!(reads.iter().all(|r| doc.libraries.variable_import(r).is_some_and(|i| i.library == b)), "{reads:?}");
|
||||
}
|
||||
|
||||
/// Copies of A nothing uses (a component imported but not placed, a variable imported but not
|
||||
/// bound) go with the swap, as they did; the result now names them (#2569). A copy the swap moves
|
||||
/// to B isn't among them.
|
||||
#[test]
|
||||
fn swap_lists_the_unused_copies_it_removes() {
|
||||
let (_dir, mut s, a, b) = two_libraries("unused", &["Only in A"]);
|
||||
let placed = idv(&ex(&mut s, "library.place", json!({"library": a, "component": "Button", "x": 0, "y": 0})));
|
||||
let only = id_of(&ex(&mut s, "library.import", json!({"library": a, "component": "Only in A"}))["component"]).unwrap();
|
||||
ex(&mut s, "library.importVariable", json!({"library": a, "variable": "accent"}));
|
||||
|
||||
let r = ex(&mut s, "library.swap", json!({"from": a, "to": b}));
|
||||
assert_eq!(r["dropped"], json!(["component Only in A", "variable Theme/accent", "collection Theme"]), "{r}");
|
||||
assert_eq!((r["components"].as_u64(), r["variables"].as_u64(), &r["unmatched"]), (Some(1), Some(0), &json!([])), "{r}");
|
||||
assert_eq!(r["removed"], true, "{r}");
|
||||
let doc = s.doc().unwrap();
|
||||
assert!(!doc.contains(only), "the dropped copy is gone");
|
||||
assert_eq!(library_of(doc, main_of(&s, placed)), Some(b.as_str()), "the placed Button moved, so it isn't listed");
|
||||
assert!(doc.variables.variables.is_empty() && doc.variables.collections.is_empty(), "{:?}", doc.variables);
|
||||
|
||||
// One undo step brings them back.
|
||||
s.undo().unwrap();
|
||||
let doc = s.doc().unwrap();
|
||||
assert!(doc.contains(only) && library_of(doc, only) == Some(a.as_str()));
|
||||
assert_eq!(doc.variables.variables.len(), 1);
|
||||
|
||||
// A deleted instance leaves its copy unused, so it is listed too; a placed copy B has no match
|
||||
// for stays and is listed as unmatched.
|
||||
ex(&mut s, "edit.delete", json!({"ids": [placed]}));
|
||||
let kept = idv(&ex(&mut s, "library.place", json!({"library": a, "component": "Only in A", "x": 0, "y": 0})));
|
||||
let r = ex(&mut s, "library.swap", json!({"from": a, "to": b}));
|
||||
assert_eq!(r["dropped"], json!(["component Button", "variable Theme/accent", "collection Theme"]), "{r}");
|
||||
assert_eq!((&r["unmatched"], &r["removed"]), (&json!(["component Only in A"]), &json!(false)), "{r}");
|
||||
assert_eq!(library_of(s.doc().unwrap(), main_of(&s, kept)), Some(a.as_str()));
|
||||
}
|
||||
|
||||
/// A component B has no match for stays on A, but the Brand style and `accent` variable its own
|
||||
/// layers link do have matches (#2568). The swap re-points them in A's read-only copy as on the
|
||||
/// placed instances, so an instance placed after the swap looks like the ones placed before it,
|
||||
|
||||
@@ -55,5 +55,9 @@ pub fn openable(url: &str) -> bool {
|
||||
// The authority is made of host characters only (an opener that can't parse the address may
|
||||
// fall back to treating it as a file path).
|
||||
let authority = after.split(['/', '?', '#']).next().unwrap_or_default();
|
||||
authority.chars().all(|c| !c.is_ascii() || c.is_ascii_alphanumeric() || "-._~:@[]%!$&'()*+,;=".contains(c))
|
||||
// A query, fragment, userinfo or port alone does not supply a host.
|
||||
let host = authority.rsplit('@').next().unwrap_or_default();
|
||||
!host.is_empty()
|
||||
&& !host.starts_with(':')
|
||||
&& authority.chars().all(|c| !c.is_ascii() || c.is_ascii_alphanumeric() || "-._~:@[]%!$&'()*+,;=".contains(c))
|
||||
}
|
||||
@@ -67,7 +67,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
spec!(
|
||||
"library.swap",
|
||||
"Swap library",
|
||||
"{from (an enabled library: id, name or path), to (another enabled library)} re-points every component instance, style and variable copied from `from` to the published one of the same name in `to` (instances keep their overrides) → {components, styles, variables, unmatched: [names still from `from`], removed (nothing of `from` is used any more: it was removed)}",
|
||||
"{from (an enabled library: id, name or path), to (another enabled library)} re-points every component instance, style and variable copied from `from` to the published one of the same name in `to` (instances keep their overrides) → {components, styles, variables, unmatched: [names still from `from`], dropped: [names of `from`'s copies nothing used (a component imported but not placed, a variable imported but not bound): removed, not moved], removed (nothing of `from` is used any more: it was removed)}",
|
||||
true,
|
||||
swap_cmd
|
||||
),
|
||||
@@ -599,7 +599,9 @@ fn swap_cmd(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
return Err(bad(cmd, "`from` and `to` are the same library"));
|
||||
}
|
||||
let r = crate::library_swap::swap_library(s.doc_mut()?, &from, &lib)?;
|
||||
Ok(json!({"components": r.components, "styles": r.styles, "variables": r.variables, "unmatched": r.unmatched, "removed": r.removed}))
|
||||
Ok(
|
||||
json!({"components": r.components, "styles": r.styles, "variables": r.variables, "unmatched": r.unmatched, "dropped": r.dropped, "removed": r.removed}),
|
||||
)
|
||||
}
|
||||
|
||||
fn assets_json(lib: &PublishedLibrary) -> Value {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
//! duplicate and delete; extended collections (overrides, keeping them in step with what they
|
||||
//! extend); alias checks; and which scope a bindable property belongs to.
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use figcraft_doc::{
|
||||
@@ -25,6 +26,20 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
update
|
||||
),
|
||||
spec!("variable.duplicate", "Duplicate variable", "{variable} → {id}", true, duplicate),
|
||||
spec!(
|
||||
"variable.move",
|
||||
"Move variables",
|
||||
"{variables [ids or names, one collection], before? (variable of that collection; default: the end)} the order the Variables window and pickers list them in",
|
||||
true,
|
||||
move_variables
|
||||
),
|
||||
spec!(
|
||||
"variable.sort",
|
||||
"Sort variables",
|
||||
"{collection, group? (\"color/indigo\"; default: the whole collection), descending? (Z to A)} by name, numbers by value (50 before 100)",
|
||||
true,
|
||||
sort_variables
|
||||
),
|
||||
spec!("variable.renameMode", "Rename mode", "{collection, mode, name}", true, rename_mode),
|
||||
spec!("variable.removeMode", "Delete mode", "{collection, mode} (a collection keeps at least one mode)", true, remove_mode),
|
||||
spec!("variable.moveMode", "Move mode", "{collection, mode, to (index; 0 = the default mode, layers on Auto follow it)}", true, move_mode),
|
||||
@@ -204,6 +219,113 @@ fn duplicate(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
Ok(json!({"id": id}))
|
||||
}
|
||||
|
||||
/// Rearrange the variables at list positions `slots` (in list order) with `order`; each slot takes
|
||||
/// the variable `order` leaves at its place.
|
||||
fn rearrange(doc: &mut Document, slots: &[usize], order: impl FnOnce(&mut Vec<Variable>)) {
|
||||
let vars = &mut doc.variables.variables;
|
||||
let mut list: Vec<Variable> = slots.iter().filter_map(|&i| vars.get(i).cloned()).collect();
|
||||
order(&mut list);
|
||||
for (&i, v) in slots.iter().zip(list) {
|
||||
if let Some(slot) = vars.get_mut(i) {
|
||||
*slot = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn move_variables(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let cmd = "variable.move";
|
||||
let doc = s.doc_mut()?;
|
||||
let keys: Vec<&str> = match get(p, "variables") {
|
||||
Some(Value::Array(a)) => a.iter().filter_map(Value::as_str).collect(),
|
||||
_ => return Err(bad(cmd, "`variables` must be a list of variable ids")),
|
||||
};
|
||||
let find = |k: &str| doc.variables.get(k).ok_or_else(|| bad(cmd, format!("no variable `{k}`")));
|
||||
let picked: Vec<&Variable> = keys.iter().map(|k| find(k)).collect::<Result<_>>()?;
|
||||
let cid = picked.first().map(|v| v.collection.clone()).ok_or_else(|| bad(cmd, "no variables to move"))?;
|
||||
if picked.iter().any(|v| v.collection != cid) {
|
||||
return Err(bad(cmd, "the variables to move must be in one collection"));
|
||||
}
|
||||
let picked: BTreeSet<VariableId> = picked.into_iter().map(|v| v.id.clone()).collect();
|
||||
let before = match string(p, "before") {
|
||||
Some(b) => {
|
||||
let v = find(&b)?;
|
||||
if v.collection != cid {
|
||||
return Err(bad(cmd, "`before` must be in the same collection"));
|
||||
}
|
||||
if picked.contains(&v.id) {
|
||||
return Err(bad(cmd, "`before` can't be one of the variables moved"));
|
||||
}
|
||||
Some(v.id.clone())
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
let slots: Vec<usize> = doc.variables.variables.iter().enumerate().filter(|(_, v)| v.collection == cid).map(|(i, _)| i).collect();
|
||||
rearrange(doc, &slots, |list| {
|
||||
let (moved, mut rest): (Vec<Variable>, Vec<Variable>) = std::mem::take(list).into_iter().partition(|v| picked.contains(&v.id));
|
||||
let at = before.and_then(|b| rest.iter().position(|v| v.id == b)).unwrap_or(rest.len());
|
||||
rest.splice(at..at, moved);
|
||||
*list = rest;
|
||||
});
|
||||
ok()
|
||||
}
|
||||
|
||||
fn sort_variables(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let cmd = "variable.sort";
|
||||
let doc = s.doc_mut()?;
|
||||
let ci = collection_index(doc, cmd, &req_string(cmd, p, "collection")?)?;
|
||||
let cid = doc.variables.collections.get(ci).map(|c| c.id.clone()).ok_or_else(|| bad(cmd, "no such collection"))?;
|
||||
let group = string(p, "group").and_then(|g| clean_name(&g));
|
||||
let prefix = group.as_ref().map(|g| format!("{g}/"));
|
||||
let slots: Vec<usize> = doc
|
||||
.variables
|
||||
.variables
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, v)| v.collection == cid && prefix.as_ref().is_none_or(|g| v.name.starts_with(g.as_str())))
|
||||
.map(|(i, _)| i)
|
||||
.collect();
|
||||
if let Some(g) = group.filter(|_| slots.is_empty()) {
|
||||
return Err(bad(cmd, format!("no variables in group `{g}`")));
|
||||
}
|
||||
let descending = boolean(p, "descending").unwrap_or(false);
|
||||
rearrange(doc, &slots, |list| {
|
||||
list.sort_by(|a, b| {
|
||||
let o = natural_cmp(&a.name, &b.name);
|
||||
if descending { o.reverse() } else { o }
|
||||
});
|
||||
});
|
||||
ok()
|
||||
}
|
||||
|
||||
/// Compare names with each run of digits as a number ("50" < "100" < "950") and letters ignoring
|
||||
/// case; names equal that way compare as plain text.
|
||||
fn natural_cmp(a: &str, b: &str) -> Ordering {
|
||||
fn digits(it: &mut std::iter::Peekable<std::str::Chars>) -> String {
|
||||
std::iter::from_fn(|| it.next_if(char::is_ascii_digit)).collect()
|
||||
}
|
||||
let (mut x, mut y) = (a.chars().peekable(), b.chars().peekable());
|
||||
loop {
|
||||
let o = match (x.peek().copied(), y.peek().copied()) {
|
||||
(None, None) => return a.cmp(b),
|
||||
(None, Some(_)) => return Ordering::Less,
|
||||
(Some(_), None) => return Ordering::Greater,
|
||||
(Some(c), Some(d)) if c.is_ascii_digit() && d.is_ascii_digit() => {
|
||||
let (n, m) = (digits(&mut x), digits(&mut y));
|
||||
let (n, m) = (n.trim_start_matches('0'), m.trim_start_matches('0'));
|
||||
n.len().cmp(&m.len()).then_with(|| n.cmp(m))
|
||||
}
|
||||
(Some(c), Some(d)) => {
|
||||
x.next();
|
||||
y.next();
|
||||
c.to_lowercase().cmp(d.to_lowercase())
|
||||
}
|
||||
};
|
||||
if o.is_ne() {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The index of collection `c` (id or name).
|
||||
fn collection_index(doc: &Document, cmd: &str, c: &str) -> Result<usize> {
|
||||
doc.variables.collections.iter().position(|x| x.id == c || x.name == c).ok_or_else(|| bad(cmd, "no such collection"))
|
||||
|
||||
@@ -9,17 +9,27 @@ fn web_links_are_opened() {
|
||||
"http://example.com",
|
||||
"https://example.com",
|
||||
"https://example.com/a/b?c=d#e",
|
||||
"https://example.com?c=d",
|
||||
"https://example.com#e",
|
||||
"HTTPS://EXAMPLE.COM",
|
||||
"HtTp://example.com",
|
||||
"mailto:a@b.c",
|
||||
"mailto:a@b.c?subject=hi",
|
||||
" https://example.com ",
|
||||
"https://user:pw@example.com:8443/p",
|
||||
"https://user:pw@[::1]:8443/p",
|
||||
] {
|
||||
assert!(openable(url), "{url:?} should open");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn web_links_without_a_host_are_refused() {
|
||||
for url in ["https://?c=d", "http://#e", "https://user@", "https://user@:443/p", "https://:443/p", "https://user:pw@?c=d", "https://@#e"] {
|
||||
assert!(!openable(url), "{url:?} must be refused");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn script_and_handler_schemes_are_refused() {
|
||||
for url in [
|
||||
|
||||
@@ -200,3 +200,56 @@ fn stored_variable_ids_keep_collection_edits_on_the_resolved_collection() {
|
||||
assert!(s.execute("variable.removeMode", &json!({"collection": "Extended", "mode": "Dark"})).is_err());
|
||||
assert_eq!(s.doc().unwrap(), &before);
|
||||
}
|
||||
|
||||
/// The names of collection `c`'s variables in their stored order.
|
||||
fn names_in(s: &Session, c: &str) -> Vec<String> {
|
||||
let vars = &s.doc().unwrap().variables;
|
||||
let cid = vars.collection(c).unwrap().id.clone();
|
||||
vars.variables.iter().filter(|v| v.collection == cid).map(|v| v.name.clone()).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn moving_variables_reorders_their_collection_only_and_undoes() {
|
||||
let mut s = Session::new();
|
||||
tokens(&mut s);
|
||||
ex(&mut s, "variable.createCollection", json!({"name": "Other"}));
|
||||
ex(&mut s, "variable.create", json!({"collection": "Other", "name": "gap", "type": "number", "value": 4}));
|
||||
ex(&mut s, "variable.create", json!({"collection": "Tokens", "name": "space/lg", "type": "number", "value": 24}));
|
||||
let before = names_in(&s, "Tokens");
|
||||
ex(&mut s, "variable.move", json!({"variables": ["space/lg", "brand"], "before": "space/sm"}));
|
||||
let after = names_in(&s, "Tokens");
|
||||
let at = |list: &[String], n: &str| list.iter().position(|x| x == n).unwrap();
|
||||
// The moved ones come first, keeping their own order; the rest keep theirs.
|
||||
assert!(at(&after, "brand") < at(&after, "space/lg") && at(&after, "space/lg") < at(&after, "space/sm"));
|
||||
assert!(at(&after, "space/sm") < at(&after, "space/md"));
|
||||
assert_eq!(names_in(&s, "Other"), ["gap"]);
|
||||
// Without `before` they go last; a variable of another collection is refused.
|
||||
ex(&mut s, "variable.move", json!({"variables": ["space/sm"]}));
|
||||
assert_eq!(names_in(&s, "Tokens").last().map(String::as_str), Some("space/sm"));
|
||||
assert!(s.execute("variable.move", &json!({"variables": ["brand"], "before": "gap"})).is_err());
|
||||
assert!(s.execute("variable.move", &json!({"variables": ["brand", "gap"]})).is_err());
|
||||
ex(&mut s, "edit.undo", json!({}));
|
||||
ex(&mut s, "edit.undo", json!({}));
|
||||
assert_eq!(names_in(&s, "Tokens"), before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sorting_orders_numbers_by_value_within_the_group_asked() {
|
||||
let mut s = Session::new();
|
||||
ex(&mut s, "variable.createCollection", json!({"name": "Palette"}));
|
||||
for n in ["indigo/500", "indigo/50", "zinc", "indigo/950", "indigo/100", "amber"] {
|
||||
ex(&mut s, "variable.create", json!({"collection": "Palette", "name": n, "type": "color", "value": "#336699"}));
|
||||
}
|
||||
ex(&mut s, "variable.sort", json!({"collection": "Palette", "group": "indigo"}));
|
||||
let names = names_in(&s, "Palette");
|
||||
let shades: Vec<&str> = names.iter().map(String::as_str).filter(|n| n.starts_with("indigo/")).collect();
|
||||
assert_eq!(shades, ["indigo/50", "indigo/100", "indigo/500", "indigo/950"]);
|
||||
// Variables outside the group stay where they were.
|
||||
assert_eq!(names.iter().position(|n| n == "zinc"), Some(2));
|
||||
ex(&mut s, "variable.sort", json!({"collection": "Palette", "descending": true}));
|
||||
let names = names_in(&s, "Palette");
|
||||
assert_eq!(names.first().map(String::as_str), Some("zinc"));
|
||||
assert_eq!(names.last().map(String::as_str), Some("amber"));
|
||||
assert!(names.iter().position(|n| n == "indigo/950") < names.iter().position(|n| n == "indigo/50"));
|
||||
assert!(s.execute("variable.sort", &json!({"collection": "Palette", "group": "teal"})).is_err());
|
||||
}
|
||||
+109
-40
@@ -207,46 +207,59 @@ fn side_strokes(n: &Node) -> Option<Arc<BezPath>> {
|
||||
}))
|
||||
}
|
||||
|
||||
/// A plain stroke: no dashes, width profile or brush.
|
||||
fn plain_stroke(n: &Node) -> bool {
|
||||
let props = &n.stroke;
|
||||
props.dashes.is_empty() && props.profile().is_none() && props.brush.is_none()
|
||||
}
|
||||
|
||||
/// Whether a closed node's inside/outside stroke is an even-odd ring of two outlines ([`ring`]).
|
||||
fn ring_stroke(n: &Node, closed: bool) -> bool {
|
||||
let props = &n.stroke;
|
||||
plain_stroke(n) && closed && props.align != StrokeAlign::Center
|
||||
// An outside ring grows square corners as miters; other joins take the generic outline.
|
||||
&& !(props.align == StrokeAlign::Outside && props.join != StrokeJoin::Miter && n.corners.radii.contains(&0.0))
|
||||
}
|
||||
|
||||
/// A rect's or full ellipse's outline moved `inset` inwards (outwards when negative), `None` for
|
||||
/// other shapes or one inset to nothing.
|
||||
fn ring(n: &Node, inset: f64) -> Option<BezPath> {
|
||||
let (x0, y0, ww, hh) = (inset, inset, n.width - 2.0 * inset, n.height - 2.0 * inset);
|
||||
if ww <= 0.0 || hh <= 0.0 {
|
||||
return None;
|
||||
}
|
||||
match n.kind {
|
||||
NodeKind::Rectangle
|
||||
| NodeKind::Frame
|
||||
| NodeKind::Component { .. }
|
||||
| NodeKind::ComponentSet { .. }
|
||||
| NodeKind::Instance { .. }
|
||||
| NodeKind::Section { .. }
|
||||
if n.corners.smoothing == 0.0 =>
|
||||
{
|
||||
let radii = n.corners.radii.map(|r| if r > 0.0 { (r - inset).max(0.0) } else { 0.0 });
|
||||
let mut p = figcraft_geom::rounded_rect(ww, hh, radii, 0.0);
|
||||
p.apply_affine(Affine::translate((x0, y0)));
|
||||
Some(p)
|
||||
}
|
||||
NodeKind::Ellipse { sweep, inner, .. } if figcraft_geom::full_sweep(sweep) && inner == 0.0 => {
|
||||
Some(figcraft_geom::kurbo::Ellipse::from_rect(Rect::new(x0, y0, x0 + ww, y0 + hh)).to_path(0.05))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// The stroke area of a node in local coordinates.
|
||||
pub fn stroke_area(n: &Node, path: &BezPath, closed: bool) -> Arc<BezPath> {
|
||||
let props = &n.stroke;
|
||||
if let Some(p) = side_strokes(n) {
|
||||
return p;
|
||||
}
|
||||
// Rect/ellipse inside/outside strokes without booleans: an even-odd ring of two outlines.
|
||||
if props.dashes.is_empty() && props.profile().is_none() && props.brush.is_none() && closed && props.align != StrokeAlign::Center
|
||||
// An outside ring grows square corners as miters; other joins take the generic outline.
|
||||
&& !(props.align == StrokeAlign::Outside && props.join != StrokeJoin::Miter && n.corners.radii.contains(&0.0))
|
||||
{
|
||||
let w = props.weight;
|
||||
let ring = |inset: f64| -> Option<BezPath> {
|
||||
let (x0, y0, ww, hh) = (inset, inset, n.width - 2.0 * inset, n.height - 2.0 * inset);
|
||||
if ww <= 0.0 || hh <= 0.0 {
|
||||
return None;
|
||||
}
|
||||
match n.kind {
|
||||
NodeKind::Rectangle
|
||||
| NodeKind::Frame
|
||||
| NodeKind::Component { .. }
|
||||
| NodeKind::ComponentSet { .. }
|
||||
| NodeKind::Instance { .. }
|
||||
| NodeKind::Section { .. }
|
||||
if n.corners.smoothing == 0.0 =>
|
||||
{
|
||||
let radii = n.corners.radii.map(|r| if r > 0.0 { (r - inset).max(0.0) } else { 0.0 });
|
||||
let mut p = figcraft_geom::rounded_rect(ww, hh, radii, 0.0);
|
||||
p.apply_affine(Affine::translate((x0, y0)));
|
||||
Some(p)
|
||||
}
|
||||
NodeKind::Ellipse { sweep, inner, .. } if figcraft_geom::full_sweep(sweep) && inner == 0.0 => {
|
||||
Some(figcraft_geom::kurbo::Ellipse::from_rect(Rect::new(x0, y0, x0 + ww, y0 + hh)).to_path(0.05))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
};
|
||||
let (outer, inner) = match props.align {
|
||||
StrokeAlign::Inside => (ring(0.0), ring(w)),
|
||||
_ => (ring(-w), ring(0.0)),
|
||||
if ring_stroke(n, closed) {
|
||||
let w = n.stroke.weight;
|
||||
let (outer, inner) = match n.stroke.align {
|
||||
StrokeAlign::Inside => (ring(n, 0.0), ring(n, w)),
|
||||
_ => (ring(n, -w), ring(n, 0.0)),
|
||||
};
|
||||
if let Some(mut o) = outer {
|
||||
if let Some(i) = inner {
|
||||
@@ -258,6 +271,54 @@ pub fn stroke_area(n: &Node, path: &BezPath, closed: bool) -> Arc<BezPath> {
|
||||
cached_stroke_outline(n, path, closed)
|
||||
}
|
||||
|
||||
/// What a closed node with outline `path` (filled by `rule`) fills under an inside or outside
|
||||
/// stroke that hides what is under it: out to the middle of the stroke, so the fill neither shows
|
||||
/// at the stroke's outer edge (a light fringe on an inside stroke) nor leaves a gap at its inner
|
||||
/// edge (what is behind showing between an outside stroke and the fill) (#2635). `None`: fill
|
||||
/// `path` as it is.
|
||||
fn fill_to_stroke_middle(n: &Node, path: &BezPath, rule: FillRule) -> Option<(Arc<BezPath>, FillRule)> {
|
||||
let props = &n.stroke;
|
||||
let opaque = n
|
||||
.strokes
|
||||
.iter()
|
||||
.rev()
|
||||
.find(|p| p.visible && p.opacity > 0.0)
|
||||
.is_some_and(|p| p.blend == BlendMode::Normal && p.opacity >= 1.0 && matches!(p.kind, PaintKind::Solid { color } if color.a >= 1.0));
|
||||
if !(opaque && plain_stroke(n) && props.sides.is_none() && props.align != StrokeAlign::Center && n.has_visible_stroke()) {
|
||||
return None;
|
||||
}
|
||||
let half = match props.align {
|
||||
StrokeAlign::Inside => props.weight / 2.0,
|
||||
_ => -props.weight / 2.0,
|
||||
};
|
||||
if ring_stroke(n, true)
|
||||
&& let Some(r) = ring(n, half)
|
||||
{
|
||||
return Some((Arc::new(r), FillRule::Winding));
|
||||
}
|
||||
// shortcut: even-odd outlines (booleans, even-odd networks) keep filling as they are, until
|
||||
// the boolean below reads them by their own rule.
|
||||
if rule != FillRule::Winding {
|
||||
return None;
|
||||
}
|
||||
let mut h = std::collections::hash_map::DefaultHasher::new();
|
||||
hash_path(path, &mut h);
|
||||
("fill to stroke middle", props.weight.to_bits(), props.align as u8, props.join as u8, props.miter_limit.to_bits()).hash(&mut h);
|
||||
let key = h.finish();
|
||||
let cached = locked(stroke_cache()).get(key);
|
||||
let out = match cached {
|
||||
Some(p) => p,
|
||||
None => {
|
||||
let centre = figcraft_pathops::stroke_center(path, props.weight, props);
|
||||
let op = if half > 0.0 { figcraft_doc::BoolOp::Subtract } else { figcraft_doc::BoolOp::Union };
|
||||
let p = Arc::new(figcraft_pathops::boolean_step(path, ¢re, op).ok()?);
|
||||
locked(stroke_cache()).insert(key, p.clone());
|
||||
p
|
||||
}
|
||||
};
|
||||
Some((out, FillRule::EvenOdd))
|
||||
}
|
||||
|
||||
/// The stroke a boolean operand contributes: like [`stroke_area`], but never an even-odd ring
|
||||
/// (boolean folding uses non-zero winding).
|
||||
fn operand_stroke(n: &Node, path: &BezPath, closed: bool) -> Arc<BezPath> {
|
||||
@@ -887,6 +948,16 @@ fn fill_vector_regions(ctx: &Ctx, pix: &mut Pixmap, n: &Node, network: &figcraft
|
||||
}
|
||||
}
|
||||
|
||||
/// Fills `n`'s closed outline `path` (by `rule`, drawn at `xf`) with `paints`, out to the middle of
|
||||
/// a stroke that hides it ([`fill_to_stroke_middle`]).
|
||||
fn fill_outline(ctx: &Ctx, pix: &mut Pixmap, n: &Node, paints: &[Paint], path: &BezPath, rule: FillRule, xf: Affine) {
|
||||
let under = fill_to_stroke_middle(n, path, rule);
|
||||
let (path, rule) = under.as_ref().map_or((path, rule), |(p, r)| (&**p, *r));
|
||||
if let Some(tp) = ts_path(path) {
|
||||
fill_with(pix, &tp, paints, n.width, n.height, xf, rule, ctx, None);
|
||||
}
|
||||
}
|
||||
|
||||
/// Fills, `over_fills`, children (clipped), strokes and text of a node, without opacity/effects.
|
||||
fn draw_content(ctx: &Ctx, pix: &mut Pixmap, n: &Node, xf: Affine, depth: usize, over_fills: OverFills) {
|
||||
let doc = ctx.doc;
|
||||
@@ -933,8 +1004,8 @@ fn draw_content(ctx: &Ctx, pix: &mut Pixmap, n: &Node, xf: Affine, depth: usize,
|
||||
// strokes on top.
|
||||
for k in &keys {
|
||||
let fills = layout.styles.get(*k).and_then(|s| s.fills.as_ref()).unwrap_or(&n.fills);
|
||||
if let Some(tp) = by_style.get(k).and_then(ts_path) {
|
||||
fill_with(pix, &tp, fills, w, h, gxf, FillRule::Winding, ctx, None);
|
||||
if let Some(path) = by_style.get(k) {
|
||||
fill_outline(ctx, pix, n, fills, path, FillRule::Winding, gxf);
|
||||
}
|
||||
for (_, item) in ink.iter().filter(|(style, _)| style == k) {
|
||||
match item {
|
||||
@@ -975,10 +1046,8 @@ fn draw_content(ctx: &Ctx, pix: &mut Pixmap, n: &Node, xf: Affine, depth: usize,
|
||||
if !splatted && closed {
|
||||
if let Some(network) = styled_network {
|
||||
fill_vector_regions(ctx, pix, n, network, xf);
|
||||
} else if let Some((path, rule)) = &outline
|
||||
&& let Some(tp) = ts_path(path)
|
||||
{
|
||||
fill_with(pix, &tp, &n.fills, w, h, xf, *rule, ctx, None);
|
||||
} else if let Some((path, rule)) = &outline {
|
||||
fill_outline(ctx, pix, n, &n.fills, path, *rule, xf);
|
||||
}
|
||||
}
|
||||
if let Some(f) = over_fills {
|
||||
|
||||
@@ -727,6 +727,8 @@ mod solo_tests;
|
||||
#[cfg(test)]
|
||||
mod spread_tests;
|
||||
#[cfg(test)]
|
||||
mod stroke_fringe_tests;
|
||||
#[cfg(test)]
|
||||
mod stroke_reach_tests;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
@@ -373,6 +373,11 @@ fn changed_areas(doc: &Document, page: NodeId, id: NodeId, out: &mut Vec<Rect>)
|
||||
}
|
||||
out.push(draw::paint_bounds(doc, parent)?);
|
||||
}
|
||||
ancestor_areas(doc, id, out)
|
||||
}
|
||||
|
||||
/// The areas of the ancestors of `id` that a change to it affects, beyond its own.
|
||||
fn ancestor_areas(doc: &Document, id: NodeId, out: &mut Vec<Rect>) -> Option<()> {
|
||||
// Ancestors that paint from their children's pixels (booleans, effects, masks): all of them.
|
||||
for a in doc.ancestors(id) {
|
||||
let Some(an) = doc.node(a) else { break };
|
||||
@@ -386,6 +391,138 @@ fn changed_areas(doc: &Document, page: NodeId, id: NodeId, out: &mut Vec<Rect>)
|
||||
Some(())
|
||||
}
|
||||
|
||||
/// Page areas in which `id` looks different in `after` than in `before` (where it was and where
|
||||
/// it is now, and what of its ancestors follows); `None` when only a full render will do.
|
||||
fn edited_areas(before: &Document, after: &Document, page: NodeId, id: NodeId, out: &mut Vec<Rect>) -> Option<()> {
|
||||
// A vector whose points moved looks different only around them.
|
||||
if let Some(area) = moved_points_area(before, after, page, id) {
|
||||
out.push(area);
|
||||
ancestor_areas(before, id, out)?;
|
||||
return ancestor_areas(after, id, out);
|
||||
}
|
||||
changed_areas(before, page, id, out)?;
|
||||
changed_areas(after, page, id, out)
|
||||
}
|
||||
|
||||
/// Vectors with more points than this are drawn again whole when they change.
|
||||
const MAX_MOVED_POINTS: usize = 4096;
|
||||
|
||||
/// Whether every visible paint of `paints` is one colour: it looks the same wherever the layer's
|
||||
/// box lies (a gradient or an image is laid out in the box).
|
||||
fn plain(paints: &[figcraft_color::Paint]) -> bool {
|
||||
paints.iter().filter(|p| p.visible).all(|p| matches!(p.kind, figcraft_color::PaintKind::Solid { .. }))
|
||||
}
|
||||
|
||||
/// The page area in which vector `id` looks different in `after` than in `before`, when all that
|
||||
/// changed is where its points and handles are (a point dragged in the vector editor): around the
|
||||
/// segments that moved and their neighbours (whose joins and rounded corners follow them), as far
|
||||
/// out as the stroke reaches. The rest of a large shape keeps its pixels, however much of the
|
||||
/// view it fills. `None` when anything else changed or the look depends on the whole outline
|
||||
/// (dashes, a width profile, a brush, gradients and images laid out in the box, effects, a mask):
|
||||
/// the layer is then drawn again whole.
|
||||
fn moved_points_area(before: &Document, after: &Document, page: NodeId, id: NodeId) -> Option<Rect> {
|
||||
let (a, b) = (before.node(id)?, after.node(id)?);
|
||||
let (NodeKind::Vector { network: na }, NodeKind::Vector { network: nb }) = (&a.kind, &b.kind) else { return None };
|
||||
if after.page_of(id) != Some(page) || before.page_of(id) != Some(page) {
|
||||
return None;
|
||||
}
|
||||
let simple = |n: &figcraft_doc::Node, net: &figcraft_doc::VectorNetwork| {
|
||||
!n.is_mask
|
||||
&& n.visible
|
||||
&& !n.effects.iter().any(|e| e.visible)
|
||||
&& n.stroke.dashes.is_empty()
|
||||
&& n.stroke.width_profile.is_none()
|
||||
&& n.stroke.brush.is_none()
|
||||
&& plain(&n.fills)
|
||||
&& plain(&n.strokes)
|
||||
&& net.regions.iter().all(|r| r.fills.as_deref().is_none_or(plain))
|
||||
};
|
||||
let same_shape = na.vertices.len() == nb.vertices.len()
|
||||
&& na.vertices.len() <= MAX_MOVED_POINTS
|
||||
&& na.segments.len() == nb.segments.len()
|
||||
&& na.segments.iter().zip(&nb.segments).all(|(x, y)| (x.a, x.b) == (y.a, y.b))
|
||||
&& na.regions.len() == nb.regions.len()
|
||||
&& na.regions.iter().zip(&nb.regions).all(|(x, y)| x.loops == y.loops && x.winding == y.winding && x.fills == y.fills);
|
||||
if !(simple(a, na) && simple(b, nb) && same_shape) {
|
||||
return None;
|
||||
}
|
||||
// A fill closes an open path with a line between its ends that is no segment: it moves
|
||||
// with either end, across the whole shape.
|
||||
let mut ends = vec![0u8; na.vertices.len()];
|
||||
for s in &na.segments {
|
||||
for i in [s.a, s.b] {
|
||||
let n = ends.get_mut(i)?;
|
||||
*n = n.saturating_add(1);
|
||||
}
|
||||
}
|
||||
let filled = a.fills.iter().any(|f| f.visible) || !na.regions.is_empty();
|
||||
if filled && ends.contains(&1) {
|
||||
return None;
|
||||
}
|
||||
// Nothing but the geometry differs: the box follows the points, and with it the transform.
|
||||
let mut as_after = a.clone();
|
||||
as_after.kind = b.kind.clone();
|
||||
(as_after.transform, as_after.width, as_after.height) = (b.transform, b.width, b.height);
|
||||
if as_after != *b {
|
||||
return None;
|
||||
}
|
||||
let (wa, wb) = (before.world_transform(id), after.world_transform(id));
|
||||
// The box following the points moves the layer; anything else a transform does (a scale, a
|
||||
// turn) changes every stroke's width or direction on the page, whether its path moved or not.
|
||||
let (ca, cb) = (wa.as_coeffs(), wb.as_coeffs());
|
||||
if ca.iter().zip(&cb).take(4).any(|(x, y)| (x - y).abs() > 1e-12 * x.abs().max(1.0)) {
|
||||
return None;
|
||||
}
|
||||
// A segment on the page: its ends and handles.
|
||||
let hull = |w: figcraft_geom::Affine, net: &figcraft_doc::VectorNetwork, s: &figcraft_doc::Segment| {
|
||||
let (pa, pb) = (net.vertices.get(s.a)?.point(), net.vertices.get(s.b)?.point());
|
||||
let pts = [pa, pa + figcraft_geom::Vec2::new(s.ta.0, s.ta.1), pb + figcraft_geom::Vec2::new(s.tb.0, s.tb.1), pb].map(|p| w * p);
|
||||
pts.iter().all(|p| p.x.is_finite() && p.y.is_finite()).then_some(pts)
|
||||
};
|
||||
let mut moved = vec![false; na.vertices.len()];
|
||||
let mut hulls = Vec::with_capacity(na.segments.len());
|
||||
for (sa, sb) in na.segments.iter().zip(&nb.segments) {
|
||||
let (ha, hb) = (hull(wa, na, sa)?, hull(wb, nb, sb)?);
|
||||
// Apart by more than float noise. When the box follows a moved point every local
|
||||
// coordinate shifts and the transform shifts back: a point that stayed put comes out a
|
||||
// few ulps from where it was. 64 of them is far above that and far under a pixel at any
|
||||
// zoom, wherever on the page the vector lies (a tenth of a millionth of a unit at
|
||||
// coordinates of ten million).
|
||||
let near = |x: f64, y: f64| (x - y).abs() <= 64.0 * f64::EPSILON * x.abs().max(y.abs()).max(1.0);
|
||||
let apart = ha.iter().zip(&hb).any(|(p, q)| !(near(p.x, q.x) && near(p.y, q.y)));
|
||||
let styled =
|
||||
|i: usize| na.vertices.get(i).zip(nb.vertices.get(i)).is_none_or(|(x, y)| (x.radius, x.cap, x.join) != (y.radius, y.cap, y.join));
|
||||
if apart || styled(sa.a) || styled(sa.b) {
|
||||
for i in [sa.a, sa.b] {
|
||||
*moved.get_mut(i)? = true;
|
||||
}
|
||||
}
|
||||
hulls.push((ha, hb));
|
||||
}
|
||||
// Every segment at a point of a segment that moved: its join or rounded corner there follows.
|
||||
let mut area: Option<Rect> = None;
|
||||
for (s, (ha, hb)) in na.segments.iter().zip(&hulls) {
|
||||
if moved.get(s.a).copied().unwrap_or(true) || moved.get(s.b).copied().unwrap_or(true) {
|
||||
for p in ha.iter().chain(hb) {
|
||||
let r = Rect::from_points(*p, *p);
|
||||
area = Some(area.map_or(r, |a| a.union(r)));
|
||||
}
|
||||
}
|
||||
}
|
||||
let area = area?;
|
||||
// As far as the stroke reaches from the path, on the page.
|
||||
// The most the transform stretches a length in any direction (its largest singular value):
|
||||
// under a skew that is more than either axis is stretched.
|
||||
let stretch = |w: figcraft_geom::Affine| {
|
||||
let c = w.as_coeffs();
|
||||
let sum = c[0] * c[0] + c[1] * c[1] + c[2] * c[2] + c[3] * c[3];
|
||||
let det = c[0] * c[3] - c[1] * c[2];
|
||||
((sum + (sum * sum - 4.0 * det * det).max(0.0).sqrt()) / 2.0).sqrt()
|
||||
};
|
||||
let reach = (a.outline_reach() * stretch(wa)).max(b.outline_reach() * stretch(wb));
|
||||
reach.is_finite().then(|| area.inflate(reach, reach))
|
||||
}
|
||||
|
||||
/// The previous frame brought up to date for `doc` at `px`, rendering only what changed; `None`
|
||||
/// when a full render is the better (or only correct) choice. Also returns the pixels rendered.
|
||||
fn patch(last: Frame, doc: &Arc<Document>, page: NodeId, view: &View, px: (i64, i64), opts: &Options, s: &Sensitive) -> Option<(Pixmap, u64)> {
|
||||
@@ -434,8 +571,7 @@ fn patch(last: Frame, doc: &Arc<Document>, page: NodeId, view: &View, px: (i64,
|
||||
if in_pattern_source(doc, s, id) || in_pattern_source(&last.doc, &last.sensitive, id) {
|
||||
return None;
|
||||
}
|
||||
changed_areas(&last.doc, page, id, &mut areas)?;
|
||||
changed_areas(doc, page, id, &mut areas)?;
|
||||
edited_areas(&last.doc, doc, page, id, &mut areas)?;
|
||||
}
|
||||
for r in areas {
|
||||
if let Some(p) = to_px(r, view.scale, px) {
|
||||
|
||||
@@ -65,3 +65,136 @@ fn a_clip_edge_on_a_pixel_boundary_clips_the_same_in_every_render() {
|
||||
assert_same(&pix, &render_view(&smaller, page, &shown, &opts).unwrap(), &format!("lod {lod}"));
|
||||
}
|
||||
}
|
||||
/// A closed zigzag of `2 * teeth + 2` points, 240 × 120 units at (20, 20): a ridge.
|
||||
fn ridge(d: &mut Document, page: NodeId, teeth: usize) -> NodeId {
|
||||
let mut pts = vec![figcraft_geom::Point::new(0.0, 120.0)];
|
||||
for i in 0..=teeth * 2 {
|
||||
pts.push(figcraft_geom::Point::new(240.0 * i as f64 / (teeth * 2) as f64, if i % 2 == 0 { 60.0 } else { 10.0 }));
|
||||
}
|
||||
pts.push(figcraft_geom::Point::new(240.0, 120.0));
|
||||
let network = figcraft_doc::VectorNetwork::from_points(&pts, true);
|
||||
let id = d.create(page, NodeKind::Vector { network }, "Ridge", 20.0, 20.0, 240.0, 120.0).unwrap();
|
||||
d.get_mut(id).unwrap().fills = vec![Paint::solid(Color::from_hex("7FAE9C").unwrap())];
|
||||
id
|
||||
}
|
||||
|
||||
fn move_point(d: &mut Document, id: NodeId, point: usize, by: (f64, f64)) {
|
||||
if let NodeKind::Vector { network } = &mut d.get_mut(id).unwrap().kind {
|
||||
network.vertices[point].x += by.0;
|
||||
network.vertices[point].y += by.1;
|
||||
}
|
||||
}
|
||||
|
||||
/// A point of a vector dragged while the vector fills the view (zoomed to it, as the vector
|
||||
/// editor does): the shape looks different only around the point's segments, and only that is
|
||||
/// drawn again. (Its whole box was, and past 60 % of the view that made every frame of the
|
||||
/// drag a full render.)
|
||||
#[test]
|
||||
fn a_moved_point_redraws_the_vector_around_it_only() {
|
||||
type Style = fn(&mut figcraft_doc::Node);
|
||||
let styles: [(&str, Style); 4] = [
|
||||
("filled", |_| {}),
|
||||
("stroked, mitred", |n| {
|
||||
n.strokes = vec![Paint::solid(Color::from_hex("203040").unwrap())];
|
||||
n.stroke.weight = 6.0;
|
||||
n.stroke.miter_limit = 4.0;
|
||||
}),
|
||||
("rounded points", |n| {
|
||||
if let NodeKind::Vector { network } = &mut n.kind {
|
||||
network.vertices.iter_mut().for_each(|v| v.radius = 9.0);
|
||||
}
|
||||
}),
|
||||
("stroked only", |n| {
|
||||
n.fills.clear();
|
||||
n.strokes = vec![Paint::solid(Color::from_hex("203040").unwrap())];
|
||||
n.stroke.weight = 3.0;
|
||||
}),
|
||||
];
|
||||
for (what, style) in styles {
|
||||
let mut d = Document::new("ridge");
|
||||
let page = d.first_page().unwrap();
|
||||
let id = ridge(&mut d, page, 6);
|
||||
style(d.get_mut(id).unwrap());
|
||||
let doc = Arc::new(d);
|
||||
// The ridge is 720 × 360 of the view's 780 × 420 pixels.
|
||||
let v = View { origin: (10.0, 10.0), scale: 3.0, width: 780, height: 420 };
|
||||
let mut r = Retained::default();
|
||||
check(&mut r, &doc, page, &v, what);
|
||||
let mut d2 = (*doc).clone();
|
||||
move_point(&mut d2, id, 6, (4.0, -7.0));
|
||||
let d2 = Arc::new(d2);
|
||||
let (_, _, work) = r.render(&d2, page, &v, &Options::default()).unwrap();
|
||||
let Work::Partial { pixels } = work else { panic!("{what}: a full render ({work:?})") };
|
||||
// A tooth of six each way from the point, and what the stroke adds (36 pixels each way
|
||||
// for the mitred one); the ridge's box is 259,200 pixels.
|
||||
assert!(pixels < 780 * 420 * 2 / 5, "{what}: {pixels} pixels drawn again");
|
||||
check(&mut r, &d2, page, &v, what);
|
||||
// And back: the same again.
|
||||
let (_, _, work) = r.render(&doc, page, &v, &Options::default()).unwrap();
|
||||
assert!(matches!(work, Work::Partial { .. }), "{what}: {work:?}");
|
||||
check(&mut r, &doc, page, &v, what);
|
||||
}
|
||||
}
|
||||
|
||||
/// What depends on the whole outline is drawn again whole: a gradient laid out in the vector's
|
||||
/// box, dashes that run on from the moved point, an open path's closing line.
|
||||
#[test]
|
||||
fn a_moved_point_redraws_a_vector_whole_when_its_look_depends_on_all_of_it() {
|
||||
type Style = fn(&mut figcraft_doc::Node);
|
||||
let styles: [(&str, Style); 3] = [
|
||||
("dashed", |n| {
|
||||
n.strokes = vec![Paint::solid(Color::from_hex("203040").unwrap())];
|
||||
n.stroke.weight = 3.0;
|
||||
n.stroke.dashes = vec![8.0, 5.0];
|
||||
}),
|
||||
("a shadow", |n| n.effects.push(Effect::inner_shadow())),
|
||||
("an open path", |n| {
|
||||
if let NodeKind::Vector { network } = &mut n.kind {
|
||||
network.segments.pop();
|
||||
}
|
||||
}),
|
||||
];
|
||||
for (what, style) in styles {
|
||||
let mut d = Document::new("ridge");
|
||||
let page = d.first_page().unwrap();
|
||||
let id = ridge(&mut d, page, 6);
|
||||
style(d.get_mut(id).unwrap());
|
||||
let doc = Arc::new(d);
|
||||
let v = View { origin: (10.0, 10.0), scale: 3.0, width: 780, height: 420 };
|
||||
let mut r = Retained::default();
|
||||
check(&mut r, &doc, page, &v, what);
|
||||
let mut d2 = (*doc).clone();
|
||||
move_point(&mut d2, id, 6, (4.0, -7.0));
|
||||
let d2 = Arc::new(d2);
|
||||
assert_eq!(r.render(&d2, page, &v, &Options::default()).unwrap().2, Work::Full, "{what}");
|
||||
check(&mut r, &d2, page, &v, what);
|
||||
}
|
||||
}
|
||||
|
||||
/// A vector's strokes are as wide on the page as its transform makes them. Scaled up with its
|
||||
/// points scaled down to match, its paths stay where they were and every stroke doubles: with a
|
||||
/// point moved too, all of it is drawn again, not the area around that point.
|
||||
#[test]
|
||||
fn a_moved_point_with_a_scaled_vector_redraws_all_of_it() {
|
||||
let mut d = Document::new("ridge");
|
||||
let page = d.first_page().unwrap();
|
||||
let id = ridge(&mut d, page, 6);
|
||||
let n = d.get_mut(id).unwrap();
|
||||
n.strokes = vec![Paint::solid(Color::from_hex("203040").unwrap())];
|
||||
n.stroke.weight = 3.0;
|
||||
let doc = Arc::new(d);
|
||||
let v = View { origin: (10.0, 10.0), scale: 3.0, width: 780, height: 420 };
|
||||
let mut r = Retained::default();
|
||||
check(&mut r, &doc, page, &v, "first");
|
||||
let mut d2 = (*doc).clone();
|
||||
let n = d2.get_mut(id).unwrap();
|
||||
n.transform *= Affine::scale(2.0);
|
||||
(n.width, n.height) = (n.width / 2.0, n.height / 2.0);
|
||||
if let NodeKind::Vector { network } = &mut n.kind {
|
||||
for p in &mut network.vertices {
|
||||
(p.x, p.y) = (p.x / 2.0, p.y / 2.0);
|
||||
}
|
||||
}
|
||||
move_point(&mut d2, id, 6, (2.0, -3.5));
|
||||
check(&mut r, &Arc::new(d2), page, &v, "scaled, a point moved");
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
//! An opaque stroke meets what lies on each side of it with nothing else showing between: no
|
||||
//! light fill fringe along an inside stroke's outer edge, no background gap along an outside
|
||||
//! stroke's inner edge (#2635).
|
||||
|
||||
use figcraft_color::{Color, Paint};
|
||||
use figcraft_doc::{Document, NodeKind, StrokeAlign};
|
||||
|
||||
use super::*;
|
||||
|
||||
const DARK: Color = Color { r: 30.0 / 255.0, g: 27.0 / 255.0, b: 75.0 / 255.0, a: 1.0 };
|
||||
|
||||
/// The red channel along the middle row of a 40-unit `kind` at (`at`, `at`) with a black 4-unit
|
||||
/// stroke, its fill `fill`, over `background`.
|
||||
fn middle_row(kind: &NodeKind, smoothing: f64, align: StrokeAlign, at: f64, fill: Color, background: Color) -> Vec<u8> {
|
||||
let mut d = Document::new("fringe");
|
||||
let p = d.first_page().unwrap();
|
||||
let n = d.create(p, kind.clone(), "S", at, at, 40.0, 40.0).unwrap();
|
||||
let node = d.get_mut(n).unwrap();
|
||||
node.fills = vec![Paint::solid(fill)];
|
||||
node.strokes = vec![Paint::solid(Color::BLACK)];
|
||||
(node.stroke.weight, node.stroke.align, node.corners.smoothing) = (4.0, align, smoothing);
|
||||
if smoothing > 0.0 {
|
||||
node.corners.radii = [8.0; 4];
|
||||
}
|
||||
let mut pix = Pixmap::new(80, 80).unwrap();
|
||||
let c = |v: f32| (v * 255.0).round() as u8;
|
||||
pix.fill(tiny_skia::Color::from_rgba8(c(background.r), c(background.g), c(background.b), 255));
|
||||
render_nodes_into(&d, &[n], &View { origin: (0.0, 0.0), scale: 1.0, width: 80, height: 80 }, &mut pix);
|
||||
let y = (at + 20.0) as u32;
|
||||
(0..80).map(|x| pix.pixel(x, y).unwrap().red()).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_opaque_stroke_shows_nothing_lighter_than_its_dark_neighbour_at_either_edge() {
|
||||
let dark = (DARK.r * 255.0).round() as u8;
|
||||
let ellipse = NodeKind::Ellipse { start: 0.0, sweep: std::f64::consts::TAU, inner: 0.0 };
|
||||
// Smoothed corners take the general outline rather than the rect ring.
|
||||
let shapes = [(&NodeKind::Frame, 0.0), (&NodeKind::Rectangle, 0.0), (&ellipse, 0.0), (&NodeKind::Rectangle, 0.6)];
|
||||
for (kind, smoothing) in shapes {
|
||||
for align in [StrokeAlign::Inside, StrokeAlign::Center, StrokeAlign::Outside] {
|
||||
for at in [20.4, 20.7] {
|
||||
let middle = at
|
||||
+ match align {
|
||||
StrokeAlign::Inside => 2.0,
|
||||
StrokeAlign::Center => 0.0,
|
||||
StrokeAlign::Outside => -2.0,
|
||||
};
|
||||
let centre = (at + 20.0) as usize;
|
||||
// Outside the stroke's middle on a dark page under a white fill, then inside it
|
||||
// under a dark fill on a white page: no pixel lighter than the dark side.
|
||||
let outer = middle_row(kind, smoothing, align, at, Color::WHITE, DARK);
|
||||
let outer = &outer[..middle.floor() as usize];
|
||||
let inner = middle_row(kind, smoothing, align, at, DARK, Color::WHITE);
|
||||
let inner = &inner[middle.ceil() as usize..centre];
|
||||
assert!(outer.iter().all(|&r| r <= dark), "{kind:?} smoothing {smoothing}, {align:?} at {at}: outer edge {outer:?}");
|
||||
assert!(inner.iter().all(|&r| r <= dark), "{kind:?} smoothing {smoothing}, {align:?} at {at}: inner edge {inner:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1482,6 +1482,8 @@ name = "English"
|
||||
"Solid" = "Solid"
|
||||
"Some variants have the same property values: give each one a unique combination" = "Some variants have the same property values: give each one a unique combination"
|
||||
"Sort" = "Sort"
|
||||
"Sort A to Z" = "Sort A to Z"
|
||||
"Sort Z to A" = "Sort Z to A"
|
||||
"Sort by" = "Sort by"
|
||||
"Sort by date" = "Sort by date"
|
||||
"Sort by page" = "Sort by page"
|
||||
|
||||
@@ -512,6 +512,9 @@ fn collection_row(app: &mut FigApp, ui: &mut Ui, view: &View, c: &Collection, st
|
||||
extend(app, view.id(), &c.id, st);
|
||||
ui.close();
|
||||
}
|
||||
if view.editable() {
|
||||
sort_items(app, ui, json!({"collection": c.id}));
|
||||
}
|
||||
if view.editable() && menu_item(ui, tr("Delete collection"), "") {
|
||||
app.run("variable.deleteCollection", json!({"collection": c.id}));
|
||||
ui.close();
|
||||
@@ -597,6 +600,7 @@ fn group_rows(app: &mut FigApp, ui: &mut Ui, view: &View, coll: &Collection, st:
|
||||
duplicate_group(app, &members, &list, g);
|
||||
ui.close();
|
||||
}
|
||||
sort_items(app, ui, json!({"collection": coll.id, "group": g}));
|
||||
if menu_item(ui, tr("Delete group"), "") {
|
||||
let steps: Vec<serde_json::Value> = members
|
||||
.iter()
|
||||
@@ -676,6 +680,35 @@ fn duplicate_group(app: &mut FigApp, members: &[&Variable], list: &[String], g:
|
||||
app.run("command.batch", json!({"label": "Duplicate group", "commands": steps}));
|
||||
}
|
||||
|
||||
/// Sort by name, A to Z and Z to A, menu items for the variables `scope` names (`variable.sort`'s
|
||||
/// collection and group).
|
||||
fn sort_items(app: &mut FigApp, ui: &mut Ui, scope: Value) {
|
||||
for (label, descending) in [(tr_noop("Sort A to Z"), false), (tr_noop("Sort Z to A"), true)] {
|
||||
if menu_item(ui, tr(label), "") {
|
||||
let mut p = scope.clone();
|
||||
p["descending"] = json!(descending);
|
||||
app.run("variable.sort", p);
|
||||
ui.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The `variable.move` params that move `v` one row up (or `down`) past its neighbour among the
|
||||
/// table's rows of its group; None at the group's end.
|
||||
fn step_move(view: &View, coll: &Collection, st: &Editor, v: &Variable, down: bool) -> Option<Value> {
|
||||
let g = group_of(&v.name);
|
||||
let rows: Vec<&String> = st.order.iter().filter(|id| view.vars.get_by_id(id).is_some_and(|x| group_of(&x.name) == g)).collect();
|
||||
let i = rows.iter().position(|id| **id == v.id)?;
|
||||
if !down {
|
||||
return Some(json!({"variables": [v.id], "before": rows.get(i.checked_sub(1)?)?}));
|
||||
}
|
||||
let next = rows.get(i + 1)?;
|
||||
// Right after the next row: before what follows it in the collection, else last.
|
||||
let all: Vec<&Variable> = view.in_collection(&coll.id).collect();
|
||||
let after = all.iter().position(|x| x.id == **next).and_then(|k| all.get(k + 1)).map(|x| &x.id);
|
||||
Some(json!({"variables": [v.id], "before": after}))
|
||||
}
|
||||
|
||||
fn create_collection(app: &mut FigApp, vars: &Variables, st: &mut Editor) {
|
||||
let name = unique("Collection", |n| vars.collections.iter().any(|c| c.name == n));
|
||||
if let Some(id) =
|
||||
@@ -769,6 +802,21 @@ fn table(app: &mut FigApp, ui: &mut Ui, view: &View, st: &mut Editor) {
|
||||
{
|
||||
st.selected.clear();
|
||||
}
|
||||
// Alt+Up / Alt+Down move the one selected variable past its neighbour in its group.
|
||||
if let [id] = st.selected.as_slice()
|
||||
&& view.editable()
|
||||
&& st.rename.is_none()
|
||||
&& !crate::a11y::field_focused(ui.ctx())
|
||||
&& let Some(v) = view.vars.get_by_id(id)
|
||||
{
|
||||
let down = ui.input_mut(|i| i.consume_key(egui::Modifiers::ALT, egui::Key::ArrowDown));
|
||||
let up = !down && ui.input_mut(|i| i.consume_key(egui::Modifiers::ALT, egui::Key::ArrowUp));
|
||||
if (up || down)
|
||||
&& let Some(p) = step_move(view, coll, st, v, down)
|
||||
{
|
||||
app.run("variable.move", p);
|
||||
}
|
||||
}
|
||||
let width = (NAME_W + coll.modes.len() as f32 * MODE_W + 40.0).max(ui.available_width());
|
||||
egui::ScrollArea::both().id_salt("vars_table").auto_shrink([false, false]).show(ui, |ui| {
|
||||
ui.spacing_mut().item_spacing = vec2(0.0, 0.0);
|
||||
@@ -944,6 +992,14 @@ fn var_row(app: &mut FigApp, ui: &mut Ui, view: &View, coll: &Collection, v: &Va
|
||||
app.run("variable.duplicate", json!({"variable": v.id}));
|
||||
ui.close();
|
||||
}
|
||||
for (label, key, down) in [(tr_noop("Move up"), "Alt+ArrowUp", false), (tr_noop("Move down"), "Alt+ArrowDown", true)] {
|
||||
if let Some(p) = step_move(view, coll, st, v, down)
|
||||
&& menu_item(ui, tr(label), &crate::toolbar::pretty_shortcut(key))
|
||||
{
|
||||
app.run("variable.move", p);
|
||||
ui.close();
|
||||
}
|
||||
}
|
||||
if !inherited && menu_item(ui, tr("Delete variable"), "") {
|
||||
app.run("variable.delete", json!({"variable": v.id}));
|
||||
ui.close();
|
||||
|
||||
+6
-3
@@ -126,7 +126,7 @@ page 1 "Screens": 380 nodes, 4 top-level
|
||||
|
||||
### `export <file> -o <out> [--format png|jpg|svg|webp|pdf|xml|fig|penpot] [--scale N] [--page NAME] [--node ID|NAME] [--bleed LENGTH] [--crop-marks] [--bleed-marks] [--cmyk] [--vd-compat bestEffort|exact|ignore]`
|
||||
|
||||
- `<out>` is a directory: one file per top-level frame of the page (default the first page), named
|
||||
- `<out>` is a directory: one file per top-level frame of the selected page, named
|
||||
after the frame (`Home.png`, `Settings.png`…); with no frames, one file per top-level layer.
|
||||
The name is kept as it is, except for the characters file systems refuse (`/ \ : * ? " < > |`
|
||||
and control characters), which become `_`, and leading or trailing spaces and dots, which are
|
||||
@@ -135,6 +135,9 @@ page 1 "Screens": 380 nodes, 4 top-level
|
||||
characters (there a `/` makes a folder). Two layers with the same name get `Name 2`, `Name 3`…
|
||||
With `--node`, the CLI writes one file named after the selected layer, including a nested layer.
|
||||
- `<out>` has an image extension: one file with the given `--node`, or the whole page composited.
|
||||
- `--page` defaults to the first non-divider page: empty pages whose names start with `-` are
|
||||
skipped. If all pages are dividers, the first is used. `--page NAME` can select one explicitly.
|
||||
The `.fig` and `.penpot` formats export the whole document and ignore `--page`.
|
||||
- `--node` takes a layer id (`12` or `0:12`) or a layer name.
|
||||
- `--format fig` (or an `<out>` ending in `.fig`) writes the whole file as `.fig`, experimental:
|
||||
written from public format notes, including variables with their modes and bindings and shared
|
||||
@@ -198,8 +201,8 @@ When converting from a `.penpot` file, import warnings are printed to stderr as
|
||||
|
||||
### `render <file> -o <out.png> [--scale N] [--page NAME]`
|
||||
|
||||
The whole page (default the first) with its background, as png, jpg or webp. Large pages are scaled
|
||||
down to fit 16384 px.
|
||||
The whole page with its background, as png, jpg or webp. `--page` defaults to the first non-divider
|
||||
page, as for `export`. Large pages are scaled down to fit 16384 px.
|
||||
|
||||
### `run <script.json|script.jsonl> [--in <file>] [--out <file>]`
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Components, variants, styles and variables parity
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-23 · **Change:** minor (Swap library re-points the styles and variables of the library copies that stay, so instances placed after a swap follow it too (#2568); with several instances selected, the Design panel shows the properties they share, Mixed where their values differ, and sets a value on all of them; an enabled library's styles are offered in the style pickers without opening the Assets tab first, and the picker filters its list by source (All libraries, This file, one library); with a variable group shown in the Local variables window, Create variable makes the variable in that group, and renaming a variable in its row changes the part shown and keeps its group; a layer inside an instance bound to a variable its main layer doesn't bind keeps that binding as an override when instances are relinked after an import, a detach or a restore, and when its value is set back to the main's, so a library copy or an edit of the main no longer drops it; switching variants keeps the text typed into an instance when the other variant nests that text layer in other frames, matched by its name; a main component copied from a library file and pasted into another file is an instance of it from that library, instead of a new main; copied variants pasted with their own set, or a layer in it, selected join the set as new variants; the Scale tool keeps variable-bound lengths scaled: a scaled instance keeps its bindings and draws them at the variable's value times its scale factor, other scaled layers keep the scaled value and drop the binding (#2090); a style of one library that reaches a file through another library's component is, in a file linking both, the first library's own bound copy, so its modes colour it (#2414); with a variant selected, its property dropdowns show its own values and choosing one renames only that variant, instead of setting the set's default and moving the variants (#2349); library analytics count insertions and detachments of styles and variables; combining components gives every variant the properties any of them had; renaming a variable group to a path with `/` nests it under a parent group instead of turning the slash into a hyphen (#2353); a group's context menu in the Local variables window has Duplicate group, a copy named after it plus " 2" holding a copy of every variable, in one undo step (#2084); pages take a variable mode: with nothing selected the Design panel's Page section shows a Variable modes section, Auto or a mode of each collection that has more than one, as the help center says ("Apply variable mode" in the Page section of the right sidebar) (#2215); a text style binds a number variable to its weight (#2174); an instance lists only the properties its variant's layers use and long property names are cut to one line (#2022); with several layers selected the Design panel header's component button offers Create multiple components (#2088); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); text styles carry paragraph spacing and indent, the list style and the OpenType features, as the Supported in text styles table of Create and apply text styles says (#1829); a layer's effect binding takes only a field its effect has; Go to main component on an instance of a library component opens the library file in a tab and selects the main there; glass effects take variables; Delete on a layer inside an instance hides it as an override instead of being refused, as the help center says: "Figma will only toggle the layer's visibility instead of removing it"; library analytics list how many layers and files use each style and variable; SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; a typed or stored variable, collection or mode id names only the object with that id (#1613); colour variables can be calculated from other colours per mode — `{alpha}` replaces a colour's alpha, `{mix}` blends two — and follow them (#1280); stored variable and collection references keep their identity when another object is named like their id (follow-up to #1542); a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every + and − stays in view; opening a file contacts no team library server it names until you check it (#1097); an explicit variables file path (`variable.import`, the `variables` of `file.open` and `file.import`) is refused past 256 MiB or when it isn't a regular filLine truncated
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-27 · **Change:** minor (Swap library re-points the styles and variables of the library copies that stay, so instances placed after a swap follow it too (#2568); the Local variables window reorders variables: Move up and Move down (Alt+↑ / Alt+↓) on a row, Sort A to Z and Z to A on a collection or group, numbers by value (#2633); `library.swap` lists the unused copies of the old library it removes in `dropped` (#2569); with several instances selected, the Design panel shows the properties they share, Mixed where their values differ, and sets a value on all of them; an enabled library's styles are offered in the style pickers without opening the Assets tab first, and the picker filters its list by source (All libraries, This file, one library); with a variable group shown in the Local variables window, Create variable makes the variable in that group, and renaming a variable in its row changes the part shown and keeps its group; a layer inside an instance bound to a variable its main layer doesn't bind keeps that binding as an override when instances are relinked after an import, a detach or a restore, and when its value is set back to the main's, so a library copy or an edit of the main no longer drops it; switching variants keeps the text typed into an instance when the other variant nests that text layer in other frames, matched by its name; a main component copied from a library file and pasted into another file is an instance of it from that library, instead of a new main; copied variants pasted with their own set, or a layer in it, selected join the set as new variants; the Scale tool keeps variable-bound lengths scaled: a scaled instance keeps its bindings and draws them at the variable's value times its scale factor, other scaled layers keep the scaled value and drop the binding (#2090); a style of one library that reaches a file through another library's component is, in a file linking both, the first library's own bound copy, so its modes colour it (#2414); with a variant selected, its property dropdowns show its own values and choosing one renames only that variant, instead of setting the set's default and moving the variants (#2349); library analytics count insertions and detachments of styles and variables; combining components gives every variant the properties any of them had; renaming a variable group to a path with `/` nests it under a parent group instead of turning the slash into a hyphen (#2353); a group's context menu in the Local variables window has Duplicate group, a copy named after it plus " 2" holding a copy of every variable, in one undo step (#2084); pages take a variable mode: with nothing selected the Design panel's Page section shows a Variable modes section, Auto or a mode of each collection that has more than one, as the help center says ("Apply variable mode" in the Page section of the right sidebar) (#2215); a text style binds a number variable to its weight (#2174); an instance lists only the properties its variant's layers use and long property names are cut to one line (#2022); with several layers selected the Design panel header's component button offers Create multiple components (#2088); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); text styles carry paragraph spacing and indent, the list style and the OpenType features, as the Supported in text styles table of Create and apply text styles says (#1829); a layer's effect binding takes only a field its effect has; Go to main component on an instance of a library component opens the library file in a tab and selects the main there; glass effects take variables; Delete on a layer inside an instance hides it as an override instead of being refused, as the help center says: "Figma will only toggle the layer's visibility instead of removing it"; library analytics list how many layers and files use each style and variable; SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; a typed or stored variable, collection or mode id names only the object with that id (#1613); colour variables can be calculated from other colours per mode — `{alpha}` replaces a colour's alpha, `{mix}` blends two — and follow them (#1280); stored variable and collection references keep their identity when another object is named like their id (follow-up to #1542); a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every Line truncated
|
||||
|
||||
Design systems are why teams adopt Figma. **Components: breadth ~96%, ready ~72%. Styles and
|
||||
variables: breadth ~95%, ready ~76% (estimated).** QA'd with a synthetic design system of ~300
|
||||
@@ -56,6 +56,7 @@ updates with overrides kept: `library_tests.rs`, `components_scale_tests.rs`.
|
||||
| Library updates available; overrides kept | done | a library file saved again within two seconds of being read, at the same length, is read again (its time stamp can't prove it unchanged; #652) |
|
||||
| Team libraries: publish to a `figcraft-server` under the file, enable by a share link (a view link reads it), background update checks | done | [server.md](server.md#team-libraries); no team-wide library list or accounts ([gaps](gaps.md) #10) |
|
||||
| Library analytics | partial | instances per component and the files using them, and the instances each file detached (per component and per file), as apps report them; insertions and detachments week by week for a year (Show usage: the past 30 days, 90 days or year), for components; the layers and files using each style and variable, with their insertions and detachments over the same periods, no modes; no chart |
|
||||
| Swap library (instances, styles and variables to another library's of the same names, overrides kept) | done | what has no match stays and is listed; one undo step; copies nothing used before the swap (imported, never placed or bound) are removed and listed in `dropped` (#2569) |
|
||||
| Swap library (instances, styles and variables to another library's of the same names, overrides kept) | done | what has no match stays and is listed; one undo step; a library copy that stays (no match, or another library's) links the swapped styles and variables too, so instances placed after the swap look like those placed before it (`library_swap/tests.rs`, #2568) |
|
||||
|
||||
## Styles and variables
|
||||
@@ -67,6 +68,7 @@ updates with overrides kept: `library_tests.rs`, `components_scale_tests.rs`.
|
||||
| Organising styles: folders by `/` names, order, duplicate, rename folder, Local styles list | done | `style.move` (into a folder renames), `style.duplicate` (right below), `style.renameFolder`; the page's Local styles list by type and folder (drag to reorder, right-click) |
|
||||
| Variables inside styles (paint, effect, grid and text styles; each user resolves them in its own modes) | done | `style.bind`, `style_vars_tests`; the editor binds paint colours, shadow colours, blur radii, grid sizes and a text style's font, font style (a face name from a string variable, or a numeric weight from a number variable, which picks the nearest face and a variable font's `wght` axis), size, line height and letter spacing, the rest through the command; a bound line height is applied in pixels, as the reference tool does (measured 2026-11-10) |
|
||||
| Variables: colour, number, string, boolean; collections, modes, aliases, scopes, groups | done | behaviour suite: `variables_behaviour_tests.rs`; aliases same type, no loops (also on create); colour calculations per mode (`{alpha}`: a colour variable with its alpha replaced, `{mix}`: a per-channel blend of two colour variables or literals; they compose, can't loop, and bound layers, modes and undo follow them; REST, CSS, Penpot and `.fig` exports write the colour they show in each of their collection's modes, other collections in their default modes; read-only in the panel, which can swap one for an alias or detach it; `variables_colour_tests.rs`), beyond the incumbent, whose variables only alias; scopes filter pickers only; several variables can be selected in the editor (Shift and Cmd/Ctrl click) and deleted, moved to a group or rescoped at once; a group can be duplicated from its row's menu (Duplicate group, one undo step); Create variable makes the variable in the group shown, and a row's rename edits the name's last part; the window resizes from its edges and corners (minimum 600 x 240) and keeps its size and place while the app runs, #2354 |
|
||||
| Variables: colour, number, string, boolean; collections, modes, aliases, scopes, groups | done | behaviour suite: `variables_behaviour_tests.rs`; aliases same type, no loops (also on create); colour calculations per mode (`{alpha}`: a colour variable with its alpha replaced, `{mix}`: a per-channel blend of two colour variables or literals; they compose, can't loop, and bound layers, modes and undo follow them; REST, CSS, Penpot and `.fig` exports write the colour they show in each of their collection's modes, other collections in their default modes; read-only in the panel, which can swap one for an alias or detach it; `variables_colour_tests.rs`), beyond the incumbent, whose variables only alias; scopes filter pickers only; several variables can be selected in the editor (Shift and Cmd/Ctrl click) and deleted, moved to a group or rescoped at once; a group can be duplicated from its row's menu (Duplicate group, one undo step); variables keep the order they are put in: Move up / Move down (Alt+↑ / Alt+↓) on a row and Sort A to Z / Z to A on a collection or group, numbers by value (`variable.move`, `variable.sort`, #2633); the window resizes from its edges and corners (minimum 600 x 240) and keeps its size and place while the app runs, #2354 |
|
||||
| Modes: add, duplicate, rename, delete, set as default / reorder | done | layers on Auto follow a new default; explicit modes stay |
|
||||
| Deleting a bound variable or its collection | done | layers keep their last value and are unbound; aliases to it take its values and colour calculations reading it keep the colour they show |
|
||||
| Code syntax per platform (Web, iOS, Android) | done | generated CSS uses the Web name, SwiftUI the iOS one and Compose the Android one (a variable without one keeps its value there); in the variables JSON; ArkUI and Flutter have no platform of their own and write values |
|
||||
@@ -87,6 +89,8 @@ updates with overrides kept: `library_tests.rs`, `components_scale_tests.rs`.
|
||||
| 2026-11-19 | patch | M3: overrides found by comparing a layer with its main (`rebase_instance`: linking instances after a Figma or REST import, detaching an outer instance, restoring a main) counted values only, so a layer bound to a variable the main layer doesn't bind, resolving to the main's colour, wasn't an override; the next copy or edit of the main (a library update reaching another file) reset it to the main's unbound paint. Icons inside buttons of a design system imported from Figma lost their colour variable this way in the files using it. A binding that differs from the main's is now an override there, and an edit that sets the value back to the main's (hiding and showing the fill) no longer clears an override the binding still makes; `fill` and `fills/0/color` count as one binding. Tests: `nested_binding_tests` |
|
||||
| 2026-11-19 | patch | M3: with a group selected in the Local variables window, + Create variable named the new variable without the group, so it went to the collection's top level and the table, showing the group, didn't show it; only All variables did. It's now made in the group shown (`space/Number`), as in Figma, where duplicating already kept the group. Renaming a variable in its row edited its whole name while the row shows the last part, so typing a name over a new grouped variable moved it out of the group; the field now edits the part shown and keeps the group (the Edit variable window still edits the whole name), and ignores a name of slashes alone. Creating a collection clears the group shown. Tests: `variables_group_create_tests` |
|
||||
| 2026-11-18 | patch | M3: enabled libraries were read only while the Assets panel showed, so after a file was opened the Design panel's style pickers offered none of their styles (a library's text styles read "No text styles yet") until the Assets tab had been opened. They are refreshed from the app's background tick now, a local library not read yet at once. The style picker has a source menu under its search field, as in Figma: All libraries (the default), This file, or one enabled library. Test: `style_picker::tests::a_reopened_files_text_styles_picker_lists_its_librarys_styles_without_the_assets_tab` |
|
||||
| 2026-11-23 | patch | M3, #2569: `library.swap {from, to}` removes `from`'s copies that nothing in the file uses before it starts (a component imported with `library.import` but not placed, a variable imported but not bound), as `library.remove` does, but its result didn't say so: `{"components": 0, "unmatched": [], "removed": true}` after an imported component had been deleted. The result now names them in `dropped` (`component auth-button`, `variable Theme/accent`, `collection Theme`), apart from copies that went because what used them moved to `to`. Test: `library_swap/tests.rs` (`swap_lists_the_unused_copies_it_removes`) |
|
||||
| 2026-11-27 | minor | M3, #2633: variables in the Local variables window stayed in creation order. A row's menu has Move up and Move down (Alt+↑ / Alt+↓ with one row selected), moving it past its neighbour in its group; a collection's and a group's menus have Sort A to Z and Sort Z to A, by name with each run of digits compared as a number, so `50, 100, 200 … 950` come in that order. The order is the stored one, so files, exports and the variable pickers follow it. New commands `variable.move {variables, before?}` and `variable.sort {collection, group?, descending?}`, one undo step each. Drag to reorder is not built. Tests: `variables_editor_tests::moving_variables_reorders_their_collection_only_and_undoes`, `variables_editor_tests::sorting_orders_numbers_by_value_within_the_group_asked`. Grade unchanged. |
|
||||
| 2026-11-23 | patch | M3, #2568: `library.swap {from, to}` re-pointed style links and variable bindings only on layers outside the read-only library copies. A copy the swap keeps (a component of `from` that `to` has no match for, or another library's component using `from`'s style) kept `from`'s style and variable, so instances placed after the swap showed the old colours while those placed before showed the new ones. The swap now re-points the copies' own layers too, with the same maps, and `from`'s style and variable copies that nothing links any more go. A layer's explicit mode for one of `from`'s collections stays next to `to`'s while a variable of that collection is left on `from` (no match), so that variable keeps its mode instead of falling back to the default. Tests: `library_swap/tests.rs` (`swap_repoints_the_styles_and_variables_of_component_copies_it_keeps`, `swap_keeps_the_mode_of_a_collection_that_still_has_a_variable_on_the_old_library`) |
|
||||
| 2026-11-19 | patch | M3, #2414: a kit's style used by a component of a second library reached a file linking both as a second, unbound copy (`<auth>:<kit>:S:1`) frozen in the kit's default mode, so a mode set on the kit's collection didn't colour it (from two hops on, every such style). Publishing now keeps the variables the published styles bind and where the file's copies of other libraries' styles, variables and collections came from; importing files such a copy under that library when the file links it, so it is the file's own bound copy. Test: `library_style_hops_tests::a_kit_style_through_another_library_is_the_kits_bound_copy`; the issue's four-file chain renders Brand and Alt everywhere. Grade unchanged. |
|
||||
| 2026-11-19 | patch | M3, #2349: with one variant of a set selected, the Design panel's variant property dropdowns showed the set's default values, and choosing a value set the default, so the variants swapped places. They now show the selected variant's own values (hover: "This variant's value"), and choosing one renames that variant only; with the set selected they still set its default. Test: `variant_own_value_tests::a_selected_variants_dropdown_shows_and_sets_its_own_value`. Grade unchanged. |
|
||||
|
||||
+11
-1
@@ -1,6 +1,6 @@
|
||||
# Where FigCraft falls short of Figma
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (gap 24: mind maps from the toolbar and the keyboard (#2226); gap 24: code blocks, first step (`board.codeBlock`, `board.setLanguage`, #2237); gap 10: library analytics count insertions and detachments of styles and variables; gap 6: the browser build uses team libraries and plugin directories on a server; gap 7: a pan past the canvas image shows a coarse image of the area around the view on the desktop, not the bare page colour; gap 7: the strips a pan uncovers render in parallel bands; gap 7: the desktop refines a zoom's preview once the zoom has paused; gap 1: the `.fig` export writes vector region paints (#2302); gap 13: a boolean group's corner radius (#2222); gap 24: mind maps, first step: a first node with three children on curved branches, laid out again after every edit (`board.mindMap`, `board.mindMapAdd`, #2226); gap 10: library analytics list how many layers and files use each style and variable; the Controller menu names each button as PlayStation and Switch controllers do; gap 6: widgets draw lines and SVG pictures (plugin API 6); gap 7: text reads only the fallback fonts it draws with; a board connector's path can be reshaped by dragging its path handles (#1710); gap 10: library analytics count insertions and show insertions and detachments over time; gap 6: a widget opens its plugin's panel (plugin API 5), whose callbacks redraw it; the keyboard's Menu key opens the context menu, as Shift+F10 does; gap 14: a collection of this file extends, following its edits at once; colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; gap 6: plugin widgets have hover styles; gap 7: the browser draws a zoom's full render a band at a time; `.fig` import keeps the file's saved line breaks while the text and its box are unedited (#1236); FigJam outer shape outlines and sticky body fallback beside author text (#1341, #1397); Arabic draft catalog; gap 7: the browser refines a zoom's preview once the zoom has paused; gap 17: branches in live sessions, branch history entries, the list-merge rows brought up to date; gap 6: plugin widgets take text input and a property menu (plugin API 4); gap 24: board templates and tables; gap 24: a shared timer and voting sessions; gap 24: the board dot grid, connector ends dragged to re-attach, curved connectors; egui/eframe 0.37 verified for gap 18; known gaps from the #1311 review in gaps 4, 14, 15 and 16; gap 16: measurements kept on the canvas, a read-only layers panel in Dev Mode; gap 24: boards and their tail; Dev Mode tail: import lines in layer trees, compare with versions, an inspect-only canvas; gap 5: reviewed Turkish, Czech and Indonesian drafts, the Japanese draft completed; reviewed Russian catalog and integer plurals; `.fig` export: instance sizes, variables with modes, shared styles, variable-width strokes; sharing with a join code; text box sizes measured against documents re-saved by other software; live sessions per document; .fig export checked by opening written files in other software; experimental .fig export; keyboard shortcut parity suite and bindings; Simplified Chinese draft catalog; Latin American Spanish overlay; prototyping tail: gamepad triggers, widgets in prototypes, mode lookups; plugin directory on figcraft-server; Japanese and Korean draft catalogs and CJK UI fonts; plugin widgets and the plugin panel tail; French, German and Brazilian Portuguese draft catalogs; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and edit tail; dev resources links; extended collections tail; branch version history and finer list merges; comments and version history behaviour suite and fixes; canvas navigation, guides and grids behaviour suite and fixes; `.fig` import: editable vector networks, more layer kinds, variable prototype actions; `.fig` import, best effort: gap 1 down to its tail; Windows QA pass: everyday workflows on Windows 11, eight fixes incl. unsaved work kept after a crash or a forced quit; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; localization layer with a draft Spanish catalog; hosting figcraft-server: wss in the desktop app, server releases, deployment guide; plugin panels and settings; canvas fixes: boolean hit testing on the result, group drags, frame outlines and slices; code connect; stretch and scatter brushes, pen pressure; text on a path and pattern fills; team libraries on the server and swap library; branches: create, update from main, review and merge; animated GIF fills and TIFF images; Open recent, outlines for the selection and mask outlines: menu breadth 100%; extended collections, variables import/export, gradient stop and variant bindings: gap 14 down to its tail; the 2026-10-17 landings: `.fig` import fidelity, budgets for large files, the import report, a `.fig` copy from Save as and pasteLine truncated
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-24 · **Change:** minor (gap 7: a moved point redraws its vector around it only; gap 24: mind maps from the toolbar and the keyboard (#2226); gap 24: code blocks, first step (`board.codeBlock`, `board.setLanguage`, #2237); gap 10: library analytics count insertions and detachments of styles and variables; gap 6: the browser build uses team libraries and plugin directories on a server; gap 7: a pan past the canvas image shows a coarse image of the area around the view on the desktop, not the bare page colour; gap 7: the strips a pan uncovers render in parallel bands; gap 7: the desktop refines a zoom's preview once the zoom has paused; gap 1: the `.fig` export writes vector region paints (#2302); gap 13: a boolean group's corner radius (#2222); gap 24: mind maps, first step: a first node with three children on curved branches, laid out again after every edit (`board.mindMap`, `board.mindMapAdd`, #2226); gap 10: library analytics list how many layers and files use each style and variable; the Controller menu names each button as PlayStation and Switch controllers do; gap 6: widgets draw lines and SVG pictures (plugin API 6); gap 7: text reads only the fallback fonts it draws with; a board connector's path can be reshaped by dragging its path handles (#1710); gap 10: library analytics count insertions and show insertions and detachments over time; gap 6: a widget opens its plugin's panel (plugin API 5), whose callbacks redraw it; the keyboard's Menu key opens the context menu, as Shift+F10 does; gap 14: a collection of this file extends, following its edits at once; colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; gap 6: plugin widgets have hover styles; gap 7: the browser draws a zoom's full render a band at a time; `.fig` import keeps the file's saved line breaks while the text and its box are unedited (#1236); FigJam outer shape outlines and sticky body fallback beside author text (#1341, #1397); Arabic draft catalog; gap 7: the browser refines a zoom's preview once the zoom has paused; gap 17: branches in live sessions, branch history entries, the list-merge rows brought up to date; gap 6: plugin widgets take text input and a property menu (plugin API 4); gap 24: board templates and tables; gap 24: a shared timer and voting sessions; gap 24: the board dot grid, connector ends dragged to re-attach, curved connectors; egui/eframe 0.37 verified for gap 18; known gaps from the #1311 review in gaps 4, 14, 15 and 16; gap 16: measurements kept on the canvas, a read-only layers panel in Dev Mode; gap 24: boards and their tail; Dev Mode tail: import lines in layer trees, compare with versions, an inspect-only canvas; gap 5: reviewed Turkish, Czech and Indonesian drafts, the Japanese draft completed; reviewed Russian catalog and integer plurals; `.fig` export: instance sizes, variables with modes, shared styles, variable-width strokes; sharing with a join code; text box sizes measured against documents re-saved by other software; live sessions per document; .fig export checked by opening written files in other software; experimental .fig export; keyboard shortcut parity suite and bindings; Simplified Chinese draft catalog; Latin American Spanish overlay; prototyping tail: gamepad triggers, widgets in prototypes, mode lookups; plugin directory on figcraft-server; Japanese and Korean draft catalogs and CJK UI fonts; plugin widgets and the plugin panel tail; French, German and Brazilian Portuguese draft catalogs; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and edit tail; dev resources links; extended collections tail; branch version history and finer list merges; comments and version history behaviour suite and fixes; canvas navigation, guides and grids behaviour suite and fixes; `.fig` import: editable vector networks, more layer kinds, variable prototype actions; `.fig` import, best effort: gap 1 down to its tail; Windows QA pass: everyday workflows on Windows 11, eight fixes incl. unsaved work kept after a crash or a forced quit; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; localization layer with a draft Spanish catalog; hosting figcraft-server: wss in the desktop app, server releases, deployment guide; plugin panels and settings; canvas fixes: boolean hit testing on the result, group drags, frame outlines and slices; code connect; stretch and scatter brushes, pen pressure; text on a path and pattern fills; team libraries on the server and swap library; branches: create, update from main, review and merge; animated GIF fills and TIFF images; Open recent, outlines for the selection and mask outlines: menu breadth 100%; extended collections, variables import/export, gradient stop and variant bindings: gap 14 down to its tail; the 2026-10-17 landings: `.fig` import fidelity, budgets for large files,Line truncated
|
||||
|
||||
Every known shortfall against Figma, one entry each, ranked by how much it stops a Figma user from
|
||||
doing real work in FigCraft. Agents: pick work from the top unless the owner says otherwise. The
|
||||
@@ -287,6 +287,15 @@ No alpha blockers: the alpha gate in [`roadmap.md`](roadmap.md#alpha-gate) passe
|
||||
sixteenth of the pixels first, then refined. With no measure to go by (the first render, another
|
||||
page, a zoom after quick renders), a watchdog thread previews any such render still running
|
||||
after 12 ms (desktop only; the browser renders inline).
|
||||
- **Landed (2026-11-24):** a moved point redraws its vector around it only. A point dragged in the
|
||||
vector editor changed the vector, so its whole box was drawn again; zoomed to the vector, as the
|
||||
editor does, that is most of the view, past the share a patch may cover (60%), and every frame of
|
||||
the drag was a full render. A vector that differs only in where its points and handles are now
|
||||
redraws the segments that moved and their neighbours (whose joins and rounded corners follow
|
||||
them), as far out as its stroke reaches: 41,866 of a view's 328,801 pixels for a point of a
|
||||
filled twelve-tooth zigzag that fills the view (`a_moved_point_redraws_the_vector_around_it_only`).
|
||||
Dashes, width profiles, brushes, gradients and images, effects, masks and open filled paths
|
||||
depend on the whole outline: those vectors are drawn again whole.
|
||||
- **Landed (2026-10-29):** the browser draws a zoom's full render a band at a time (`Retained::begin`,
|
||||
`Steps`; at least a band a frame and at most eight bands, so a frame draws a part of the render
|
||||
where it drew the whole of it: 0.7–1.4 s where the render took 3.7–4.0 s in the measurement of
|
||||
@@ -615,6 +624,7 @@ No alpha blockers: the alpha gate in [`roadmap.md`](roadmap.md#alpha-gate) passe
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-24 | minor | Gap 7: a point moved in the vector editor redraws the segments that moved and their neighbours, not the vector's whole box (a full render of the view when the vector fills it). Numbers unchanged |
|
||||
| 2026-11-19 | minor | Gap 24: code blocks, first step (`board.codeBlock`, `board.setLanguage`; a block is as tall as its lines and keeps its text plain code, #2237); the toolbar entry, language menu, highlighting, line numbers and `.jam` import are missing. |
|
||||
| 2026-11-18 | minor | Gap 10: library analytics count insertions and detachments of styles and variables; modes stay on the missing list. |
|
||||
| 2026-11-18 | minor | Gap 6: the plugin directory works in the browser build, so that item leaves the missing list; what's installed there lasts as long as the page. Team libraries on a server work there too. |
|
||||
|
||||
+7
-2
@@ -374,7 +374,10 @@ Or in a project's `.mcp.json`:
|
||||
tracking shortcuts, a canvas drag) detaches that field's variable; fields the edit
|
||||
left as they were stay bound.
|
||||
`variable.addMode {from}` duplicates a mode, `variable.moveMode {collection, mode, to}` reorders
|
||||
(index 0 is the default mode, which layers on Auto follow). `variable.update {codeSyntax: {WEB?,
|
||||
(index 0 is the default mode, which layers on Auto follow). `variable.move {variables, before?}`
|
||||
reorders variables within their collection (the order the Variables window and the pickers list),
|
||||
`variable.sort {collection, group?, descending?}` sorts them by name, numbers by value (50 before
|
||||
100). `variable.update {codeSyntax: {WEB?,
|
||||
iOS?, ANDROID?}}` sets code names (`""` clears); generated CSS uses the Web one, SwiftUI the iOS one and
|
||||
Compose the Android one (a variable without one keeps its value there).
|
||||
- **Live previews**: `text.preview {command, params}` shows what `style.apply`,
|
||||
@@ -1124,7 +1127,9 @@ most when it can't be reached).
|
||||
by name in their set, styles by name and type, variables by collection, name and type, modes by
|
||||
name), keeping overrides; one undo step → `{components, styles, variables, unmatched: [names
|
||||
still from `from`, including this file's collections that extend one of its collections],
|
||||
removed (nothing of `from` was left, so it was removed)}`.
|
||||
dropped: [`from`'s copies nothing used before the swap, which it removed rather than moved: a
|
||||
component imported but not placed, or whose instances were deleted; a variable imported but not
|
||||
bound], removed (nothing of `from` was left, so it was removed)}`.
|
||||
|
||||
### Overrides and variants
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# FigCraft parity with Figma
|
||||
|
||||
> **Last reviewed:** 2026-11-15 · **Last updated:** 2026-11-19 · **Change:** minor (mind maps from the toolbar and the keyboard: Shapes ▸ Mind map places one with a click, Cmd/Ctrl+Enter adds a child and Shift+Cmd/Ctrl+Enter a sibling, Tab goes to the next sibling (#2226); M4, #2405: Outline stroke (Cmd/Ctrl+Alt+O) on a text without a stroke turns its glyphs into a vector filled as the text was, with its colour style, in place, instead of doing nothing; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); gap 6: the browser build uses team libraries and plugin directories on a server; M6 `.fig` export writes text on a path (#2323), list spacing, hanging punctuation and lists, vertical trim (#2305), vector region paints (#2302), image adjustments (#2297) and a page's prototype background (#2326); M8 Tidy up keeps a row's or column's order and sizes and evens the gaps, rounds the gap, tidies overlapping rows and grids along their longer axis, and raises a negative gap, as measured in Figma (#2319); a polygon's or star's Count handle and a double-click on a layer's icon (zoom, range anchor) follow Figma; Tab while renaming moves only the rename; Align is unavailable in an auto layout frame's flow; the Scale tool pivots on the opposite handle; Paste over selection puts copies above the selected layer; Crop from the image fill's menu crops with a drag (#2307); M10 code export writes every colour and gradient fill in paint order for CSS, SwiftUI, Compose and Flutter (#2271); 24 pt icon buttons draw 16 pt glyphs (#2227, #2238); M5 marquee selection follows Figma's measured rules and Select layer lists locked layers (#1560); M7 the Design panel shows the page's variable modes with nothing selected (#2215); M12 mind maps centre in a section or frame without a place, stickies take a Small–Huge text-size menu, and M9 `.jam` shapes with text import as native board shapes (#1808); M4 a boolean group's corner radius rounds its result (#2222), Flatten bakes a point's corner radius (#2195) and loops close through a joining segment (#1951); library links survive moving or cloning the project folder (#2132); a variable group renamed to a path with `/` nests (#2353); SVG import, widget images, batches and grids take bounded work, and a host's server key is never sent over plain `ws://` to another machine (#1923); releases FigCraft v0.18.0 and v0.18.1; the 2026-10-17 menu measurement (212 / 212) and every percentage and hour stand, not re-measured) · **Target:** Figma Design (desktop app 126.10.7, macOS)
|
||||
> **Last reviewed:** 2026-11-15 · **Last updated:** 2026-11-27 · **Change:** minor (M8, #2635: an opaque inside or outside stroke meets the background and the fill with no light fringe or gap at its edges; mind maps from the toolbar and the keyboard: Shapes ▸ Mind map places one with a click, Cmd/Ctrl+Enter adds a child and Shift+Cmd/Ctrl+Enter a sibling, Tab goes to the next sibling (#2226); M4, #2405: Outline stroke (Cmd/Ctrl+Alt+O) on a text without a stroke turns its glyphs into a vector filled as the text was, with its colour style, in place, instead of doing nothing; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); gap 6: the browser build uses team libraries and plugin directories on a server; M6 `.fig` export writes text on a path (#2323), list spacing, hanging punctuation and lists, vertical trim (#2305), vector region paints (#2302), image adjustments (#2297) and a page's prototype background (#2326); M8 Tidy up keeps a row's or column's order and sizes and evens the gaps, rounds the gap, tidies overlapping rows and grids along their longer axis, and raises a negative gap, as measured in Figma (#2319); a polygon's or star's Count handle and a double-click on a layer's icon (zoom, range anchor) follow Figma; Tab while renaming moves only the rename; Align is unavailable in an auto layout frame's flow; the Scale tool pivots on the opposite handle; Paste over selection puts copies above the selected layer; Crop from the image fill's menu crops with a drag (#2307); M10 code export writes every colour and gradient fill in paint order for CSS, SwiftUI, Compose and Flutter (#2271); 24 pt icon buttons draw 16 pt glyphs (#2227, #2238); M5 marquee selection follows Figma's measured rules and Select layer lists locked layers (#1560); M7 the Design panel shows the page's variable modes with nothing selected (#2215); M12 mind maps centre in a section or frame without a place, stickies take a Small–Huge text-size menu, and M9 `.jam` shapes with text import as native board shapes (#1808); M4 a boolean group's corner radius rounds its result (#2222), Flatten bakes a point's corner radius (#2195) and loops close through a joining segment (#1951); library links survive moving or cloning the project folder (#2132); a variable group renamed to a path with `/` nests (#2353); SVG import, widget images, batches and grids take bounded work, and a host's server key is never sent over plain `ws://` to another machine (#1923); releases FigCraft v0.18.0 and v0.18.1; the 2026-10-17 menu measurement (212 / 212) and every percentage and hour stand, not re-measured) · **Target:** Figma Design (desktop app 126.10.7, macOS)
|
||||
|
||||
The authoritative assessment of how close FigCraft is to Figma Design. [`ROADMAP.md`](../ROADMAP.md)
|
||||
summarizes it; [`gaps.md`](gaps.md) is the ranked work list; the measured menu checklist is
|
||||
@@ -652,6 +652,7 @@ Carried over from the ROADMAP's "Shipped so far" (2026-10-10). The test count th
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-27 | patch | M8, #2635: a stroked layer showed a thin light line along the outer edge of an inside stroke (the fill under the stroke's anti-aliased edge showed through it), and what lies behind showed between an outside stroke and the fill. Where the stroke hides what is under it (its top paint an opaque solid colour, normal blend, one weight all round, no dashes, width profile or brush), the fill now reaches the middle of the stroke, so neither edge has the fill or the background showing through: rectangles, frames and ellipses by their inset or grown outline, other shapes and text by their outline less or plus the centred stroke. Translucent, gradient and image strokes and even-odd outlines fill as before. Test: `stroke_fringe_tests::an_opaque_stroke_shows_nothing_lighter_than_its_dark_neighbour_at_either_edge` (fails on main). |
|
||||
| 2026-11-19 | patch | M4, #2405: Outline stroke (Cmd/Ctrl+Alt+O) on a text without a stroke turns its glyphs into a vector filled as the text was, with its colour style, in place, instead of doing nothing. |
|
||||
| 2026-11-18 | minor | M9, gap 6: the browser build uses team libraries and plugin directories on a server, through its WebSocket requests: adding a library by its link, its styles and components, publishing to it, Show usage and the reports a file sends; browsing a directory and installing from it, for the page only. Scripts through `window.figcraft` still can't, as commands there don't wait for the server. Numbers unchanged. Tests: `exchange_tests`. |
|
||||
| 2026-11-09 | patch | M5, #2127: presenting a frame taller than about 2900 units at 1440 wide on a 2x display (Fit width, or 100%) drew it blurry: the whole frame is rasterised once, capped at 16.8 million pixels (a 1440 by 9701 frame at 1.1 pixels a unit, 1579 by 10632), and stretched up 1.8 times with linear filtering, while the canvas, which renders only what is in view, stayed sharp. Now the part in view plus a quarter of its size each way is drawn again over that texture from one more at the full pixel scale (never past the GPU's side or the same pixel cap), rendered when it stops covering the view and not while a fling, drag or the wheel moves it (while the view moves, a detail is drawn only while it covers the whole view: past it the capped texture shows alone, with no sharp edge across the view, until the view settles); transitions, smart animate, overlays and thumbnails keep the capped texture. Tests: `present::tests::tall_frame_detail_plan_renders_the_view_at_device_scale`, `presenting_a_tall_frame_on_a_hidpi_display_draws_the_view_at_device_scale`. Numbers unchanged |
|
||||
|
||||
Reference in new issue
Block a user