mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-18 11:14:13 +00:00
Merge pull request #8410 from dotCooCoo/feat/transform-constrain-pie-angle
Transform: Ellipse Properties has a Constrain Pie Angle link that keeps the pie span
This commit is contained in:
@@ -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), 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)",
|
||||
"{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), constrainPie?: bool (Constrain Pie Angle: with one of pieStart and pieEnd, not both and not with invertPie, the other angle moves by as much, so each ellipse keeps its span), 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
|
||||
),
|
||||
|
||||
@@ -124,7 +124,7 @@ fn line_edit(l: &LiveShape, len: Option<f64>, angle: Option<f64>) -> Option<Live
|
||||
}
|
||||
|
||||
pub(super) fn set_live_shape(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
check_switches(p, &["invertPie", "makeSidesEqual", "relativeRadii"], "object.setLiveShape")?;
|
||||
check_switches(p, &["constrainPie", "invertPie", "makeSidesEqual", "relativeRadii"], "object.setLiveShape")?;
|
||||
check_numbers(p, &["radius", "sides"], "object.setLiveShape")?;
|
||||
// `items`: objects each with its own `corners`; else `ids` (or the selection) sharing them.
|
||||
let items = match p.get("items").filter(|v| !v.is_null()) {
|
||||
@@ -193,6 +193,12 @@ pub(super) fn set_live_shape(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
// An ellipse's pie (Ellipse Properties: Pie Start and End Angle, degrees; Invert Pie swaps them).
|
||||
let (pie_start, pie_end) = (angle("pieStart")?, angle("pieEnd")?);
|
||||
let invert = p.get("invertPie").and_then(Value::as_bool) == Some(true);
|
||||
// Constrain Pie Angle: the one angle given moves the other by as much, so each ellipse keeps
|
||||
// its span (its end angle less its start angle, counterclockwise).
|
||||
let constrain = p.get("constrainPie").and_then(Value::as_bool) == Some(true);
|
||||
if constrain && (invert || pie_start.is_some() == pie_end.is_some()) {
|
||||
return Err(bad("object.setLiveShape", "`constrainPie` needs one of `pieStart` and `pieEnd`, without `invertPie`"));
|
||||
}
|
||||
// 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);
|
||||
@@ -204,7 +210,16 @@ pub(super) fn set_live_shape(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
// ellipse as 0° to 360°).
|
||||
let end_of = |a: f64| if a == 0.0 { 360.0 } else { a };
|
||||
let pie_of = |pie: (f64, f64)| {
|
||||
let pie = (pie_start.unwrap_or(pie.0), pie_end.map_or(pie.1, end_of));
|
||||
let span = (pie.1 - pie.0).rem_euclid(360.0);
|
||||
let pie = match (constrain, pie_start, pie_end) {
|
||||
// The angle it already has: nothing moves.
|
||||
(true, Some(a), _) if a == pie.0 => pie,
|
||||
(true, _, Some(a)) if end_of(a) == pie.1 => pie,
|
||||
// A whole ellipse (a span of 0) stays whole.
|
||||
(true, Some(a), _) => (a, end_of((a + span).rem_euclid(360.0))),
|
||||
(true, _, Some(a)) => ((a - span).rem_euclid(360.0), end_of(a)),
|
||||
_ => (pie_start.unwrap_or(pie.0), pie_end.map_or(pie.1, end_of)),
|
||||
};
|
||||
if invert { (pie.1.rem_euclid(360.0), end_of(pie.0)) } else { pie }
|
||||
};
|
||||
// When every value given is the current one, the document and its undo history stay as they
|
||||
|
||||
@@ -392,6 +392,67 @@ fn an_ellipse_takes_pie_angles_and_inverts() {
|
||||
assert!(s.execute("object.setLiveShape", &json!({"pieStart": "half"})).is_err());
|
||||
}
|
||||
|
||||
/// Constrain Pie Angle (`constrainPie`): a new Pie Start or End Angle moves the other angle by as
|
||||
/// much, so each selected ellipse keeps its own span, across 0° too; a whole ellipse stays whole;
|
||||
/// after Invert Pie the inverted span is kept; one undo step for all of them; the angle each
|
||||
/// already has records nothing; and `constrainPie` with both angles, with neither, with Invert Pie
|
||||
/// or as text is an error that changes nothing.
|
||||
#[test]
|
||||
fn constrain_pie_keeps_each_ellipses_span() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 300, "height": 300})).unwrap();
|
||||
let id = |v: Value| NodeId(v["id"].as_u64().unwrap());
|
||||
let [a, b, c] = [0, 100, 200].map(|y| id(s.execute("shape.ellipse", &json!({"x": 0, "y": y, "width": 200, "height": 80})).unwrap()));
|
||||
run(&mut s, json!({"ids": [a.0], "pieStart": 300, "pieEnd": 60}));
|
||||
run(&mut s, json!({"ids": [b.0], "pieStart": 0, "pieEnd": 90}));
|
||||
let pies = |s: &Session| {
|
||||
[a, b, c].map(|i| match &s.doc().unwrap().doc.node(i).unwrap().kind {
|
||||
NodeKind::Path { live: Some(l), .. } => match &**l {
|
||||
LiveShape::Ellipse { pie, .. } => *pie,
|
||||
k => panic!("{k:?}"),
|
||||
},
|
||||
k => panic!("{k:?}"),
|
||||
})
|
||||
};
|
||||
let near = |p: (f64, f64), q: (f64, f64)| (p.0 - q.0).abs() < 1e-9 && (p.1 - q.1).abs() < 1e-9;
|
||||
let undo = |s: &Session| s.doc().unwrap().history.undo.len();
|
||||
let n = undo(&s);
|
||||
// 300° to 60° spans 120°, through 0°; 0° to 90° spans 90°; the third ellipse is whole.
|
||||
run(&mut s, json!({"ids": [a.0, b.0, c.0], "pieStart": 350, "constrainPie": true}));
|
||||
let [pa, pb, pc] = pies(&s);
|
||||
assert!(near(pa, (350.0, 110.0)) && near(pb, (350.0, 80.0)), "{pa:?} {pb:?}");
|
||||
assert!(near(pc, (350.0, 350.0)), "{pc:?}");
|
||||
assert_eq!(s.doc().unwrap().doc.node(c).unwrap().path_data().unwrap().anchor_count(), 4, "the whole ellipse stays whole");
|
||||
assert_eq!(undo(&s), n + 1, "one undo step");
|
||||
run(&mut s, json!({"ids": [a.0, b.0], "pieEnd": 20, "constrainPie": true}));
|
||||
let [pa, pb, _] = pies(&s);
|
||||
assert!(near(pa, (260.0, 20.0)) && near(pb, (290.0, 20.0)), "{pa:?} {pb:?}");
|
||||
let n = undo(&s);
|
||||
run(&mut s, json!({"ids": [a.0, b.0], "pieEnd": 380, "constrainPie": true}));
|
||||
assert_eq!(undo(&s), n, "the end each already has: no undo step");
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
let [pa, pb, _] = pies(&s);
|
||||
assert!(near(pa, (350.0, 110.0)) && near(pb, (350.0, 80.0)), "{pa:?} {pb:?}");
|
||||
// Inverted, 80° to 350° spans 270°, and a linked edit keeps that.
|
||||
run(&mut s, json!({"ids": [b.0], "invertPie": true}));
|
||||
run(&mut s, json!({"ids": [b.0], "pieStart": 0, "constrainPie": true}));
|
||||
assert!(near(pies(&s)[1], (0.0, 270.0)), "{:?}", pies(&s)[1]);
|
||||
let before = (undo(&s), pies(&s));
|
||||
for (p, want) in [
|
||||
(json!({"ids": [b.0], "pieStart": 10, "pieEnd": 20, "constrainPie": true}), "needs one of"),
|
||||
(json!({"ids": [b.0], "constrainPie": true}), "needs one of"),
|
||||
(json!({"ids": [b.0], "pieStart": 10, "constrainPie": true, "invertPie": true}), "needs one of"),
|
||||
(json!({"ids": [b.0], "pieStart": 10, "constrainPie": "yes"}), "`constrainPie` must be true or false"),
|
||||
] {
|
||||
let r = s.execute("object.setLiveShape", &p);
|
||||
assert!(matches!(&r, Err(EngineError::BadParams { msg, .. }) if msg.contains(want)), "{p}: {r:?}");
|
||||
assert_eq!((undo(&s), pies(&s)), before, "{p}");
|
||||
}
|
||||
// Off, each angle is set on its own, as before.
|
||||
run(&mut s, json!({"ids": [b.0], "pieStart": 90, "constrainPie": false}));
|
||||
assert!(near(pies(&s)[1], (90.0, 270.0)), "{:?}", pies(&s)[1]);
|
||||
}
|
||||
|
||||
/// Invert Pie and Make Sides Equal given as text or as another value that is not true or false are
|
||||
/// an error naming the key: the ellipse's pie, the polygon and the undo history stay as they were.
|
||||
/// True makes the change, and false and null leave the shape as it is.
|
||||
|
||||
@@ -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!({"pieEnd": 90, "constrainPie": true}),
|
||||
json!({"ids": [3], "lineLength": 72, "lineAngle": 90}),
|
||||
json!({"items": null}),
|
||||
] {
|
||||
|
||||
@@ -2637,6 +2637,7 @@ font-technology Variable Променливи
|
||||
Line Properties: Свойства на линията:
|
||||
Line Length: Дължина на линията:
|
||||
Line Angle: Ъгъл на линията:
|
||||
Constrain Pie Angle Запазване на ъгъла на сектора
|
||||
Polygon Tool Инструмент „Многоъгълник“
|
||||
Portrait Портретна
|
||||
Power Saving (integrated) Пестене на енергия (интегрирано)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2369,6 +2369,7 @@ digits Malayalam Malajalam
|
||||
Line Properties: Svojstva linije:
|
||||
Line Length: Dužina linije:
|
||||
Line Angle: Ugao linije:
|
||||
Constrain Pie Angle Zadrži ugao pite
|
||||
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.
|
@@ -3412,6 +3412,7 @@ digits Malayalam Malaiàlam
|
||||
Line Properties: Propietats de la línia:
|
||||
Line Length: Longitud de la línia:
|
||||
Line Angle: Angle de la línia:
|
||||
Constrain Pie Angle Restringeix l’angle del sector
|
||||
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.
|
@@ -2440,6 +2440,7 @@ digits Malayalam Malajálamské
|
||||
Line Properties: Vlastnosti čáry:
|
||||
Line Length: Délka čáry:
|
||||
Line Angle: Úhel čáry:
|
||||
Constrain Pie Angle Zachovat úhel výseče
|
||||
Rectangle Properties: Vlastnosti obdélníku:
|
||||
Shape Properties: Vlastnosti tvaru:
|
||||
Shape Properties Vlastnosti tvaru
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4954,6 +4954,7 @@ digits Malayalam Malayalam
|
||||
Line Properties: Linjeegenskaber:
|
||||
Line Length: Linjelængde:
|
||||
Line Angle: Linjevinkel:
|
||||
Constrain Pie Angle Fasthold udsnittets vinkel
|
||||
Rectangle Properties: Rektangelegenskaber:
|
||||
Shape Properties: Figuregenskaber:
|
||||
Shape Properties Figuregenskaber
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2696,6 +2696,7 @@ diagnostics ui Oberfläche
|
||||
Line Properties: Linieneigenschaften:
|
||||
Line Length: Linienlänge:
|
||||
Line Angle: Linienwinkel:
|
||||
Constrain Pie Angle Winkel des Kreissegments beibehalten
|
||||
Polygon Tool Polygon-Werkzeug
|
||||
Portrait Hochformat
|
||||
Power Saving (integrated) Energiesparen (integriert)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3633,6 +3633,7 @@ theme Appearance Εμφάνιση
|
||||
Line Properties: Ιδιότητες γραμμής:
|
||||
Line Length: Μήκος γραμμής:
|
||||
Line Angle: Γωνία γραμμής:
|
||||
Constrain Pie Angle Διατήρηση γωνίας κυκλικού τομέα
|
||||
Power Saving (integrated) Εξοικονόμηση ενέργειας (ενσωματωμένη GPU)
|
||||
Portuguese Πορτογαλικά
|
||||
PostScript: PostScript:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2735,6 +2735,7 @@ font-technology Variable Variables
|
||||
Line Properties: Propiedades de la línea:
|
||||
Line Length: Longitud de la línea:
|
||||
Line Angle: Ángulo de la línea:
|
||||
Constrain Pie Angle Restringir ángulo del sector
|
||||
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.
|
@@ -2404,6 +2404,7 @@ digits Malayalam Malajalam
|
||||
Line Properties: Viivan ominaisuudet:
|
||||
Line Length: Viivan pituus:
|
||||
Line Angle: Viivan kulma:
|
||||
Constrain Pie Angle Säilytä sektorin 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.
|
@@ -2723,6 +2723,7 @@ font-technology Variable Variables
|
||||
Line Properties: Propriétés de la ligne :
|
||||
Line Length: Longueur de la ligne :
|
||||
Line Angle: Angle de la ligne :
|
||||
Constrain Pie Angle Conserver l’angle du secteur
|
||||
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.
|
@@ -2790,6 +2790,7 @@
|
||||
Line Properties: રેખાના ગુણધર્મો:
|
||||
Line Length: રેખાની લંબાઈ:
|
||||
Line Angle: રેખાનો કોણ:
|
||||
Constrain Pie 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.
|
@@ -3745,6 +3745,7 @@ antiAlias Sharp शार्प
|
||||
Line Properties: रेखा प्रॉपर्टीज़:
|
||||
Line Length: रेखा की लंबाई:
|
||||
Line Angle: रेखा का कोण:
|
||||
Constrain Pie Angle पाई एंगल बनाए रखें
|
||||
Polygon Tool पॉलीगोन टूल
|
||||
Polygonal Lasso बहुभुज लैस्सो
|
||||
Polygonal Lasso Tool बहुभुज लैस्सो टूल
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3284,6 +3284,7 @@ diagnostics ui felület
|
||||
Line Properties: Vonal tulajdonságai:
|
||||
Line Length: Vonal hossza:
|
||||
Line Angle: Vonal szöge:
|
||||
Constrain Pie Angle Körcikk szögének megtartása
|
||||
Polygon Tool Sokszög
|
||||
Portrait Álló
|
||||
Portrait (flipped) Álló (megfordítva)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2192,6 +2192,7 @@ digits Malayalam Malayalam
|
||||
Line Properties: Properti garis:
|
||||
Line Length: Panjang garis:
|
||||
Line Angle: Sudut garis:
|
||||
Constrain Pie Angle Kendalikan sudut pai
|
||||
Rectangle Properties: Properti persegi panjang:
|
||||
Shape Properties: Properti bentuk:
|
||||
Shape Properties Properti bentuk
|
||||
|
||||
|
@@ -2780,6 +2780,7 @@ diagnostics ui interfaccia
|
||||
Line Properties: Proprietà linea:
|
||||
Line Length: Lunghezza linea:
|
||||
Line Angle: Angolo linea:
|
||||
Constrain Pie Angle Vincola angolo del settore
|
||||
Polygon Tool Strumento Poligono
|
||||
Portrait Verticale
|
||||
Power Saving (integrated) Risparmio energetico (integrata)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2873,6 +2873,7 @@ diagnostics ui UI
|
||||
Line Properties: 線のプロパティ:
|
||||
Line Length: 線の長さ:
|
||||
Line Angle: 線の角度:
|
||||
Constrain Pie Angle 扇形の角度を固定
|
||||
Polygon Tool 多角形ツール
|
||||
Portrait 縦置き
|
||||
Portuguese ポルトガル語
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4360,6 +4360,7 @@ digits Malayalam მალაიალამური
|
||||
Line Properties: ხაზის თვისებები:
|
||||
Line Length: ხაზის სიგრძე:
|
||||
Line Angle: ხაზის კუთხე:
|
||||
Constrain Pie Angle სექტორის კუთხის შენარჩუნება
|
||||
Rectangle Properties: მართკუთხედის თვისებები:
|
||||
Shape Properties: ფიგურის თვისებები:
|
||||
Shape Properties ფიგურის თვისებები
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2863,6 +2863,7 @@ diagnostics ui UI
|
||||
Line Properties: 선 속성:
|
||||
Line Length: 선 길이:
|
||||
Line Angle: 선 각도:
|
||||
Constrain Pie Angle 파이 각도 고정
|
||||
Polygon Tool 다각형 도구
|
||||
Portrait 세로
|
||||
Portuguese Português
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2828,6 +2828,7 @@ digits Malayalam Malayalam
|
||||
Line Properties: Lijneigenschappen:
|
||||
Line Length: Lijnlengte:
|
||||
Line Angle: Lijnhoek:
|
||||
Constrain Pie Angle Taarthoek vastleggen
|
||||
Rectangle Properties: Rechthoekeigenschappen:
|
||||
Shape Properties: Vormeigenschappen:
|
||||
Shape Properties Vormeigenschappen
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2359,6 +2359,7 @@ digits Malayalam Malajalam
|
||||
Line Properties: Właściwości linii:
|
||||
Line Length: Długość linii:
|
||||
Line Angle: Kąt linii:
|
||||
Constrain Pie Angle Zachowaj kąt wycinka
|
||||
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.
|
@@ -2263,6 +2263,7 @@ antiAlias Sharp Nítido
|
||||
Line Properties: Propriedades da Linha:
|
||||
Line Length: Comprimento da Linha:
|
||||
Line Angle: Ângulo da Linha:
|
||||
Constrain Pie Angle Restringir Ângulo da Fatia
|
||||
Polygon Tool Ferramenta Polígono
|
||||
Portrait Retrato
|
||||
Portuguese Português
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2762,6 +2762,7 @@ diagnostics ui интерфейс
|
||||
Line Properties: Свойства линии:
|
||||
Line Length: Длина линии:
|
||||
Line Angle: Угол линии:
|
||||
Constrain Pie Angle Сохранять угол сектора
|
||||
Polygon Tool Инструмент «Многоугольник»
|
||||
Portrait Книжная
|
||||
Power Saving (integrated) Энергосбережение (встроенная)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2660,6 +2660,7 @@ font-technology Variable Variabla
|
||||
Line Properties: Linjeegenskaper:
|
||||
Line Length: Linjelängd:
|
||||
Line Angle: Linjevinkel:
|
||||
Constrain Pie Angle Behåll cirkeldiagrammets vinkel
|
||||
Polygon Tool Polygonverktyg
|
||||
Portrait Stående
|
||||
Power Saving (integrated) Energisparläge (integrerad)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2507,6 +2507,7 @@ shape Open Açık
|
||||
Line Properties: Çizgi Özellikleri:
|
||||
Line Length: Çizgi Uzunluğu:
|
||||
Line Angle: Çizgi Açısı:
|
||||
Constrain Pie Angle Pasta Açısını Sınırla
|
||||
Polygon Tool Çokgen Aracı
|
||||
Portrait Portre
|
||||
Power Saving (integrated) Güç Tasarrufu (entegre)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2772,6 +2772,7 @@ diagnostics ui інтерфейс
|
||||
Line Properties: Властивості лінії:
|
||||
Line Length: Довжина лінії:
|
||||
Line Angle: Кут лінії:
|
||||
Constrain Pie Angle Зберігати кут сектора
|
||||
Polygon Tool Інструмент «Багатокутник»
|
||||
Portrait Книжкова
|
||||
Power Saving (integrated) Енергозбереження (вбудована)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3089,6 +3089,7 @@ diagnostics ui giao diện
|
||||
Line Properties: Thuộc tính đường thẳng:
|
||||
Line Length: Độ dài đường thẳng:
|
||||
Line Angle: Góc đường thẳng:
|
||||
Constrain Pie Angle Ràng buộc góc hình quạt
|
||||
Polygon Tool Công cụ Đa giác
|
||||
Portrait Đứng
|
||||
Portuguese Tiếng Bồ Đào Nha
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2631,6 +2631,7 @@ diagnostics ui 界面
|
||||
Line Properties: 直线属性:
|
||||
Line Length: 直线长度:
|
||||
Line Angle: 直线角度:
|
||||
Constrain Pie Angle 约束扇形角度
|
||||
Polygon Tool 多边形工具
|
||||
Portrait 纵向
|
||||
Portuguese 葡萄牙语
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3957,6 +3957,7 @@ diagnostics ui 介面
|
||||
Line Properties: 直線內容:
|
||||
Line Length: 直線長度:
|
||||
Line Angle: 直線角度:
|
||||
Constrain Pie Angle 強制扇形角度
|
||||
Polygon Tool 多邊形工具
|
||||
Portrait 直向
|
||||
Power Saving (integrated) 節能 (內建顯示晶片)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -491,21 +491,43 @@ pub(crate) fn line_rows(app: &mut VectorcraftApp, ui: &mut Ui, live: &LiveShape,
|
||||
}
|
||||
|
||||
/// 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).
|
||||
/// whole ellipse), the Constrain Pie Angle link beside them, and Invert Pie, which shows the other
|
||||
/// part of it (Transform and Properties panels). With the link on, a typed angle moves the other
|
||||
/// one by as much, so each selected ellipse keeps its span.
|
||||
pub(crate) fn pie_rows(app: &mut VectorcraftApp, ui: &mut Ui, pie: (f64, f64), id: &str) {
|
||||
for (label, key, v) in [(tl!("Pie Start Angle:"), "pieStart", pie.0), (tl!("Pie End Angle:"), "pieEnd", pie.1)] {
|
||||
ui.horizontal(|ui| {
|
||||
widgets::dim_label(ui, label);
|
||||
if let Some(a) = widgets::plain_field(ui, (id, key), v, "°", 1, 60.0) {
|
||||
app.run("object.setLiveShape", json!({ key: a })).ok();
|
||||
ui.horizontal(|ui| {
|
||||
ui.vertical(|ui| {
|
||||
for (label, key, v) in [(tl!("Pie Start Angle:"), "pieStart", pie.0), (tl!("Pie End Angle:"), "pieEnd", pie.1)] {
|
||||
ui.horizontal(|ui| {
|
||||
widgets::dim_label(ui, label);
|
||||
if let Some(a) = widgets::plain_field(ui, (id, key), v, "°", 1, 60.0) {
|
||||
let params = if app.ui.constrain_pie_angle { json!({ key: a, "constrainPie": true }) } else { json!({ key: a }) };
|
||||
app.run("object.setLiveShape", params).ok();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
pie_link(app, ui);
|
||||
});
|
||||
if widgets::flat_button(ui, tl!("Invert Pie"), 90.0).clicked() {
|
||||
app.run("object.setLiveShape", json!({"invertPie": true})).ok();
|
||||
}
|
||||
}
|
||||
|
||||
/// The Constrain Pie Angle link between Pie Start and End Angle: one toggle for the Transform and
|
||||
/// Properties panels, kept while the app runs and off at launch. It is drawn after the fields, so
|
||||
/// Tab reaches them first; with the keyboard on it, Space or Enter toggles it.
|
||||
fn pie_link(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
let (_, at) = ui.allocate_exact_size(egui::Vec2::splat(CONSTRAIN_LINK_SIZE), egui::Sense::click());
|
||||
let on = app.ui.constrain_pie_angle;
|
||||
let tip = tl!("Constrain Pie Angle");
|
||||
let keyed = at.has_focus()
|
||||
&& ui.input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Space) | i.consume_key(egui::Modifiers::NONE, egui::Key::Enter));
|
||||
if widgets::paint_icon_button(ui, at, if on { "link" } else { "link-2-off" }, tip, on).clicked() || keyed {
|
||||
app.ui.constrain_pie_angle = !on;
|
||||
}
|
||||
}
|
||||
|
||||
/// A live polygon's Polygon Properties (Transform and Properties panels): its side count, angle
|
||||
/// (counterclockwise), corner type and radius, radius (centre to vertex) and side length, and Make
|
||||
/// Sides Equal, which an uneven scale enables.
|
||||
|
||||
@@ -154,6 +154,67 @@ fn an_ellipse_shows_its_pie_properties() {
|
||||
assert!(shown.iter().any(|s| s == "30°") && shown.iter().any(|s| s == "120°"), "{shown:?}");
|
||||
}
|
||||
|
||||
/// Ellipse Properties' Constrain Pie Angle link, in the Transform panel and the Properties panel's
|
||||
/// Transform section: off at first, a click or Space with the keyboard on it toggles it, and while
|
||||
/// it is on a typed Pie Start or End Angle moves the other angle by as much, keeping the span, in
|
||||
/// one undo step. Off, each angle changes on its own.
|
||||
#[test]
|
||||
fn the_constrain_pie_angle_link_keeps_the_span() {
|
||||
use egui_kittest::kittest::Queryable;
|
||||
const LINK: &str = "Constrain Pie Angle";
|
||||
let pie = |app: &VectorcraftApp| match &first_selected(app).unwrap().kind {
|
||||
NodeKind::Path { live: Some(l), .. } => match **l {
|
||||
LiveShape::Ellipse { pie, .. } => pie,
|
||||
ref k => panic!("{k:?}"),
|
||||
},
|
||||
k => panic!("{k:?}"),
|
||||
};
|
||||
let undo = |app: &VectorcraftApp| app.session.doc().unwrap().history.undo.len();
|
||||
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();
|
||||
app.run("shape.ellipse", json!({"x": 50, "y": 50, "width": 120, "height": 80})).unwrap();
|
||||
app.run("object.setLiveShape", json!({"pieStart": 30, "pieEnd": 120})).unwrap();
|
||||
assert!(!app.ui.constrain_pie_angle, "off at first");
|
||||
let mut fonts = false;
|
||||
let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(320.0, 900.0)).with_accessibility_check(false).build_ui_state(
|
||||
move |ui, app: &mut VectorcraftApp| {
|
||||
if !std::mem::replace(&mut fonts, true) {
|
||||
crate::theme::install_fonts(ui.ctx());
|
||||
return;
|
||||
}
|
||||
draw(app, ui);
|
||||
},
|
||||
app,
|
||||
);
|
||||
h.run_steps(3);
|
||||
h.get_by_role_and_label(egui::accesskit::Role::Button, LINK).click();
|
||||
h.run_steps(2);
|
||||
assert!(h.state().ui.constrain_pie_angle, "a click turns it on");
|
||||
h.get_by_role_and_label(egui::accesskit::Role::Button, LINK).focus();
|
||||
h.run_steps(1);
|
||||
h.key_press(egui::Key::Space);
|
||||
h.run_steps(2);
|
||||
assert!(!h.state().ui.constrain_pie_angle, "Space turns it off");
|
||||
h.get_by_role_and_label(egui::accesskit::Role::Button, LINK).click();
|
||||
h.run_steps(2);
|
||||
assert!(h.state().ui.constrain_pie_angle);
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install_fonts(&ctx);
|
||||
let n = undo(h.state());
|
||||
type_into(&ctx, h.state_mut(), draw, "30°", "60");
|
||||
assert_eq!(pie(h.state()), (60.0, 150.0));
|
||||
assert_eq!(undo(h.state()), n + 1, "one undo step");
|
||||
type_into(&ctx, h.state_mut(), draw, "150°", "200");
|
||||
assert_eq!(pie(h.state()), (110.0, 200.0));
|
||||
h.get_by_role_and_label(egui::accesskit::Role::Button, LINK).click();
|
||||
h.run_steps(2);
|
||||
assert!(!h.state().ui.constrain_pie_angle);
|
||||
type_into(&ctx, h.state_mut(), draw, "110°", "100");
|
||||
assert_eq!(pie(h.state()), (100.0, 200.0), "off, the end stays");
|
||||
}
|
||||
}
|
||||
|
||||
/// 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
|
||||
|
||||
@@ -420,6 +420,11 @@ pub struct UiState {
|
||||
/// Type › Find Font…'s last Find In choice (`find_font::FIND_IN`), kept while the app runs.
|
||||
#[serde(skip)]
|
||||
pub find_font_in: String,
|
||||
/// Ellipse Properties' Constrain Pie Angle link (Transform and Properties panels): a Pie Start
|
||||
/// or End Angle typed while it is on keeps each selected ellipse's pie span. Kept while the app
|
||||
/// runs; off at every launch.
|
||||
#[serde(skip)]
|
||||
pub constrain_pie_angle: bool,
|
||||
/// The Learn panel's tab, skill and tutorial, kept while the app runs.
|
||||
#[serde(skip)]
|
||||
pub learn: crate::panels::learn::View,
|
||||
@@ -1175,6 +1180,7 @@ impl Default for UiState {
|
||||
transient_focus: false,
|
||||
color_settings_scroll: false,
|
||||
find_font_in: String::new(),
|
||||
constrain_pie_angle: false,
|
||||
learn: Default::default(),
|
||||
learn_locate: None,
|
||||
learn_practice: Default::default(),
|
||||
|
||||
+6
-2
@@ -6833,8 +6833,11 @@ 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. A line drawn
|
||||
with the Line Segment tool (Line Properties): `lineLength` (pt, above 0; the line's first end stays in place) and
|
||||
counterclockwise from 3 o'clock; 0 to 360 is the whole ellipse) and `invertPie: true`, which swaps them.
|
||||
`constrainPie: true` with one of `pieStart` and `pieEnd` (the panels' Constrain Pie Angle link) moves the other angle
|
||||
by as much, so each selected ellipse keeps its own span, counterclockwise from its start to its end; a whole ellipse
|
||||
stays whole. `constrainPie: true` with both angles, with neither, or with `invertPie: true` is a parameter error. 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,
|
||||
@@ -6851,6 +6854,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":{"pieStart":350,"constrainPie":true}}}
|
||||
{"name":"run_command","arguments":{"command":"object.setLiveShape","params":{"lineLength":72,"lineAngle":90}}}
|
||||
```
|
||||
|
||||
|
||||
@@ -1300,6 +1300,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 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`).
|
||||
Ellipse Properties in the Transform panel and the Properties panel's Transform section has a Constrain Pie Angle link beside Pie Start and Pie End Angle: while it is on, a typed angle moves the other one by the same amount, so the pie keeps its size, as [the help page](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/modify-live-shapes/live-shape-properties.html) describes (`object.setLiveShape {pieStart or pieEnd, constrainPie}`). These rules are VectorCraft's own: the link starts off at every launch and is not saved; the two panels share it; each selected ellipse keeps its own span, counted counterclockwise from its start angle to its end angle and across 0°, in one undo step for all of them; a whole ellipse stays whole; after Invert Pie the swapped span is kept; and the on-canvas pie widgets still move one angle at a time (tests `the_constrain_pie_angle_link_keeps_the_span` and, through the engine, `constrain_pie_keeps_each_ellipses_span`).
|
||||
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