mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-18 13:33:51 +00:00
Merge pull request #8371 from dotCooCoo/feat/transform-line-properties
Transform: a live line shows Line Properties with Line Length and Line Angle
This commit is contained in:
@@ -179,6 +179,48 @@ impl LiveShape {
|
||||
*xf = Affine::rotate_about((now - angle).to_radians(), centre) * *xf;
|
||||
}
|
||||
}
|
||||
/// A line's length in the document, from its first end to its second. None for other shapes.
|
||||
pub fn line_length(&self) -> Option<f64> {
|
||||
let LiveShape::Line { a, b } = self else { return None };
|
||||
Some((*b - *a).hypot())
|
||||
}
|
||||
/// A line's angle: the counterclockwise degrees in [0, 360) from the page's horizontal to the
|
||||
/// direction from its first end to its second (the Rotate field's sense). 0 for a line whose
|
||||
/// ends meet. None for other shapes.
|
||||
pub fn line_angle(&self) -> Option<f64> {
|
||||
let LiveShape::Line { a, b } = self else { return None };
|
||||
if a == b {
|
||||
return Some(0.0);
|
||||
}
|
||||
// No −0° or 360° from rounding: a line drawn left to right reads 0°.
|
||||
let a = (-self.angle_deg()).rem_euclid(360.0);
|
||||
Some(if a > 360.0 - 1e-9 { 0.0 } else { a + 0.0 })
|
||||
}
|
||||
/// Make a line `len` long (0 or more), keeping its first end in place and its direction, or
|
||||
/// pointing it to the right when its ends meet.
|
||||
pub fn set_line_length(&mut self, len: f64) {
|
||||
let LiveShape::Line { a, b } = self else { return };
|
||||
if !len.is_finite() || len < 0.0 {
|
||||
return;
|
||||
}
|
||||
let now = (*b - *a).hypot();
|
||||
*b = if now > 0.0 { *a + (*b - *a) * (len / now) } else { Point::new(a.x + len, a.y) };
|
||||
}
|
||||
/// Turn a line about its midpoint to `angle` (degrees, as [`LiveShape::line_angle`]). A line
|
||||
/// whose ends meet stays as it is.
|
||||
pub fn set_line_angle(&mut self, angle: f64) {
|
||||
let LiveShape::Line { a, b } = self else { return };
|
||||
let half = (*b - *a).hypot() / 2.0;
|
||||
if !angle.is_finite() || half <= 0.0 {
|
||||
return;
|
||||
}
|
||||
let mid = a.midpoint(*b);
|
||||
let t = angle.to_radians();
|
||||
// The page's y axis points down, so a counterclockwise angle goes up the page.
|
||||
let (dx, dy) = (half * t.cos(), -half * t.sin());
|
||||
*a = Point::new(mid.x - dx, mid.y - dy);
|
||||
*b = Point::new(mid.x + dx, mid.y + dy);
|
||||
}
|
||||
/// Make a polygon's sides equal (Make Sides Equal): drop the uneven scale and the shear from
|
||||
/// `xf`, keeping its centre, angle, reflection and [`LiveShape::polygon_radius`].
|
||||
pub fn make_sides_equal(&mut self) {
|
||||
|
||||
@@ -305,7 +305,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Live Shape Properties",
|
||||
[],
|
||||
None,
|
||||
"{id?, ids?, radius?: pt (or % of each corner's maximum when `relativeRadii` is true), kind?: \"round\"|\"invertedRound\"|\"chamfer\", relativeRadii?: bool (Relative rounding, as in the reference app: store radii as fractions of each corner's maximum so they scale with the shape), corners?: [i…], items?: [{id, corners?: [i…]}] (several objects, each with its own corners, in place of ids and corners: the canvas's corner widgets across a selection), sides?: n, polygonAngle?: degrees (counter-clockwise from its first vertex straight up), polygonRadius?: pt (centre to vertex), sideLength?: pt (sets the radius), makeSidesEqual?: true (a polygon scaled unevenly: drops the uneven scale and shear, keeping its centre, angle and mean radius), pieStart?, pieEnd?: degrees (an ellipse's pie, counter-clockwise from 3 o'clock; 0 to 360 is the whole ellipse), invertPie?: true (swaps them: the other part of the ellipse)} (Live Corners on any path: radius and kind set its corners (anchors that aren't smooth, where two sides, straight or curved (#1144), meet at an angle): `corners` (anchor indices of the path with its corners uncut, counting every subpath's anchors in order: a rectangle's 0 top-left, 1 top-right, 2 bottom-right, 3 bottom-left; a polygon's from the first vertex clockwise), else the corners with a Direct-Selected anchor, else every corner; each radius is drawn no larger than half the corner's shorter side allows; a path that isn't a live shape keeps its uncut outline so its corners stay editable, and is plain again once none is cut; sides: a polygon's, which keep the radius they shared; the polygon params apply in that order: sides, makeSidesEqual, polygonAngle, then sideLength or else polygonRadius)",
|
||||
"{id?, ids?, radius?: pt (or % of each corner's maximum when `relativeRadii` is true), kind?: \"round\"|\"invertedRound\"|\"chamfer\", relativeRadii?: bool (Relative rounding, as in the reference app: store radii as fractions of each corner's maximum so they scale with the shape), corners?: [i…], items?: [{id, corners?: [i…]}] (several objects, each with its own corners, in place of ids and corners: the canvas's corner widgets across a selection), sides?: n, polygonAngle?: degrees (counter-clockwise from its first vertex straight up), polygonRadius?: pt (centre to vertex), sideLength?: pt (sets the radius), makeSidesEqual?: true (a polygon scaled unevenly: drops the uneven scale and shear, keeping its centre, angle and mean radius), pieStart?, pieEnd?: degrees (an ellipse's pie, counter-clockwise from 3 o'clock; 0 to 360 is the whole ellipse), invertPie?: true (swaps them: the other part of the ellipse), lineLength?: pt (a live line's length, above 0; its first end stays), lineAngle?: degrees (a live line's angle, counter-clockwise from 3 o'clock, from its first end to its second; it turns about its midpoint)} (Live Corners on any path: radius and kind set its corners (anchors that aren't smooth, where two sides, straight or curved (#1144), meet at an angle): `corners` (anchor indices of the path with its corners uncut, counting every subpath's anchors in order: a rectangle's 0 top-left, 1 top-right, 2 bottom-right, 3 bottom-left; a polygon's from the first vertex clockwise), else the corners with a Direct-Selected anchor, else every corner; each radius is drawn no larger than half the corner's shorter side allows; a path that isn't a live shape keeps its uncut outline so its corners stay editable, and is plain again once none is cut; sides: a polygon's, which keep the radius they shared; the polygon params apply in that order: sides, makeSidesEqual, polygonAngle, then sideLength or else polygonRadius; a line's lineLength applies before its lineAngle)",
|
||||
has_selection,
|
||||
set_live_shape
|
||||
),
|
||||
|
||||
@@ -6,6 +6,7 @@ use super::{
|
||||
BTreeSet, CornerKind, EngineError, LiveCorners, LiveShape, NodeId, NodeKind, Result, Session, Value, bad, check_numbers, check_switches,
|
||||
convert_radii_relative, ok, selected_roots, set_corners, targets,
|
||||
};
|
||||
use crate::MAX_COORD;
|
||||
|
||||
/// The largest scale of 0 or more at which `spans`, with the margins that scale grown by `k`,
|
||||
/// reach across `size` together. Returns 1 when their geometric boxes reach 1e-9 or less across
|
||||
@@ -98,6 +99,30 @@ fn corners_param(p: &Value) -> Result<Option<BTreeSet<usize>>> {
|
||||
list.iter().map(|k| k.as_u64().and_then(|k| usize::try_from(k).ok()).ok_or_else(err)).collect::<Result<_>>().map(Some)
|
||||
}
|
||||
|
||||
/// Live line `l` with Line Length `len` (its first end stays) and then Line Angle `angle` (about
|
||||
/// its midpoint; a line whose ends meet has none to turn), or None when neither changes it.
|
||||
fn line_edit(l: &LiveShape, len: Option<f64>, angle: Option<f64>) -> Option<LiveShape> {
|
||||
let now = l.line_length()?;
|
||||
let mut new = l.clone();
|
||||
let mut changed = false;
|
||||
if let Some(len) = len
|
||||
&& (len - now).abs() > 1e-9 * len.max(now)
|
||||
{
|
||||
new.set_line_length(len);
|
||||
changed = true;
|
||||
}
|
||||
if let Some(a) = angle
|
||||
&& new.line_length().is_some_and(|n| n > 0.0)
|
||||
&& let Some(turn) = new.line_angle().map(|now| (a - now).rem_euclid(360.0))
|
||||
&& turn > 1e-9
|
||||
&& turn < 360.0 - 1e-9
|
||||
{
|
||||
new.set_line_angle(a);
|
||||
changed = true;
|
||||
}
|
||||
(changed && new != *l).then_some(new)
|
||||
}
|
||||
|
||||
pub(super) fn set_live_shape(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
check_switches(p, &["invertPie", "makeSidesEqual", "relativeRadii"], "object.setLiveShape")?;
|
||||
check_numbers(p, &["radius", "sides"], "object.setLiveShape")?;
|
||||
@@ -148,7 +173,7 @@ pub(super) fn set_live_shape(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
};
|
||||
let angle = |k: &str| Ok::<_, EngineError>(number(k, |_| true, "an angle in degrees")?.map(|a| a.rem_euclid(360.0)));
|
||||
let length = |k: &str| number(k, |x| x > 0.0 && x <= crate::MAX_COORD, "a length in points above 0");
|
||||
let length = |k: &str| number(k, |x| x > 0.0 && x <= MAX_COORD, "a length in points above 0");
|
||||
// Saved steps ([`Session::replay`]) can hold values a direct call refuses, recorded before these
|
||||
// checks: a negative radius is 0, a whole side count of 0 or more is brought into 3 to 1000, and
|
||||
// a fractional or negative one is ignored. A whole number written as 5.0 counts as 5, as in a
|
||||
@@ -171,6 +196,10 @@ pub(super) fn set_live_shape(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
// A polygon's Polygon Properties: its angle, radius or side length, Make Sides Equal.
|
||||
let (polygon_angle, polygon_radius, side) = (angle("polygonAngle")?, length("polygonRadius")?, length("sideLength")?);
|
||||
let equal = p.get("makeSidesEqual").and_then(Value::as_bool) == Some(true);
|
||||
// A line's Line Properties: its length (its first end stays) and its angle (about its midpoint).
|
||||
// A line's length can reach across the whole canvas, past `MAX_COORD`: its ends are checked below.
|
||||
let line_length = number("lineLength", |x| x > 0.0, "a length in points above 0")?;
|
||||
let line_angle = angle("lineAngle")?;
|
||||
// An ellipse's pie becomes `pie_of(pie)`. An end of 0 is a full turn (Illustrator shows a whole
|
||||
// ellipse as 0° to 360°).
|
||||
let end_of = |a: f64| if a == 0.0 { 360.0 } else { a };
|
||||
@@ -181,8 +210,26 @@ pub(super) fn set_live_shape(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
// When every value given is the current one, the document and its undo history stay as they
|
||||
// are.
|
||||
let st = s.doc()?;
|
||||
// The lines that Line Length or Line Angle changes, as they become. A line that would reach
|
||||
// past the document's coordinate limit is an error before anything changes.
|
||||
let mut lines = std::collections::BTreeMap::new();
|
||||
if line_length.is_some() || line_angle.is_some() {
|
||||
for id in &ids {
|
||||
let Some(NodeKind::Path { live: Some(l), .. }) = st.doc.node(*id).map(|n| &n.kind) else { continue };
|
||||
if let Some(new) = line_edit(l, line_length, line_angle) {
|
||||
let LiveShape::Line { a, b } = &new else { continue };
|
||||
if ![a.x, a.y, b.x, b.y].iter().all(|c| c.abs() <= MAX_COORD) {
|
||||
return Err(bad("object.setLiveShape", format!("coordinate out of range (limit ±{MAX_COORD} pt)")));
|
||||
}
|
||||
lines.insert(*id, new);
|
||||
}
|
||||
}
|
||||
}
|
||||
let has_values = |id: &NodeId| {
|
||||
let Some(NodeKind::Path { path, live, .. }) = st.doc.node(*id).map(|n| &n.kind) else { return true };
|
||||
if lines.contains_key(id) {
|
||||
return false;
|
||||
}
|
||||
match live.as_deref() {
|
||||
Some(l @ LiveShape::Polygon { sides: now, .. })
|
||||
if !(sides.is_none_or(|n| n.clamp(3, 1000) == u64::from(*now))
|
||||
@@ -244,6 +291,12 @@ pub(super) fn set_live_shape(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
*path = l.to_path();
|
||||
}
|
||||
if let Some(new) = lines.get(id)
|
||||
&& let Some(l) = live.as_deref_mut()
|
||||
{
|
||||
*l = new.clone();
|
||||
*path = l.to_path();
|
||||
}
|
||||
if let Some(on) = relative_radii
|
||||
&& let Some(l) = live.as_deref_mut()
|
||||
{
|
||||
|
||||
@@ -524,6 +524,107 @@ fn a_polygon_takes_its_angle_radius_side_length_and_equal_sides() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A live line's Line Properties: Line Length keeps its first end in place, Line Angle (degrees
|
||||
/// counterclockwise, any finite value brought into 0 to 360) turns it about its midpoint, the
|
||||
/// length applies before the angle, every selected line takes them in one undo step, and a value
|
||||
/// that changes nothing records none.
|
||||
#[test]
|
||||
fn a_line_takes_its_length_and_angle() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 400, "height": 400})).unwrap();
|
||||
let line = |s: &mut Session, a: (f64, f64), b: (f64, f64)| {
|
||||
NodeId(s.execute("shape.line", &json!({"x1": a.0, "y1": a.1, "x2": b.0, "y2": b.1})).unwrap()["id"].as_u64().unwrap())
|
||||
};
|
||||
let id = line(&mut s, (100.0, 100.0), (200.0, 100.0));
|
||||
let ends = |s: &Session, id: NodeId| match &s.doc().unwrap().doc.node(id).unwrap().kind {
|
||||
NodeKind::Path { live: Some(l), path, .. } => {
|
||||
let LiveShape::Line { a, b } = **l else { panic!("{l:?}") };
|
||||
assert_eq!(*path, l.to_path(), "the path follows the line");
|
||||
(a.x, a.y, b.x, b.y)
|
||||
}
|
||||
k => panic!("{k:?}"),
|
||||
};
|
||||
let near = |got: (f64, f64, f64, f64), want: (f64, f64, f64, f64)| {
|
||||
assert!([got.0 - want.0, got.1 - want.1, got.2 - want.2, got.3 - want.3].iter().all(|d| d.abs() < 1e-9), "{got:?} ≠ {want:?}")
|
||||
};
|
||||
let steps = |s: &Session| s.doc().unwrap().history.undo.len();
|
||||
run(&mut s, json!({"lineLength": 50}));
|
||||
near(ends(&s, id), (100.0, 100.0, 150.0, 100.0));
|
||||
// 90° points up the page.
|
||||
run(&mut s, json!({"lineAngle": 90}));
|
||||
near(ends(&s, id), (125.0, 125.0, 125.0, 75.0));
|
||||
let n = steps(&s);
|
||||
for same in [json!({"lineAngle": 450}), json!({"lineAngle": -270}), json!({"lineLength": 50}), json!({"lineLength": 50, "lineAngle": 90})] {
|
||||
run(&mut s, same.clone());
|
||||
assert_eq!(steps(&s), n, "{same} records no undo step");
|
||||
}
|
||||
near(ends(&s, id), (125.0, 125.0, 125.0, 75.0));
|
||||
run(&mut s, json!({"lineLength": 20, "lineAngle": 0}));
|
||||
near(ends(&s, id), (115.0, 115.0, 135.0, 115.0));
|
||||
assert_eq!(steps(&s), n + 1, "both in one step");
|
||||
run(&mut s, json!({"lineAngle": 180}));
|
||||
near(ends(&s, id), (135.0, 115.0, 115.0, 115.0));
|
||||
run(&mut s, json!({"lineAngle": -90}));
|
||||
near(ends(&s, id), (125.0, 105.0, 125.0, 125.0));
|
||||
let LiveShape::Line { .. } = s.doc().unwrap().doc.node(id).unwrap().live_shape().unwrap() else { panic!("still live") };
|
||||
assert_eq!(s.doc().unwrap().doc.node(id).unwrap().live_shape().unwrap().line_angle(), Some(270.0));
|
||||
// Several lines: each keeps its own first end, in one undo step.
|
||||
let other = line(&mut s, (0.0, 0.0), (0.0, 40.0));
|
||||
let n = steps(&s);
|
||||
run(&mut s, json!({"ids": [id.0, other.0], "lineLength": 10}));
|
||||
near(ends(&s, id), (125.0, 105.0, 125.0, 115.0));
|
||||
near(ends(&s, other), (0.0, 0.0, 0.0, 10.0));
|
||||
assert_eq!(steps(&s), n + 1);
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
near(ends(&s, id), (125.0, 105.0, 125.0, 125.0));
|
||||
near(ends(&s, other), (0.0, 0.0, 0.0, 40.0));
|
||||
// Bad values, and a line that would reach past the coordinate limit, change neither line.
|
||||
let far = line(&mut s, (3_900_000.0, 0.0), (3_900_100.0, 0.0));
|
||||
let n = steps(&s);
|
||||
for bad in [
|
||||
json!({"ids": [id.0], "lineLength": 0}),
|
||||
json!({"ids": [id.0], "lineLength": -3}),
|
||||
json!({"ids": [id.0], "lineLength": "long"}),
|
||||
json!({"ids": [id.0], "lineAngle": "up"}),
|
||||
json!({"ids": [id.0], "lineLength": 1e300}),
|
||||
json!({"ids": [id.0, far.0], "lineLength": 200_000}),
|
||||
] {
|
||||
assert!(s.execute("object.setLiveShape", &bad).is_err(), "{bad}");
|
||||
assert_eq!(steps(&s), n, "{bad}");
|
||||
}
|
||||
near(ends(&s, id), (125.0, 105.0, 125.0, 125.0));
|
||||
near(ends(&s, far), (3_900_000.0, 0.0, 3_900_100.0, 0.0));
|
||||
// A length past the coordinate limit is fine while both ends stay inside it.
|
||||
let wide = line(&mut s, (-3_500_000.0, 0.0), (3_500_000.0, 0.0));
|
||||
run(&mut s, json!({"ids": [wide.0], "lineLength": 6_000_000}));
|
||||
near(ends(&s, wide), (-3_500_000.0, 0.0, 2_500_000.0, 0.0));
|
||||
// A line whose ends meet reads 0°: an angle leaves it as it is, and a length points it right.
|
||||
let dot = line(&mut s, (10.0, 10.0), (10.0, 10.0));
|
||||
assert_eq!(s.doc().unwrap().doc.node(dot).unwrap().live_shape().unwrap().line_angle(), Some(0.0));
|
||||
let n = steps(&s);
|
||||
run(&mut s, json!({"lineAngle": 45}));
|
||||
assert_eq!(steps(&s), n);
|
||||
run(&mut s, json!({"lineLength": 30}));
|
||||
near(ends(&s, dot), (10.0, 10.0, 40.0, 10.0));
|
||||
// A very short length is applied.
|
||||
let speck = line(&mut s, (20.0, 20.0), (20.0, 20.0));
|
||||
let n = steps(&s);
|
||||
run(&mut s, json!({"ids": [speck.0], "lineLength": 1e-12}));
|
||||
assert_eq!(steps(&s), n + 1, "a length of 1e-12 pt is a change");
|
||||
assert!(ends(&s, speck).2 > 20.0, "{:?}", ends(&s, speck));
|
||||
// A length so short that the rounded ends do not move records no undo step.
|
||||
let dust = line(&mut s, (20.0, 20.0), (20.0, 20.0));
|
||||
let n = steps(&s);
|
||||
run(&mut s, json!({"ids": [dust.0], "lineLength": 1e-20}));
|
||||
assert_eq!(steps(&s), n, "a length of 1e-20 pt changes nothing");
|
||||
near(ends(&s, dust), (20.0, 20.0, 20.0, 20.0));
|
||||
// Other live shapes ignore the line params.
|
||||
let rect = NodeId(s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap());
|
||||
let n = steps(&s);
|
||||
run(&mut s, json!({"ids": [rect.0], "lineLength": 30, "lineAngle": 45}));
|
||||
assert_eq!(steps(&s), n);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn relative_corner_rounding_keeps_fraction_on_resize() {
|
||||
let (mut s, id) = session();
|
||||
|
||||
@@ -430,6 +430,7 @@ fn set_live_shape_refuses_an_unknown_key() {
|
||||
json!({"id": 3, "radius": 5}),
|
||||
json!({"ids": [3], "sides": 6, "polygonAngle": 15, "polygonRadius": 20, "sideLength": null, "makeSidesEqual": true}),
|
||||
json!({"pieStart": 30, "pieEnd": 90, "invertPie": true}),
|
||||
json!({"ids": [3], "lineLength": 72, "lineAngle": 90}),
|
||||
json!({"items": null}),
|
||||
] {
|
||||
assert!(check_params(ID, &ok).is_ok(), "{ok}");
|
||||
|
||||
@@ -1273,6 +1273,36 @@ fn polygon_properties_junk() {
|
||||
assert!(failures.is_empty(), "{} failures:\n{}", failures.len(), failures.join("\n"));
|
||||
}
|
||||
|
||||
/// A live line's Line Properties with junk values (the fixtures have no line), on a line, a line
|
||||
/// whose ends meet and one at the coordinate limit: never a panic, and the document stays sound.
|
||||
#[test]
|
||||
fn line_properties_junk() {
|
||||
let mut cases: Vec<Value> = vec![json!({"lineLength": 4.0e6, "lineAngle": 45})];
|
||||
for key in ["lineLength", "lineAngle"] {
|
||||
for v in junk_values() {
|
||||
cases.push(json!({ key: v }));
|
||||
}
|
||||
}
|
||||
let mut failures = vec![];
|
||||
for (a, b) in [((10.0, 20.0), (110.0, 70.0)), ((50.0, 50.0), (50.0, 50.0)), ((-4.0e6, 4.0e6), (4.0e6, -4.0e6))] {
|
||||
for p in &cases {
|
||||
let mut s = Fixture::Multi.session();
|
||||
let Ok(_) = no_panic(s.execute("shape.line", &json!({"x1": a.0, "y1": a.1, "x2": b.0, "y2": b.1}))) else {
|
||||
continue;
|
||||
};
|
||||
match catch_quiet(|| no_panic(s.execute("object.setLiveShape", p))) {
|
||||
Err(m) => failures.push(format!("PANIC object.setLiveShape {p} [{a:?} {b:?}]: {m}")),
|
||||
Ok(_) => {
|
||||
if let Err(e) = catch_quiet(|| check_all(&mut s)).unwrap_or_else(|m| Err(format!("panic in checks: {m}"))) {
|
||||
failures.push(format!("object.setLiveShape {p} [{a:?} {b:?}]: {e}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
assert!(failures.is_empty(), "{} failures:\n{}", failures.len(), failures.join("\n"));
|
||||
}
|
||||
|
||||
/// The params `fuzzed_calls_keep_documents_serializable` sends `c`: each key with each of the
|
||||
/// first junk values, a string under a file or folder key replaced by a location inside `path`'s
|
||||
/// folder.
|
||||
|
||||
@@ -2623,6 +2623,9 @@ font-technology Variable Променливи
|
||||
Polar Grid Tool Инструмент „Полярна мрежа“
|
||||
Polygon Многоъгълник
|
||||
Polygon Properties: Свойства на многоъгълника:
|
||||
Line Properties: Свойства на линията:
|
||||
Line Length: Дължина на линията:
|
||||
Line Angle: Ъгъл на линията:
|
||||
Polygon Tool Инструмент „Многоъгълник“
|
||||
Portrait Портретна
|
||||
Power Saving (integrated) Пестене на енергия (интегрирано)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2363,6 +2363,9 @@ digits Malayalam Malajalam
|
||||
Flip Horizontal Preokreni vodoravno
|
||||
Flip Vertical Preokreni okomito
|
||||
Polygon Properties: Svojstva mnogougla:
|
||||
Line Properties: Svojstva linije:
|
||||
Line Length: Dužina linije:
|
||||
Line Angle: Ugao linije:
|
||||
Rectangle Properties: Svojstva pravougaonika:
|
||||
Shape Properties: Svojstva oblika:
|
||||
Shape Properties Svojstva oblika
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3399,6 +3399,9 @@ digits Malayalam Malaiàlam
|
||||
Polar Grid Tool Options Opcions de l’eina de quadrícula polar
|
||||
Polygon Polígon
|
||||
Polygon Properties: Propietats del polígon:
|
||||
Line Properties: Propietats de la línia:
|
||||
Line Length: Longitud de la línia:
|
||||
Line Angle: Angle de la línia:
|
||||
Polygon Tool Eina de polígon
|
||||
Portrait Vertical
|
||||
Portrait (flipped) Vertical (invertit)
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2434,6 +2434,9 @@ digits Malayalam Malajálamské
|
||||
Flip Horizontal Překlopit vodorovně
|
||||
Flip Vertical Překlopit svisle
|
||||
Polygon Properties: Vlastnosti mnohoúhelníku:
|
||||
Line Properties: Vlastnosti čáry:
|
||||
Line Length: Délka čáry:
|
||||
Line Angle: Úhel čáry:
|
||||
Rectangle Properties: Vlastnosti obdélníku:
|
||||
Shape Properties: Vlastnosti tvaru:
|
||||
Shape Properties Vlastnosti tvaru
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4947,6 +4947,9 @@ digits Malayalam Malayalam
|
||||
Flip Horizontal Spejl vandret
|
||||
Flip Vertical Spejl lodret
|
||||
Polygon Properties: Polygonegenskaber:
|
||||
Line Properties: Linjeegenskaber:
|
||||
Line Length: Linjelængde:
|
||||
Line Angle: Linjevinkel:
|
||||
Rectangle Properties: Rektangelegenskaber:
|
||||
Shape Properties: Figuregenskaber:
|
||||
Shape Properties Figuregenskaber
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2682,6 +2682,9 @@ diagnostics ui Oberfläche
|
||||
Polar Grid Tool Radiales-Raster-Werkzeug
|
||||
Polygon Polygon
|
||||
Polygon Properties: Polygoneigenschaften:
|
||||
Line Properties: Linieneigenschaften:
|
||||
Line Length: Linienlänge:
|
||||
Line Angle: Linienwinkel:
|
||||
Polygon Tool Polygon-Werkzeug
|
||||
Portrait Hochformat
|
||||
Power Saving (integrated) Energiesparen (integriert)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3619,6 +3619,9 @@ theme Appearance Εμφάνιση
|
||||
Polar Grid Tool Πολικό πλέγμα (Polar Grid Tool)
|
||||
Polygon Πολύγωνο
|
||||
Polygon Properties: Ιδιότητες πολυγώνου:
|
||||
Line Properties: Ιδιότητες γραμμής:
|
||||
Line Length: Μήκος γραμμής:
|
||||
Line Angle: Γωνία γραμμής:
|
||||
Power Saving (integrated) Εξοικονόμηση ενέργειας (ενσωματωμένη GPU)
|
||||
Portuguese Πορτογαλικά
|
||||
PostScript: PostScript:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2721,6 +2721,9 @@ font-technology Variable Variables
|
||||
Polar Grid Tool Herramienta Cuadrícula polar
|
||||
Polygon Polígono
|
||||
Polygon Properties: Propiedades del polígono:
|
||||
Line Properties: Propiedades de la línea:
|
||||
Line Length: Longitud de la línea:
|
||||
Line Angle: Ángulo de la línea:
|
||||
Polygon Tool Herramienta Polígono
|
||||
Portrait Vertical
|
||||
Power Saving (integrated) Ahorro de energía (integrada)
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2398,6 +2398,9 @@ digits Malayalam Malajalam
|
||||
Flip Horizontal Käännä vaakasuunnassa
|
||||
Flip Vertical Käännä pystysuunnassa
|
||||
Polygon Properties: Monikulmion ominaisuudet:
|
||||
Line Properties: Viivan ominaisuudet:
|
||||
Line Length: Viivan pituus:
|
||||
Line Angle: Viivan kulma:
|
||||
Rectangle Properties: Suorakulmion ominaisuudet:
|
||||
Shape Properties: Muodon ominaisuudet:
|
||||
Shape Properties Muodon ominaisuudet
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2709,6 +2709,9 @@ font-technology Variable Variables
|
||||
Polar Grid Tool Outil Grille à coordonnées polaires
|
||||
Polygon Polygone
|
||||
Polygon Properties: Propriétés du polygone :
|
||||
Line Properties: Propriétés de la ligne :
|
||||
Line Length: Longueur de la ligne :
|
||||
Line Angle: Angle de la ligne :
|
||||
Polygon Tool Outil Polygone
|
||||
Portrait Portrait
|
||||
Power Saving (integrated) Économie d’énergie (intégrée)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2777,6 +2777,9 @@
|
||||
Polish પોલિશ
|
||||
Polygon બહુકોણ
|
||||
Polygon Properties: બહુકોણના ગુણધર્મો:
|
||||
Line Properties: રેખાના ગુણધર્મો:
|
||||
Line Length: રેખાની લંબાઈ:
|
||||
Line Angle: રેખાનો કોણ:
|
||||
Polygon Tool બહુકોણ ટૂલ
|
||||
Polygonal Lasso બહુકોણીય લાસો
|
||||
Polygonal Lasso Tool બહુકોણીય લાસો ટૂલ
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 72 and column 5.
|
@@ -3732,6 +3732,9 @@ antiAlias Sharp शार्प
|
||||
Polish पोलिश
|
||||
Polygon बहुभुज
|
||||
Polygon Properties: बहुभुज प्रॉपर्टीज़:
|
||||
Line Properties: रेखा प्रॉपर्टीज़:
|
||||
Line Length: रेखा की लंबाई:
|
||||
Line Angle: रेखा का कोण:
|
||||
Polygon Tool पॉलीगोन टूल
|
||||
Polygonal Lasso बहुभुज लैस्सो
|
||||
Polygonal Lasso Tool बहुभुज लैस्सो टूल
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3271,6 +3271,9 @@ diagnostics ui felület
|
||||
Polar Grid Tool Polárrács
|
||||
Polygon Sokszög
|
||||
Polygon Properties: Sokszög tulajdonságai:
|
||||
Line Properties: Vonal tulajdonságai:
|
||||
Line Length: Vonal hossza:
|
||||
Line Angle: Vonal szöge:
|
||||
Polygon Tool Sokszög
|
||||
Portrait Álló
|
||||
Portrait (flipped) Álló (megfordítva)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2186,6 +2186,9 @@ digits Malayalam Malayalam
|
||||
Flip Horizontal Balik horizontal
|
||||
Flip Vertical Balik vertikal
|
||||
Polygon Properties: Properti poligon:
|
||||
Line Properties: Properti garis:
|
||||
Line Length: Panjang garis:
|
||||
Line Angle: Sudut garis:
|
||||
Rectangle Properties: Properti persegi panjang:
|
||||
Shape Properties: Properti bentuk:
|
||||
Shape Properties Properti bentuk
|
||||
|
||||
|
@@ -2766,6 +2766,9 @@ diagnostics ui interfaccia
|
||||
Polar Grid Tool Strumento Griglia polare
|
||||
Polygon Poligono
|
||||
Polygon Properties: Proprietà poligono:
|
||||
Line Properties: Proprietà linea:
|
||||
Line Length: Lunghezza linea:
|
||||
Line Angle: Angolo linea:
|
||||
Polygon Tool Strumento Poligono
|
||||
Portrait Verticale
|
||||
Power Saving (integrated) Risparmio energetico (integrata)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2859,6 +2859,9 @@ diagnostics ui UI
|
||||
Polar Grid Tool 同心円グリッドツール
|
||||
Polygon 多角形
|
||||
Polygon Properties: 多角形のプロパティ:
|
||||
Line Properties: 線のプロパティ:
|
||||
Line Length: 線の長さ:
|
||||
Line Angle: 線の角度:
|
||||
Polygon Tool 多角形ツール
|
||||
Portrait 縦置き
|
||||
Portuguese ポルトガル語
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4353,6 +4353,9 @@ digits Malayalam მალაიალამური
|
||||
Flip Horizontal ჰორიზონტალურად არეკვლა
|
||||
Flip Vertical ვერტიკალურად არეკვლა
|
||||
Polygon Properties: მრავალკუთხედის თვისებები:
|
||||
Line Properties: ხაზის თვისებები:
|
||||
Line Length: ხაზის სიგრძე:
|
||||
Line Angle: ხაზის კუთხე:
|
||||
Rectangle Properties: მართკუთხედის თვისებები:
|
||||
Shape Properties: ფიგურის თვისებები:
|
||||
Shape Properties ფიგურის თვისებები
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2849,6 +2849,9 @@ diagnostics ui UI
|
||||
Polar Grid Tool 극좌표 격자 도구
|
||||
Polygon 다각형
|
||||
Polygon Properties: 다각형 속성:
|
||||
Line Properties: 선 속성:
|
||||
Line Length: 선 길이:
|
||||
Line Angle: 선 각도:
|
||||
Polygon Tool 다각형 도구
|
||||
Portrait 세로
|
||||
Portuguese Português
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2822,6 +2822,9 @@ digits Malayalam Malayalam
|
||||
Flip Horizontal Horizontaal spiegelen
|
||||
Flip Vertical Verticaal spiegelen
|
||||
Polygon Properties: Veelhoekeigenschappen:
|
||||
Line Properties: Lijneigenschappen:
|
||||
Line Length: Lijnlengte:
|
||||
Line Angle: Lijnhoek:
|
||||
Rectangle Properties: Rechthoekeigenschappen:
|
||||
Shape Properties: Vormeigenschappen:
|
||||
Shape Properties Vormeigenschappen
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2353,6 +2353,9 @@ digits Malayalam Malajalam
|
||||
Flip Horizontal Odbij w poziomie
|
||||
Flip Vertical Odbij w pionie
|
||||
Polygon Properties: Właściwości wielokąta:
|
||||
Line Properties: Właściwości linii:
|
||||
Line Length: Długość linii:
|
||||
Line Angle: Kąt linii:
|
||||
Rectangle Properties: Właściwości prostokąta:
|
||||
Shape Properties: Właściwości kształtu:
|
||||
Shape Properties Właściwości kształtu
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2250,6 +2250,9 @@ antiAlias Sharp Nítido
|
||||
Polar Grid Tool Ferramenta Grade Polar
|
||||
Polygon Polígono
|
||||
Polygon Properties: Propriedades do Polígono:
|
||||
Line Properties: Propriedades da Linha:
|
||||
Line Length: Comprimento da Linha:
|
||||
Line Angle: Ângulo da Linha:
|
||||
Polygon Tool Ferramenta Polígono
|
||||
Portrait Retrato
|
||||
Portuguese Português
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2748,6 +2748,9 @@ diagnostics ui интерфейс
|
||||
Polar Grid Tool Инструмент «Полярная сетка»
|
||||
Polygon Многоугольник
|
||||
Polygon Properties: Свойства многоугольника:
|
||||
Line Properties: Свойства линии:
|
||||
Line Length: Длина линии:
|
||||
Line Angle: Угол линии:
|
||||
Polygon Tool Инструмент «Многоугольник»
|
||||
Portrait Книжная
|
||||
Power Saving (integrated) Энергосбережение (встроенная)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2646,6 +2646,9 @@ font-technology Variable Variabla
|
||||
Polar Grid Tool Verktyg för polärt rutnät
|
||||
Polygon Polygon
|
||||
Polygon Properties: Polygonegenskaper:
|
||||
Line Properties: Linjeegenskaper:
|
||||
Line Length: Linjelängd:
|
||||
Line Angle: Linjevinkel:
|
||||
Polygon Tool Polygonverktyg
|
||||
Portrait Stående
|
||||
Power Saving (integrated) Energisparläge (integrerad)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2493,6 +2493,9 @@ shape Open Açık
|
||||
Polar Grid Tool Yuvarlak Izgara Aracı
|
||||
Polygon Çokgen
|
||||
Polygon Properties: Poligon Özellikleri:
|
||||
Line Properties: Çizgi Özellikleri:
|
||||
Line Length: Çizgi Uzunluğu:
|
||||
Line Angle: Çizgi Açısı:
|
||||
Polygon Tool Çokgen Aracı
|
||||
Portrait Portre
|
||||
Power Saving (integrated) Güç Tasarrufu (entegre)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2758,6 +2758,9 @@ diagnostics ui інтерфейс
|
||||
Polar Grid Tool Інструмент «Полярна сітка»
|
||||
Polygon Багатокутник
|
||||
Polygon Properties: Властивості багатокутника:
|
||||
Line Properties: Властивості лінії:
|
||||
Line Length: Довжина лінії:
|
||||
Line Angle: Кут лінії:
|
||||
Polygon Tool Інструмент «Багатокутник»
|
||||
Portrait Книжкова
|
||||
Power Saving (integrated) Енергозбереження (вбудована)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3076,6 +3076,9 @@ diagnostics ui giao diện
|
||||
Polar Grid Tool Công cụ Lưới cực
|
||||
Polygon Đa giác
|
||||
Polygon Properties: Thuộc tính đa giác:
|
||||
Line Properties: Thuộc tính đường thẳng:
|
||||
Line Length: Độ dài đường thẳng:
|
||||
Line Angle: Góc đường thẳng:
|
||||
Polygon Tool Công cụ Đa giác
|
||||
Portrait Đứng
|
||||
Portuguese Tiếng Bồ Đào Nha
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 206 and column 5.
|
@@ -2617,6 +2617,9 @@ diagnostics ui 界面
|
||||
Polar Grid Tool 极坐标网格工具
|
||||
Polygon 多边形
|
||||
Polygon Properties: 多边形属性:
|
||||
Line Properties: 直线属性:
|
||||
Line Length: 直线长度:
|
||||
Line Angle: 直线角度:
|
||||
Polygon Tool 多边形工具
|
||||
Portrait 纵向
|
||||
Portuguese 葡萄牙语
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3939,6 +3939,9 @@ diagnostics ui 介面
|
||||
Polar Grid Tool 極座標格點工具
|
||||
Polygon 多邊形
|
||||
Polygon Properties: 多邊形內容:
|
||||
Line Properties: 直線內容:
|
||||
Line Length: 直線長度:
|
||||
Line Angle: 直線角度:
|
||||
Polygon Tool 多邊形工具
|
||||
Portrait 直向
|
||||
Power Saving (integrated) 節能 (內建顯示晶片)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -422,10 +422,11 @@ fn pixel_aligned_ids(app: &VectorcraftApp) -> Vec<u64> {
|
||||
app.session.active().map(|st| st.selection.objects.iter().filter(|id| st.doc.node(**id).is_some()).map(|id| id.0).collect()).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// A live rectangle's, polygon's or ellipse's properties (Transform and Properties panels, and the
|
||||
/// Contextual Task Bar), their widget ids under `id`. `headed` adds the Rectangle and Polygon
|
||||
/// Properties headings; an ellipse's heading always shows. Returns false, drawing nothing, for
|
||||
/// other live shapes.
|
||||
/// A live rectangle's, polygon's, ellipse's or line's properties (Transform and Properties panels,
|
||||
/// and for the first three the Contextual Task Bar), their widget ids under `id`. `headed` adds
|
||||
/// the Rectangle and Polygon Properties headings; an ellipse's and a line's heading always show.
|
||||
/// Returns false, drawing nothing, for other live shapes, and for a line unless every selected
|
||||
/// object is one.
|
||||
pub(crate) fn live_shape_rows(app: &mut VectorcraftApp, ui: &mut Ui, n: &Node, live: &LiveShape, id: &str, headed: bool) -> bool {
|
||||
match live {
|
||||
LiveShape::Rectangle { .. } => {
|
||||
@@ -444,11 +445,51 @@ pub(crate) fn live_shape_rows(app: &mut VectorcraftApp, ui: &mut Ui, n: &Node, l
|
||||
widgets::subheader(ui, tl!("Ellipse Properties:"));
|
||||
pie_rows(app, ui, *pie, &format!("{id}-pie"));
|
||||
}
|
||||
LiveShape::Line { .. } => return line_rows(app, ui, live, &format!("{id}-line")),
|
||||
_ => return false,
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
/// Whether every selected object is a live line (and one is selected).
|
||||
fn only_lines_selected(app: &VectorcraftApp) -> bool {
|
||||
let Some(st) = app.session.active() else { return false };
|
||||
let line = |n: &Node| matches!(&n.kind, NodeKind::Path { live: Some(l), .. } if matches!(**l, LiveShape::Line { .. }));
|
||||
!st.selection.objects.is_empty() && st.selection.objects.iter().all(|o| st.doc.node(*o).is_some_and(line))
|
||||
}
|
||||
|
||||
/// A live line's Line Properties (Transform and Properties panels), under its heading: its length,
|
||||
/// end to end, and its angle (counterclockwise from 3 o'clock, from its first end to its second). A new length keeps each selected line's first end in place, and a
|
||||
/// new angle turns each one about its midpoint. Returns false, drawing nothing, unless every
|
||||
/// selected object is a live line.
|
||||
pub(crate) fn line_rows(app: &mut VectorcraftApp, ui: &mut Ui, live: &LiveShape, id: &str) -> bool {
|
||||
if !only_lines_selected(app) {
|
||||
return false;
|
||||
}
|
||||
let (units, fw) = (app.session.general_unit(), super::field_width(ui));
|
||||
widgets::subheader(ui, tl!("Line Properties:"));
|
||||
// The `object.setLiveShape` params the edited fields set, all sent in one call.
|
||||
let mut set = serde_json::Map::new();
|
||||
egui::Grid::new((id, "grid")).num_columns(2).spacing([6.0, 6.0]).show(ui, |ui| {
|
||||
widgets::dim_label(ui, tl!("Line Length:"));
|
||||
if let Some(l) = widgets::num_field_named(ui, (id, "length"), Some(tl!("Line Length:")), live.line_length(), units, fw) {
|
||||
set.insert("lineLength".into(), json!(l));
|
||||
}
|
||||
ui.end_row();
|
||||
widgets::dim_label(ui, tl!("Line Angle:"));
|
||||
if let Some(a) = widgets::plain_field_named(ui, (id, "angle"), Some(tl!("Line Angle:")), live.line_angle().unwrap_or(0.0), "°", 1, fw) {
|
||||
set.insert("lineAngle".into(), json!(a));
|
||||
}
|
||||
ui.end_row();
|
||||
});
|
||||
if !set.is_empty()
|
||||
&& let Err(e) = app.run("object.setLiveShape", serde_json::Value::Object(set))
|
||||
{
|
||||
app.status(e);
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
/// An ellipse's Pie Start and End Angle (degrees, counterclockwise from 3 o'clock; 0 to 360 is the
|
||||
/// whole ellipse) and Invert Pie, which shows the other part of it (Transform and Properties panels).
|
||||
pub(crate) fn pie_rows(app: &mut VectorcraftApp, ui: &mut Ui, pie: (f64, f64), id: &str) {
|
||||
|
||||
@@ -154,6 +154,52 @@ fn an_ellipse_shows_its_pie_properties() {
|
||||
assert!(shown.iter().any(|s| s == "30°") && shown.iter().any(|s| s == "120°"), "{shown:?}");
|
||||
}
|
||||
|
||||
/// A live line shows its Line Properties in the Transform panel and the Properties panel's
|
||||
/// Transform section: a typed length keeps its first end in place and a typed angle turns it
|
||||
/// about its midpoint, each one undo step. A line with other objects selected, and a line after
|
||||
/// Expand Shape, show none.
|
||||
#[test]
|
||||
fn a_line_shows_and_takes_its_line_properties() {
|
||||
let ends = |app: &VectorcraftApp| match &first_selected(app).unwrap().kind {
|
||||
NodeKind::Path { live: Some(l), .. } => match **l {
|
||||
LiveShape::Line { a, b } => (a, b),
|
||||
ref k => panic!("{k:?}"),
|
||||
},
|
||||
k => panic!("{k:?}"),
|
||||
};
|
||||
let near = |p: Point, x: f64, y: f64| (p.x - x).abs() < 1e-6 && (p.y - y).abs() < 1e-6;
|
||||
for draw in [show as fn(&mut VectorcraftApp, &mut Ui), crate::panels::properties::transform_section] {
|
||||
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 300, "height": 300})).unwrap();
|
||||
// 100 pt long, going down the page to the right: 53.13° clockwise, 306.87° counterclockwise.
|
||||
let id = app.run("shape.line", json!({"x1": 50, "y1": 50, "x2": 110, "y2": 130})).unwrap()["id"].as_u64().unwrap();
|
||||
let shown = texts(&mut app, draw);
|
||||
for t in ["Line Properties:", "Line Length:", "100 pt", "Line Angle:", "306.9°"] {
|
||||
assert!(shown.iter().any(|s| s == t), "{t} in {shown:?}");
|
||||
}
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install_fonts(&ctx);
|
||||
type_into(&ctx, &mut app, draw, "100 pt", "50");
|
||||
let (a, b) = ends(&app);
|
||||
assert!(near(a, 50.0, 50.0) && near(b, 80.0, 90.0), "{a:?} {b:?}");
|
||||
type_into(&ctx, &mut app, draw, "306.9°", "90");
|
||||
let (a, b) = ends(&app);
|
||||
assert!(near(a, 65.0, 95.0) && near(b, 65.0, 45.0), "{a:?} {b:?}");
|
||||
assert!(texts(&mut app, draw).iter().any(|s| s == "90°"));
|
||||
app.run("edit.undo", json!({})).unwrap();
|
||||
let (a, b) = ends(&app);
|
||||
assert!(near(a, 50.0, 50.0) && near(b, 80.0, 90.0), "one undo step: {a:?} {b:?}");
|
||||
// With a rectangle selected too, the fields would set the line alone: they don't show.
|
||||
let rect = app.run("shape.rectangle", json!({"x": 200, "y": 200, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap();
|
||||
app.run("select.set", json!({"ids": [id, rect]})).unwrap();
|
||||
assert!(!texts(&mut app, draw).iter().any(|s| s == "Line Properties:" || s == "Line Length:"));
|
||||
app.run("select.set", json!({"ids": [id]})).unwrap();
|
||||
assert!(texts(&mut app, draw).iter().any(|s| s == "Line Properties:"));
|
||||
app.run("object.expandShape", json!({})).unwrap();
|
||||
assert!(!texts(&mut app, draw).iter().any(|s| s == "Line Properties:" || s == "Line Length:"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_artboard_tool_shows_the_active_artboard() {
|
||||
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
|
||||
|
||||
+7
-1
@@ -6770,7 +6770,12 @@ polygon (Polygon Properties): `sides` (3–1000), `polygonAngle` (degrees counte
|
||||
at 0), `polygonRadius` (pt, centre to vertex), `sideLength` (pt, which sets the radius) and `makeSidesEqual: true`,
|
||||
which drops an uneven scale or shear (its sides then differ) and keeps its centre, angle and mean radius; a radius or
|
||||
length that isn't a number above 0 is an error. An ellipse (Ellipse Properties): `pieStart` and `pieEnd` (degrees
|
||||
counterclockwise from 3 o'clock; 0 to 360 is the whole ellipse) and `invertPie: true`, which swaps them. Each call is
|
||||
counterclockwise from 3 o'clock; 0 to 360 is the whole ellipse) and `invertPie: true`, which swaps them. A line drawn
|
||||
with the Line Segment tool (Line Properties): `lineLength` (pt, above 0; the line's first end stays in place) and
|
||||
`lineAngle` (degrees counterclockwise from 3 o'clock, from the first end to the second; the line turns about its
|
||||
midpoint; any finite value is brought into 0 to 360). With both, the length applies first. A line whose ends meet reads
|
||||
0° and keeps its place under `lineAngle`; `lineLength` points it to the right. A length that isn't a number above 0,
|
||||
and a line that would reach past the coordinate limit (±4,000,000 pt), are errors that change no line. Each call is
|
||||
one undo step.
|
||||
|
||||
`object.setLiveShape` returns a parameter error, and leaves the document and its undo history as they were, for a key
|
||||
@@ -6783,6 +6788,7 @@ below 3 or above 1000 counts as 3 or 1000, and a fractional or negative `sides`
|
||||
```json
|
||||
{"name":"run_command","arguments":{"command":"object.setLiveShape","params":{"sides":8,"polygonAngle":22.5,"sideLength":40}}}
|
||||
{"name":"run_command","arguments":{"command":"object.setLiveShape","params":{"makeSidesEqual":true}}}
|
||||
{"name":"run_command","arguments":{"command":"object.setLiveShape","params":{"lineLength":72,"lineAngle":90}}}
|
||||
```
|
||||
|
||||
## Align to Artboard
|
||||
|
||||
@@ -1276,6 +1276,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
- **Shapes:** all shape tools (including Flare) and the line, arc, spiral and grid tools. Space held while dragging out a shape, line, arc, spiral or grid moves it at its current size. The Flare tool's center drag turns the rays by 0.1 radian at each drag update in which the pointer's document y grows, and back by as much at each one in which it falls, Shift held keeps their turn, and Space held during either of its drags moves the flare. While a grid is dragged out, Up/Down change its rows (concentric dividers) and Left/Right its columns (radial dividers). A click with a grid tool asks for the size, the divider counts and the grid options (#1377, in part): a skew for each set of dividers, Use Outside Rectangle As Frame or Create Compound Path From Ellipses, and Fill Grid; they are parameters of `shape.rectangularGrid` and `shape.polarGrid`, stay as the tool's options and apply to drags too. The curve a skew percentage follows and the direction of the radial skew are our own (the public documentation gives neither), and the dialogs have no reference point locator. An ellipse's Pie Start and End Angle and Invert Pie (Transform and Properties panels' Ellipse Properties, `object.setLiveShape {pieStart, pieEnd, invertPie}`) cut it as a pie (#812). With the bounding box showing, the Selection tool shows a selected ellipse's two pie widgets just outside it; dragging one sets its angle in one undo step and double-clicking one makes the ellipse whole again. A live polygon's Polygon Properties there: side count, angle, corner type and radius, radius, side length and Make Sides Equal once an uneven scale has made its sides differ (`object.setLiveShape {sides, polygonAngle, polygonRadius, sideLength, makeSidesEqual}`, part of #812); a star is a plain path, as in Illustrator. The Flare Tool Options last as the tool's options: the next flare dragged out uses them, a click's dialog shows them and double-clicking the tool opens them (part of #812).
|
||||
- **Shapes:** all shape tools (including Flare) and the line, arc, spiral and grid tools. Space held while dragging out a shape, line, arc, spiral or grid moves it at its current size. The Flare tool's center drag turns the rays with the pointer, Shift keeps them in their original orientation (unturned, or turned by a nonzero General › Constrain Angle), and Space held during either of its drags moves the flare. While a grid is dragged out, Up/Down change its rows (concentric dividers) and Left/Right its columns (radial dividers). A click with a grid tool asks for the size, the divider counts and the grid options (#1377, in part): a skew for each set of dividers, Use Outside Rectangle As Frame or Create Compound Path From Ellipses, and Fill Grid; they are parameters of `shape.rectangularGrid` and `shape.polarGrid`, stay as the tool's options and apply to drags too. The curve a skew percentage follows and the direction of the radial skew are our own (the public documentation gives neither), and the dialogs have no reference point locator. An ellipse's Pie Start and End Angle and Invert Pie (Transform and Properties panels' Ellipse Properties, `object.setLiveShape {pieStart, pieEnd, invertPie}`) cut it as a pie (#812). With the bounding box showing, the Selection tool shows a selected ellipse's two pie widgets just outside it; dragging one sets its angle in one undo step and double-clicking one makes the ellipse whole again. A live polygon's Polygon Properties there: side count, angle, corner type and radius, radius, side length and Make Sides Equal once an uneven scale has made its sides differ (`object.setLiveShape {sides, polygonAngle, polygonRadius, sideLength, makeSidesEqual}`, part of #812); a star is a plain path, as in Illustrator. The Flare Tool Options last as the tool's options: the next flare dragged out uses them, a click's dialog shows them and double-clicking the tool opens them (part of #812).
|
||||
- **Shapes:** all shape tools (including Flare) and the line, arc, spiral and grid tools. Space held while dragging out a shape, line, arc, spiral or grid moves it at its current size. The Flare tool's center drag turns the rays with the pointer, Shift keeps them in their original orientation, and Space held during either of its drags moves the flare. While a grid is dragged out, Up/Down change its rows (concentric dividers) and Left/Right its columns (radial dividers). A click with a grid tool asks for the size, the divider counts and the grid options (#1377, in part): a skew for each set of dividers, Use Outside Rectangle As Frame or Create Compound Path From Ellipses, and Fill Grid; they are parameters of `shape.rectangularGrid` and `shape.polarGrid`, stay as the tool's options and apply to drags too. The curve a skew percentage follows and the direction of the radial skew are our own (the public documentation gives neither), and the dialogs have no reference point locator. An ellipse's Pie Start and End Angle and Invert Pie (Transform and Properties panels' Ellipse Properties, `object.setLiveShape {pieStart, pieEnd, invertPie}`) cut it as a pie (#812). With the bounding box showing, the Selection tool shows a selected ellipse's two pie widgets just outside it; dragging one sets its angle in one undo step and double-clicking one makes the ellipse whole again. A live polygon's Polygon Properties there: side count, angle, corner type and radius, radius, side length and Make Sides Equal once an uneven scale has made its sides differ (`object.setLiveShape {sides, polygonAngle, polygonRadius, sideLength, makeSidesEqual}`, part of #812); a star is a plain path, as in Illustrator. The Flare Tool Options last as the tool's options: the next flare dragged out uses them, a click's dialog shows them and double-clicking the tool opens them (part of #812).
|
||||
A live line drawn with the Line Segment tool shows Line Properties in the Transform panel and the Properties panel's Transform section: Line Length (a length above 0, in the document's units) and Line Angle (0° horizontal, 90° vertical, any value brought into 0° to 360°), the two properties that [the help page](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/modify-live-shapes/live-shape-properties.html) lists for a line (`object.setLiveShape {lineLength, lineAngle}`). Typing one sets every selected line in one undo step. These rules are VectorCraft's own: the angle runs counterclockwise from 3 o'clock, as the Rotate field does; a new length keeps the line's first end in place and a new angle turns it about its midpoint; a line whose ends meet reads 0°; the section shows only while every selected object is a live line; and a line that would reach past the document's coordinate limit is an error that changes nothing. Expand Shape makes the line a plain path without these properties (tests `a_line_shows_and_takes_its_line_properties` and, through the engine, `a_line_takes_its_length_and_angle`).
|
||||
Backtick (`` ` ``) held while a rectangle, rounded rectangle, ellipse, polygon, star or line is dragged out leaves copies of the shape being drawn along the drag, each its own object: the continuous duplicate that the Keys for drawing table of [the help page](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=469) lists. Each copy is the shape as the drag showed it then, with its modifiers and Up/Down counts; the release keeps the copies and the last shape as one undo step, and Escape takes them all back. The spacing (a copy each time the pointer has moved 8 screen points with the key down, none for the key alone) and the limit of 128 copies a drag are VectorCraft's own values, and a shape with no width, height or length leaves no copy. The arc, spiral, grid and Flare tools do not leave copies (tests `backtick_drag_leaves_copies_of_the_rectangle_being_drawn` and, through the engine, `a_backtick_drag_leaves_copies_of_the_shape_as_one_undo_step`).
|
||||
Escape while a polygon, star or rounded rectangle is dragged out cancels it and puts back the side count, point count, corner radius or star ratio its Up/Down and Ctrl/Cmd changed, so the next drag, the tool's options and General › Corner Radius start from the values before the canceled drag; a drag that is let go keeps them, and an option set with `tool.setOption` during the drag stays. This is VectorCraft's own rule.
|
||||
A click with the Rounded Rectangle tool opens the size dialog with its radius at General › Corner Radius, and OK makes the radius typed there that preference, so later rounded rectangles and the dialog's next opening start from it while rounded rectangles already drawn keep their corners, as [the help page](https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf#page=64) describes. A radius outside the preference's range of 0 to 1296 pt, which is VectorCraft's own, or one that is not a length is refused with an error: the dialog stays open, nothing is drawn and the preference keeps its value. Evidence: `dialogs::shapes::tests::{rounded_rectangle_click_dialog_opens_on_and_sets_the_corner_radius, rounded_rectangle_click_dialog_refuses_a_radius_out_of_range}`.
|
||||
|
||||
Reference in New Issue
Block a user