From a198046384b37e1c9e6fe98207a36b3ba6967c7d Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Sat, 7 Nov 2026 19:57:05 -0500 Subject: [PATCH 1/7] Smart guides: objects snap within 4.5 screen pixels, as measured in Figma Figma snaps a dragged object's edge to another's at a gap of 4.4 screen pixels and not at 4.6, at 100% and at 200% zoom, so the threshold is about 4.5 screen pixels; FigCraft used 5. The object snap (move, resize, draw, vector points) now uses 4.5, and the equal-spacing snap in a move shares that threshold so it follows. Ruler-guide and rotation-origin snapping keep 5, unmeasured. Co-Authored-By: Claude Sonnet 5.5 Model-Effort: Opus 5.5 drove and briefed; Sonnet 5.5 measured and wrote at medium --- crates/engine/src/canvas/rotation_origin.rs | 4 ++-- crates/engine/src/canvas/snap.rs | 6 +++--- crates/engine/src/canvas/tools.rs | 2 +- crates/engine/src/canvas/tools/handles.rs | 9 ++++++-- .../engine/src/transform_behaviour_tests.rs | 21 +++++++++++++++++++ docs/ui-parity.md | 3 ++- 6 files changed, 36 insertions(+), 9 deletions(-) diff --git a/crates/engine/src/canvas/rotation_origin.rs b/crates/engine/src/canvas/rotation_origin.rs index 8498f708a..5552bc77b 100644 --- a/crates/engine/src/canvas/rotation_origin.rs +++ b/crates/engine/src/canvas/rotation_origin.rs @@ -8,7 +8,7 @@ use figcraft_doc::{Document, NodeId}; use figcraft_geom::Point; use crate::cmd::edit::roots; -use crate::tools::{SNAP_PX, selection_box}; +use crate::tools::{UNMEASURED_SNAP_PX, selection_box}; use crate::{DocState, EngineError, Result, Session}; /// How near (screen pixels) a press must be to grab the origin handle. @@ -115,7 +115,7 @@ impl Session { let snapped = box_points(&ds.doc, &ds.selection).and_then(|b| { b.iter() .enumerate() - .filter(|(_, q)| (**q - p).hypot() * zoom.max(1e-6) <= SNAP_PX) + .filter(|(_, q)| (**q - p).hypot() * zoom.max(1e-6) <= UNMEASURED_SNAP_PX) .min_by(|x, y| (*x.1 - p).hypot().total_cmp(&(*y.1 - p).hypot())) .map(|(i, q)| (i, *q)) }); diff --git a/crates/engine/src/canvas/snap.rs b/crates/engine/src/canvas/snap.rs index cd40437d3..ff1a6b64d 100644 --- a/crates/engine/src/canvas/snap.rs +++ b/crates/engine/src/canvas/snap.rs @@ -9,7 +9,7 @@ use figcraft_geom::{Affine, Point, Rect, Vec2, transform_rect_bbox}; use serde::Serialize; use crate::guides; -use crate::tools::SNAP_PX; +use crate::tools::UNMEASURED_SNAP_PX; /// A guide line to draw: from (x0, y0) to (x1, y1) in page coordinates, with an optional label /// (a distance) at its middle; `dashed` marks a measurement's extension line. @@ -438,14 +438,14 @@ impl Targets { } /// Snap a guide on `owner` (a page or a top-level frame) to the nearest layer edge or centre along -/// its own axis, within `SNAP_PX` screen pixels at `zoom`. Returns the new offset in `owner`'s +/// its own axis, within `UNMEASURED_SNAP_PX` screen pixels at `zoom`. Returns the new offset in `owner`'s /// coordinates, or `None` when nothing is in reach. pub fn snap_guide(doc: &Document, page: NodeId, owner: NodeId, vertical: bool, offset: f64, zoom: f64) -> Option { // The guide moves along the owner's own axis (x for a vertical guide, y for a horizontal one), // which the owner's transform may scale: convert the screen-pixel reach into owner units. let [a, b, c, d, _, _] = doc.world_transform(owner).as_coeffs(); let axis = if vertical { a.hypot(b) } else { c.hypot(d) }; - let threshold = SNAP_PX / (zoom.max(1e-6) * axis.max(1e-6)); + let threshold = UNMEASURED_SNAP_PX / (zoom.max(1e-6) * axis.max(1e-6)); Targets::gather_for_guide(doc, page, owner).snap_axis(vertical, offset, threshold).map(|d| offset + d).filter(|v| v.is_finite()) } diff --git a/crates/engine/src/canvas/tools.rs b/crates/engine/src/canvas/tools.rs index a3284cd52..0c409a682 100644 --- a/crates/engine/src/canvas/tools.rs +++ b/crates/engine/src/canvas/tools.rs @@ -34,7 +34,7 @@ pub use handles::{ PENCIL_STROKE, SMALL_BOX_PX, anchor_name, anchor_of, box_sides_px, handle_at, handle_at_corners, label_at, locked_in, scale_anchor_point, selection_box, selection_frame, }; -pub(crate) use handles::{SNAP_PX, handle_cursor, readable_text_fills, resized_box}; +pub(crate) use handles::{SNAP_PX, UNMEASURED_SNAP_PX, handle_cursor, readable_text_fills, resized_box}; #[cfg(test)] pub(crate) use pen::pressure_profile; diff --git a/crates/engine/src/canvas/tools/handles.rs b/crates/engine/src/canvas/tools/handles.rs index 9fa04d9bb..f60866ec1 100644 --- a/crates/engine/src/canvas/tools/handles.rs +++ b/crates/engine/src/canvas/tools/handles.rs @@ -71,8 +71,13 @@ const HANDLE_PX: f64 = 5.0; const ROTATE_PX: f64 = 18.0; -/// Snap distance in screen pixels. -pub(crate) const SNAP_PX: f64 = 5.0; +/// Object snap distance in screen pixels: measured in Figma, where an edge snaps at a gap of 4.4 +/// screen px and not at 4.6, at 100% and at 200% zoom. +pub(crate) const SNAP_PX: f64 = 4.5; + +/// Snap distance in screen pixels for ruler guides and the rotation origin, not measured against +/// Figma. +pub(crate) const UNMEASURED_SNAP_PX: f64 = 5.0; /// Screen pixels the pointer travels after a press before a move or resize starts: a click or a /// double-click made with an unsteady hand doesn't drag what it lands on. diff --git a/crates/engine/src/transform_behaviour_tests.rs b/crates/engine/src/transform_behaviour_tests.rs index e22eb0418..56d581b32 100644 --- a/crates/engine/src/transform_behaviour_tests.rs +++ b/crates/engine/src/transform_behaviour_tests.rs @@ -625,6 +625,27 @@ fn smart_guides_snap_to_edges_centres_and_equal_spacing() { assert_eq!(bounds(&s, b).origin(), Point::new(198.0, 2.0)); } +#[test] +fn a_layer_edge_snaps_within_4_5_screen_pixels_at_any_zoom() { + // Measured in Figma (2026-11-08): a dragged edge snaps at a gap of 4.4 screen px and not at 4.6, + // at 100% and at 200% zoom. + for (zoom, gap_px, snaps) in [(1.0, 4.4, true), (1.0, 4.8, false), (2.0, 4.4, true), (2.0, 4.8, false)] { + let mut s = Session::new(); + ex(&mut s, "view.snapPixel", json!({"on": false})); + rect(&mut s, 0.0, 0.0, 100.0, 100.0, None); + let b = rect(&mut s, 300.0, 300.0, 100.0, 100.0, None); + ex(&mut s, "select.set", json!({"ids": [b]})); + let gap = gap_px / zoom; + let to = Point::new(350.0 - (200.0 - gap), 350.0); + for (kind, p) in [(PointerKind::Down, Point::new(350.0, 350.0)), (PointerKind::Move, to), (PointerKind::Up, to)] { + s.pointer(&PointerEvent::at(kind, p.x, p.y, zoom)).unwrap(); + } + let want = if snaps { 100.0 } else { 100.0 + gap }; + let got = bounds(&s, b).x0; + assert!(near(got, want), "zoom {zoom}, gap {gap_px} screen px: left edge at {got}, wanted {want}"); + } +} + #[test] fn snapping_to_layers_wins_over_the_pixel_grid() { // Both on (the defaults): a layer's centre at x = 5.5 is still a target. diff --git a/docs/ui-parity.md b/docs/ui-parity.md index aa0ef25bd..b19d0c5a5 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -69,7 +69,7 @@ interaction feel not yet compared. | Drag threshold; double-click into groups and text | done | a press moves or resizes only once the pointer has travelled 3 px on screen, so a click or double-click made with an unsteady hand drags nothing; a double-click goes one level into a group and the next one edits the text under it, wherever on the text it lands, with all of it selected (a double-click in the text being edited selects the word) (`double_click_tests`); Enter on a selected text does the same (all of it selected, typing replaces it) and Escape leaves editing with the layer still selected (`text_enter_tests`) | | Scale tool (K): handles about an anchor, live factor, panel | done | | | Nudge 1 / Shift 10 (preference), Cmd+arrows resize | done | arrows reorder auto layout children | -| Smart guides: edges, centres, equal spacing (between two layers or continuing a row's gap, labelled), spacing labels, parent, layout grid, ruler guides | done | red, `snap.rs`; a guide dragged out of a ruler or moved snaps to layer edges and centres too (Snap to Objects; Cmd/Ctrl suspends), on its own axis only; page guides see the page's top-level layers, frame guides the frame's box, layout grids and every layer in it, along a rotated frame's own axes; thresholds not yet compared with Figma's (`guide_snap_tests`) | +| Smart guides: edges, centres, equal spacing (between two layers or continuing a row's gap, labelled), spacing labels, parent, layout grid, ruler guides | done | red, `snap.rs`; a guide dragged out of a ruler or moved snaps to layer edges and centres too (Snap to Objects; Cmd/Ctrl suspends), on its own axis only; page guides see the page's top-level layers, frame guides the frame's box, layout grids and every layer in it, along a rotated frame's own axes; the object snap threshold is 4.5 screen pixels, measured against Figma (snapped at a gap of 4.4 screen px, not at 4.6, at 100% and 200% zoom, 2026-11-08; the equal-spacing snap shares it), but the ruler-guide and rotation-origin thresholds (5 px), the red guide's look and snapping with Snap to pixel grid off are not yet compared with Figma's (`guide_snap_tests`, `transform_behaviour_tests`) | | Ctrl to suspend snapping while dragging (macOS) | done | Control on macOS (Cmd keeps working), Ctrl elsewhere; moving, resizing and drawing | | Measure (Alt hover, Cmd+Alt nested, Shift+Alt padding/gaps) | done | labels never overlap; the arrows still nudge while measuring (Shift: the big step) and the distances follow; the selection's handles and size label hide while measuring (`measure_nudge_tests`, #894) | | Pixel grid snapping, pixel preview, 2x preview | done | moves, resizes and new shapes land on whole pixels; the pixel grid shows from 400% (`view_behaviour_tests`) | @@ -187,6 +187,7 @@ in the table. `crates/ui-egui/src/shortcut_keys_tests.rs` drives the keys a look | Date | Change | Summary | |---|---|---| +| 2026-11-08 | patch | Smart guides: the object snap threshold is 4.5 screen pixels, measured against Figma (a dragged edge snapped at a gap of 4.4 screen px and not at 4.6, at 100% and at 200% zoom, Snap to pixel grid on); FigCraft used 5. Equal spacing shares the move's threshold so it follows; ruler-guide and rotation-origin snapping keep 5, unmeasured (`transform_behaviour_tests`) | | 2026-11-02 | patch | Shortcuts: a Cmd/Ctrl-click on a padding field (the horizontal or vertical pair, or a side with Individual padding open) makes the value typed go to all four sides, in one undo step (Guide to auto layout, Keyboard shortcut guide); a plain click still edits that axis or side alone. A documented gesture row: 134 documented, 133 bound. Test: `padding_individual_tests` | | 2026-11-01 | patch | Number fields: dragging the field itself with Alt held scrubs it ("You can also hover the input field itself and hold down the modifier key: Mac: ⌥ Option Windows: Alt", Adjust alignment, rotation, position, and dimensions), with the resize cursor and the label's rates (Alt is the enabler there, so it isn't the fine rate); a click with Alt doesn't open the editor. Found by a documentation audit of the ui-parity rows. Test: `field_tests::alt_held_over_a_field_scrubs_it`. Counts unchanged | | 2026-11-02 | patch | M6, #1839: with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it by the nudge amounts (`tool.crosshair`), Enter places the object there (`tool.place`), Escape or a tool change takes it away; the canvas draws the crosshair and `ui.inspect` reports it (`tool.crosshair`), the Keyboard shortcuts panel lists the gesture ("Use the arrow keys to activate the crosshair cursor...", Accessibility at Figma). The board Shapes tool places on it too (its 160 px shape centred, as the tool centres a press), and the view pans by the overshoot when the crosshair is nudged past its edge. Tests: `place_crosshair_tests`, `shortcut_keys_tests::arrows_show_and_move_the_placement_crosshair_with_a_shape_tool`. | From ebe0a8c23a2cbb8e47992401acd00c4eeb431629 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Sat, 7 Nov 2026 20:37:35 -0500 Subject: [PATCH 2/7] Measure test: the Alt-drag ends within the new 4.5 px snap distance alt_drag_shows_live_distances_to_the_neighbours dragged the copy to 5 px from the equal-spacing target, which the old 5 px threshold caught and 4.5 does not. The drag now ends at 129 (4 px off); the expected labels are unchanged. Co-Authored-By: Claude Sonnet 5.5 Model-Effort: Opus 5.5 drove and briefed; Sonnet 5.5 wrote at medium --- crates/engine/src/measure_tests.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/measure_tests.rs b/crates/engine/src/measure_tests.rs index 9f7937214..fb031102d 100644 --- a/crates/engine/src/measure_tests.rs +++ b/crates/engine/src/measure_tests.rs @@ -196,9 +196,9 @@ fn alt_drag_shows_live_distances_to_the_neighbours() { e }; s.pointer(&ev(PointerKind::Down, 30.0)).unwrap(); - // Alt duplicates: the copy, dragged to 110..160, snaps to equal spacing between the original + // Alt duplicates: the copy, dragged to 109..159, snaps to equal spacing between the original // and the other layer (105..155). - s.pointer(&ev(PointerKind::Move, 130.0)).unwrap(); + s.pointer(&ev(PointerKind::Move, 129.0)).unwrap(); let g = s.tool.overlay.guides.clone(); assert_eq!( labelled(&g), @@ -209,7 +209,7 @@ fn alt_drag_shows_live_distances_to_the_neighbours() { ("45".into(), [155, 50, 200, 50]) ] ); - s.pointer(&ev(PointerKind::Up, 130.0)).unwrap(); + s.pointer(&ev(PointerKind::Up, 129.0)).unwrap(); assert!(s.tool.overlay.guides.is_empty()); } From b54df860de57f23d73346d732a794080de929cc9 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Thu, 12 Nov 2026 07:10:52 -0500 Subject: [PATCH 3/7] M6: .fig export writes image adjustments (#2297) An image paint's adjustments (exposure, contrast, saturation, temperature, tint, highlights, shadows) were dropped on export with a warning, although the importer already reads them. The export now writes them as the paint's `paintFilter`: seven floats, with saturation as vibrance and the tint's sign flipped to the file's (positive towards magenta). A paint without adjustments gets no `paintFilter`. The warning is gone. The schema gains `PaintFilterMessage` and `Paint.paintFilter`. A round-trip test turns the importer's fixture around and pins the written values and field numbers. Not checked in other software. Co-Authored-By: Claude Sonnet 5.5 Model-Effort: Opus 5.5 drove; Fable 5.2 briefed; Sonnet 5.5 wrote at medium --- crates/format/src/fig/export.rs | 3 +- crates/format/src/fig/export/paint.rs | 17 +++++- crates/format/src/fig/image_filter_tests.rs | 65 ++++++++++++++++++++- docs/file-format-parity.md | 7 ++- 4 files changed, 83 insertions(+), 9 deletions(-) diff --git a/crates/format/src/fig/export.rs b/crates/format/src/fig/export.rs index f00de3606..e8fe84166 100644 --- a/crates/format/src/fig/export.rs +++ b/crates/format/src/fig/export.rs @@ -141,7 +141,8 @@ message StyleId GUID guid=1 message VariableID GUID guid=1 message VariableSetID GUID guid=1 message ColorStopVar Color color=1, VariableData colorVar=2, float position=3 -message Paint PaintType type=1, Color color=2, float opacity=3, bool visible=4, BlendMode blendMode=5, ColorStop[] stops=6, Matrix transform=7, Image image=8, ImageScaleMode imageScaleMode=10, float rotation=11, float scale=12, VariableData colorVar=21, ColorStopVar[] stopsVar=23 +message PaintFilterMessage float tint=1, float shadows=2, float highlights=3, float exposure=5, float temperature=7, float vibrance=8, float contrast=9 +message Paint PaintType type=1, Color color=2, float opacity=3, bool visible=4, BlendMode blendMode=5, ColorStop[] stops=6, Matrix transform=7, Image image=8, ImageScaleMode imageScaleMode=10, float rotation=11, float scale=12, PaintFilterMessage paintFilter=14, VariableData colorVar=21, ColorStopVar[] stopsVar=23 message Effect EffectType type=1, Color color=2, Vector offset=3, float radius=4, bool visible=5, BlendMode blendMode=6, float spread=7, bool showShadowBehindNode=8, BlurOpType blurOpType=19, float startRadius=21, Vector startOffset=20, Vector endOffset=28, NoiseType noiseType=26, Vector noiseSize=22, float density=25, float opacity=27, Color secondaryColor=24, bool clipToShape=23, VariableData radiusVar=9, VariableData colorVar=10, VariableData spreadVar=11, VariableData xVar=12, VariableData yVar=13, VariableData startRadiusVar=45 struct FontName string family, string style, string postscript struct Number float value, NumberUnits units diff --git a/crates/format/src/fig/export/paint.rs b/crates/format/src/fig/export/paint.rs index 2bb62ae2f..4d87871f6 100644 --- a/crates/format/src/fig/export/paint.rs +++ b/crates/format/src/fig/export/paint.rs @@ -76,8 +76,21 @@ impl<'d> Exporter<'d> { if let (ImageScaleMode::Crop, Some(c)) = (img.scale_mode, img.crop) { f.push(("transform", matrix(Affine::new(c)))); } - if img.filters != Default::default() { - self.warn("image adjustments (exposure, contrast, …) were left out"); + if !img.filters.is_identity() { + let x = &img.filters; + // The file's tint is positive towards magenta, ours towards green; `0.0 -` keeps zero positive. + f.push(( + "paintFilter", + o(vec![ + ("exposure", fl(f64::from(x.exposure))), + ("contrast", fl(f64::from(x.contrast))), + ("vibrance", fl(f64::from(x.saturation))), + ("temperature", fl(f64::from(x.temperature))), + ("tint", fl(0.0 - f64::from(x.tint))), + ("highlights", fl(f64::from(x.highlights))), + ("shadows", fl(f64::from(x.shadows))), + ]), + )); } } PaintKind::Pattern(_) => { diff --git a/crates/format/src/fig/image_filter_tests.rs b/crates/format/src/fig/image_filter_tests.rs index 3fa50a200..d1297293f 100644 --- a/crates/format/src/fig/image_filter_tests.rs +++ b/crates/format/src/fig/image_filter_tests.rs @@ -16,8 +16,8 @@ fn image_filter_schema() -> Schema { Schema::parse(&text).unwrap() } -#[test] -fn image_filters_import_from_current_container_and_skip_ambiguous_data() { +/// A file with one image rectangle per filter case (current container, legacy, both, neutral, unknown fields). +fn image_filter_fixture() -> Vec { let filter = |fields: Vec<(&'static str, Kv<'static>)>| o(fields); let image_paint = |id: u64, name: &'static str, mut extra: Vec<(&'static str, Kv<'static>)>| { let mut paint = vec![("type", e("IMAGE")), ("image", o(vec![("hash", Kv::Bytes(HASH.to_vec()))]))]; @@ -54,7 +54,12 @@ fn image_filters_import_from_current_container_and_skip_ambiguous_data() { vec![("paintFilter", filter(vec![("brightness", f(0.4)), ("detail", f(-0.2)), ("vignette", f(0.3)), ("mystery", f(0.1))]))], ), ]; - let bytes = zip_file(&canvas(&image_filter_schema(), &o(vec![("nodeChanges", arr(nodes))]))); + zip_file(&canvas(&image_filter_schema(), &o(vec![("nodeChanges", arr(nodes))]))) +} + +#[test] +fn image_filters_import_from_current_container_and_skip_ambiguous_data() { + let bytes = image_filter_fixture(); let (doc, warnings) = import(&bytes, "ImageFilters.fig").unwrap(); let get = |name: &str| { let node = doc.nodes().find(|node| node.name == name).unwrap(); @@ -102,3 +107,57 @@ fn warnings_naming_unknown_filter_fields_are_capped() { let named = warnings.iter().filter(|w| w.contains("unsupported image filter")).count(); assert!((100..=crate::rest::MAX_WARNINGS).contains(&named), "{named} of {} warnings", warnings.len()); } + +#[test] +fn image_adjustments_survive_a_fig_export() { + let (doc, _) = import(&image_filter_fixture(), "ImageFilters.fig").unwrap(); + let filters_of = |doc: &figcraft_doc::Document, name: &str| { + let node = doc.nodes().find(|node| node.name == name).unwrap(); + let figcraft_doc::color::PaintKind::Image(image) = &node.fills[0].kind else { panic!("{name} is not an image fill") }; + image.filters + }; + let (bytes, warnings) = export::export(&doc, None).unwrap(); + assert!(!warnings.iter().any(|w| w.contains("image adjustments")), "{warnings:?}"); + let (back, _) = import(&bytes, "Back.fig").unwrap(); + for name in ["Current", "Negative tint", "Neutral"] { + let (a, b) = (filters_of(&doc, name), filters_of(&back, name)); + for (x, y) in [ + (a.exposure, b.exposure), + (a.contrast, b.contrast), + (a.saturation, b.saturation), + (a.temperature, b.temperature), + (a.tint, b.tint), + (a.highlights, b.highlights), + (a.shadows, b.shadows), + ] { + assert!((x - y).abs() < 1e-6, "{name}: {a:?} came back as {b:?}"); + } + } + assert!(filters_of(&back, "Neutral").is_identity()); + assert!(!filters_of(&back, "Current").is_identity()); + + // What is written: the file's names and signs. + let archive = Archive::open(&bytes).unwrap(); + let (schema, message) = decode_canvas(&archive.canvas).unwrap(); + let msg = schema.decode_message(schema.find("Message").unwrap(), &message).unwrap(); + let fill_of = |name: &str| { + let nc = msg.get("nodeChanges").unwrap().list().iter().find(|nc| nc.get("name").and_then(Kv::str) == Some(name)).unwrap(); + nc.get("fillPaints").unwrap().list()[0].clone() + }; + let current = fill_of("Current"); + let written = |paint: &Kv, field: &str| paint.get("paintFilter").and_then(|f| f.get(field)).and_then(Kv::f64); + assert!((written(¤t, "vibrance").unwrap() + 0.4).abs() < 1e-6); + assert!((written(¤t, "tint").unwrap() - 1.0).abs() < 1e-6); + assert!((written(¤t, "shadows").unwrap() - 0.7).abs() < 1e-6); + assert!(fill_of("Neutral").get("paintFilter").is_none()); + + // The numbers the format uses. + let s = Schema::parse(export::SCHEMA).unwrap(); + let def = |n: &str| s.defs.iter().find(|d| d.name == n).unwrap(); + let id = |d: &str, f: &str| def(d).fields.iter().find(|x| x.name == f).unwrap().value; + assert_eq!(id("Paint", "paintFilter"), 14); + assert_eq!( + ["tint", "shadows", "highlights", "exposure", "temperature", "vibrance", "contrast"].map(|f| id("PaintFilterMessage", f)), + [1, 2, 3, 5, 7, 8, 9] + ); +} diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index 56de5f480..d38af63f9 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -1,6 +1,6 @@ # File format parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-10 · **Change:** minor (`.fig` import and export read and write a boolean group's corner radius and smoothing (#2222); `.jam` import: stickies come in as native board stickies (#1808); `.fig` import scales per-point vector corner radii with the row that supplies their network and keeps different instance scales separate in the network cache (#2097); `.fig` export preserves scaled-instance lengths reset to their unscaled main values, including nested linked-style overrides (#2097); `.fig` import: the layers of an instance scaled with the Scale tool draw at its scale factor, not at their main's lengths (#2091); a color profile per PNG, JPG and WebP export setting (Same as file, sRGB or Display P3), the pixels converted; a `.jam` connector end with an `AUTO` or `CENTER` magnet leaves the side facing the other end, not the side its stale saved point named (#1909); a FigJam elbow connector saved with its path (`connectorControlPoints`) keeps it on import, as a board connector reshaped by hand does, instead of being routed again (#1910); JPG exports take a quality, 1 to 100 with 90 the default, and embed the file's colour profile when it is sRGB too (#2004); a FigJam connector without a saved snapshot took no stroke and was invisible; its line's paint, weight, cap and dashes now come from the file's generated line record (#1807); a Dash cap setting (none, round or square) on Dash and Custom strokes, drawn on both ends of every dash; pasted layers whose image the clipboard lacks are named and show a placeholder that reads as missing (#1646); paint-style colours on layers pasted from another design app keep their style instead of turning black (#1638); imported and pasted text finds an installed family under the other names its fonts give it, and with other case and spacing (#1292); `.fig` export writes colour calculations as the colour they show in each mode and leaves out, with a warning, one that resolves to nothing (#1280); `.fig` import budgets four decoded values per compressed byte instead of one, still within 20M–128M, so dense files within that budget open instead of being refused as having too many values (#574); `.fig` ZIP image reads share a total byte budget and count skipped images in the import warnings (#1076); every file a command reads whole by path is a regular file within a cap that fits it: documents 16 GiB, placed images 256 MiB, CLI scripts 1 GiB; folders, devices and pipes are refused before anything is read (#1114); files nested 256 levels deep import on the browser's 1 MB stack (#1101); SVG and PDF exports count pattern sources and the renders they embed from the layer's depth, so one cap bounds a whole export (#1082); opening a `.figcraft` file unpacks at most 6 GiB in all (2 GiB in the browser), every area together (#1079); `.fig` instance expansion no longer walks variable nodes for every instance or copies every outer override row into each nested instance (#1077); a FigJam `.jam` file opens as a board (#1342); FigJam `.jam` files open like `.fig` files: File ▸ Open, drag and drop, `file.import` and the command line (#1342); SVG import reads `color()` and `color-mix()` colours, with a note and a grey for those it can't (#1550); SVG import draws each pattern tile once per scale, within the layer budget (#1080); a file's JPEG thumbnail can't crash the home screen (#1491's progressive JPEG check, now shared); `.fig` import: library text styles linked by asset key, and override rows restating a nested level (#1234); `.fig` import keeps the file's saved line breaks while the text and its box are unedited (#1236); Download a missing free font from the Missing fonts window (`font.download`, #754); offline Penpot 2.x import/export (#1143); `.sketch` import checked against Sketch's renders: master backgrounds, symbol clipping, tints before Sketch 64, mask opacity, bitmap fills, image overrides on shapes, stretching stacks, blur radii, colour adjustments, OKLab gradients, text growth, shape group borders (#1389); FigJam outer shape outlines and sticky body fallback beside author text (#1341, #1397); image member names are checked on read, and REST image placeholders get archive-safe keys (#1086); Android Vector Drawable (XML) export; `.fig` export: files the incumbent imports, with component set properties, and grid track sizes at its field ids; Save and auto-save don't replace changes another app made to the open file (#1330); `.sketch` import, best effort, Sketch 48 and newer; the PNG row names ignore overlapping layers and where include bounding box is offered; the Fonts table's missing-font row describes the Missing fonts window; `.figcraft` carries the file kind (boards); `.fig` import: resized instances and variable modes by asset key; atomic saves; auto-save; SVG export clip of nested frames; SVG/PDF export depth refusal (#208); `.fig` export: instance sizes, variables with modes, shared styles, variable-width strokes; `.fig` export: written files checked by opening them in other software; experimental `.fig` export; export and inspect behaviour suite and fixes; .fig import: editable vector networks and more layer kinds; embedded image colour profiles; `.fig` import, best effort; animated GIF fills and TIFF images; last major: created, formats from the installed Figma's Info.plist and help center, ours from source; REST import keeps slot layers and instances' slot content (#792); REST import reads grid track sizes (#465); `.fig` import fidelity from the community batches, budgets for large files, the import report, a `.fig` copy from Save as, paste from another design app; instance layers' size and resizing and Hug on import (#731, #732)) · **Target:** Figma Design (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-12 · **Change:** minor (`.fig` export writes image adjustments (#2297); `.fig` import and export read and write a boolean group's corner radius and smoothing (#2222); `.jam` import: stickies come in as native board stickies (#1808); `.fig` import scales per-point vector corner radii with the row that supplies their network and keeps different instance scales separate in the network cache (#2097); `.fig` export preserves scaled-instance lengths reset to their unscaled main values, including nested linked-style overrides (#2097); `.fig` import: the layers of an instance scaled with the Scale tool draw at its scale factor, not at their main's lengths (#2091); a color profile per PNG, JPG and WebP export setting (Same as file, sRGB or Display P3), the pixels converted; a `.jam` connector end with an `AUTO` or `CENTER` magnet leaves the side facing the other end, not the side its stale saved point named (#1909); a FigJam elbow connector saved with its path (`connectorControlPoints`) keeps it on import, as a board connector reshaped by hand does, instead of being routed again (#1910); JPG exports take a quality, 1 to 100 with 90 the default, and embed the file's colour profile when it is sRGB too (#2004); a FigJam connector without a saved snapshot took no stroke and was invisible; its line's paint, weight, cap and dashes now come from the file's generated line record (#1807); a Dash cap setting (none, round or square) on Dash and Custom strokes, drawn on both ends of every dash; pasted layers whose image the clipboard lacks are named and show a placeholder that reads as missing (#1646); paint-style colours on layers pasted from another design app keep their style instead of turning black (#1638); imported and pasted text finds an installed family under the other names its fonts give it, and with other case and spacing (#1292); `.fig` export writes colour calculations as the colour they show in each mode and leaves out, with a warning, one that resolves to nothing (#1280); `.fig` import budgets four decoded values per compressed byte instead of one, still within 20M–128M, so dense files within that budget open instead of being refused as having too many values (#574); `.fig` ZIP image reads share a total byte budget and count skipped images in the import warnings (#1076); every file a command reads whole by path is a regular file within a cap that fits it: documents 16 GiB, placed images 256 MiB, CLI scripts 1 GiB; folders, devices and pipes are refused before anything is read (#1114); files nested 256 levels deep import on the browser's 1 MB stack (#1101); SVG and PDF exports count pattern sources and the renders they embed from the layer's depth, so one cap bounds a whole export (#1082); opening a `.figcraft` file unpacks at most 6 GiB in all (2 GiB in the browser), every area together (#1079); `.fig` instance expansion no longer walks variable nodes for every instance or copies every outer override row into each nested instance (#1077); a FigJam `.jam` file opens as a board (#1342); FigJam `.jam` files open like `.fig` files: File ▸ Open, drag and drop, `file.import` and the command line (#1342); SVG import reads `color()` and `color-mix()` colours, with a note and a grey for those it can't (#1550); SVG import draws each pattern tile once per scale, within the layer budget (#1080); a file's JPEG thumbnail can't crash the home screen (#1491's progressive JPEG check, now shared); `.fig` import: library text styles linked by asset key, and override rows restating a nested level (#1234); `.fig` import keeps the file's saved line breaks while the text and its box are unedited (#1236); Download a missing free font from the Missing fonts window (`font.download`, #754); offline Penpot 2.x import/export (#1143); `.sketch` import checked against Sketch's renders: master backgrounds, symbol clipping, tints before Sketch 64, mask opacity, bitmap fills, image overrides on shapes, stretching stacks, blur radii, colour adjustments, OKLab gradients, text growth, shape group borders (#1389); FigJam outer shape outlines and sticky body fallback beside author text (#1341, #1397); image member names are checked on read, and REST image placeholders get archive-safe keys (#1086); Android Vector Drawable (XML) export; `.fig` export: files the incumbent imports, with component set properties, and grid track sizes at its field ids; Save and auto-save don't replace changes another app made to the open file (#1330); `.sketch` import, best effort, Sketch 48 and newer; the PNG row names ignore overlapping layers and where include bounding box is offered; the Fonts table's missing-font row describes the Missing fonts window; `.figcraft` carries the file kind (boards); `.fig` import: resized instances and variable modes by asset key; atomic saves; auto-save; SVG export clip of nested frames; SVG/PDF export depth refusal (#208); `.fig` export: instance sizes, variables with modes, shared styles, variable-width strokes; `.fig` export: written files checked by opening them in other software; experimental `.fig` export; export and inspect behaviour suite and fixes; .fig import: editable vector networks and more layer kinds; embedded image colour profiles; `.fig` import, best effort; animated GIF fills and TIFF images; last major: created, formats from the installed Figma's Info.plist and help center, ours from source; REST import keeps slot layers and instances' slot content (#792); REST import reads grid track sizes (#465); `.fig` import fidelity from the community batches, budgets for large files, the import report, a `.fig` copy from Save as, paste from another design app; instance layers' size and resizing and Hug on import (#731, #732)) · **Target:** Figma Design (desktop app 126.10.7) Every format Figma reads or writes, with FigCraft's support. Sources: `Info.plist` of `/Applications/Figma.app` (document types only; nothing inside the bundle's code was read), Figma's @@ -98,7 +98,7 @@ scales and empty-style clears; they have not been checked in other software. stroke outline of plain strokes (a ring around boxes and whole ellipses, the widened path of other centred strokes); solid, gradient (handles as the paint transform) and image paints (the image bytes, named by their SHA-1, scale mode, - rotation, tile scale, crop); strokes (weight, align, join, caps, dashes, miter limit, per-side + rotation, tile scale, crop, adjustments: exposure, contrast, saturation (the file's vibrance), temperature, tint, highlights and shadows); strokes (weight, align, join, caps, dashes, miter limit, per-side weights); shadows, layer and background blurs (progressive too), noise and texture; corners and smoothing, constraints, clip content, masks with their type; auto layout (direction, wrap, gaps, padding, alignment, hug, strokes in layout, stacking order, grids with their tracks, their sizes (fixed, hug, fill) and cells) and how @@ -139,7 +139,7 @@ scales and empty-style clears; they have not been checked in other software. guides, prototype device settings, slot properties and slot content, brush strokes (written plain), strokes wider on one side of their path (written as filled outlines, or with the width on both sides when the shape has a fill too), pattern fills, WebP export settings (written as PNG), - image adjustments, glass settings other than frost, springs other than Gentle (written as ease + glass settings other than frost, springs other than Gentle (written as ease out), set-variable, set-variable-mode and conditional actions, scroll-to offsets, text decoration looks, variable font axes, text on a path, nested list levels, list spacing, hanging punctuation, leading trim, OpenType features, per-layer operations inside boolean groups, different stroke ends @@ -196,6 +196,7 @@ scales and empty-style clears; they have not been checked in other software. | Date | Change | Summary | |---|---|---| +| 2026-11-12 | minor | M6, #2297: the `.fig` exporter writes an image paint's adjustments as `paintFilter` (seven fields: exposure, contrast, vibrance from saturation, temperature, tint, highlights, shadows; the tint's sign is flipped, as the importer reads it), and no longer warns about them; the importer already read them. Not checked in other software | | 2026-11-10 | minor | M4, #2222: a boolean group's corner radius and smoothing are read and written by the `.fig` importer and exporter, and by the REST importer | | 2026-11-07 | patch | Fonts, #2092: a font loaded with `text.loadFont` is the counterpart of a font uploaded to the organization, which Figma's help center ("Manage conflicting fonts") ranks first, ahead of installed fonts and the web fonts. FigCraft chose the first face added for a family and style, so the built-in Inter 4.x kept Regular, SemiBold and Bold after Inter 3.19 was loaded and only Medium refitted. A loaded face now wins over the other faces of its family and style, the latest load over earlier ones; style matching and fallbacks are unchanged, and `refitted` lists the text whose size changes. Installed versus built-in order is not changed here. Test: `fontdb::tests::a_loaded_face_wins_over_the_built_in_one_of_its_family_and_style`. Numbers unchanged. | | 2026-11-08 | minor | M6, #2097 follow-up: per-point vector corner radii take the scale of the row supplying `vectorData`, including nested instance rows; override and derived rows are not scaled twice. Network caching distinguishes the instance scale even when resizing gives two vectors the same final box. Synthetic tests cover missing/unit factors, half/double scale, derived size alone, overridden and derived vector data, nested scale and equal-size cache separation. Layer-radius fallback remains the separate #2115 change. Numbers unchanged. | From 501df234997fabf2340944cb6e3ca03c25e3b446 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Thu, 12 Nov 2026 07:33:54 -0500 Subject: [PATCH 4/7] M6: the .fig export writes sanitized image adjustments (#2297) A document can hold image adjustments outside -1..=1 or not a number (a saved file, or a fills property); the renderer and the importer clamp them, but the export wrote the raw values for other readers. The export now writes the sanitized values, and a paint whose adjustments are all neutral after sanitizing writes no `paintFilter`. The round-trip test pins both cases and that all seven fields are written on a partly neutral paint. Co-Authored-By: Claude Sonnet 5.5 Model-Effort: Opus 5.5 drove; Fable 5.2 briefed; Sonnet 5.5 wrote at medium --- crates/format/src/fig/export/paint.rs | 4 ++-- crates/format/src/fig/image_filter_tests.rs | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/crates/format/src/fig/export/paint.rs b/crates/format/src/fig/export/paint.rs index 4d87871f6..bec9a72c8 100644 --- a/crates/format/src/fig/export/paint.rs +++ b/crates/format/src/fig/export/paint.rs @@ -76,8 +76,8 @@ impl<'d> Exporter<'d> { if let (ImageScaleMode::Crop, Some(c)) = (img.scale_mode, img.crop) { f.push(("transform", matrix(Affine::new(c)))); } - if !img.filters.is_identity() { - let x = &img.filters; + let x = img.filters.sanitized(); + if !x.is_identity() { // The file's tint is positive towards magenta, ours towards green; `0.0 -` keeps zero positive. f.push(( "paintFilter", diff --git a/crates/format/src/fig/image_filter_tests.rs b/crates/format/src/fig/image_filter_tests.rs index d1297293f..8923a4d7d 100644 --- a/crates/format/src/fig/image_filter_tests.rs +++ b/crates/format/src/fig/image_filter_tests.rs @@ -110,12 +110,24 @@ fn warnings_naming_unknown_filter_fields_are_capped() { #[test] fn image_adjustments_survive_a_fig_export() { - let (doc, _) = import(&image_filter_fixture(), "ImageFilters.fig").unwrap(); + let (mut doc, _) = import(&image_filter_fixture(), "ImageFilters.fig").unwrap(); let filters_of = |doc: &figcraft_doc::Document, name: &str| { let node = doc.nodes().find(|node| node.name == name).unwrap(); let figcraft_doc::color::PaintKind::Image(image) = &node.fills[0].kind else { panic!("{name} is not an image fill") }; image.filters }; + // Values a document can hold and the file can't: out of range, and not a number. + let ids: Vec = doc.ids().collect(); + for id in ids { + let Some(node) = doc.node_mut(id) else { continue }; + let name = node.name.clone(); + let Some(figcraft_doc::color::PaintKind::Image(image)) = node.fills.first_mut().map(|p| &mut p.kind) else { continue }; + match name.as_str() { + "Legacy" => image.filters.exposure = 5.0, + "Explicit neutral" => image.filters.contrast = f32::NAN, + _ => {} + } + } let (bytes, warnings) = export::export(&doc, None).unwrap(); assert!(!warnings.iter().any(|w| w.contains("image adjustments")), "{warnings:?}"); let (back, _) = import(&bytes, "Back.fig").unwrap(); @@ -150,6 +162,13 @@ fn image_adjustments_survive_a_fig_export() { assert!((written(¤t, "tint").unwrap() - 1.0).abs() < 1e-6); assert!((written(¤t, "shadows").unwrap() - 0.7).abs() < 1e-6); assert!(fill_of("Neutral").get("paintFilter").is_none()); + assert!((written(&fill_of("Legacy"), "exposure").unwrap() - 1.0).abs() < 1e-6, "written within the file's range"); + assert!(fill_of("Explicit neutral").get("paintFilter").is_none(), "not a number is no adjustment"); + let partly = fill_of("Negative tint"); + for field in ["exposure", "contrast", "vibrance", "temperature", "tint", "highlights", "shadows"] { + assert!(written(&partly, field).is_some(), "{field} is written"); + } + assert!((written(&partly, "tint").unwrap() + 1.0).abs() < 1e-6); // The numbers the format uses. let s = Schema::parse(export::SCHEMA).unwrap(); From 9467d2355bb56b229922c3399d4a4b7f00d6ff5f Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Thu, 12 Nov 2026 13:54:12 -0500 Subject: [PATCH 5/7] M10: CSS code export writes several fills as one layered background, top first, as Figma does (#2271) inspect.code wrote one `background` per visible fill, so only the last survived. A non-text layer now gets one `background` with every visible fill as a layer, top fill first (a document's fills run bottom to top), joined with ", ". A solid above another fill is `linear-gradient(0deg, c, c)` since CSS allows a plain colour only as the last layer; the bottom solid stays a plain colour (and keeps its variable token); gradients, images and patterns keep their layers. A single fill is unchanged. Text keeps one `color` per fill. Tailwind emits a layered value as one `[background:...]` class. Native targets are unchanged. Tests: several_fills_are_one_layered_background_top_first, one_solid_fill_stays_a_plain_colour, several_fills_are_one_layered_background_class. Co-Authored-By: Claude Sonnet 5.5 Model-Effort: Opus 5.5 drove; Fable 5.2 queued; Opus 5.5 briefed; Sonnet 5.5 measured and wrote at medium --- crates/engine/src/dev/codegen.rs | 38 +++++++++++++++++++++ crates/engine/src/dev/codegen/css.rs | 51 ++++++++++++++++++++++------ crates/engine/src/dev/tailwind.rs | 19 +++++++++++ crates/engine/src/tailwind_tests.rs | 16 +++++++++ docs/dev-mode-parity.md | 5 +-- 5 files changed, 117 insertions(+), 12 deletions(-) diff --git a/crates/engine/src/dev/codegen.rs b/crates/engine/src/dev/codegen.rs index 202f7ef0f..bbb0415de 100644 --- a/crates/engine/src/dev/codegen.rs +++ b/crates/engine/src/dev/codegen.rs @@ -506,6 +506,44 @@ mod tests { assert!(!css.contains("#000000 0%"), "{css}"); } + /// The measured frame: white at the bottom, a 20% gradient above it, 50% black on top. + fn layered_frame(s: &mut Session) -> figcraft_doc::NodeId { + let f = id_of(&s.execute("frame.create", &json!({"x": 0, "y": 0, "width": 200, "height": 120})).unwrap()["id"]).unwrap(); + let mut g = figcraft_color::Paint::gradient(figcraft_color::Gradient::default_for(figcraft_color::GradientKind::Linear, Color::BLACK)); + g.opacity = 0.2; + let mut top = figcraft_color::Paint::solid(Color::BLACK); + top.opacity = 0.5; + s.doc_mut().unwrap().get_mut(f).unwrap().fills = vec![figcraft_color::Paint::solid(Color::WHITE), g, top]; + f + } + + #[test] + fn several_fills_are_one_layered_background_top_first() { + let mut s = Session::new(); + let f = layered_frame(&mut s); + let css = code_for(s.doc().unwrap(), f, CodeLang::Css); + let bg: Vec<&str> = css.lines().filter(|l| l.starts_with("background:")).collect(); + assert_eq!(bg.len(), 1, "{css}"); + let v = bg[0]; + assert!( + v.starts_with( + "background: linear-gradient(0deg, rgba(0, 0, 0, 0.50), rgba(0, 0, 0, 0.50)), linear-gradient(180deg, rgba(0, 0, 0, 0.20) 0%, " + ), + "{v}" + ); + assert!(v.ends_with(", #FFFFFF;"), "{v}"); + } + + #[test] + fn one_solid_fill_stays_a_plain_colour() { + let mut s = Session::new(); + let f = id_of(&s.execute("frame.create", &json!({"x": 0, "y": 0, "width": 200, "height": 100})).unwrap()["id"]).unwrap(); + s.doc_mut().unwrap().get_mut(f).unwrap().fills = vec![figcraft_color::Paint::solid(Color::WHITE)]; + let css = code_for(s.doc().unwrap(), f, CodeLang::Css); + assert!(css.contains("background: #FFFFFF;\n"), "{css}"); + assert!(!css.contains("gradient"), "{css}"); + } + #[test] fn swiftui_and_compose_for_an_auto_layout_card() { let mut s = Session::new(); diff --git a/crates/engine/src/dev/codegen/css.rs b/crates/engine/src/dev/codegen/css.rs index 46f579123..a5e6726a3 100644 --- a/crates/engine/src/dev/codegen/css.rs +++ b/crates/engine/src/dev/codegen/css.rs @@ -160,17 +160,48 @@ pub(crate) fn css_decls(doc: &Document, n: &Node, t: &mut Tokens, hug: (bool, bo put("transform", format!("rotate({}deg)", num(-rot))); put("transform-origin", "top left".into()); } - for (i, p) in n.fills.iter().enumerate().filter(|(_, p)| p.visible) { - match &p.kind { - PaintKind::Solid { color } => { - let key = if matches!(n.kind, NodeKind::Text(_)) { "color" } else { "background" }; - let c = color.with_alpha(color.a * p.opacity).to_css(); - // A variable binds the first paint's colour. - put(key, if i == 0 { tok(doc, n, &["fill"], c, t) } else { c }); + if matches!(n.kind, NodeKind::Text(_)) { + // Text: a solid is the ink (`color`), one per fill, so the last (top) one wins. + for (i, p) in n.fills.iter().enumerate().filter(|(_, p)| p.visible) { + match &p.kind { + PaintKind::Solid { color } => { + let c = color.with_alpha(color.a * p.opacity).to_css(); + // A variable binds the first paint's colour. + put("color", if i == 0 { tok(doc, n, &["fill"], c, t) } else { c }); + } + PaintKind::Gradient(g) => put("background", css_gradient(g, n.width, n.height, p.opacity)), + PaintKind::Image(_) => put("background", "url(image.png) center / cover".into()), + PaintKind::Pattern(_) => put("background", "url(pattern.png) repeat".into()), } - PaintKind::Gradient(g) => put("background", css_gradient(g, n.width, n.height, p.opacity)), - PaintKind::Image(_) => put("background", "url(image.png) center / cover".into()), - PaintKind::Pattern(_) => put("background", "url(pattern.png) repeat".into()), + } + } else { + // One `background` with every visible fill as a layer, top first (a document's fills run + // bottom to top, as the renderer paints them). CSS allows a plain colour only as the last + // layer, so a solid above another fill becomes a one-colour gradient. + let visible: Vec<(usize, &figcraft_color::Paint)> = n.fills.iter().enumerate().filter(|(_, p)| p.visible).collect(); + let layers: Vec = visible + .iter() + .enumerate() + .rev() + .map(|(pos, (i, p))| match &p.kind { + PaintKind::Solid { color } => { + let c = color.with_alpha(color.a * p.opacity).to_css(); + if pos > 0 { + format!("linear-gradient(0deg, {c}, {c})") + } else if *i == 0 { + // A variable binds the first paint's colour. + tok(doc, n, &["fill"], c, t) + } else { + c + } + } + PaintKind::Gradient(g) => css_gradient(g, n.width, n.height, p.opacity), + PaintKind::Image(_) => "url(image.png) center / cover".into(), + PaintKind::Pattern(_) => "url(pattern.png) repeat".into(), + }) + .collect(); + if !layers.is_empty() { + put("background", layers.join(", ")); } } for (key, value) in css_borders(doc, n, t) { diff --git a/crates/engine/src/dev/tailwind.rs b/crates/engine/src/dev/tailwind.rs index a29c0f316..049122787 100644 --- a/crates/engine/src/dev/tailwind.rs +++ b/crates/engine/src/dev/tailwind.rs @@ -105,6 +105,23 @@ fn arb(v: &str) -> String { format!("[{}]", v.trim().replace('_', "\\_").replace(' ', "_")) } +/// Whether `v` has a comma outside any parentheses (a multi-layer `background`). +fn layered(v: &str) -> bool { + let mut depth = 0usize; + v.chars().any(|c| match c { + '(' => { + depth += 1; + false + } + ')' => { + depth = depth.saturating_sub(1); + false + } + ',' => depth == 0, + _ => false, + }) +} + /// The custom property a `var(--name, fallback)` value reads, when that one call is the whole /// value (not `var(--a, 4px) 8px`, four corners of which only the first is a variable). fn var_name(v: &str) -> Option<&str> { @@ -270,6 +287,8 @@ fn decl(key: &str, value: &str) -> Vec<(String, String)> { Ok(o) if ((o * 100.0).round() - o * 100.0).abs() < 1e-9 => one(format!("opacity-{}", num(o * 100.0))), _ => one(util("opacity", "", v, "")), }, + // Several fills are one layered `background`: commas between the layers, outside any call. + ("background", v) if layered(v) => one(format!("[background:{}]", arb(v).trim_matches(['[', ']']))), ("background", v) if v.contains("gradient(") => one(format!("bg-{}", arb(v))), // An image shorthand (`url(…) center / cover`) is a whole `background`, not a bg colour. ("background", v) if v.starts_with("url(") => one(format!("[background:{}]", arb(v).trim_matches(['[', ']']))), diff --git a/crates/engine/src/tailwind_tests.rs b/crates/engine/src/tailwind_tests.rs index 163e3580c..97e891e6b 100644 --- a/crates/engine/src/tailwind_tests.rs +++ b/crates/engine/src/tailwind_tests.rs @@ -353,3 +353,19 @@ fn font_family_with_quote_and_bracket_stays_a_valid_class_token() { assert!(after.starts_with('>') && !attr.contains('\\'), "{out}"); assert!(!inner.is_empty() && !inner.contains(['\\', '"', ']']), "{out}"); } + +#[test] +fn several_fills_are_one_layered_background_class() { + let mut s = Session::new(); + let f = idv(&ex(&mut s, "frame.create", json!({"x": 0, "y": 0, "width": 200, "height": 120}))); + let mut g = + figcraft_color::Paint::gradient(figcraft_color::Gradient::default_for(figcraft_color::GradientKind::Linear, figcraft_color::Color::BLACK)); + g.opacity = 0.2; + let mut top = figcraft_color::Paint::solid(figcraft_color::Color::BLACK); + top.opacity = 0.5; + s.doc_mut().unwrap().get_mut(f).unwrap().fills = vec![figcraft_color::Paint::solid(figcraft_color::Color::WHITE), g, top]; + let out = code(&mut s, f, json!({})); + let class = out.split(['"', ' ']).find(|c| c.starts_with("[background:")).unwrap_or_default(); + assert!(class.starts_with("[background:linear-gradient(0deg,_rgba(0,_0,_0,_0.50),_rgba(0,_0,_0,_0.50)),_linear-gradient(180deg"), "{out}"); + assert!(class.ends_with(",_#FFFFFF]"), "{out}"); +} diff --git a/docs/dev-mode-parity.md b/docs/dev-mode-parity.md index 66ef3a0ae..07e618495 100644 --- a/docs/dev-mode-parity.md +++ b/docs/dev-mode-parity.md @@ -1,6 +1,6 @@ # Dev Mode parity -> **Last reviewed:** 2026-10-24 · **Last updated:** 2026-11-09 · **Change:** patch (the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the Inspect tab then opens (never toggles away) with the caret in that layer's new-note field, and the engine never writes the note itself (#1840); the handoff mode reads Developer Mode in the interface, its ids and saved fields unchanged; class names transliterate non-ASCII layer names (#1235); measurements kept on the canvas; a read-only layers panel in Dev Mode; earlier: import lines in generated layer trees; compare with any saved version; Dev Mode behaviour suite: an inspect-only canvas, Changed in the ready list, statuses only on frames and sections; plugin panels from the Inspect tab) · **Target:** Figma Design Dev Mode (desktop app 126.10.7) +> **Last reviewed:** 2026-10-24 · **Last updated:** 2026-11-12 · **Change:** patch (CSS code export writes several fills as one layered `background`, top first, as the incumbent does (#2271): a solid above another fill becomes a one-colour gradient, the bottom solid stays a plain colour, Tailwind gets one `[background:...]` class; the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the Inspect tab then opens (never toggles away) with the caret in that layer's new-note field, and the engine never writes the note itself (#1840); the handoff mode reads Developer Mode in the interface, its ids and saved fields unchanged; class names transliterate non-ASCII layer names (#1235); measurements kept on the canvas; a read-only layers panel in Dev Mode; earlier: import lines in generated layer trees; compare with any saved version; Dev Mode behaviour suite: an inspect-only canvas, Changed in the ready list, statuses only on frames and sections; plugin panels from the Inspect tab) · **Target:** Figma Design Dev Mode (desktop app 126.10.7) **Breadth ~98%, ready ~78% (estimated).** The inspect surface is broad, components connect to the code components of a repository (with their imports, also inside generated layer trees), @@ -13,7 +13,7 @@ repository, third-party integrations. Remaining: 1–2 h. | 2026-11-07 | patch | Naming: the handoff mode is called Developer Mode in the interface, its shortcut row, its toasts, the control channel's refusal, the board refusal, the measurement parameter doc, the `.fig` export note, the CLI help and every catalog (24 languages, translations awaiting native review), since Figma holds a US registration for Dev Mode (7574348); command ids (`view.devMode`, `devMode.*`), preference keys and saved-document fields are unchanged, and the Actions palette still finds the command by the old name | | Dev Mode toggle (Shift+D), Inspect panel | done | the canvas only inspects: presses select, pan and comment but never move, resize, draw or edit text and vectors; menus and shortcuts refuse design edits with a note (Dev Mode's annotations, statuses, dev resources, measurements, code connections and comments still work); a drawing tool chosen in the toolbar goes back to the design. The layers panel only selects and expands (no renaming, reordering, hiding or locking; a double click says why), and the Pages list only opens pages (no adding, renaming, reordering, duplicating or deleting). Files dropped on the canvas aren't imported (a dropped document still opens as a file of its own), and the Assets panel places, swaps and applies nothing, doesn't change Hide when publishing, and doesn't accept library updates or add, remove or swap libraries; each says why | | Properties with their styles and variables; redlines on hover | done | positions from the frame around the layer (groups aren't frames), rotation, radius (CSS corner order), opacity, blend; colours in hex, RGB, CSS, HSL or HSB (`inspect.properties {colorFormat}`, the Inspect tab's Color format) | -| Code: CSS, iOS (SwiftUI), Android (Compose), Flutter | done | plus HTML, React, Vue and Leptos (ours; Leptos: `#[component]` functions with `#[prop]` defaults, variant enums and `view!` markup; Flutter is ours too: a `StatelessWidget` for a component, a widget tree for a layer); components take properties as parameters, instances are calls; CSS in px or rem (`inspect.code {unit, rootFontSize}`), with rotation, blend modes, gradient directions and kinds (linear, radial, conic), text alignment, case and decoration; class names from layer names transliterate non-ASCII scripts into readable ASCII (로그인 화면 → `rogeuin-hwamyeon`, кнопка → `knopka`, über → `uber`; symbols-only names take the node's kind, `.text`), and the 40-character cut lands on a word boundary (#1235) | +| Code: CSS, iOS (SwiftUI), Android (Compose), Flutter | done | plus HTML, React, Vue and Leptos (ours; Leptos: `#[component]` functions with `#[prop]` defaults, variant enums and `view!` markup; Flutter is ours too: a `StatelessWidget` for a component, a widget tree for a layer); components take properties as parameters, instances are calls; CSS in px or rem (`inspect.code {unit, rootFontSize}`), with rotation, blend modes, several fills as one layered `background` (top first), gradient directions and kinds (linear, radial, conic), text alignment, case and decoration; class names from layer names transliterate non-ASCII scripts into readable ASCII (로그인 화면 → `rogeuin-hwamyeon`, кнопка → `knopka`, über → `uber`; symbols-only names take the node's kind, `.text`), and the 40-character cut lands on a word boundary (#1235) | | Assets list with export | done | layers with export settings, icons (small, vector shapes only: SVG) and images (PNG); the icon rule is ours | | Annotations: pinned properties, categories, coloured callouts, filter | done | the Annotation tool (Shift+T, `tool.annotation`) picks a layer by a click or from the selection and opens its note field in the Inspect tab. Figma's placement, cursor and whether the tool stays selected are unmeasured (Developer Mode is paywalled in the web app); staying selected until V or Escape, like the Comment tool, is inferred, and there is no toolbar button or icon yet | | Ready for dev list, statuses, "Changed" after edits | done | the list filters Ready for dev, Changed, Completed or any, and badges changed ones (`inspect.readyForDev {status: changed}`, `changed` per item); only sections and frames at the top of a page or section take a status (others are refused) | @@ -29,6 +29,7 @@ repository, third-party integrations. Remaining: 1–2 h. | Date | Change | Summary | |---|---|---| +| 2026-11-12 | patch | CSS code export (#2271): a layer with several fills wrote one `background` per fill, so only the last survived. It now writes one `background` with every visible fill as a layer, top fill first, comma-separated: a solid above another fill is `linear-gradient(0deg, c, c)` (CSS allows a plain colour only as the last layer), the bottom solid stays a plain colour (with its variable), images and patterns keep their `url(...)` layers. Tailwind output carries the layered value as one `[background:...]` class. Text keeps one `color` per fill. Native targets unchanged. Percentages and hours unchanged | | 2026-11-09 | patch | The Annotation tool (Shift+T, `tool.annotation {id?}`): selects the layer pressed on (or the selection, or `id`) and asks the UI for its note, which the Inspect tab takes in its new-note field; the engine writes nothing itself, and Developer Mode lets the tool through its gates (#1840). Figma's placement, cursor and whether the tool stays selected are unmeasured (Developer Mode is paywalled in the web app); staying selected until V or Escape, like the Comment tool, is inferred, and there is no toolbar button or icon yet | | 2026-10-30 | minor | Gap 16: `figcraft-cli connect publish [--mappings figcraft.connect.json] [--dry-run]` publishes a code repository's mappings to a design file (as the incumbent's Code Connect CLI publishes a repository's mappings): it links each entry's component or set by name, warns about and skips links that don't fit, saves the file in place through the engine's save (or not, with `--dry-run`) and fails when nothing links. Dev Mode breadth (~98%) and ready (~78%) unchanged at this rounding; hours unchanged | | 2026-10-26 | minor | Class names from layer names transliterate non-ASCII scripts (#1235): `class_name` runs names through `deunicode` (new dependency: pure Rust tables, zero deps, BSD-3-Clause), so Korean, Cyrillic, Latin-diacritic and CJK names become readable ASCII classes in HTML/CSS/React/Leptos output, component roots and `data-*` variant attributes (`rogeuin-hwamyeon`, `knopka`, `uber`, `an-niu`; before, every one of them came out `layer-`); symbols-only names take the node's kind (`.text`, `.frame`) instead of `layer-`, and the 40-character cut lands on a word boundary. ASCII-only names are unchanged. `html_codegen_tests` updated (its diacritics expectation improves from `layer-1-n-code-name` to `layer-1-unicode-name`) and extended. Percentages and hours unchanged | From 02199134b7c3e10ae665de94fb0ca77c0e751487 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Thu, 12 Nov 2026 17:38:44 -0500 Subject: [PATCH 6/7] M10: Flutter code writes no spacing beside a space distribution flutter_line skipped `spacing:` when the main-axis alignment string contained "Space", but the strings are MainAxisAlignment.spaceBetween, spaceAround and spaceEvenly (lower-case s), so it never matched and the gap was written on top of the distribution. It now checks the MainAlign value itself. Co-Authored-By: Claude Opus 5.5 Model-Effort: Opus 5.5 drove and wrote; Fable 5.2 spotted it --- crates/engine/src/dev/codegen.rs | 21 +++++++++++++++++++++ crates/engine/src/dev/codegen/flutter.rs | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/dev/codegen.rs b/crates/engine/src/dev/codegen.rs index 202f7ef0f..8d448a334 100644 --- a/crates/engine/src/dev/codegen.rs +++ b/crates/engine/src/dev/codegen.rs @@ -675,6 +675,27 @@ mod tests { assert!(!dart.lines().any(|l| l.trim_start().starts_with("void main()")), "a name never leaves its comment: {dart}"); } + #[test] + fn flutter_writes_no_spacing_for_the_space_distributions() { + // The space distributions spread the children themselves; a `spacing:` beside them would + // add the gap on top. + let mut s = Session::new(); + let row = id_of(&s.execute("frame.create", &json!({"x": 0, "y": 0, "width": 300, "height": 40})).unwrap()["id"]).unwrap(); + s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 50, "height": 20, "parent": row})).unwrap(); + s.execute("shape.rectangle", &json!({"x": 60, "y": 0, "width": 50, "height": 20, "parent": row})).unwrap(); + s.execute("layout.add", &json!({"ids": [row], "direction": "horizontal"})).unwrap(); + for (align, flutter) in [("spaceBetween", "spaceBetween"), ("spaceAround", "spaceAround"), ("spaceEvenly", "spaceEvenly")] { + s.execute("node.set", &json!({"id": row, "props": {"gap": 10, "mainAlign": align}})).unwrap(); + let dart = code_for(s.doc().unwrap(), row, CodeLang::Flutter); + assert!(dart.contains(&format!("mainAxisAlignment: MainAxisAlignment.{flutter},")), "{dart}"); + assert!(!dart.contains("spacing:"), "{align} spreads the children itself: {dart}"); + } + // A packed line keeps its gap. + s.execute("node.set", &json!({"id": row, "props": {"gap": 10, "mainAlign": "center"}})).unwrap(); + let dart = code_for(s.doc().unwrap(), row, CodeLang::Flutter); + assert!(dart.contains("spacing: 10,"), "{dart}"); + } + #[test] fn flutter_expands_and_stretches_fill_children() { let mut s = Session::new(); diff --git a/crates/engine/src/dev/codegen/flutter.rs b/crates/engine/src/dev/codegen/flutter.rs index 98f280eaf..7a144a147 100644 --- a/crates/engine/src/dev/codegen/flutter.rs +++ b/crates/engine/src/dev/codegen/flutter.rs @@ -335,7 +335,7 @@ fn flutter_line(ctx: &Ctx, l: &AutoLayout, flow: &[Placed], slot: Option<&Param> out.push_str(&format!("{inner}textBaseline: TextBaseline.alphabetic,\n")); } // The gap between the children; the space distributions already spread them. - if l.gap > 0.0 && flutter_main_align(l.main_align).is_none_or(|m| !m.contains("Space")) { + if l.gap > 0.0 && !matches!(l.main_align, MainAlign::SpaceBetween | MainAlign::SpaceAround | MainAlign::SpaceEvenly) { out.push_str(&format!("{inner}spacing: {},\n", num(l.gap))); } out.push_str(&format!("{inner}children: [\n")); From e0e57dd42a65bc2d42874e3cb459075806225a08 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Fri, 13 Nov 2026 00:45:11 -0500 Subject: [PATCH 7/7] M12: a mind map in a section or frame without a place is centred on the view board.mindMap's default x and y came from the view's centre, which is on the page, but x and y are the root's place in its parent: under a section at (1000, 500) the map landed 1000 right and 500 down of the view's centre. The default now takes the centre through the parent's inverse world transform (a parent that can't be inverted gives a non-finite centre, which the coordinate check refuses). Explicit x and y stay parent-local. Tests: two in board_mindmap_tests (a section; a frame turned 30 degrees, with a given place carried through the frame). Co-Authored-By: Claude Sonnet 5.5 Model-Effort: Opus 5.5 drove; Opus 5.5 briefed; Sonnet 5.5 wrote at medium --- crates/engine/src/board_mindmap_tests.rs | 38 +++++++++++++++++++++++ crates/engine/src/boards/board/mindmap.rs | 8 +++-- docs/mcp.md | 2 +- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/board_mindmap_tests.rs b/crates/engine/src/board_mindmap_tests.rs index 19bb459ae..fa717b8eb 100644 --- a/crates/engine/src/board_mindmap_tests.rs +++ b/crates/engine/src/board_mindmap_tests.rs @@ -383,3 +383,41 @@ fn the_caps_refuse_what_is_too_far_and_cut_what_is_too_long() { assert_eq!(text_data(&s, id(&out, "id")).characters.chars().count(), 500); assert_eq!(text_data(&s, id(&out["children"][0], "id")).characters.chars().count(), 500); } + +/// Where a node's own origin (the place `x`/`y` name) is on the page. +fn origin(s: &Session, n: NodeId) -> Point { + s.doc().unwrap().world_transform(n) * Point::new(0.0, 0.0) +} + +#[test] +fn a_mind_map_in_a_section_without_a_place_is_centred_on_the_view() { + let mut s = board(); + let (vx, vy) = { + let v = &s.ds().unwrap().view; + (v.cx, v.cy) + }; + let sec = id(&s.execute("node.create", &json!({"type": "section", "x": 1000, "y": 500, "width": 4000, "height": 4000})).unwrap(), "id"); + let out = s.execute("board.mindMap", &json!({"parent": sec})).unwrap(); + let c = origin(&s, id(&out, "id")); + assert!(same(c.x, vx) && same(c.y, vy), "the root's place {c:?} is the view's centre ({vx}, {vy})"); +} + +#[test] +fn a_mind_map_in_a_turned_frame_without_a_place_is_centred_on_the_view_and_a_given_place_is_the_frames() { + let mut s = board(); + let (vx, vy) = { + let v = &s.ds().unwrap().view; + (v.cx, v.cy) + }; + let fr = id(&s.execute("node.create", &json!({"type": "frame", "x": 300, "y": 200, "width": 2000, "height": 2000})).unwrap(), "id"); + s.execute("node.set", &json!({"id": fr, "props": {"rotation": 30}})).unwrap(); + let out = s.execute("board.mindMap", &json!({"parent": fr})).unwrap(); + let c = origin(&s, id(&out, "id")); + assert!(same(c.x, vx) && same(c.y, vy), "the root's place {c:?} is the view's centre ({vx}, {vy})"); + + // A given place is the frame's own, as on the page: (10, 20) of the frame, carried through it. + let given = id(&s.execute("board.mindMap", &json!({"parent": fr, "x": 10, "y": 20})).unwrap(), "id"); + let want = s.doc().unwrap().world_transform(fr) * Point::new(10.0, 20.0); + let got = origin(&s, given); + assert!(same(got.x, want.x) && same(got.y, want.y), "{got:?} against {want:?}"); +} diff --git a/crates/engine/src/boards/board/mindmap.rs b/crates/engine/src/boards/board/mindmap.rs index 5e2cff1ce..656a3fa14 100644 --- a/crates/engine/src/boards/board/mindmap.rs +++ b/crates/engine/src/boards/board/mindmap.rs @@ -168,9 +168,13 @@ pub(super) fn mind_map_cmd(s: &mut Session, p: &Value) -> Result { let cmd = "board.mindMap"; require(s, cmd)?; let parent = parent_of(cmd, s, p)?; + // The view's centre is on the page, and `x`/`y` are in the parent: a map in a section or frame + // takes the centre in that parent's coordinates (a parent that can't be inverted gives a + // non-finite centre, which `coord` refuses). let (vx, vy) = { - let v = &s.ds()?.view; - (v.cx, v.cy) + let ds = s.ds()?; + let c = ds.doc.world_transform(parent).inverse() * figcraft_geom::Point::new(ds.view.cx, ds.view.cy); + (c.x, c.y) }; let (x, y) = (coord(cmd, p, "x", vx)?, coord(cmd, p, "y", vy)?); let texts = starters(cmd, p)?; diff --git a/docs/mcp.md b/docs/mcp.md index 21dfe8ca9..8d03540ba 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -498,7 +498,7 @@ one undo step and returns the ids it made: in the app does both). - `board.mindMap {x?, y?, text?, children?, parent?, edit?}` → `{id, text, children: [{id, text, connector}]}`: a mind map: a first node (`mindNode`, bold 24, no box; `text` defaults to `Topic`, `x`/`y` to the - middle of the view) with up to 20 `children` (texts; default `Idea 1`, `Idea 2`, `Idea 3`) + view's centre, in the parent's coordinates) with up to 20 `children` (texts; default `Idea 1`, `Idea 2`, `Idea 3`) on its right, each joined to it by a curved branch (a connector with `branch: true`: stroke 4, `#757575`, round caps). The map lays itself out: children stand in one column 88 units right of the widest node of their parent's column, 48 apart, centred on their parent; a node is its text,