mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-26 04:58:50 +00:00
M8: points align and distribute in vector edit mode, as in Figma
In vector edit mode, align.* and distribute.* act on the selected points instead of moving the whole vector. The Design panel shows the alignment row, and the existing shortcuts apply to those points. Closes #2109.
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
//! the transform box around several points (in one layer or several) in [`transform`], point snapping in `point_snap.rs` and
|
||||
//! hovering, hatching and selecting filled regions in [`regions`].
|
||||
|
||||
#[cfg(test)]
|
||||
mod align_tests;
|
||||
pub mod ops;
|
||||
pub(crate) mod point_snap;
|
||||
mod pointer;
|
||||
|
||||
@@ -0,0 +1,261 @@
|
||||
//! Align and distribute the selected points in vector edit mode.
|
||||
|
||||
use serde_json::json;
|
||||
|
||||
use super::tests::{ex, net, pt, ve};
|
||||
use super::*;
|
||||
|
||||
/// The measured path: points at (330, 480), (480, 430), (560, 560), (380, 620), in edit mode.
|
||||
fn path(s: &mut Session) -> NodeId {
|
||||
let r = ex(s, "vector.create", json!({"points": [[330, 480], [480, 430], [560, 560], [380, 620]], "closed": false}));
|
||||
let id = crate::params::id_of(&r["id"]).unwrap();
|
||||
ex(s, "vector.edit.begin", json!({"id": id}));
|
||||
id
|
||||
}
|
||||
|
||||
fn page(s: &Session, id: NodeId) -> Vec<Point> {
|
||||
let w = s.doc().unwrap().world_transform(id);
|
||||
net(s, id).vertices.iter().map(|v| w * v.point()).collect()
|
||||
}
|
||||
|
||||
fn page_of(s: &Session, id: NodeId, p: Point) -> Point {
|
||||
s.doc().unwrap().world_transform(id) * p
|
||||
}
|
||||
|
||||
fn select(s: &mut Session, v: &[usize]) {
|
||||
ex(s, "vector.edit.select", json!({"vertices": v}));
|
||||
}
|
||||
|
||||
fn near(a: Point, b: Point) -> bool {
|
||||
(a - b).hypot() < 1e-6
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn each_alignment_moves_the_points_along_one_axis_to_their_box() {
|
||||
// Points 0 and 1: box x 330..480, y 430..480.
|
||||
let cases = [
|
||||
("align.left", [pt(330.0, 480.0), pt(330.0, 430.0)]),
|
||||
("align.hcenter", [pt(405.0, 480.0), pt(405.0, 430.0)]),
|
||||
("align.right", [pt(480.0, 480.0), pt(480.0, 430.0)]),
|
||||
("align.top", [pt(330.0, 430.0), pt(480.0, 430.0)]),
|
||||
("align.vcenter", [pt(330.0, 455.0), pt(480.0, 455.0)]),
|
||||
("align.bottom", [pt(330.0, 480.0), pt(480.0, 480.0)]),
|
||||
];
|
||||
for (cmd, want) in cases {
|
||||
let mut s = Session::new();
|
||||
let id = path(&mut s);
|
||||
let before = page(&s, id);
|
||||
select(&mut s, &[0, 1]);
|
||||
ex(&mut s, cmd, json!({}));
|
||||
let after = page(&s, id);
|
||||
assert!(near(after[0], want[0]) && near(after[1], want[1]), "{cmd}: {after:?}");
|
||||
assert!(near(after[2], before[2]) && near(after[3], before[3]), "{cmd} left the others");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn one_point_does_not_move() {
|
||||
let mut s = Session::new();
|
||||
let id = path(&mut s);
|
||||
let before = page(&s, id);
|
||||
select(&mut s, &[1]);
|
||||
for c in ["align.left", "align.bottom", "distribute.horizontal"] {
|
||||
ex(&mut s, c, json!({}));
|
||||
}
|
||||
assert_eq!(page(&s, id), before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn two_points_do_not_distribute() {
|
||||
let mut s = Session::new();
|
||||
let id = path(&mut s);
|
||||
let before = page(&s, id);
|
||||
select(&mut s, &[0, 1]);
|
||||
for c in ["distribute.horizontal", "distribute.vertical"] {
|
||||
ex(&mut s, c, json!({}));
|
||||
}
|
||||
assert_eq!(page(&s, id), before);
|
||||
}
|
||||
|
||||
/// A vector inside a frame at (100, 100), its left (150) well inside the frame.
|
||||
fn framed(s: &mut Session) -> (NodeId, NodeId) {
|
||||
let f = crate::params::id_of(&ex(s, "frame.create", json!({"x": 100, "y": 100, "width": 400, "height": 400}))["id"]).unwrap();
|
||||
let r = ex(s, "vector.create", json!({"points": [[50, 100], [150, 50], [200, 200]], "closed": false, "parent": f}));
|
||||
(f, crate::params::id_of(&r["id"]).unwrap())
|
||||
}
|
||||
|
||||
const ALIGNS: [&str; 6] = ["align.left", "align.hcenter", "align.right", "align.top", "align.vcenter", "align.bottom"];
|
||||
|
||||
#[test]
|
||||
fn no_points_selected_moves_nothing_and_not_the_layer() {
|
||||
let mut s = Session::new();
|
||||
let (frame, v) = framed(&mut s);
|
||||
ex(&mut s, "vector.edit.begin", json!({"id": v}));
|
||||
ex(&mut s, "vector.edit.select", json!({"vertices": []}));
|
||||
assert_eq!(transform::edit_point_count(s.doc().unwrap(), &ve(&s)), 0);
|
||||
let (points, bounds, local) = (page(&s, v), s.doc().unwrap().world_bounds(v), net(&s, v).vertices);
|
||||
assert!(bounds.unwrap().x0 > s.doc().unwrap().world_bounds(frame).unwrap().x0 + 10.0, "starts well inside the frame");
|
||||
for c in ALIGNS.into_iter().chain(["distribute.horizontal", "distribute.vertical"]) {
|
||||
ex(&mut s, c, json!({}));
|
||||
assert_eq!(page(&s, v), points, "{c}");
|
||||
assert_eq!(s.doc().unwrap().world_bounds(v), bounds, "{c} moved the layer");
|
||||
assert_eq!(net(&s, v).vertices, local, "{c}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn points_of_several_layers_align_and_one_undo_restores_all() {
|
||||
let mut s = Session::new();
|
||||
let mut line = |p: serde_json::Value| crate::params::id_of(&ex(&mut s, "vector.create", json!({"points": p, "closed": false}))["id"]).unwrap();
|
||||
let (a, b) = (line(json!([[0, 100], [100, 150]])), line(json!([[300, 40], [400, 90]])));
|
||||
ex(&mut s, "vector.edit.begin", json!({"ids": [a, b]}));
|
||||
ex(&mut s, "vector.edit.select", json!({"id": a, "vertices": [0]}));
|
||||
ex(&mut s, "vector.edit.select", json!({"id": b, "vertices": [1], "add": true}));
|
||||
let (pa, pb) = (page(&s, a), page(&s, b));
|
||||
ex(&mut s, "align.top", json!({}));
|
||||
let (na, nb) = (page(&s, a), page(&s, b));
|
||||
let top = pa[0].y.min(pb[1].y);
|
||||
assert!(near(na[0], pt(pa[0].x, top)) && near(nb[1], pt(pb[1].x, top)), "{na:?} {nb:?}");
|
||||
assert!(near(na[1], pa[1]) && near(nb[0], pb[0]), "unselected points stay");
|
||||
s.undo().unwrap();
|
||||
let (ua, ub) = (page(&s, a), page(&s, b));
|
||||
assert!(pa.iter().zip(&ua).chain(pb.iter().zip(&ub)).all(|(x, y)| near(*x, *y)), "{ua:?} {ub:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_rotated_layer_aligns_in_the_boxs_own_frame() {
|
||||
let mut s = Session::new();
|
||||
let id = path(&mut s);
|
||||
ex(&mut s, "node.set", json!({"id": id, "props": {"rotation": 30}}));
|
||||
select(&mut s, &[0, 1]);
|
||||
let b = transform::point_box(s.doc().unwrap(), &ve(&s)).unwrap();
|
||||
let inv = b.frame.inverse();
|
||||
let before: Vec<Point> = page(&s, id).iter().map(|p| inv * *p).collect();
|
||||
assert!((before[0].x - before[1].x).abs() > 1.0, "the points differ in box x");
|
||||
ex(&mut s, "align.left", json!({}));
|
||||
let after: Vec<Point> = page(&s, id).iter().map(|p| inv * *p).collect();
|
||||
for i in 0..2 {
|
||||
assert!(after[i].x.abs() < 1e-6, "box x is the box's left: {after:?}");
|
||||
assert!((after[i].y - before[i].y).abs() < 1e-6, "box y unchanged: {after:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn id_in_edit_mode_moves_the_layer_not_the_points() {
|
||||
let mut s = Session::new();
|
||||
let (frame, v) = framed(&mut s);
|
||||
ex(&mut s, "vector.edit.begin", json!({"id": v}));
|
||||
select(&mut s, &[0, 1]);
|
||||
let local = net(&s, v).vertices;
|
||||
ex(&mut s, "align.left", json!({"id": v}));
|
||||
let d = s.doc().unwrap();
|
||||
assert!((d.world_bounds(v).unwrap().x0 - d.world_bounds(frame).unwrap().x0).abs() < 1e-6, "layer at the frame's left");
|
||||
assert_eq!(net(&s, v).vertices, local, "points were not aligned to each other");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ids_distribute_layers_and_leave_the_edited_layers_points() {
|
||||
let mut s = Session::new();
|
||||
let mut rect = |x: f64| crate::params::id_of(&ex(&mut s, "shape.rectangle", json!({"x": x, "y": 0, "width": 50, "height": 50}))["id"]).unwrap();
|
||||
let (r1, r2, r3) = (rect(0.0), rect(60.0), rect(400.0));
|
||||
ex(&mut s, "vector.edit.begin", json!({"id": r2}));
|
||||
select(&mut s, &[0, 1]);
|
||||
let local = net(&s, r2).vertices;
|
||||
ex(&mut s, "distribute.horizontal", json!({"ids": [r1, r2, r3]}));
|
||||
let x0 = s.doc().unwrap().world_bounds(r2).unwrap().x0;
|
||||
assert!((x0 - 200.0).abs() < 1e-6, "middle layer centred between the outer two: {x0}");
|
||||
assert_eq!(net(&s, r2).vertices, local);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn distribute_spaces_the_points_evenly_between_the_outermost() {
|
||||
let mut s = Session::new();
|
||||
let id = path(&mut s);
|
||||
select(&mut s, &[0, 1, 2, 3]);
|
||||
ex(&mut s, "distribute.horizontal", json!({}));
|
||||
let p = page(&s, id);
|
||||
let want_x = [330.0, 483.0 + 1.0 / 3.0, 560.0, 380.0 + 80.0 / 3.0];
|
||||
for (q, x) in p.iter().zip(want_x) {
|
||||
assert!((q.x - x).abs() < 1e-6, "{p:?}");
|
||||
}
|
||||
let want_y = [480.0, 430.0, 560.0, 620.0];
|
||||
assert!(p.iter().zip(want_y).all(|(q, y)| (q.y - y).abs() < 1e-6), "y unchanged: {p:?}");
|
||||
|
||||
ex(&mut s, "distribute.vertical", json!({}));
|
||||
let p = page(&s, id);
|
||||
// y sorted 430, 480, 560, 620 spread over 430..620.
|
||||
let step = 190.0 / 3.0;
|
||||
let want_y = [430.0 + step, 430.0, 430.0 + 2.0 * step, 620.0];
|
||||
assert!(p.iter().zip(want_y).all(|(q, y)| (q.y - y).abs() < 1e-6), "{p:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_curved_points_handles_move_with_it() {
|
||||
let mut s = Session::new();
|
||||
let r = ex(&mut s, "vector.create", json!({"path": "M 0 0 C 0 50 50 100 100 100 L 200 0", "x": 0, "y": 0}));
|
||||
let id = crate::params::id_of(&r["id"]).unwrap();
|
||||
ex(&mut s, "vector.edit.begin", json!({"id": id}));
|
||||
let before = net(&s, id);
|
||||
let page_before = page(&s, id);
|
||||
let handle = |s: &Session, n: &VectorNetwork, v: usize, t: (f64, f64)| page_of(s, id, n.vertices[v].point() + Vec2::new(t.0, t.1));
|
||||
let (h1_before, h0_before) = (handle(&s, &before, 1, before.segments[0].tb), handle(&s, &before, 0, before.segments[0].ta));
|
||||
select(&mut s, &[0, 1]);
|
||||
ex(&mut s, "align.left", json!({}));
|
||||
let after = net(&s, id);
|
||||
let moved: Vec<usize> = (0..2).filter(|i| !near(page(&s, id)[*i], page_before[*i])).collect();
|
||||
assert!(!moved.is_empty(), "something moved");
|
||||
let p = page(&s, id);
|
||||
assert!(near(p[0], pt(0.0, 0.0)) && near(p[1], pt(0.0, 100.0)), "{p:?}");
|
||||
assert!(near(p[2], page_before[2]), "vertex 2 stays");
|
||||
// Handles: vertex 1's incoming one (vertex + segment 0's `tb`) moves with it by (-100, 0).
|
||||
let a0 = &after.segments[0];
|
||||
assert!(near(h1_before, pt(50.0, 100.0)) && near(handle(&s, &after, 1, a0.tb), pt(-50.0, 100.0)), "vertex 1's handle moved by (-100, 0)");
|
||||
assert!(near(h0_before, handle(&s, &after, 0, a0.ta)), "vertex 0's handle stays");
|
||||
assert_eq!(before.segments.len(), after.segments.len());
|
||||
for (a, b) in before.segments.iter().zip(&after.segments) {
|
||||
assert_eq!((a.ta, a.tb), (b.ta, b.tb), "handle offsets travel with their vertex");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn one_undo_restores_the_points() {
|
||||
let mut s = Session::new();
|
||||
let id = path(&mut s);
|
||||
let before = page(&s, id);
|
||||
select(&mut s, &[0, 1, 2, 3]);
|
||||
ex(&mut s, "align.right", json!({}));
|
||||
assert_ne!(page(&s, id), before);
|
||||
s.undo().unwrap();
|
||||
let after = page(&s, id);
|
||||
assert!(before.iter().zip(&after).all(|(a, b)| near(*a, *b)), "{after:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ids_in_edit_mode_still_align_layers() {
|
||||
let mut s = Session::new();
|
||||
let mut square = |x: f64| crate::params::id_of(&ex(&mut s, "shape.rectangle", json!({"x": x, "y": 0, "width": 50, "height": 50}))["id"]).unwrap();
|
||||
let (a, b) = (square(0.0), square(200.0));
|
||||
ex(&mut s, "vector.edit.begin", json!({"id": a}));
|
||||
select(&mut s, &[0, 1]);
|
||||
let local = net(&s, a).vertices;
|
||||
ex(&mut s, "align.left", json!({"ids": [a, b]}));
|
||||
let x = |id| s.doc().unwrap().world_bounds(id).unwrap().x0;
|
||||
assert!((x(a) - x(b)).abs() < 1e-6, "layers aligned");
|
||||
assert_eq!(net(&s, a).vertices, local, "the selected points kept their local positions");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_segment_selected_in_another_edited_layer_counts_both_its_ends() {
|
||||
// `a`'s segment (two ends) and `b`'s first point: three points, so the panel offers
|
||||
// Distribute and the command spaces all three.
|
||||
let mut s = Session::new();
|
||||
let mut line = |p: serde_json::Value| crate::params::id_of(&ex(&mut s, "vector.create", json!({"points": p, "closed": false}))["id"]).unwrap();
|
||||
let (a, b) = (line(json!([[0, 0], [100, 50]])), line(json!([[300, 200], [400, 260]])));
|
||||
ex(&mut s, "vector.edit.begin", json!({"ids": [a, b]}));
|
||||
ex(&mut s, "vector.edit.select", json!({"id": a, "segments": [0]}));
|
||||
ex(&mut s, "vector.edit.select", json!({"id": b, "vertices": [0], "add": true}));
|
||||
assert_eq!(transform::edit_point_count(s.doc().unwrap(), &ve(&s)), 3);
|
||||
ex(&mut s, "distribute.horizontal", json!({}));
|
||||
let xs: Vec<f64> = page(&s, a).iter().chain(page(&s, b).first()).map(|p| p.x).collect();
|
||||
assert!(xs.iter().zip([0.0, 150.0, 300.0]).all(|(x, w)| (x - w).abs() < 1e-6), "{xs:?}");
|
||||
}
|
||||
@@ -172,6 +172,126 @@ pub fn transform_in_edit_mode(s: &mut Session, p: &Value, f: impl FnOnce(&PointB
|
||||
Some(s.doc_mut().and_then(|doc| transform_points(doc, ve.id, &b.points, m)).map(|()| json!({"ok": true})))
|
||||
}
|
||||
|
||||
/// Which edge or centre line of the selected points' box each point goes to.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub enum PointAlign {
|
||||
Left,
|
||||
HCenter,
|
||||
Right,
|
||||
Top,
|
||||
VCenter,
|
||||
Bottom,
|
||||
}
|
||||
|
||||
/// Every selected point of `b` in every layer as (layer, vertex, page position).
|
||||
fn page_points(doc: &Document, b: &PointBox, id: NodeId) -> Vec<(NodeId, usize, Point)> {
|
||||
let layers = std::iter::once((id, &b.points)).chain(b.others.iter().map(|(o, v)| (*o, v)));
|
||||
layers
|
||||
.flat_map(|(l, verts)| {
|
||||
let w = doc.world_transform(l);
|
||||
let net = network(doc, l);
|
||||
verts.iter().filter_map(move |v| net.and_then(|n| n.vertices.get(*v)).map(|vx| (l, *v, w * vx.point()))).collect::<Vec<_>>()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The box to align or distribute in: all edited layers' points when several are selected.
|
||||
fn edit_box(doc: &Document, ve: &VectorEdit) -> Option<PointBox> {
|
||||
let b = if ve.others_selected() { layers_box(doc, ve) } else { point_box(doc, ve) };
|
||||
b.filter(|b| b.point_count() > 0)
|
||||
}
|
||||
|
||||
/// How many points align and distribute act on: the selected points and selected segments' ends
|
||||
/// of every edited layer.
|
||||
pub fn edit_point_count(doc: &Document, ve: &VectorEdit) -> usize {
|
||||
edit_box(doc, ve).map_or(0, |b| b.point_count())
|
||||
}
|
||||
|
||||
/// Move each point by its own page delta, one vertex at a time (handles go with their vertex).
|
||||
fn move_each(doc: &mut Document, moves: &[(NodeId, usize, Point)]) -> Result<()> {
|
||||
for (l, v, d) in moves {
|
||||
if d.x.is_finite() && d.y.is_finite() && (d.x != 0.0 || d.y != 0.0) {
|
||||
transform_points(doc, *l, &[*v], Affine::translate((d.x, d.y)))?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The page delta of moving by `(dx, dy)` along the box's axes.
|
||||
fn along(frame: Affine, dx: f64, dy: f64) -> Point {
|
||||
let [a, b, c, d, _, _] = frame.as_coeffs();
|
||||
Point::new(a * dx + c * dy, b * dx + d * dy)
|
||||
}
|
||||
|
||||
/// Align the selected points to their box's edge or centre line (`None` when edit mode is off or
|
||||
/// the command names layers; with no points selected in edit mode nothing moves, and the edited
|
||||
/// layer is not aligned to its parent). Each point moves along one axis of the box only; fewer than
|
||||
/// two points stay put.
|
||||
pub fn align_points_in_edit_mode(s: &mut Session, p: &Value, how: PointAlign) -> Option<Result<Value>> {
|
||||
if get(p, "ids").is_some() || get(p, "id").is_some() {
|
||||
return None;
|
||||
}
|
||||
let ve = editing(s).ok()?;
|
||||
let Some(b) = edit_box(s.doc().ok()?, &ve) else {
|
||||
return Some(Ok(json!({"ok": true})));
|
||||
};
|
||||
let pts = page_points(s.doc().ok()?, &b, ve.id);
|
||||
let inv = b.frame.inverse();
|
||||
let moves: Vec<(NodeId, usize, Point)> = if b.point_count() < 2 {
|
||||
vec![]
|
||||
} else {
|
||||
pts.iter()
|
||||
.map(|(l, v, pg)| {
|
||||
let q = inv * *pg;
|
||||
let (dx, dy) = match how {
|
||||
PointAlign::Left => (-q.x, 0.0),
|
||||
PointAlign::HCenter => (b.width / 2.0 - q.x, 0.0),
|
||||
PointAlign::Right => (b.width - q.x, 0.0),
|
||||
PointAlign::Top => (0.0, -q.y),
|
||||
PointAlign::VCenter => (0.0, b.height / 2.0 - q.y),
|
||||
PointAlign::Bottom => (0.0, b.height - q.y),
|
||||
};
|
||||
(*l, *v, along(b.frame, dx, dy))
|
||||
})
|
||||
.collect()
|
||||
};
|
||||
Some(s.doc_mut().and_then(|doc| move_each(doc, &moves)).map(|()| json!({"ok": true})))
|
||||
}
|
||||
|
||||
/// Space the selected points evenly along the box's x (or y) axis between the outermost two, in
|
||||
/// order along it (`None` when edit mode is off or the command names layers; with no points
|
||||
/// selected in edit mode nothing moves). Fewer than three points stay put.
|
||||
pub fn distribute_points_in_edit_mode(s: &mut Session, p: &Value, horizontal: bool) -> Option<Result<Value>> {
|
||||
if get(p, "ids").is_some() || get(p, "id").is_some() {
|
||||
return None;
|
||||
}
|
||||
let ve = editing(s).ok()?;
|
||||
let Some(b) = edit_box(s.doc().ok()?, &ve) else {
|
||||
return Some(Ok(json!({"ok": true})));
|
||||
};
|
||||
let pts = page_points(s.doc().ok()?, &b, ve.id);
|
||||
let inv = b.frame.inverse();
|
||||
let mut items: Vec<(NodeId, usize, Point)> = pts.iter().map(|(l, v, pg)| (*l, *v, inv * *pg)).collect();
|
||||
let axis = |q: &Point| if horizontal { q.x } else { q.y };
|
||||
items.sort_by(|a, c| axis(&a.2).total_cmp(&axis(&c.2)));
|
||||
let n = items.len();
|
||||
let moves: Vec<(NodeId, usize, Point)> = if n < 3 {
|
||||
vec![]
|
||||
} else {
|
||||
let (lo, hi) = (0.0, if horizontal { b.width } else { b.height });
|
||||
items
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(k, (l, v, q))| {
|
||||
let target = lo + (hi - lo) * k as f64 / (n - 1) as f64;
|
||||
let d = target - axis(q);
|
||||
(*l, *v, if horizontal { along(b.frame, d, 0.0) } else { along(b.frame, 0.0, d) })
|
||||
})
|
||||
.collect()
|
||||
};
|
||||
Some(s.doc_mut().and_then(|doc| move_each(doc, &moves)).map(|()| json!({"ok": true})))
|
||||
}
|
||||
|
||||
/// The selected points' box, or an error naming `cmd`.
|
||||
fn selected_box(s: &Session, cmd: &str) -> Result<(VectorEdit, PointBox)> {
|
||||
let ve = editing(s)?;
|
||||
|
||||
@@ -315,9 +315,23 @@ fn edit_mode_transform_commands_survive_junk() {
|
||||
json!({"width": -1e308, "height": "x", "center": "maybe", "angle": 1e308, "cx": "NaN", "matrix": [1, 2, 3, "a", 5, 6]}),
|
||||
json!({"matrix": [0, 0, 0, 0, 0, 0], "vertices": [1e12, -1], "width": 1e308, "height": 0}),
|
||||
];
|
||||
for c in
|
||||
["object.flipH", "object.flipV", "object.rotate180", "object.rotateLeft", "object.rotateRight", "vector.edit.resize", "vector.edit.rotate"]
|
||||
{
|
||||
for c in [
|
||||
"object.flipH",
|
||||
"object.flipV",
|
||||
"object.rotate180",
|
||||
"object.rotateLeft",
|
||||
"object.rotateRight",
|
||||
"vector.edit.resize",
|
||||
"vector.edit.rotate",
|
||||
"align.left",
|
||||
"align.hcenter",
|
||||
"align.right",
|
||||
"align.top",
|
||||
"align.vcenter",
|
||||
"align.bottom",
|
||||
"distribute.horizontal",
|
||||
"distribute.vertical",
|
||||
] {
|
||||
for j in &junk {
|
||||
let mut s = Session::new();
|
||||
let id = rect(&mut s);
|
||||
|
||||
@@ -11,14 +11,62 @@ use crate::{Result, Session, bad, spec};
|
||||
|
||||
pub fn specs() -> Vec<CommandSpec> {
|
||||
vec![
|
||||
spec!("align.left", "Align left", "{ids?}", true, |s, p| align(s, p, Al::Left)),
|
||||
spec!("align.hcenter", "Align horizontal centers", "{ids?}", true, |s, p| align(s, p, Al::HCenter)),
|
||||
spec!("align.right", "Align right", "{ids?}", true, |s, p| align(s, p, Al::Right)),
|
||||
spec!("align.top", "Align top", "{ids?}", true, |s, p| align(s, p, Al::Top)),
|
||||
spec!("align.vcenter", "Align vertical centers", "{ids?}", true, |s, p| align(s, p, Al::VCenter)),
|
||||
spec!("align.bottom", "Align bottom", "{ids?}", true, |s, p| align(s, p, Al::Bottom)),
|
||||
spec!("distribute.horizontal", "Distribute horizontal spacing", "{ids?, spacing?}", true, |s, p| distribute(s, p, true)),
|
||||
spec!("distribute.vertical", "Distribute vertical spacing", "{ids?, spacing?}", true, |s, p| distribute(s, p, false)),
|
||||
spec!(
|
||||
"align.left",
|
||||
"Align left",
|
||||
"{ids?} (in vector edit mode without ids: the selected points, and nothing moves with none selected)",
|
||||
true,
|
||||
|s, p| align(s, p, Al::Left)
|
||||
),
|
||||
spec!(
|
||||
"align.hcenter",
|
||||
"Align horizontal centers",
|
||||
"{ids?} (in vector edit mode without ids: the selected points, and nothing moves with none selected)",
|
||||
true,
|
||||
|s, p| align(s, p, Al::HCenter)
|
||||
),
|
||||
spec!(
|
||||
"align.right",
|
||||
"Align right",
|
||||
"{ids?} (in vector edit mode without ids: the selected points, and nothing moves with none selected)",
|
||||
true,
|
||||
|s, p| align(s, p, Al::Right)
|
||||
),
|
||||
spec!(
|
||||
"align.top",
|
||||
"Align top",
|
||||
"{ids?} (in vector edit mode without ids: the selected points, and nothing moves with none selected)",
|
||||
true,
|
||||
|s, p| align(s, p, Al::Top)
|
||||
),
|
||||
spec!(
|
||||
"align.vcenter",
|
||||
"Align vertical centers",
|
||||
"{ids?} (in vector edit mode without ids: the selected points, and nothing moves with none selected)",
|
||||
true,
|
||||
|s, p| align(s, p, Al::VCenter)
|
||||
),
|
||||
spec!(
|
||||
"align.bottom",
|
||||
"Align bottom",
|
||||
"{ids?} (in vector edit mode without ids: the selected points, and nothing moves with none selected)",
|
||||
true,
|
||||
|s, p| align(s, p, Al::Bottom)
|
||||
),
|
||||
spec!(
|
||||
"distribute.horizontal",
|
||||
"Distribute horizontal spacing",
|
||||
"{ids?, spacing?} (in vector edit mode without ids: the selected points, and nothing moves with none selected)",
|
||||
true,
|
||||
|s, p| distribute(s, p, true)
|
||||
),
|
||||
spec!(
|
||||
"distribute.vertical",
|
||||
"Distribute vertical spacing",
|
||||
"{ids?, spacing?} (in vector edit mode without ids: the selected points, and nothing moves with none selected)",
|
||||
true,
|
||||
|s, p| distribute(s, p, false)
|
||||
),
|
||||
spec!(
|
||||
"arrange.spacing",
|
||||
"Spacing",
|
||||
@@ -192,6 +240,18 @@ fn align_target(doc: &Document, roots: &[NodeId]) -> Option<Rect> {
|
||||
}
|
||||
|
||||
fn align(s: &mut Session, p: &Value, a: Al) -> Result<Value> {
|
||||
use crate::vectoredit::transform::PointAlign;
|
||||
let how = match a {
|
||||
Al::Left => PointAlign::Left,
|
||||
Al::HCenter => PointAlign::HCenter,
|
||||
Al::Right => PointAlign::Right,
|
||||
Al::Top => PointAlign::Top,
|
||||
Al::VCenter => PointAlign::VCenter,
|
||||
Al::Bottom => PointAlign::Bottom,
|
||||
};
|
||||
if let Some(r) = crate::vectoredit::transform::align_points_in_edit_mode(s, p, how) {
|
||||
return r;
|
||||
}
|
||||
let ids = req_targets("align", s, p)?;
|
||||
let doc = s.doc_mut()?;
|
||||
let ids = roots(doc, &ids);
|
||||
@@ -212,6 +272,9 @@ fn align(s: &mut Session, p: &Value, a: Al) -> Result<Value> {
|
||||
}
|
||||
|
||||
fn distribute(s: &mut Session, p: &Value, horizontal: bool) -> Result<Value> {
|
||||
if let Some(r) = crate::vectoredit::transform::distribute_points_in_edit_mode(s, p, horizontal) {
|
||||
return r;
|
||||
}
|
||||
let ids = req_targets("distribute", s, p)?;
|
||||
let doc = s.doc_mut()?;
|
||||
let ids = roots(doc, &ids);
|
||||
|
||||
@@ -300,6 +300,8 @@ mod variables_window_resize_tests;
|
||||
#[cfg(test)]
|
||||
mod variants_discovery_tests;
|
||||
#[cfg(test)]
|
||||
mod vector_align_tests;
|
||||
#[cfg(test)]
|
||||
mod vector_keys_tests;
|
||||
#[cfg(test)]
|
||||
mod vector_panel_tests;
|
||||
|
||||
@@ -671,7 +671,7 @@ pub(crate) fn tidy_available(ctx: &egui::Context, doc: &Arc<Document>, sel: &[No
|
||||
fn position_fields(app: &mut FigApp, ui: &mut Ui, doc: &Arc<Document>, sel: &[NodeId]) {
|
||||
let pv = position_values(ui.ctx(), doc, sel);
|
||||
let col = widgets::col_width(ui.available_width());
|
||||
align_row(app, ui, sel, pv.can_align, pv.align_blocked, col);
|
||||
align_row(app, ui, AlignTarget::Layers(sel), pv.can_align, pv.align_blocked, col);
|
||||
position_row(app, ui, doc, sel, &pv, col);
|
||||
rotation_row(app, ui, doc, sel, pv.rot, col);
|
||||
if pv.in_frame {
|
||||
@@ -679,9 +679,24 @@ fn position_fields(app: &mut FigApp, ui: &mut Ui, doc: &Arc<Document>, sel: &[No
|
||||
}
|
||||
}
|
||||
|
||||
/// Alignment, and distribution and tidy up for three or more layers.
|
||||
fn align_row(app: &mut FigApp, ui: &mut Ui, sel: &[NodeId], can_align: bool, blocked: bool, col: f32) {
|
||||
let ids = sel.to_vec();
|
||||
/// What the alignment row acts on.
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum AlignTarget<'a> {
|
||||
/// These layers (distribution and tidy up from three).
|
||||
Layers(&'a [NodeId]),
|
||||
/// The selected points in vector edit mode, this many of them (distribution from three, no
|
||||
/// tidy up).
|
||||
Points(usize),
|
||||
}
|
||||
|
||||
/// Alignment, and distribution and tidy up for three or more layers (or the selected points).
|
||||
pub fn align_row(app: &mut FigApp, ui: &mut Ui, target: AlignTarget, can_align: bool, blocked: bool, col: f32) {
|
||||
let (ids, count, points) = match target {
|
||||
AlignTarget::Layers(sel) => (sel.to_vec(), sel.len(), false),
|
||||
AlignTarget::Points(n) => (vec![], n, true),
|
||||
};
|
||||
// Points take the commands with no ids: they act on the selected points.
|
||||
let params = || if points { json!({}) } else { json!({"ids": ids}) };
|
||||
widgets::sublabels(ui, tr("Alignment"), None);
|
||||
row(ui, 32.0, |ui| {
|
||||
let cmds = ["align.left", "align.hcenter", "align.right", "align.top", "align.vcenter", "align.bottom"];
|
||||
@@ -707,24 +722,26 @@ fn align_row(app: &mut FigApp, ui: &mut Ui, sel: &[NodeId], can_align: bool, blo
|
||||
};
|
||||
picked.response.on_disabled_hover_text(why);
|
||||
if let Some(i) = picked.inner {
|
||||
app.run(cmds[i], json!({"ids": ids}));
|
||||
app.run(cmds[i], params());
|
||||
}
|
||||
if sel.len() > 2 {
|
||||
if count > 2 {
|
||||
let more = icons::button(ui, Icon::DistributeH, 24.0, false, tr("Distribute and tidy"));
|
||||
menu_popup(&more).show(|ui| {
|
||||
let can_tidy = app.session.ds().is_ok_and(|ds| tidy_available(ui.ctx(), &ds.doc, &ids));
|
||||
for (l, c, on) in [
|
||||
let can_tidy = !points && app.session.ds().is_ok_and(|ds| tidy_available(ui.ctx(), &ds.doc, &ids));
|
||||
let tidy = (tr("Tidy up"), "arrange.tidy", can_tidy);
|
||||
let entries = [
|
||||
(tr("Distribute horizontal spacing"), "distribute.horizontal", true),
|
||||
(tr("Distribute vertical spacing"), "distribute.vertical", true),
|
||||
(tr("Tidy up"), "arrange.tidy", can_tidy),
|
||||
] {
|
||||
];
|
||||
// Points have no tidy up.
|
||||
for (l, c, on) in entries.into_iter().chain((!points).then_some(tidy)) {
|
||||
let item = ui.add_enabled_ui(on, |ui| menu_item(ui, l, crate::shortcuts::shortcut(c).unwrap_or("")));
|
||||
if !on {
|
||||
item.response
|
||||
.on_disabled_hover_text(tr("Select a row, a column or a full grid of three or more layers, outside an auto layout flow"));
|
||||
}
|
||||
if item.inner {
|
||||
app.run(c, json!({"ids": ids}));
|
||||
app.run(c, params());
|
||||
ui.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,12 +99,19 @@ pub fn points(app: &mut FigApp, ui: &mut Ui, doc: &Document, ve: &VectorEdit) {
|
||||
let Some(net) = vectoredit::network(doc, ve.id) else { return };
|
||||
let pts = vectoredit::selected_points(net, ve);
|
||||
widgets::section_header(ui, if pts.len() > 1 { tr("Points") } else { tr("Point") }, &[], false);
|
||||
let col = widgets::col_width(ui.available_width());
|
||||
// Figma puts alignment first; one point is a no-op there too. The count is the engine's, so
|
||||
// selected segments' ends in any edited layer count as the commands do: the row shows even
|
||||
// when only another edited layer has points selected.
|
||||
let count = vectoredit::transform::edit_point_count(doc, ve);
|
||||
if count > 0 {
|
||||
crate::right::align_row(app, ui, crate::right::AlignTarget::Points(count), true, false, col);
|
||||
}
|
||||
if pts.is_empty() {
|
||||
let t = crate::theme::Tokens::get(ui.ctx());
|
||||
widgets::note(ui, tr("Select points to edit their position, radius and mirroring"), t.text_secondary);
|
||||
return;
|
||||
}
|
||||
let col = widgets::col_width(ui.available_width());
|
||||
let round = |v: f64| (v * 100.0).round() / 100.0;
|
||||
let parent_pts = vectoredit::selected_parent_points(doc, ve);
|
||||
// The value the selected points share (within 1e-6), or none: Mixed.
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
//! Align and distribute the selected points in vector edit mode: the Design panel's alignment row
|
||||
//! and the Alt+letter keys act on the points.
|
||||
|
||||
use egui::accesskit::Node;
|
||||
use egui::{Event, Key, Modifiers, Pos2};
|
||||
use figcraft_doc::NodeId;
|
||||
use figcraft_engine::Session;
|
||||
use serde_json::json;
|
||||
|
||||
use crate::layers_drag_tests::Ui;
|
||||
|
||||
/// A four-point open path in edit mode, the first two points selected.
|
||||
fn two_selected() -> (Ui, NodeId) {
|
||||
let mut s = Session::new();
|
||||
let r = s.execute("vector.create", &json!({"points": [[330, 480], [480, 430], [560, 560], [380, 620]], "closed": false})).unwrap();
|
||||
let path = NodeId(r["id"].as_u64().unwrap());
|
||||
s.execute("vector.edit.begin", &json!({"id": path})).unwrap();
|
||||
s.execute("vector.edit.select", &json!({"vertices": [0, 1]})).unwrap();
|
||||
let mut u = Ui::new(s);
|
||||
u.frame(vec![]);
|
||||
(u, path)
|
||||
}
|
||||
|
||||
/// Page x of every point of `path`.
|
||||
fn xs(u: &Ui, path: NodeId) -> Vec<f64> {
|
||||
let doc = u.app.session.doc().unwrap();
|
||||
let w = doc.world_transform(path);
|
||||
figcraft_engine::vectoredit::network(doc, path).unwrap().vertices.iter().map(|v| (w * v.point()).x).collect()
|
||||
}
|
||||
|
||||
fn tree(u: &mut Ui) -> Vec<Node> {
|
||||
u.ctx.enable_accesskit();
|
||||
u.frame(vec![]);
|
||||
let out = u.frame_output(vec![]);
|
||||
out.platform_output.accesskit_update.expect("an AccessKit update").nodes.into_iter().map(|(_, n)| n).collect()
|
||||
}
|
||||
|
||||
fn button<'a>(nodes: &'a [Node], label: &str) -> Option<&'a Node> {
|
||||
nodes.iter().find(|n| n.label().is_some_and(|l| l.starts_with(label)))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_alignment_row_shows_for_points_and_align_left_moves_them() {
|
||||
let (mut u, path) = two_selected();
|
||||
let nodes = tree(&mut u);
|
||||
let left = button(&nodes, "Align left").expect("the alignment row shows in edit mode with points selected");
|
||||
assert!(!left.is_disabled(), "enabled whenever points are selected");
|
||||
assert!(button(&nodes, "Distribute and tidy").is_none(), "two points have nothing to distribute");
|
||||
let b = left.bounds().expect("bounds");
|
||||
let p = Pos2::new(((b.x0 + b.x1) / 2.0) as f32, ((b.y0 + b.y1) / 2.0) as f32);
|
||||
u.button(p, true);
|
||||
u.button(p, false);
|
||||
u.frame(vec![]);
|
||||
let x = xs(&u, path);
|
||||
assert!((x[0] - 330.0).abs() < 1e-6 && (x[1] - 330.0).abs() < 1e-6, "{x:?}");
|
||||
assert!((x[2] - 560.0).abs() < 1e-6, "unselected points stay: {x:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_distribute_menu_shows_from_three_points() {
|
||||
let (mut u, _) = two_selected();
|
||||
u.app.session.execute("vector.edit.select", &json!({"vertices": [0, 1, 2]})).unwrap();
|
||||
let nodes = tree(&mut u);
|
||||
assert!(button(&nodes, "Distribute and tidy").is_some());
|
||||
}
|
||||
|
||||
/// Two layers edited at once, points selected only in the one that isn't active: the row still
|
||||
/// shows, since the commands act on every edited layer's selected points.
|
||||
#[test]
|
||||
fn the_alignment_row_shows_when_only_another_edited_layer_has_points_selected() {
|
||||
let mut s = Session::new();
|
||||
let mut make =
|
||||
|pts: serde_json::Value| NodeId(s.execute("vector.create", &json!({"points": pts, "closed": false})).unwrap()["id"].as_u64().unwrap());
|
||||
let a = make(json!([[330, 480], [480, 430], [560, 560]]));
|
||||
let b = make(json!([[700, 480], [800, 430], [900, 560]]));
|
||||
s.execute("vector.edit.begin", &json!({"ids": [a, b]})).unwrap();
|
||||
s.execute("vector.edit.select", &json!({"id": a, "vertices": [0, 1, 2]})).unwrap();
|
||||
s.execute("vector.edit.select", &json!({"id": b, "vertices": [], "add": true})).unwrap();
|
||||
let mut u = Ui::new(s);
|
||||
u.frame(vec![]);
|
||||
let nodes = tree(&mut u);
|
||||
assert!(button(&nodes, "Align left").is_some(), "the row shows for the other layer's points");
|
||||
assert!(button(&nodes, "Distribute and tidy").is_some(), "three points there: distribute too");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn alt_d_in_edit_mode_aligns_the_points_right() {
|
||||
let (mut u, path) = two_selected();
|
||||
let m = Modifiers::ALT;
|
||||
u.frame_with(
|
||||
vec![
|
||||
Event::Key { key: Key::D, physical_key: Some(Key::D), pressed: true, repeat: false, modifiers: m },
|
||||
Event::Key { key: Key::D, physical_key: Some(Key::D), pressed: false, repeat: false, modifiers: m },
|
||||
],
|
||||
m,
|
||||
);
|
||||
let x = xs(&u, path);
|
||||
assert!((x[0] - 480.0).abs() < 1e-6 && (x[1] - 480.0).abs() < 1e-6, "{x:?}");
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
# FigCraft parity with Figma
|
||||
|
||||
> **Last reviewed:** 2026-11-15 · **Last updated:** 2026-11-18 · **Change:** minor (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-18 · **Change:** minor (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
|
||||
@@ -255,7 +255,7 @@ Hours in this narrative are the builders' estimates; the tables above supersede
|
||||
smooth interpolation per subpath, dashes, caps and joins, canvas/PNG/SVG/PDF and outline stroke),
|
||||
a transform box around several selected points (corners and edges scale them, Shift keeps
|
||||
proportions, Alt from the centre; just outside a corner rotates, Shift in 15° steps; drag inside
|
||||
to move; the Design panel's X/Y/W/H and flip/rotate act on the points), point snapping while
|
||||
to move; the Design panel's X/Y/W/H, align, distribute and flip/rotate act on the points), point snapping while
|
||||
dragging points or handles and with both pens (to the points and segment midpoints of this and
|
||||
other vectors, the usual layer targets and the pixel grid, with guides and a marker on the point
|
||||
landed on; Ctrl/Cmd turns it off), arc handles on the canvas (sweep, start and ratio with a
|
||||
@@ -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-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-08 | minor | M8, #2109: in vector edit mode the Align commands (`align.left` to `align.bottom`, Alt+A/H/D/W/V/S) and Distribute horizontal and vertical spacing act on the selected points when no `ids` are given, as in Figma (measured in Figma on 2026-11-08): each point moves along one axis only, to its box's left, horizontal centre, right, top, vertical centre or bottom, and distribute spaces the points evenly between the outermost two in order along the axis; handles go with their vertex, a single point stays, with no point selected nothing moves (the layer is not aligned to its frame, as measured in Figma), and one undo restores them. The Design panel draws the alignment row first, with a Distribute menu from three points. Numbers unchanged. |
|
||||
| 2026-11-15 | minor | 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 |
|
||||
| 2026-11-10 | minor | M4, #2222: a boolean group's corner radius rounds every sharp corner of its result (row 4). Numbers unchanged |
|
||||
| 2026-11-08 | minor | M8: measured in Figma on 2026-11-08, vector edit mode's Point section: X and Y show the value the selected points share, or Mixed when they differ, and a typed value sets every selected point's own coordinate in the layer being edited, points of other edited layers left as they are (it moved the group's top-left before); a relative edit (`+10`, `*2`, `/2`) typed into a Mixed field applies to each point's own value (`vector.edit.position` takes a number or `{add}`, `{mul}`, `{div}` per axis); the W and H row and other edited layers' points are unchanged. |
|
||||
|
||||
+3
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user