mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-21 01:44:57 +01:00
Merge remote-tracking branch 'origin/main' into feat/brushes-item-context-menu
# Conflicts: # docs/target-app-parity.md
This commit is contained in:
commit
52a36ea1cc
22 files changed
+1173
-105
No files matched your search
@@ -500,11 +500,73 @@ impl Document {
|
||||
self.patterns.iter_mut().find(|p| p.name == name)
|
||||
}
|
||||
|
||||
/// The [`Self::unknown`] key that holds each symbol set's Symbol Set Density, `{set id: density}`.
|
||||
/// [`Self::reid`] gives a copy of a set in this document the density recorded for its source, and
|
||||
/// [`Self::carry_set_densities`] gives a pasted set the density recorded for it at Copy.
|
||||
pub const SYMBOL_SET_DENSITY_KEY: &'static str = "symbolSetDensity";
|
||||
|
||||
/// The Symbol Set Densities recorded for `nodes` and their descendants, by id.
|
||||
pub fn set_densities_of(&self, nodes: &[Node]) -> std::collections::BTreeMap<NodeId, serde_json::Value> {
|
||||
let Some(serde_json::Value::Object(record)) = self.unknown.get(Self::SYMBOL_SET_DENSITY_KEY) else { return Default::default() };
|
||||
let mut out = std::collections::BTreeMap::new();
|
||||
let mut stack: Vec<&Node> = nodes.iter().collect();
|
||||
while let Some(n) = stack.pop() {
|
||||
if let Some(v) = record.get(&n.id.0.to_string()) {
|
||||
out.insert(n.id, v.clone());
|
||||
}
|
||||
stack.extend(n.children().into_iter().flatten().map(|c| &**c));
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Record for `copy`, a [`Self::reid`] copy of `source`, and its descendants the Symbol Set
|
||||
/// Densities that `densities` holds for `source` and its descendants, and none for those it
|
||||
/// holds none for (whatever [`Self::reid`] recorded).
|
||||
pub fn carry_set_densities(&mut self, source: &Node, copy: &Node, densities: &std::collections::BTreeMap<NodeId, serde_json::Value>) {
|
||||
if densities.is_empty() && !self.unknown.contains_key(Self::SYMBOL_SET_DENSITY_KEY) {
|
||||
return;
|
||||
}
|
||||
let mut pairs = vec![(source, copy)];
|
||||
while let Some((s, c)) = pairs.pop() {
|
||||
match densities.get(&s.id) {
|
||||
Some(v) => {
|
||||
if let serde_json::Value::Object(m) =
|
||||
self.unknown.entry(Self::SYMBOL_SET_DENSITY_KEY).or_insert_with(|| serde_json::Value::Object(Default::default()))
|
||||
{
|
||||
m.insert(c.id.0.to_string(), v.clone());
|
||||
}
|
||||
}
|
||||
None => {
|
||||
if let Some(serde_json::Value::Object(m)) = self.unknown.get_mut(Self::SYMBOL_SET_DENSITY_KEY) {
|
||||
m.remove(&c.id.0.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
if let (Some(sc), Some(cc)) = (s.children(), c.children()) {
|
||||
pairs.extend(sc.iter().zip(cc.iter()).map(|(a, b)| (&**a, &**b)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Deep-clone `node` with fresh ids for it and all descendants, its images' own pixels taken
|
||||
/// in ([`Self::adopt_pixels`]).
|
||||
pub fn reid(&mut self, node: &Node) -> Node {
|
||||
let mut n = node.clone();
|
||||
n.id = self.alloc_id();
|
||||
// A copy of a symbol set keeps the Symbol Set Density recorded for its source, when the source
|
||||
// is this document's node with that id; a node from another document may share the id of an
|
||||
// unrelated set here.
|
||||
let density = self
|
||||
.unknown
|
||||
.get(Self::SYMBOL_SET_DENSITY_KEY)
|
||||
.and_then(|m| m.get(node.id.0.to_string()))
|
||||
.filter(|_| self.node(node.id) == Some(node))
|
||||
.cloned();
|
||||
if let Some(v) = density
|
||||
&& let Some(serde_json::Value::Object(m)) = self.unknown.get_mut(Self::SYMBOL_SET_DENSITY_KEY)
|
||||
{
|
||||
m.insert(n.id.0.to_string(), v);
|
||||
}
|
||||
if let NodeKind::Image(im) = &mut n.kind {
|
||||
self.adopt_image_pixels(im);
|
||||
}
|
||||
|
||||
@@ -686,6 +686,43 @@ fn reid_gives_fresh_ids() {
|
||||
assert!(!ids.contains(&a) && !ids.contains(&b));
|
||||
}
|
||||
|
||||
/// A copy of a node in the document takes the Symbol Set Density recorded for it; a node from
|
||||
/// another document with the same id does not.
|
||||
#[test]
|
||||
fn reid_copies_the_set_density_of_the_documents_own_node() {
|
||||
let (mut d, a, _) = doc_with_rects();
|
||||
d.unknown.insert(Document::SYMBOL_SET_DENSITY_KEY.into(), serde_json::json!({ a.0.to_string(): 2.0 }));
|
||||
let density = |d: &Document, id: NodeId| d.unknown[Document::SYMBOL_SET_DENSITY_KEY].get(id.0.to_string()).cloned();
|
||||
let own = d.node(a).cloned().unwrap();
|
||||
let copy = d.reid(&own);
|
||||
assert_eq!(density(&d, copy.id), Some(serde_json::json!(2.0)));
|
||||
let foreign = Node::group(a, vec![]);
|
||||
let copy = d.reid(&foreign);
|
||||
assert_eq!(density(&d, copy.id), None);
|
||||
}
|
||||
|
||||
/// A pasted copy and its descendants take the densities recorded at Copy, and none where Copy
|
||||
/// recorded none, whatever [`Document::reid`] found for an identical node in the document.
|
||||
#[test]
|
||||
fn carry_set_densities_gives_the_densities_recorded_at_copy() {
|
||||
let (mut d, a, b) = doc_with_rects();
|
||||
d.unknown.insert(Document::SYMBOL_SET_DENSITY_KEY.into(), serde_json::json!({ a.0.to_string(): 2.0 }));
|
||||
let density = |d: &Document, id: NodeId| d.unknown[Document::SYMBOL_SET_DENSITY_KEY].get(id.0.to_string()).cloned();
|
||||
let (na, nb) = (d.node(a).cloned().unwrap(), d.node(b).cloned().unwrap());
|
||||
// Copy recorded nothing for `a`: the copy reid gave a density loses it.
|
||||
let copy = d.reid(&na);
|
||||
assert_eq!(density(&d, copy.id), Some(serde_json::json!(2.0)));
|
||||
d.carry_set_densities(&na, ©, &Default::default());
|
||||
assert_eq!(density(&d, copy.id), None);
|
||||
// Copy recorded 7 for `b` inside a group: the group's copy has none, and `b`'s copy has 7.
|
||||
let g = d.alloc_id();
|
||||
let group = Node::group(g, vec![Arc::new(nb)]);
|
||||
let copy = d.reid(&group);
|
||||
d.carry_set_densities(&group, ©, &[(b, serde_json::json!(7.0))].into_iter().collect());
|
||||
let inner = copy.children().unwrap()[0].id;
|
||||
assert_eq!((density(&d, copy.id), density(&d, inner)), (None, Some(serde_json::json!(7.0))));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn setup_round_trips_and_old_files_load() {
|
||||
let (mut d, _, _) = doc_with_rects();
|
||||
|
||||
@@ -362,7 +362,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Symbol Sprayer",
|
||||
[],
|
||||
None,
|
||||
"{points: [[x,y]…] (a third number is not used; one that isn't a number is an error), name?, radius?: 40, density?: 1..10 (5), scale?: 1, alt?: bool (remove instances), attributes?: {scrunch?, size?, spin?, screen?, stain?, style?: average|userDefined (average)}, color? (#rrggbbaa and #rgba are refused), keepModel?: bool (as paint.setFill), style?: name} spray instances into a symbol set → {id, count}. Each of `attributes` says what a new instance takes: average, the mean of the selected set's instances within `radius` of the stroke point (their spacing along the stroke, size, rotation, opacity, and the stain or style of the nearest one that has one at the mean amount), and with none there the symbol's size, no rotation, full opacity and no stain or style; or userDefined: spacing from the symbol's size and `density`, the symbol's size times `scale`, turned the way the stroke runs there (not turned for one point), full opacity, stained in full with `color` (default: the fill color), and the fill of graphic style `style` (default: the first style after the default one) in full; a `style` the document does not have is then an error. The stain and the style are both the instance's fill, and the style replaces the stain. Another key or value in `attributes` is an error",
|
||||
"{points: [[x,y]…] (a third value is a number or null and is not used), name?, radius?: 40, density?: 1..10 (5; a number outside 1..10 is taken as the nearer end), scale?: 1, alt?: bool (remove instances), attributes?: {scrunch?, size?, spin?, screen?, stain?, style?: average|userDefined (average)}, color? (#rrggbbaa and #rgba are refused), keepModel?: bool (as paint.setFill), style?: name} spray instances into a symbol set → {id, count}. Each of `attributes` says what a new instance takes: average, the mean of the selected set's instances within `radius` of the stroke point (their spacing along the stroke, size, rotation, opacity, and the stain or style of the nearest one that has one with an amount above 0, at the mean amount), and with none there the symbol's size, no rotation, full opacity and no stain or style; or userDefined: spacing from the symbol's size and `density`, the symbol's size times `scale`, turned the way the stroke runs there (not turned for one point), full opacity, stained in full with `color` (default: the fill color), and the fill of graphic style `style` (default: the first style after the default one) in full; a `style` the document does not have is then an error. The stain and the style are both the instance's fill, and the style replaces the stain. Another key or value in `attributes` is an error",
|
||||
has_doc,
|
||||
symbol_spray
|
||||
),
|
||||
@@ -380,7 +380,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Symbolism Tool",
|
||||
[],
|
||||
None,
|
||||
"{tool: shift|scrunch|size|spin|stain|screen|style, points: [[x,y,pressure?]…] (pen pressure 0..1, default 1), radius?: 40, intensity?: 1..10 (5), usePressure?: bool (each point's pressure is the intensity there, in place of `intensity`), method?: userDefined|average|random (userDefined; not used by shift), proportional?: bool (size; true), affectsDensity?: bool (size; false), alt?: bool, color? (#rrggbbaa and #rgba are refused), keepModel?: bool (as paint.setFill), style?: name} adjust instances near the points (selection, else all) → {count}. `method` userDefined changes each instance by the tool's amount at its distance from the point; random gives each instance its own share of that amount for the whole stroke, from none to twice it (spin: a turn either way); average moves each instance's value toward the mean of the instances within `radius` of the point (scrunch: its distance from their middle toward their mean distance; size: the geometric mean of their sizes; spin: their mean direction; stain and style: their mean amount; screen: their mean opacity), and `alt` does not reverse it; average leaves an instance without a size (a scale of 0) as it is. With `proportional` false a drag resizes along its own direction (a level drag the width, an upright one the height; the first point takes the direction to the second) and one point resizes both; average resizes both whatever `proportional` is. With `affectsDensity` an instance also moves away from the point as it grows and toward it as it shrinks. An instance counts only when it changes, and no undo step is added when none does (none under the brush, average with each already at the mean, or each already at the tool's limit). A `method` that is none of the three, or a pressure that isn't a number, is an error",
|
||||
"{tool: shift|scrunch|size|spin|stain|screen|style, points: [[x,y,pressure?]…] (pen pressure 0..1, default 1), radius?: 40, intensity?: 1..10 (5), usePressure?: bool (each point's pressure is the intensity there, in place of `intensity`), method?: userDefined|average|random (userDefined; not used by shift), proportional?: bool (size; true), affectsDensity?: bool (size; false), alt?: bool, shift?: bool (shift, size, stain and style; false), color? (#rrggbbaa and #rgba are refused), keepModel?: bool (as paint.setFill), style?: name (a graphic style's; left out, or naming no style in the document, the first style after the default one)} adjust instances near the points (selection, else all) → {count}. `method` userDefined changes each instance by the tool's amount at its distance from the point; random gives each instance its own share of that amount for the whole stroke, from none to twice it (spin: a turn either way; style without `shift`: from none to the userDefined amount); average moves each instance's value toward the mean of the instances within `radius` of the point (scrunch: its distance from their middle toward their mean distance; size: the geometric mean of their sizes; spin: their mean direction; stain and style: their mean amount; screen: their mean opacity), and `alt` does not reverse it; average leaves an instance without a size as it is. With `proportional` false a drag resizes along its own direction, the width by the drag's horizontal share and the height by its vertical share (a level drag the width, an upright one the height, a 45° drag both alike; the first point takes the direction to the second) and one point resizes both; average resizes both whatever `proportional` is. With `affectsDensity` an instance also moves away from the point as it grows and toward it as it shrinks. The style goes on by the brush's strength at each sample, and a stroke's samples add up. With `alt` and without `shift`, userDefined and random style remove all of an instance's appearance items under the brush at once, whatever the brush's strength. `shift` is the tool's Shift form: shift brings the instances within `radius` of any point one place forward among their siblings (with `alt`, one place backward), once for the stroke, and does not move them; size keeps the instances where they are, `affectsDensity` included; stain and style keep each instance's amount and move its paint toward `color` or the style (stain by the tool's amount at its distance from the point, style by the brush's strength there), whatever `method` is, and leave an instance without a stain or style as it is, and `alt` has no effect. An instance counts only when it changes, and no undo step is added when none does (none under the brush, average with each already at the mean, each already at the tool's limit, or shift with nothing to move or change). A `method` that is none of the three, or a pressure that isn't a number, is an error",
|
||||
has_doc,
|
||||
symbol_adjust
|
||||
),
|
||||
|
||||
@@ -86,8 +86,9 @@ pub(super) fn spacing(density: f64) -> f64 {
|
||||
}
|
||||
|
||||
/// The document key that holds each symbol set's Symbol Set Density: `{set id: density}`, written
|
||||
/// when the Symbol Sprayer creates a set and when `symbol.setDensity` spaces it.
|
||||
const SET_DENSITY_KEY: &str = "symbolSetDensity";
|
||||
/// when the Symbol Sprayer creates a set and when `symbol.setDensity` spaces it, and copied to a
|
||||
/// copy of a set by [`Document::reid`].
|
||||
const SET_DENSITY_KEY: &str = Document::SYMBOL_SET_DENSITY_KEY;
|
||||
|
||||
/// The Symbol Set Density symbol set `set` was created at or last given (None when not recorded).
|
||||
fn set_density_of(d: &Document, set: NodeId) -> Option<f64> {
|
||||
@@ -261,7 +262,10 @@ pub(super) fn mean(looks: &[&Look], at: Point, with_gap: bool) -> Option<Mean> {
|
||||
cos += l.angle.cos();
|
||||
opacity += l.opacity;
|
||||
middle += l.center.to_vec2();
|
||||
if let Some((p, o)) = &l.fill {
|
||||
// A fill at no opacity shows nothing: it is no stain or style, and its paint is not taken.
|
||||
if let Some((p, o)) = &l.fill
|
||||
&& *o > 0.0
|
||||
{
|
||||
amount += o;
|
||||
let far = l.center.distance(at);
|
||||
if paint.is_none_or(|(_, nearest)| far < nearest) {
|
||||
|
||||
@@ -118,6 +118,20 @@ fn instances_of(d: &Document, name: Option<&str>) -> Vec<NodeId> {
|
||||
v
|
||||
}
|
||||
|
||||
/// The symbol instances in `nodes` and inside them, each once, in the order a walk of each node in
|
||||
/// turn first reaches them.
|
||||
fn instances_in<'a>(nodes: impl IntoIterator<Item = &'a Node>) -> Vec<NodeId> {
|
||||
let (mut v, mut seen) = (vec![], std::collections::HashSet::new());
|
||||
for n in nodes {
|
||||
n.walk(&mut |c| {
|
||||
if matches!(c.kind, NodeKind::SymbolInstance { .. }) && seen.insert(c.id) {
|
||||
v.push(c.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
v
|
||||
}
|
||||
|
||||
/// The symbols an instance in `n` (its opacity masks included) places, pushed onto `out`.
|
||||
fn art_symbols(n: &Node, out: &mut Vec<String>) {
|
||||
vectorcraft_doc::swatches::walk_with_masks(n, &mut |m| {
|
||||
@@ -917,11 +931,12 @@ fn samples(p: &Value, cmd: &str) -> Result<Vec<(Point, f64)>> {
|
||||
let a = p.get("points").and_then(Value::as_array).ok_or_else(|| bad(cmd, "missing points [[x,y]…]"))?;
|
||||
let mut v = Vec::with_capacity(a.len());
|
||||
for q in a {
|
||||
let (Some(x), Some(y)) = (q.get(0).and_then(Value::as_f64), q.get(1).and_then(Value::as_f64)) else { continue };
|
||||
// The pressure is checked first: a point skipped for its coordinates still has a bad one refused.
|
||||
let pressure = match q.get(2) {
|
||||
None | Some(Value::Null) => 1.0,
|
||||
Some(f) => f.as_f64().filter(|f| f.is_finite()).ok_or_else(|| bad(cmd, format!("a point's pressure must be a number, not {f}")))?,
|
||||
};
|
||||
let (Some(x), Some(y)) = (q.get(0).and_then(Value::as_f64), q.get(1).and_then(Value::as_f64)) else { continue };
|
||||
v.push((Point::new(x, y), pressure.clamp(0.0, 1.0)));
|
||||
}
|
||||
if v.is_empty() || v.iter().any(|(q, _)| !q.x.is_finite() || !q.y.is_finite()) {
|
||||
@@ -930,13 +945,15 @@ fn samples(p: &Value, cmd: &str) -> Result<Vec<(Point, f64)>> {
|
||||
Ok(v)
|
||||
}
|
||||
|
||||
/// The fill of the graphic style `p` names with `style`, else of the document's first style after
|
||||
/// the default one.
|
||||
/// The fill of the graphic style `p` names with `style`, else (no name, or one the document has no
|
||||
/// style for, such as the Symbol Styler's style from another document) of the document's first
|
||||
/// style after the default one.
|
||||
fn style_paint(d: &Document, p: &Value) -> Option<Paint> {
|
||||
match str_param(p, "style") {
|
||||
Some(n) => d.graphic_styles.iter().find(|g| g.name == n).map(|g| g.appearance.fill_paint()),
|
||||
None => d.graphic_styles.get(1).or(d.graphic_styles.first()).map(|g| g.appearance.fill_paint()),
|
||||
}
|
||||
str_param(p, "style")
|
||||
.and_then(|n| d.graphic_styles.iter().find(|g| g.name == n))
|
||||
.or(d.graphic_styles.get(1))
|
||||
.or(d.graphic_styles.first())
|
||||
.map(|g| g.appearance.fill_paint())
|
||||
}
|
||||
|
||||
/// Deterministic per-point jitter in [-1, 1]² (so previews re-applied on the snapshot agree).
|
||||
@@ -976,7 +993,7 @@ pub(super) fn symbol_spray(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
let style = style_paint(&st.doc, p);
|
||||
// Style: User Defined uses the style `style` names, so one the document does not have is an error.
|
||||
if let Some(n) = str_param(p, "style").filter(|_| !modes.style && style.is_none()) {
|
||||
if let Some(n) = str_param(p, "style").filter(|n| !modes.style && !st.doc.graphic_styles.iter().any(|g| g.name == *n)) {
|
||||
return Err(bad(C, format!("unknown graphic style `{n}`")));
|
||||
}
|
||||
let size = natural_size(&st.doc, &name);
|
||||
@@ -1129,6 +1146,7 @@ pub(super) fn symbol_adjust(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let use_pressure = switch_or(p, "usePressure", false, C)?;
|
||||
let proportional = switch_or(p, "proportional", true, C)?;
|
||||
let affects_density = switch_or(p, "affectsDensity", false, C)?;
|
||||
let shift = switch_or(p, "shift", false, C)?;
|
||||
// The Symbol Shifter has no Method.
|
||||
let method = if tool == "shift" { method_param(p, C).map(|_| Method::UserDefined)? } else { method_param(p, C)? };
|
||||
// Refused while an object of a dynamic instance's art is selected: the instance stays as it is.
|
||||
@@ -1141,20 +1159,8 @@ pub(super) fn symbol_adjust(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let style_paint = style_paint(&st.doc, p);
|
||||
let candidates: Vec<NodeId> = {
|
||||
let d = &st.doc;
|
||||
let mut v = vec![];
|
||||
if st.selection.is_empty() {
|
||||
v = instances_of(d, None);
|
||||
} else {
|
||||
for id in &st.selection.objects {
|
||||
if let Some(n) = d.node(*id) {
|
||||
n.walk(&mut |c| {
|
||||
if matches!(c.kind, NodeKind::SymbolInstance { .. }) && !v.contains(&c.id) {
|
||||
v.push(c.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut v =
|
||||
if st.selection.is_empty() { instances_of(d, None) } else { instances_in(st.selection.objects.iter().filter_map(|id| d.node(*id))) };
|
||||
let editable = d.editable();
|
||||
v.retain(|id| editable(*id));
|
||||
v
|
||||
@@ -1172,12 +1178,39 @@ pub(super) fn symbol_adjust(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
// for the whole stroke (and for every preview of it).
|
||||
let first = pts.first().map_or(Point::ZERO, |(q, _)| *q);
|
||||
let share = |id: NodeId| if method == Method::Random { jitter(id.0 as usize, first).0 + 1.0 } else { 1.0 };
|
||||
// Shift with the Symbol Shifter: the instances under the brush come one place forward among
|
||||
// their siblings (with `alt`, go one place backward), once for the whole stroke.
|
||||
if tool == "shift" && shift {
|
||||
let count = crate::cmd::colorcmds::edit_if_changed(s, label, |_, d| {
|
||||
let under: std::collections::HashSet<NodeId> = candidates
|
||||
.iter()
|
||||
.copied()
|
||||
.filter(|id| {
|
||||
d.node(*id).and_then(instance_center).is_some_and(|c| {
|
||||
pts.iter().any(|(q, pressure)| (if use_pressure { *pressure } else { intensity }) > 0.0 && c.distance(*q) < radius)
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
let moved = restack(d, &under, alt)?;
|
||||
Ok((moved, moved > 0))
|
||||
})?;
|
||||
return Ok(json!({ "count": count }));
|
||||
}
|
||||
// Shift with the Symbol Stainer or the Symbol Styler: the paint an instance's stain or style
|
||||
// moves toward, and the share of the brush's strength it moves by. Shift with the Symbol Sizer
|
||||
// keeps the instances where they are, Resizing Affects Density included.
|
||||
let recolor = match tool.as_str() {
|
||||
"stain" if shift => Some((Paint::solid(color), 0.15)),
|
||||
"style" if shift => Some((style_paint.clone().unwrap_or(Paint::solid(color)), 1.0)),
|
||||
_ => None,
|
||||
};
|
||||
let spread = affects_density && !shift;
|
||||
// No undo step when no instance changes (none under the brush, or Average with each at the mean).
|
||||
let count = crate::cmd::colorcmds::edit_if_changed(s, label, |orig, d| {
|
||||
let mut touched = std::collections::BTreeSet::new();
|
||||
let mut sides = Sides::new();
|
||||
for (j, (q, pressure)) in pts.iter().enumerate() {
|
||||
let delta = if j > 0 { *q - pts[j - 1].0 } else { Vec2::ZERO };
|
||||
let delta = j.checked_sub(1).and_then(|i| pts.get(i)).map_or(Vec2::ZERO, |(prev, _)| *q - *prev);
|
||||
// Use Pressure Pen: the pen's pressure at the point is the intensity there.
|
||||
let strength = if use_pressure { *pressure } else { intensity };
|
||||
// Average: the mean of the instances under the brush, as they are at this point.
|
||||
@@ -1198,6 +1231,14 @@ pub(super) fn symbol_adjust(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if w <= 0.0 {
|
||||
continue;
|
||||
}
|
||||
// Shift with the Symbol Stainer or the Symbol Styler: the instance keeps the amount
|
||||
// of its stain or style, and its paint moves toward the color or the style. An
|
||||
// instance without one, or without a size, is left as it is.
|
||||
if let Some((to, step)) = &recolor {
|
||||
let fill = d.node(*id).and_then(|n| look(d, n, &mut sides)).and_then(|l| l.fill);
|
||||
touched.extend(recolor_keeping_amount(d, *id, fill, to, step * w).then_some(*id));
|
||||
continue;
|
||||
}
|
||||
// Average needs the instance's own values, so it leaves an instance without a size
|
||||
// as it is; the other methods change it as before.
|
||||
// The instance's own values are read for Average only.
|
||||
@@ -1261,8 +1302,9 @@ pub(super) fn symbol_adjust(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
};
|
||||
n.transform(about(Affine::scale_non_uniform(kx, ky)), false);
|
||||
// Resizing Affects Density: instances move away from the brush's center as
|
||||
// they grow and toward it as they shrink.
|
||||
if affects_density {
|
||||
// they grow and toward it as they shrink. Shift keeps the instances where
|
||||
// they are, so the set's density stays as it was.
|
||||
if spread {
|
||||
n.transform(Affine::translate((c - *q) * ((kx * ky).sqrt() - 1.0)), false);
|
||||
}
|
||||
}
|
||||
@@ -1280,9 +1322,10 @@ pub(super) fn symbol_adjust(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
"stain" | "style" => {
|
||||
let paint = if tool == "style" { style_paint.clone().unwrap_or(Paint::solid(color)) } else { Paint::solid(color) };
|
||||
let (paint, o) = match &avg {
|
||||
// Toward the mean amount, keeping the stain or style the instance has.
|
||||
// Toward the mean amount, keeping the stain or style the instance has
|
||||
// (one at no opacity is none).
|
||||
Some((t, look)) => {
|
||||
let (own, cur) = look.fill.clone().map_or((None, 0.0), |(p, o)| (Some(p), o));
|
||||
let (own, cur) = look.fill.clone().filter(|(_, o)| *o > 0.0).map_or((None, 0.0), |(p, o)| (Some(p), o));
|
||||
(own.or(t.paint.clone()).unwrap_or(paint), (cur + (t.amount - cur) * w.min(1.0)) as f32)
|
||||
}
|
||||
// Alt with the Symbol Styler removes the instance's appearance.
|
||||
@@ -1292,11 +1335,11 @@ pub(super) fn symbol_adjust(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
None => {
|
||||
let cur = n.appearance.fill().filter(|f| f.paint == paint).map(|f| f.opacity).unwrap_or(0.0);
|
||||
// The style goes on gradually, by the brush's strength there: in
|
||||
// full at the center at full intensity or pressure.
|
||||
let step = match (tool.as_str(), method) {
|
||||
// Random: the instance's share of the style, scaled by the
|
||||
// brush strength there.
|
||||
("style", Method::Random) => (share / 2.0 * w.min(1.0)) as f32,
|
||||
("style", _) => 1.0,
|
||||
("style", Method::Random) => (w * share / 2.0) as f32,
|
||||
("style", _) => w as f32,
|
||||
_ => (0.15 * w * share) as f32,
|
||||
};
|
||||
(paint, if alt { cur - step } else { cur + step })
|
||||
@@ -1324,9 +1367,108 @@ pub(super) fn symbol_adjust(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
}
|
||||
}
|
||||
// An instance the stroke moved away and back again is not counted.
|
||||
// An instance the stroke moved away and back again, or reached but left as it was (at a
|
||||
// limit already), is not counted.
|
||||
touched.retain(|id| d.node(*id) != orig.node(*id));
|
||||
Ok((touched.len(), !touched.is_empty()))
|
||||
})?;
|
||||
Ok(json!({ "count": count }))
|
||||
}
|
||||
|
||||
/// Move the paint of instance `id`'s stain or style (`fill`, its topmost fill with the amount)
|
||||
/// toward `to` by `t`. The fill keeps its amount and everything else it has, and the instance's
|
||||
/// other appearance items stay as they are. A paint with no form between it and `to` (a solid
|
||||
/// color and a pattern, say) takes `to` at once, so repeated strokes below half strength still
|
||||
/// reach it. An instance without a stain or style, or one whose paint does not change, is left as
|
||||
/// it is. Returns whether it changed.
|
||||
fn recolor_keeping_amount(d: &mut Document, id: NodeId, fill: Option<(Paint, f64)>, to: &Paint, t: f64) -> bool {
|
||||
use vectorcraft_doc::blend::lerp_paint;
|
||||
let Some((own, _)) = fill.filter(|(_, o)| *o > 0.0) else { return false };
|
||||
let t = t.clamp(0.0, 1.0) as f32;
|
||||
let mut paint = lerp_paint(&own, to, t);
|
||||
// `lerp_paint` switches such a pair halfway, so just below half it still gives `own`.
|
||||
if paint == own && t > 0.0 && lerp_paint(&own, to, 0.49) == own {
|
||||
paint = to.clone();
|
||||
}
|
||||
if paint == own {
|
||||
return false;
|
||||
}
|
||||
let Some(f) = d.node_mut(id).and_then(|n| n.appearance.fill_mut()) else { return false };
|
||||
f.paint = paint;
|
||||
true
|
||||
}
|
||||
|
||||
/// Bring each of `ids` one place forward among its siblings past a sibling that is not one of them
|
||||
/// (`back`: one place backward). Ones already in front of (behind) every other sibling stay, and
|
||||
/// so do the clipping path of a clip group and the ruler guides above a layer's art. Returns how
|
||||
/// many moved.
|
||||
fn restack(d: &mut Document, ids: &std::collections::HashSet<NodeId>, back: bool) -> Result<usize> {
|
||||
let parents: std::collections::BTreeSet<Option<NodeId>> = ids.iter().map(|id| d.parent_of(*id)).collect();
|
||||
let mut moved = 0;
|
||||
for par in parents {
|
||||
let floor = usize::from(par.and_then(|p| d.node(p)).is_some_and(Node::clips));
|
||||
let ch = d.children_mut(par)?;
|
||||
let len = Node::guide_run_start(ch);
|
||||
if len <= floor + 1 {
|
||||
continue;
|
||||
}
|
||||
let picked = |n: &Arc<Node>| ids.contains(&n.id);
|
||||
if back {
|
||||
for i in floor + 1..len {
|
||||
if picked(&ch[i]) && !picked(&ch[i - 1]) {
|
||||
ch.swap(i - 1, i);
|
||||
moved += 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for i in (floor..len - 1).rev() {
|
||||
if picked(&ch[i]) && !picked(&ch[i + 1]) {
|
||||
ch.swap(i, i + 1);
|
||||
moved += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(moved)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn instance(id: u64) -> Arc<Node> {
|
||||
Arc::new(Node::new(NodeId(id), NodeKind::SymbolInstance { symbol: "Dot".into(), xf: Affine::IDENTITY }))
|
||||
}
|
||||
|
||||
/// The instances come out in the order a search of the list built so far gives: nested
|
||||
/// groups, a group listed twice, a member listed after its group and one listed before it.
|
||||
#[test]
|
||||
fn instances_in_matches_searching_the_list_so_far() {
|
||||
let groups: Vec<Node> = (0..40u64)
|
||||
.map(|g| {
|
||||
let base = g * 100;
|
||||
let mut children: Vec<Arc<Node>> = (0..40).map(|i| instance(base + i)).collect();
|
||||
let inner = (40..50).map(|i| instance(base + i)).collect();
|
||||
children.insert(20, Arc::new(Node::group(NodeId(base + 90), inner)));
|
||||
children.push(Arc::new(Node::group(NodeId(base + 91), vec![])));
|
||||
Node::group(NodeId(base + 99), children)
|
||||
})
|
||||
.collect();
|
||||
let early = Node::new(NodeId(1_245), NodeKind::SymbolInstance { symbol: "Dot".into(), xf: Affine::IDENTITY });
|
||||
let late = Node::new(NodeId(305), NodeKind::SymbolInstance { symbol: "Dot".into(), xf: Affine::IDENTITY });
|
||||
let nodes: Vec<&Node> = std::iter::once(&early).chain(&groups).chain([&groups[0], &late, &groups[7]]).collect();
|
||||
let mut searched = vec![];
|
||||
for n in &nodes {
|
||||
n.walk(&mut |c| {
|
||||
if matches!(c.kind, NodeKind::SymbolInstance { .. }) && !searched.contains(&c.id) {
|
||||
searched.push(c.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
let found = instances_in(nodes.iter().copied());
|
||||
assert_eq!(found, searched);
|
||||
assert_eq!(found.len(), 2_000);
|
||||
assert_eq!(found[0], NodeId(1_245));
|
||||
assert!(instances_in([]).is_empty());
|
||||
}
|
||||
}
|
||||
@@ -109,6 +109,9 @@ pub struct Clipboard {
|
||||
/// The selected ruler guides copied with (or without) the objects (#3226), as canvas guides on
|
||||
/// no layer: pasting puts them on the layer new art goes to, moved as the objects are.
|
||||
pub guides: Vec<vectorcraft_doc::Guide>,
|
||||
/// The Symbol Set Density recorded at Copy for each copied symbol set, by its id in
|
||||
/// [`Self::nodes`]: a pasted set packs from it.
|
||||
pub set_densities: BTreeMap<NodeId, Value>,
|
||||
/// The RGB and CMYK profiles the objects' colors showed through in the document they were
|
||||
/// copied from (its assigned profiles, else the working spaces then), by name; none for objects
|
||||
/// from outside an open document. Paste compares them with the destination's
|
||||
@@ -484,6 +487,7 @@ impl Clipboard {
|
||||
})
|
||||
.collect(),
|
||||
guides: self.guides.clone(),
|
||||
set_densities: self.set_densities.clone(),
|
||||
source_profiles: self.source_profiles.clone(),
|
||||
colors_converted: self.colors_converted,
|
||||
}
|
||||
|
||||
@@ -1161,6 +1161,7 @@ impl Clipboard {
|
||||
char_styles: pick(Res::CharStyle, &src.char_styles),
|
||||
para_styles: pick(Res::ParaStyle, &src.para_styles),
|
||||
brushes,
|
||||
set_densities: src.set_densities_of(&nodes),
|
||||
nodes,
|
||||
..Default::default()
|
||||
}
|
||||
|
||||
@@ -1568,6 +1568,8 @@ fn paste_clip(s: &mut Session, p: &Value, mode: PasteMode, clip: &Clipboard, cho
|
||||
for xf in placements {
|
||||
for (k, n) in clip.nodes.iter().enumerate() {
|
||||
let mut c = d.reid(n);
|
||||
// A pasted symbol set packs from the density recorded for it at Copy.
|
||||
d.carry_set_densities(n, &c, &clip.set_densities);
|
||||
imported.apply(&mut c);
|
||||
let sc = vectorcraft_doc::Scaling { patterns: mode == PasteMode::Drag, ..Default::default() };
|
||||
if xf != Affine::IDENTITY {
|
||||
|
||||
@@ -202,6 +202,7 @@ mod symbol_nine_slice;
|
||||
mod symbolbounds;
|
||||
mod symboledit;
|
||||
mod symbolism_options;
|
||||
mod symbolism_shift;
|
||||
mod symbollib;
|
||||
mod tangent_line;
|
||||
mod targeting;
|
||||
|
||||
@@ -180,6 +180,48 @@ fn average_at_the_mean_adds_no_undo_step() {
|
||||
assert!(state(&s) == before);
|
||||
}
|
||||
|
||||
/// An instance the brush reaches but leaves as it is (the Symbol Screener with Alt on an opaque
|
||||
/// instance, or without Alt on one at the lowest opacity it gives) is not counted, and a stroke
|
||||
/// that changes no instance adds no undo step.
|
||||
#[test]
|
||||
fn an_instance_left_as_it_is_is_not_counted() {
|
||||
let mut s = session();
|
||||
let (opaque, faint) = (dot(&mut s, 100.0, 150.0), dot(&mut s, 300.0, 150.0));
|
||||
s.execute("transparency.set", &json!({"ids": [faint.0], "opacity": 5})).unwrap();
|
||||
let before = state(&s);
|
||||
let r = adjust(&mut s, json!({"tool": "screen", "points": [[100, 150]], "radius": 30, "intensity": 10, "alt": true}));
|
||||
assert_eq!(r["count"], 0, "Alt on an opaque instance");
|
||||
let r = adjust(&mut s, json!({"tool": "screen", "points": [[300, 150]], "radius": 30, "intensity": 10}));
|
||||
assert_eq!(r["count"], 0, "an instance at 5%");
|
||||
assert!(state(&s) == before, "a stroke that changes nothing changed the document or its history");
|
||||
// A stroke over both counts only the instance it changes.
|
||||
let r = adjust(&mut s, json!({"tool": "screen", "points": [[200, 150]], "radius": 150, "intensity": 10}));
|
||||
assert_eq!(r["count"], 1);
|
||||
assert!(node(&s, opaque).opacity < 1.0 && node(&s, faint).opacity == 0.05);
|
||||
}
|
||||
|
||||
/// Average gives an opacity below 5% when that is the mean: the Symbol Sprayer's new instance and
|
||||
/// the Symbol Screener's instances take the mean of the instances under the brush.
|
||||
#[test]
|
||||
fn average_keeps_a_mean_opacity_below_five_percent() {
|
||||
let mut s = session();
|
||||
let set = NodeId(s.execute("symbol.spray", &json!({"name": "Dot", "points": [[200, 150]], "radius": 4})).unwrap()["id"].as_u64().unwrap());
|
||||
let first = members(&s, set)[0];
|
||||
s.execute("transparency.set", &json!({"ids": [first.0], "opacity": 2})).unwrap();
|
||||
s.select(|_, sel| sel.set([set])).unwrap();
|
||||
s.execute("symbol.spray", &json!({"name": "Dot", "points": [[215, 150]], "radius": 30})).unwrap();
|
||||
let sprayed = *members(&s, set).last().unwrap();
|
||||
assert!((node(&s, sprayed).opacity - 0.02).abs() < 1e-6, "{}", node(&s, sprayed).opacity);
|
||||
// Two instances at 0% and 4%: Average brings both toward 2%, and neither goes past it.
|
||||
let mut s = session();
|
||||
let (a, b) = (dot(&mut s, 200.0, 150.0), dot(&mut s, 220.0, 150.0));
|
||||
s.execute("transparency.set", &json!({"ids": [a.0], "opacity": 0})).unwrap();
|
||||
s.execute("transparency.set", &json!({"ids": [b.0], "opacity": 4})).unwrap();
|
||||
adjust(&mut s, json!({"tool": "screen", "points": [[210, 150]], "radius": 40, "intensity": 10, "method": "average"}));
|
||||
let (pa, pb) = (node(&s, a).opacity, node(&s, b).opacity);
|
||||
assert!(pa > 0.0 && pa <= 0.02 + 1e-6 && (0.02 - 1e-6..0.04).contains(&pb), "{pa} {pb}");
|
||||
}
|
||||
|
||||
/// Average evens out the Symbol Stainer's amount and the Symbol Scruncher's spacing.
|
||||
#[test]
|
||||
fn average_evens_out_the_stain_and_the_spacing() {
|
||||
@@ -279,6 +321,38 @@ fn an_unknown_method_is_refused() {
|
||||
assert_eq!(center(&s, a), Point::new(200.0, 150.0));
|
||||
}
|
||||
|
||||
/// `tool.setOption` refuses a Symbolism Tools Options value of the wrong kind or name, and the
|
||||
/// tool's options stay as they were.
|
||||
#[test]
|
||||
fn tool_set_option_refuses_bad_symbolism_options() {
|
||||
let mut s = session();
|
||||
let before = s.tool_options_of("symbolSizer");
|
||||
for (key, bad, want) in [
|
||||
("method", json!("smooth"), "`method` must be one of userDefined, average, random"),
|
||||
("sprayStain", json!("random"), "`sprayStain` must be one of average, userDefined"),
|
||||
("usePressure", json!("yes"), "`usePressure` must be true or false"),
|
||||
("diameter", json!("big"), "`diameter` must be a number from 2 to 2000"),
|
||||
("style", json!(3), "`style` must be a string or null"),
|
||||
("diameter", json!(1), "`diameter` must be a number from 2 to 2000"),
|
||||
] {
|
||||
let r = s.set_tool_option_cmd(&json!({"tool": "symbolSizer", "values": {key: bad}}));
|
||||
assert_eq!(r, Err(want.to_string()), "{key}");
|
||||
assert_eq!(s.tool_options_of("symbolSizer"), before, "{key}");
|
||||
}
|
||||
let r = s.set_tool_option_cmd(&json!({"tool": "symbolSizer", "values": {"method": "random", "sprayStain": "userDefined"}})).unwrap();
|
||||
assert_eq!((r["method"].as_str(), r["sprayStain"].as_str()), (Some("random"), Some("userDefined")));
|
||||
// Every option the options dialog sends is taken, together.
|
||||
let all = json!({
|
||||
"diameter": 100.0, "intensity": 6.0, "density": 4.0, "usePressure": true, "method": "average", "showBrush": false,
|
||||
"sprayScrunch": "userDefined", "spraySize": "userDefined", "spraySpin": "userDefined", "sprayScreen": "userDefined",
|
||||
"sprayStain": "average", "sprayStyle": "userDefined", "proportional": false, "affectsDensity": true,
|
||||
});
|
||||
let r = s.set_tool_option_cmd(&json!({"tool": "symbolSizer", "values": all})).unwrap();
|
||||
for (key, v) in all.as_object().unwrap() {
|
||||
assert_eq!(&r[key], v, "{key}");
|
||||
}
|
||||
}
|
||||
|
||||
/// With `usePressure` each point's pen pressure is the intensity there; without it the pressure is
|
||||
/// not used. A pressure that isn't a number is an error.
|
||||
#[test]
|
||||
@@ -316,6 +390,13 @@ fn pen_pressure_is_the_intensity_with_use_pressure() {
|
||||
json!({"tool": tool, "points": [[200, 150, "hard"]], "usePressure": true}),
|
||||
"a point's pressure must be a number, not \"hard\"",
|
||||
);
|
||||
// Also on a point without coordinates, beside one that has them.
|
||||
refused(
|
||||
&mut s,
|
||||
"symbol.adjust",
|
||||
json!({"tool": tool, "points": [[200, 150], [null, 0, "bad"]], "usePressure": true}),
|
||||
"a point's pressure must be a number, not \"bad\"",
|
||||
);
|
||||
}
|
||||
for key in ["usePressure", "proportional", "affectsDensity"] {
|
||||
let mut p = json!({"tool": "size", "points": [[200, 150]]});
|
||||
@@ -644,6 +725,45 @@ fn set_density_starts_from_the_density_a_set_was_sprayed_at() {
|
||||
assert!((center(&s, a).x - (150.0 - 50.0 * 0.25 / 0.65)).abs() < 1e-9, "{:?}", center(&s, a));
|
||||
}
|
||||
|
||||
/// A set duplicated packs from the density recorded for its source, and a pasted set from the
|
||||
/// density its source had at Copy: after Cut, after the source is given another density, and in
|
||||
/// another document.
|
||||
#[test]
|
||||
fn a_copied_set_packs_from_the_density_of_its_source() {
|
||||
for copy in ["duplicate", "paste", "cut", "changed after copy", "other document"] {
|
||||
let mut s = session();
|
||||
let row: Vec<Value> = (0..4).map(|i| json!([60.0 + 60.0 * f64::from(i), 150.0])).collect();
|
||||
let set =
|
||||
NodeId(s.execute("symbol.spray", &json!({"name": "Dot", "points": row, "radius": 4, "density": 2})).unwrap()["id"].as_u64().unwrap());
|
||||
s.select(|_, sel| sel.set([set])).unwrap();
|
||||
let first = match copy {
|
||||
"duplicate" => "edit.duplicate",
|
||||
"cut" => "edit.cut",
|
||||
_ => "edit.copy",
|
||||
};
|
||||
s.execute(first, &json!({})).unwrap();
|
||||
if copy == "changed after copy" {
|
||||
s.execute("symbol.setDensity", &json!({"from": 5, "to": 9, "ids": [set.0]})).unwrap();
|
||||
}
|
||||
if copy == "other document" {
|
||||
s.execute("file.new", &json!({"width": 400, "height": 300})).unwrap();
|
||||
}
|
||||
if copy != "duplicate" {
|
||||
s.execute("edit.paste", &json!({})).unwrap();
|
||||
}
|
||||
let copied = s.doc().unwrap().selection.objects.clone();
|
||||
assert!(copied.len() == 1 && (copy == "other document" || copied[0] != set), "{copy}: {copied:?}");
|
||||
let ids = members(&s, copied[0]);
|
||||
let xs = |s: &Session| ids.iter().map(|id| center(s, *id).x).collect::<Vec<_>>();
|
||||
let was = xs(&s);
|
||||
let middle = was.iter().sum::<f64>() / 4.0;
|
||||
s.execute("symbol.setDensity", &json!({"from": 5, "to": 9, "ids": [copied[0].0]})).unwrap();
|
||||
for (before, after) in was.iter().zip(xs(&s)) {
|
||||
assert!((after - (middle + (before - middle) * 0.25 / 0.95)).abs() < 1e-9, "{copy}: {before} -> {after}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A set of one instance takes the new density without moving, as one undo step, so a later change
|
||||
/// packs it from that density; setting the density it already has adds no undo step.
|
||||
#[test]
|
||||
@@ -719,6 +839,102 @@ fn set_density_refuses_bad_densities_and_objects_without_a_set() {
|
||||
assert!(state(&s) == before);
|
||||
}
|
||||
|
||||
/// The Symbol Styler applies the style gradually, by the brush's strength at the instance: the pen
|
||||
/// pressure with Use Pressure Pen, else the intensity, less toward the brush's edge. Random gives
|
||||
/// each instance a share of that amount.
|
||||
#[test]
|
||||
fn the_styler_applies_the_style_by_the_brushs_strength() {
|
||||
let styled = |extra: Value, x: f64| {
|
||||
let mut s = session();
|
||||
let a = dot(&mut s, 100.0, 150.0);
|
||||
let id = s.execute("shape.rectangle", &json!({"x": 300, "y": 250, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap();
|
||||
s.execute("paint.setFill", &json!({"color": "#0000ff"})).unwrap();
|
||||
s.execute("graphicStyle.new", &json!({"name": "Blue", "id": id})).unwrap();
|
||||
s.select(|_, sel| sel.clear()).unwrap();
|
||||
let mut p = json!({"tool": "style", "points": [[x, 150]], "radius": 10, "style": "Blue"});
|
||||
p.as_object_mut().unwrap().extend(extra.as_object().unwrap().clone());
|
||||
adjust(&mut s, p);
|
||||
node(&s, a).appearance.fill().map_or(0.0, |f| f.opacity)
|
||||
};
|
||||
let near = |a: f32, b: f32| (a - b).abs() < 1e-6;
|
||||
assert!(near(styled(json!({"intensity": 10}), 100.0), 1.0), "full strength at the center");
|
||||
assert!(near(styled(json!({"intensity": 5}), 100.0), 0.5));
|
||||
assert!(near(styled(json!({"intensity": 10}), 105.0), 0.5), "half way to the edge");
|
||||
assert!(near(styled(json!({"usePressure": true, "points": [[100, 150, 0.25]]}), 100.0), 0.25));
|
||||
assert!(near(styled(json!({"usePressure": true, "points": [[100, 150, 1.0]]}), 100.0), 1.0));
|
||||
assert_eq!(styled(json!({"usePressure": true, "points": [[100, 150, 0.0]]}), 100.0), 0.0, "no pressure, no style");
|
||||
// Random: instances the same distance from the point take different amounts, each from none to
|
||||
// the User Defined amount there (0.25: pressure 0.5, half way to the brush's edge).
|
||||
let mut s = session();
|
||||
let ring: Vec<NodeId> = (0..6)
|
||||
.map(|i| {
|
||||
let a = f64::from(i) * std::f64::consts::TAU / 6.0;
|
||||
dot(&mut s, 100.0 + 5.0 * a.cos(), 150.0 + 5.0 * a.sin())
|
||||
})
|
||||
.collect();
|
||||
let id = s.execute("shape.rectangle", &json!({"x": 300, "y": 250, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap();
|
||||
s.execute("paint.setFill", &json!({"color": "#0000ff"})).unwrap();
|
||||
s.execute("graphicStyle.new", &json!({"name": "Blue", "id": id})).unwrap();
|
||||
s.select(|_, sel| sel.clear()).unwrap();
|
||||
adjust(&mut s, json!({"tool": "style", "points": [[100, 150, 0.5]], "radius": 10, "usePressure": true, "method": "random", "style": "Blue"}));
|
||||
let amounts: Vec<f32> = ring.iter().map(|a| node(&s, *a).appearance.fill().map_or(0.0, |f| f.opacity)).collect();
|
||||
assert!(amounts.iter().all(|a| *a <= 0.25 + 1e-6), "{amounts:?}");
|
||||
assert!(amounts.iter().any(|a| *a > 0.0), "{amounts:?}");
|
||||
assert!(amounts.iter().any(|a| (a - amounts[0]).abs() > 1e-6), "{amounts:?}");
|
||||
}
|
||||
|
||||
/// A sprayed instance's Average stain is the stain of the nearest instance whose stain shows: one
|
||||
/// at no opacity is passed over and counts as no stain in the mean amount.
|
||||
#[test]
|
||||
fn average_spray_passes_over_a_stain_at_no_opacity() {
|
||||
use vectorcraft_color::{Color, Paint};
|
||||
let mut s = session();
|
||||
let set =
|
||||
NodeId(s.execute("symbol.spray", &json!({"name": "Dot", "points": [[100, 150], [130, 150]], "radius": 4})).unwrap()["id"].as_u64().unwrap());
|
||||
let ids = members(&s, set);
|
||||
assert_eq!(ids.len(), 2);
|
||||
s.edit("Stains", |d, _| {
|
||||
for (id, color, amount) in [(ids[0], Color::rgb(1.0, 0.0, 0.0), 0.0), (ids[1], Color::rgb(0.0, 0.0, 1.0), 1.0)] {
|
||||
let n = d.node_mut(id).unwrap();
|
||||
n.appearance.items.retain(|i| !matches!(i, vectorcraft_doc::AppearanceItem::Fill(_)));
|
||||
let mut f = vectorcraft_doc::FillLayer::new(Paint::solid(color));
|
||||
f.opacity = amount;
|
||||
n.appearance.items.insert(0, vectorcraft_doc::AppearanceItem::Fill(f));
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
s.execute("symbol.spray", &json!({"name": "Dot", "points": [[100, 150]], "radius": 40})).unwrap();
|
||||
let new: Vec<NodeId> = members(&s, set).into_iter().filter(|id| !ids.contains(id)).collect();
|
||||
assert_eq!(new.len(), 1);
|
||||
let f = node(&s, new[0]).appearance.fill().cloned().unwrap();
|
||||
assert_eq!(f.paint, Paint::solid(Color::rgb(0.0, 0.0, 1.0)));
|
||||
assert!((f.opacity - 0.5).abs() < 1e-6, "{}", f.opacity);
|
||||
}
|
||||
|
||||
/// The Symbol Shifter moves an instance whose transform flattens it (it has no size), as it moves
|
||||
/// any other, and counts it.
|
||||
#[test]
|
||||
fn the_shifter_moves_an_instance_without_a_size() {
|
||||
let mut s = session();
|
||||
let a = dot(&mut s, 200.0, 150.0);
|
||||
s.edit("Flatten", |d, _| {
|
||||
if let Some(NodeKind::SymbolInstance { xf, .. }) = d.node_mut(a).map(|n| &mut n.kind) {
|
||||
*xf = Affine::new([0.0, 0.0, 0.0, 0.0, 200.0, 150.0]);
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
let r = adjust(&mut s, json!({"tool": "shift", "points": [[200, 150], [210, 150]], "radius": 40, "intensity": 10}));
|
||||
assert_eq!(r["count"], 1);
|
||||
assert!(center(&s, a).x > 200.0, "{:?}", center(&s, a));
|
||||
// Average has no mean of such instances to move toward: it leaves them as they are.
|
||||
let (before, x) = (state(&s), center(&s, a).x);
|
||||
let r = adjust(&mut s, json!({"tool": "screen", "method": "average", "points": [[x, 150]], "radius": 40, "intensity": 10}));
|
||||
assert_eq!(r["count"], 0);
|
||||
assert!(state(&s) == before);
|
||||
}
|
||||
|
||||
/// An instance with no size is shifted and screened as before; only Average, which needs its size,
|
||||
/// leaves it as it is.
|
||||
#[test]
|
||||
@@ -759,6 +975,29 @@ fn an_instance_without_a_size_is_changed_by_every_method_but_average() {
|
||||
assert!(state(&s) == before);
|
||||
}
|
||||
|
||||
/// Average Stainer: an instance whose stain is at no opacity has no stain of its own, so it takes
|
||||
/// the stain the mean picks, not its hidden paint.
|
||||
#[test]
|
||||
fn average_stain_replaces_a_stain_at_no_opacity() {
|
||||
use vectorcraft_color::{Color, Paint};
|
||||
let mut s = session();
|
||||
let (a, b) = (dot(&mut s, 100.0, 150.0), dot(&mut s, 120.0, 150.0));
|
||||
s.edit("Stains", |d, _| {
|
||||
for (id, color, amount) in [(a, Color::rgb(1.0, 0.0, 0.0), 0.0), (b, Color::rgb(0.0, 0.0, 1.0), 1.0)] {
|
||||
let n = d.node_mut(id).unwrap();
|
||||
let mut f = vectorcraft_doc::FillLayer::new(Paint::solid(color));
|
||||
f.opacity = amount;
|
||||
n.appearance.items.insert(0, vectorcraft_doc::AppearanceItem::Fill(f));
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
adjust(&mut s, json!({"tool": "stain", "method": "average", "points": [[100, 150]], "radius": 40, "intensity": 10}));
|
||||
let f = node(&s, a).appearance.fill().cloned().unwrap();
|
||||
assert_eq!(f.paint, Paint::solid(Color::rgb(0.0, 0.0, 1.0)));
|
||||
assert!(f.opacity > 0.0, "{}", f.opacity);
|
||||
}
|
||||
|
||||
/// A stroke that leaves every instance under the brush as it is (each already at full stain, or
|
||||
/// at the least opacity) counts none and adds no undo step.
|
||||
#[test]
|
||||
|
||||
@@ -0,0 +1,272 @@
|
||||
//! The symbolism tools' Shift forms in `symbol.adjust {shift}`: the Symbol Shifter's stacking
|
||||
//! order, the Symbol Sizer keeping the set's density, and the Symbol Stainer and Symbol Styler
|
||||
//! keeping their amount while the color or style changes.
|
||||
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_doc::{Document, Node, NodeKind};
|
||||
use vectorcraft_geom::Point;
|
||||
|
||||
use crate::*;
|
||||
|
||||
/// A document with the 20 pt square symbol "Dot" and nothing selected.
|
||||
fn session() -> Session {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 400, "height": 300})).unwrap();
|
||||
s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 20, "height": 20})).unwrap();
|
||||
s.execute("symbol.new", &json!({"name": "Dot"})).unwrap();
|
||||
s.select(|_, sel| sel.clear()).unwrap();
|
||||
s
|
||||
}
|
||||
|
||||
/// An instance of Dot centered on (`x`, `y`), not selected.
|
||||
fn dot(s: &mut Session, x: f64, y: f64) -> NodeId {
|
||||
let id = NodeId(s.execute("symbol.place", &json!({"name": "Dot", "x": x, "y": y})).unwrap()["id"].as_u64().unwrap());
|
||||
s.select(|_, sel| sel.clear()).unwrap();
|
||||
id
|
||||
}
|
||||
|
||||
fn node(s: &Session, id: NodeId) -> Node {
|
||||
s.doc().unwrap().doc.node(id).cloned().unwrap()
|
||||
}
|
||||
|
||||
fn center(s: &Session, id: NodeId) -> Point {
|
||||
match node(s, id).kind {
|
||||
NodeKind::SymbolInstance { xf, .. } => xf * Point::ZERO,
|
||||
other => panic!("not an instance: {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
fn width(s: &Session, id: NodeId) -> f64 {
|
||||
node(s, id).geometric_bounds().unwrap().width()
|
||||
}
|
||||
|
||||
fn undo_len(s: &Session) -> usize {
|
||||
s.doc().unwrap().history.undo.len()
|
||||
}
|
||||
|
||||
fn state(s: &Session) -> (Document, usize) {
|
||||
((*s.doc().unwrap().doc).clone(), undo_len(s))
|
||||
}
|
||||
|
||||
fn adjust(s: &mut Session, p: Value) -> Value {
|
||||
s.execute("symbol.adjust", &p).unwrap()
|
||||
}
|
||||
|
||||
/// The children of symbol set `set`, in stacking order (the first is at the back).
|
||||
fn members(s: &Session, set: NodeId) -> Vec<NodeId> {
|
||||
node(s, set).children().unwrap().iter().map(|c| c.id).collect()
|
||||
}
|
||||
|
||||
/// The instance's fill: its color as RGB and its amount.
|
||||
fn fill(s: &Session, id: NodeId) -> Option<([f32; 3], f32)> {
|
||||
node(s, id).appearance.fill().map(|f| (f.paint.color().map_or([0.0; 3], |c| c.to_rgb()), f.opacity))
|
||||
}
|
||||
|
||||
/// A symbol set of four instances in a row at x = 40, 120, 200 and 280, selected.
|
||||
fn row(s: &mut Session) -> (NodeId, Vec<NodeId>) {
|
||||
let pts: Vec<Value> = (0..4).map(|i| json!([40.0 + 80.0 * f64::from(i), 150.0])).collect();
|
||||
let set = NodeId(s.execute("symbol.spray", &json!({"name": "Dot", "points": pts, "radius": 4})).unwrap()["id"].as_u64().unwrap());
|
||||
let ids = members(s, set);
|
||||
assert_eq!(ids.len(), 4);
|
||||
(set, ids)
|
||||
}
|
||||
|
||||
/// Shift-click with the Symbol Shifter brings the instances under the brush one place forward in
|
||||
/// the set, and Alt+Shift-click sends them one place backward, without moving them on the canvas.
|
||||
#[test]
|
||||
fn shift_click_with_the_shifter_changes_the_stacking_order() {
|
||||
let mut s = session();
|
||||
let (set, ids) = row(&mut s);
|
||||
let centers: Vec<Point> = ids.iter().map(|id| center(&s, *id)).collect();
|
||||
let click = |s: &mut Session, x: f64, alt: bool| {
|
||||
adjust(s, json!({"tool": "shift", "points": [[x, 150]], "radius": 10, "intensity": 10, "shift": true, "alt": alt}))["count"].clone()
|
||||
};
|
||||
let steps = undo_len(&s);
|
||||
assert_eq!(click(&mut s, 120.0, false), 1);
|
||||
assert_eq!(members(&s, set), [ids[0], ids[2], ids[1], ids[3]]);
|
||||
assert_eq!(undo_len(&s), steps + 1, "one undo step");
|
||||
assert_eq!(ids.iter().map(|id| center(&s, *id)).collect::<Vec<_>>(), centers, "nothing moves on the canvas");
|
||||
assert_eq!(click(&mut s, 120.0, false), 1);
|
||||
assert_eq!(members(&s, set), [ids[0], ids[2], ids[3], ids[1]]);
|
||||
// Already in front of the others: nothing changes and no undo step is added.
|
||||
let before = state(&s);
|
||||
assert_eq!(click(&mut s, 120.0, false), 0);
|
||||
assert!(state(&s) == before);
|
||||
// Alt sends it back one place at a time; at the back it stays.
|
||||
assert_eq!(click(&mut s, 120.0, true), 1);
|
||||
assert_eq!(members(&s, set), [ids[0], ids[2], ids[1], ids[3]]);
|
||||
click(&mut s, 120.0, true);
|
||||
click(&mut s, 120.0, true);
|
||||
assert_eq!(members(&s, set), [ids[1], ids[0], ids[2], ids[3]]);
|
||||
assert_eq!(click(&mut s, 120.0, true), 0);
|
||||
// Two instances under the brush move together past the next one.
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
let both = adjust(&mut s, json!({"tool": "shift", "points": [[40, 150], [120, 150]], "radius": 10, "intensity": 10, "shift": true}));
|
||||
assert_eq!(both["count"], 2);
|
||||
assert_eq!(members(&s, set), [ids[2], ids[0], ids[1], ids[3]]);
|
||||
// Without Shift a drag moves the instances, as before.
|
||||
adjust(&mut s, json!({"tool": "shift", "points": [[280, 150], [290, 150]], "radius": 30, "intensity": 10}));
|
||||
assert!(center(&s, ids[3]).x > centers[3].x);
|
||||
}
|
||||
|
||||
/// Shift with the Symbol Sizer resizes the instances and keeps their centers where they are, even
|
||||
/// with Resizing Affects Density.
|
||||
#[test]
|
||||
fn shift_with_the_sizer_keeps_the_density() {
|
||||
let at = |affects: bool, shift: bool| {
|
||||
let mut s = session();
|
||||
let a = dot(&mut s, 220.0, 150.0);
|
||||
adjust(
|
||||
&mut s,
|
||||
json!({"tool": "size", "points": [[200, 150], [200, 150]], "radius": 60, "intensity": 10, "affectsDensity": affects, "shift": shift}),
|
||||
);
|
||||
(center(&s, a), width(&s, a))
|
||||
};
|
||||
let (moved, _) = at(true, false);
|
||||
assert!(moved.x > 220.5, "{moved:?}");
|
||||
let (kept, grown) = at(true, true);
|
||||
assert!((kept.x - 220.0).abs() < 1e-9 && (kept.y - 150.0).abs() < 1e-9 && grown > 20.5, "{kept:?} {grown}");
|
||||
// It resizes as the Sizer does with Resizing Affects Density off.
|
||||
assert_eq!(at(false, false), (kept, grown));
|
||||
assert_eq!(at(false, true), (kept, grown));
|
||||
}
|
||||
|
||||
/// Shift with the Symbol Stainer keeps the stain's amount and moves its color toward the fill
|
||||
/// color; an instance without a stain is left as it is.
|
||||
#[test]
|
||||
fn shift_with_the_stainer_keeps_the_amount_and_changes_the_color() {
|
||||
let mut s = session();
|
||||
let (a, b) = (dot(&mut s, 100.0, 150.0), dot(&mut s, 300.0, 150.0));
|
||||
adjust(&mut s, json!({"tool": "stain", "points": [[100, 150], [100, 150]], "radius": 5, "intensity": 10, "color": "#ff0000"}));
|
||||
let (red, amount) = fill(&s, a).unwrap();
|
||||
assert!(amount > 0.2 && red[0] > 0.99 && red[2] < 0.01, "{red:?} {amount}");
|
||||
// A second fill below the stain, which Shift leaves as it is.
|
||||
s.edit("Add fill", |d, _| {
|
||||
let n = d.node_mut(a).unwrap();
|
||||
let lower = n.appearance.fill().unwrap().clone();
|
||||
n.appearance.items.insert(0, vectorcraft_doc::AppearanceItem::Fill(vectorcraft_doc::FillLayer { opacity: 0.5, ..lower }));
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
let lower = node(&s, a).appearance.items[0].clone();
|
||||
let stain = |s: &mut Session, x: f64| {
|
||||
adjust(s, json!({"tool": "stain", "points": [[x, 150], [x, 150]], "radius": 5, "intensity": 10, "color": "#0000ff", "shift": true}))
|
||||
};
|
||||
assert_eq!(stain(&mut s, 100.0)["count"], 1);
|
||||
let (color, kept) = fill(&s, a).unwrap();
|
||||
assert_eq!(kept, amount, "the amount stays");
|
||||
assert!(color[0] < red[0] && color[2] > 0.01, "toward blue: {color:?}");
|
||||
assert_eq!((node(&s, a).appearance.items.len(), &node(&s, a).appearance.items[0]), (2, &lower), "the other fill stays");
|
||||
// More strokes go on toward blue, with the amount still the same.
|
||||
for _ in 0..30 {
|
||||
stain(&mut s, 100.0);
|
||||
}
|
||||
let (bluer, kept) = fill(&s, a).unwrap();
|
||||
assert_eq!(kept, amount);
|
||||
assert!(bluer[2] > 0.9 && bluer[0] < 0.1, "{bluer:?}");
|
||||
// Alt has no effect with Shift.
|
||||
let green = json!({"tool": "stain", "points": [[100, 150]], "radius": 5, "intensity": 10, "color": "#00ff00", "shift": true});
|
||||
adjust(&mut s, green.clone());
|
||||
let plain = fill(&s, a);
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
let mut with_alt = green;
|
||||
with_alt["alt"] = json!(true);
|
||||
adjust(&mut s, with_alt);
|
||||
assert_eq!(fill(&s, a), plain);
|
||||
// No stain on b: nothing changes and no undo step is added.
|
||||
let before = state(&s);
|
||||
assert_eq!(stain(&mut s, 300.0)["count"], 0);
|
||||
assert!(state(&s) == before && fill(&s, b).is_none());
|
||||
}
|
||||
|
||||
/// Shift with the Symbol Styler keeps the amount of the instance's stain or style and moves its
|
||||
/// fill toward the selected style's fill.
|
||||
#[test]
|
||||
fn shift_with_the_styler_keeps_the_amount_and_changes_the_style() {
|
||||
let mut s = session();
|
||||
let a = dot(&mut s, 100.0, 150.0);
|
||||
let id = s.execute("shape.rectangle", &json!({"x": 300, "y": 250, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap();
|
||||
s.execute("paint.setFill", &json!({"color": "#0000ff"})).unwrap();
|
||||
s.execute("graphicStyle.new", &json!({"name": "Blue", "id": id})).unwrap();
|
||||
s.select(|_, sel| sel.clear()).unwrap();
|
||||
// A red stain at part strength.
|
||||
adjust(&mut s, json!({"tool": "stain", "points": [[100, 150]], "radius": 5, "intensity": 10, "color": "#ff0000"}));
|
||||
let (red, amount) = fill(&s, a).unwrap();
|
||||
assert!(red[0] > 0.99 && amount > 0.0 && amount < 0.5, "{red:?} {amount}");
|
||||
// Half the brush's strength at a point 2.5 pt from the instance: half way to blue.
|
||||
adjust(&mut s, json!({"tool": "style", "points": [[102.5, 150]], "radius": 5, "intensity": 10, "style": "Blue", "shift": true}));
|
||||
let (mixed, kept) = fill(&s, a).unwrap();
|
||||
assert_eq!(kept, amount);
|
||||
assert!(mixed[0] < 0.99 && mixed[2] > 0.01, "{mixed:?}");
|
||||
// At the brush's center with full intensity it takes the style's fill.
|
||||
adjust(&mut s, json!({"tool": "style", "points": [[100, 150]], "radius": 5, "intensity": 10, "style": "Blue", "shift": true}));
|
||||
let (blue, kept) = fill(&s, a).unwrap();
|
||||
assert_eq!(kept, amount);
|
||||
assert!(blue[2] > 0.99 && blue[0] < 0.01, "{blue:?}");
|
||||
}
|
||||
|
||||
/// A stain or style with no form between it and the new paint (a pattern and a solid color) takes
|
||||
/// the new paint at once, at any strength, and keeps its amount.
|
||||
#[test]
|
||||
fn shift_changes_a_paint_that_has_no_form_in_between() {
|
||||
use vectorcraft_color::Paint;
|
||||
let mut s = session();
|
||||
let a = dot(&mut s, 100.0, 150.0);
|
||||
s.edit("Pattern fill", |d, _| {
|
||||
let mut f = vectorcraft_doc::FillLayer::new(Paint::Pattern { pattern: "Tile".into(), xf: Default::default() });
|
||||
f.opacity = 0.4;
|
||||
d.node_mut(a).unwrap().appearance.items.insert(0, vectorcraft_doc::AppearanceItem::Fill(f));
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
// Low intensity, near the brush's edge: far below half strength.
|
||||
let r = adjust(&mut s, json!({"tool": "stain", "points": [[104, 150]], "radius": 5, "intensity": 1, "color": "#ff0000", "shift": true}));
|
||||
assert_eq!(r["count"], 1);
|
||||
let f = node(&s, a).appearance.fill().cloned().unwrap();
|
||||
assert_eq!(f.opacity, 0.4, "the amount stays");
|
||||
assert!(f.paint.color().is_some_and(|c| c.to_rgb()[0] > 0.99), "{:?}", f.paint);
|
||||
}
|
||||
|
||||
/// A style name the document has no style for (the Styler's style from another document, or one
|
||||
/// since renamed or deleted) moves the fill toward the document's first style after the default
|
||||
/// one, as no name does, and the stain's amount stays.
|
||||
#[test]
|
||||
fn the_styler_takes_the_first_style_for_a_name_the_document_lacks() {
|
||||
use vectorcraft_color::{Color, Paint};
|
||||
let styled = |style: Option<&str>| {
|
||||
let mut s = session();
|
||||
let a = dot(&mut s, 100.0, 150.0);
|
||||
s.execute("paint.setFill", &json!({"color": "#00ff00"})).unwrap();
|
||||
s.select(|_, sel| sel.clear()).unwrap();
|
||||
adjust(&mut s, json!({"tool": "stain", "points": [[100, 150]], "radius": 5, "intensity": 10, "color": "#ff0000"}));
|
||||
let mut p = json!({"tool": "style", "points": [[100, 150]], "radius": 5, "intensity": 10, "shift": true});
|
||||
if let Some(n) = style {
|
||||
p["style"] = json!(n);
|
||||
}
|
||||
let stained = node(&s, a).appearance.fill().map(|f| f.opacity);
|
||||
adjust(&mut s, p);
|
||||
let f = node(&s, a).appearance.fill().cloned().unwrap();
|
||||
assert_eq!(Some(f.opacity), stained, "the amount stays");
|
||||
let first = s.doc().unwrap().doc.graphic_styles[1].appearance.fill_paint();
|
||||
(f.paint, first)
|
||||
};
|
||||
let (missing, first) = styled(Some("No Such Style"));
|
||||
let (none, _) = styled(None);
|
||||
assert_eq!(missing, none);
|
||||
// The paint is the first style's, not the active fill color.
|
||||
assert_eq!(none, first);
|
||||
assert_ne!(none, Paint::solid(Color::rgb(0.0, 1.0, 0.0)));
|
||||
}
|
||||
|
||||
/// A `shift` that is not true, false or null is refused and changes nothing.
|
||||
#[test]
|
||||
fn a_bad_shift_is_refused() {
|
||||
let mut s = session();
|
||||
dot(&mut s, 100.0, 150.0);
|
||||
for tool in ["shift", "size", "stain", "style"] {
|
||||
let before = state(&s);
|
||||
let r = s.execute("symbol.adjust", &json!({"tool": tool, "points": [[100, 150]], "shift": "yes"}));
|
||||
assert!(matches!(&r, Err(EngineError::BadParams { msg, .. }) if msg == "`shift` must be true or false"), "{tool}: {r:?}");
|
||||
assert!(state(&s) == before);
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,9 @@ const ROWS: &[Row] = &[
|
||||
"affectsDensity",
|
||||
],
|
||||
),
|
||||
// The graphic style the Symbol Styler and the Symbol Sprayer's User Defined Style apply, set
|
||||
// from the Graphic Styles panel.
|
||||
(&["symbolSprayer", "symbolStyler"], Some("symbolismStyle"), &["style"]),
|
||||
(&["mirrorCut"], None, &["axis", "keep"]),
|
||||
(&["puppetWarp"], None, &["showMesh", "expand"]),
|
||||
(&["arc"], None, &["closed", "lengthX", "lengthY", "reference", "baseAlong", "slope", "fillArc"]),
|
||||
|
||||
@@ -48,6 +48,8 @@ pub struct SymbolismTool {
|
||||
active: bool,
|
||||
hover: Option<Point>,
|
||||
alt: bool,
|
||||
/// Shift was held when the drag began (the Shifter, Sizer, Stainer and Styler have a Shift form).
|
||||
shift: bool,
|
||||
/// Brush diameter in points.
|
||||
pub diameter: f64,
|
||||
/// 1..10.
|
||||
@@ -113,6 +115,7 @@ impl SymbolismTool {
|
||||
active: false,
|
||||
hover: None,
|
||||
alt: false,
|
||||
shift: false,
|
||||
diameter: 80.0,
|
||||
intensity: 5.0,
|
||||
density: 5.0,
|
||||
@@ -196,6 +199,9 @@ impl SymbolismTool {
|
||||
v["proportional"] = json!(self.proportional);
|
||||
v["affectsDensity"] = json!(self.affects_density);
|
||||
}
|
||||
if self.shift && matches!(tool, "shift" | "size" | "stain" | "style") {
|
||||
v["shift"] = json!(true);
|
||||
}
|
||||
("symbol.adjust".into(), v)
|
||||
}
|
||||
}
|
||||
@@ -230,6 +236,7 @@ impl Tool for SymbolismTool {
|
||||
self.previewed = 1;
|
||||
self.active = true;
|
||||
self.alt = ev.mods.alt;
|
||||
self.shift = ev.mods.shift;
|
||||
let (c, v) = self.command(cx);
|
||||
vec![Action::Begin(self.label().into()), Action::Preview(c, v)]
|
||||
}
|
||||
@@ -577,6 +584,39 @@ mod tests {
|
||||
assert!(v["method"] == "random" && v.get("proportional").is_none(), "{v}");
|
||||
}
|
||||
|
||||
/// A drag begun with Shift sends `shift` with the Shifter, Sizer, Stainer and Styler, and only
|
||||
/// with them; one begun without it sends none.
|
||||
#[test]
|
||||
fn shift_reaches_the_tools_that_have_a_shift_form() {
|
||||
let (d, _) = doc_with_rect();
|
||||
let (s, p) = (Selection::default(), paint());
|
||||
let cx = cx(&d, &s, &p);
|
||||
let shifted = Mods { shift: true, ..Default::default() };
|
||||
for (id, sends) in [
|
||||
("symbolShifter", true),
|
||||
("symbolSizer", true),
|
||||
("symbolStainer", true),
|
||||
("symbolStyler", true),
|
||||
("symbolScruncher", false),
|
||||
("symbolSpinner", false),
|
||||
("symbolScreener", false),
|
||||
("symbolSprayer", false),
|
||||
] {
|
||||
let mut t = SymbolismTool::new(id);
|
||||
let a = t.pointer(&cx, &PointerEvent::new(PointerKind::Down, 5.0, 5.0).with_mods(shifted));
|
||||
let Action::Preview(_, v) = &a[1] else { panic!("{a:?}") };
|
||||
assert_eq!(v.get("shift"), sends.then_some(&json!(true)), "{id}");
|
||||
// The drag keeps the Shift it began with.
|
||||
let a = t.pointer(&cx, &PointerEvent::new(PointerKind::Drag, 60.0, 5.0));
|
||||
let Action::Preview(_, v) = &a[0] else { panic!("{a:?}") };
|
||||
assert_eq!(v.get("shift"), sends.then_some(&json!(true)), "{id} drag");
|
||||
t.pointer(&cx, &PointerEvent::new(PointerKind::Up, 60.0, 5.0));
|
||||
let a = t.pointer(&cx, &PointerEvent::new(PointerKind::Down, 5.0, 5.0));
|
||||
let Action::Preview(_, v) = &a[1] else { panic!("{a:?}") };
|
||||
assert!(v.get("shift").is_none(), "{id} without Shift: {v}");
|
||||
}
|
||||
}
|
||||
|
||||
/// With Use Pressure Pen a drag sample where the pen stays is kept when the pressure changes;
|
||||
/// without it, or with the same pressure, the drag keeps thinning the samples by distance.
|
||||
#[test]
|
||||
|
||||
@@ -25,8 +25,8 @@ pub struct CanvasCache {
|
||||
/// last render took more than 8 ms, the canvas draws the frame shown reprojected and renders
|
||||
/// once the view has been still for [`canvas::STILL_SECS`].
|
||||
pub waits_for_still: bool,
|
||||
/// The cache key the canvas last asked for and when it first asked for it (seconds, egui's
|
||||
/// input time), kept while [`Self::waits_for_still`] is set.
|
||||
/// The cache key the canvas last asked for and when it first asked for its view (seconds,
|
||||
/// egui's input time), kept while [`Self::waits_for_still`] is set.
|
||||
pub still: Option<(CacheKey, f64)>,
|
||||
/// The low-resolution frame that covers the parts of the canvas the frame shown leaves
|
||||
/// uncovered while it is drawn for a view it was not rendered for ([`canvas::Fill`]).
|
||||
|
||||
@@ -359,8 +359,10 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
poll_worker(app, ui, key.doc);
|
||||
// With `waits_for_still` set (the web build, which has no render worker), a heavy document is
|
||||
// not rendered while only the view changes: the frame shown is drawn reprojected below, and the
|
||||
// first frame after the view has been still for STILL_SECS renders.
|
||||
// first frame after the view has been still for STILL_SECS renders. An edit meanwhile is drawn
|
||||
// into the frame shown ([`edit_in_frame_shown`]).
|
||||
let wait = if app.canvas.waits_for_still {
|
||||
edit_in_frame_shown(app, &key, &doc, &effects, &drawn, (mask_view, smooth_images));
|
||||
let slow = app.canvas.last_ms > 8.0 && app.canvas.texture.is_some();
|
||||
still_wait(&mut app.canvas.still, app.canvas.key.as_ref(), &key, slow, ui.input(|i| i.time))
|
||||
} else {
|
||||
@@ -1150,6 +1152,72 @@ struct Frame<'a> {
|
||||
/// shows the document's paper without the art: about a frame at 60 Hz.
|
||||
pub(crate) const FIRST_FRAME_GRACE: std::time::Duration = std::time::Duration::from_millis(16);
|
||||
|
||||
/// Draw `region` of `frame` again, into the texture of the frame shown, which then shows `frame`'s
|
||||
/// key: only the document changed since the frame shown, in that part of it
|
||||
/// ([`changed_pixels`]). `None`: nothing in view changed. `last_ms` stays the whole frame's.
|
||||
fn draw_changed(app: &mut VectorcraftApp, frame: &Frame, region: Option<[u32; 4]>) {
|
||||
let Frame { key, doc, effects, view, opts, pixel, .. } = frame;
|
||||
let t0 = now_ms();
|
||||
if region.is_none() {
|
||||
// Nothing in view to draw again: what was made to measure the edit isn't drawn.
|
||||
app.canvas.renderer.let_go_of_measured();
|
||||
}
|
||||
let display = app.display_profile.transform(app.session.prefs.monitor_profile_display);
|
||||
if let (Some([x0, y0, x1, y1]), Some(tex)) = (region, &mut app.canvas.texture) {
|
||||
let renderer = &mut app.canvas.renderer;
|
||||
let part_view = Affine::translate((-f64::from(x0), -f64::from(y0))) * *view;
|
||||
let mut part = effects.view(|| renderer.render(doc, x1 - x0, y1 - y0, part_view, opts));
|
||||
let width = part.width;
|
||||
crate::display_profile::convert_over(display.as_deref(), &mut part.pixels, width, part_view, key.over());
|
||||
let color = color_image(&part);
|
||||
let options = if pixel.is_some() { egui::TextureOptions::NEAREST } else { egui::TextureOptions::LINEAR };
|
||||
tex.set_partial([x0 as usize, y0 as usize], color, options);
|
||||
app.canvas.moved |= app.canvas.renderer.stats.moved > 0;
|
||||
}
|
||||
app.canvas.key = Some((*key).clone());
|
||||
app.canvas.shown = Some(((*doc).clone(), opts.clone()));
|
||||
app.perf.render_ms = now_ms() - t0;
|
||||
}
|
||||
|
||||
/// With `waits_for_still` set (the web build) and the last render slow, an edit while the view
|
||||
/// moves (a tool's drag that scrolls the view at an edge of the canvas, or a wheel scroll during a
|
||||
/// drag) is drawn into the frame shown, at the view it was rendered for: the part the edit changed
|
||||
/// only ([`changed_pixels`]). The frame shown then stays drawn reprojected with the view, and the
|
||||
/// canvas renders whole once the view has been still for [`STILL_SECS`], as for a view change
|
||||
/// without an edit (#8688). When more than the view and the document differ from the frame shown,
|
||||
/// or the edit changed more than half of it, nothing is drawn here: the frame renders whole.
|
||||
fn edit_in_frame_shown(
|
||||
app: &mut VectorcraftApp,
|
||||
key: &CacheKey,
|
||||
doc: &std::sync::Arc<vectorcraft_doc::Document>,
|
||||
effects: &vectorcraft_plugins::deferred::Deferrals,
|
||||
drawn: &View,
|
||||
(mask_view, smooth_images): (Option<vectorcraft_doc::NodeId>, bool),
|
||||
) {
|
||||
let slow = app.canvas.last_ms > 8.0 && app.canvas.texture.is_some();
|
||||
let Some(shown) = app.canvas.key.clone().filter(|_| slow) else { return };
|
||||
let at_shown = CacheKey {
|
||||
zoom: shown.zoom,
|
||||
cx: shown.cx,
|
||||
cy: shown.cy,
|
||||
w: shown.w,
|
||||
h: shown.h,
|
||||
ppp: shown.ppp,
|
||||
rot: shown.rot,
|
||||
pixel: shown.pixel,
|
||||
..key.clone()
|
||||
};
|
||||
if at_shown == shown || at_shown == *key || shown.pixel.is_some() != key.pixel.is_some() {
|
||||
return;
|
||||
}
|
||||
let v = View { center: Point::new(shown.cx, shown.cy), zoom: shown.zoom, rotation: shown.rot, ..*drawn };
|
||||
let (w, h, view) = frame_view(at_shown.pixel, (at_shown.w, at_shown.h), &v, at_shown.ppp);
|
||||
let opts = frame_options(app, &at_shown, mask_view, smooth_images);
|
||||
if let Some(region) = changed_pixels(app, &at_shown, doc, &opts, view, w, h) {
|
||||
draw_changed(app, &Frame { key: &at_shown, doc, effects, size: (w, h), view, opts, pixel: at_shown.pixel }, region);
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_frame(app: &mut VectorcraftApp, ui: &Ui, frame: Frame) {
|
||||
let Frame { key, doc, effects, size: (w, h), view, opts, pixel } = frame;
|
||||
// Frames that would be slow on this thread (the last one took over 8 ms) go
|
||||
@@ -1173,27 +1241,7 @@ fn draw_frame(app: &mut VectorcraftApp, ui: &Ui, frame: Frame) {
|
||||
match (&mut app.canvas.worker, heavy, changed) {
|
||||
// Only the document changed since the frame shown, in a part of it: that part is
|
||||
// rendered again, here, into the texture. `last_ms` stays the whole frame's.
|
||||
(_, _, Some(region)) => {
|
||||
let t0 = now_ms();
|
||||
if region.is_none() {
|
||||
// Nothing in view to draw again: what was made to measure the edit isn't drawn.
|
||||
app.canvas.renderer.let_go_of_measured();
|
||||
}
|
||||
if let (Some([x0, y0, x1, y1]), Some(tex)) = (region, &mut app.canvas.texture) {
|
||||
let renderer = &mut app.canvas.renderer;
|
||||
let part_view = Affine::translate((-f64::from(x0), -f64::from(y0))) * view;
|
||||
let mut part = effects.view(|| renderer.render(doc, x1 - x0, y1 - y0, part_view, &opts));
|
||||
let width = part.width;
|
||||
crate::display_profile::convert_over(display.as_deref(), &mut part.pixels, width, part_view, key.over());
|
||||
let color = color_image(&part);
|
||||
let options = if pixel.is_some() { egui::TextureOptions::NEAREST } else { egui::TextureOptions::LINEAR };
|
||||
tex.set_partial([x0 as usize, y0 as usize], color, options);
|
||||
app.canvas.moved |= app.canvas.renderer.stats.moved > 0;
|
||||
}
|
||||
app.canvas.key = Some(key.clone());
|
||||
app.canvas.shown = Some((doc.clone(), opts.clone()));
|
||||
app.perf.render_ms = now_ms() - t0;
|
||||
}
|
||||
(_, _, Some(region)) => draw_changed(app, &Frame { key, doc, effects, size: (w, h), view, opts, pixel }, region),
|
||||
(Some(worker), true, None) => {
|
||||
// The worker draws the frame: what this thread's renderer made to measure the edit
|
||||
// isn't drawn here.
|
||||
|
||||
@@ -51,11 +51,13 @@ pub(super) fn hover_wait(moved: &mut Option<(ViewKey, f64)>, key: ViewKey, now:
|
||||
|
||||
/// Note that the canvas asks for `key` at time `now` (seconds, egui's input time) → how many more
|
||||
/// seconds it draws the frame `shown` reprojected instead of rendering `key`: while the last
|
||||
/// render was `slow`, only the view differs between the two, and the canvas has asked for `key`
|
||||
/// for less than [`STILL_SECS`]. `still` holds the key last asked for and when the canvas first
|
||||
/// asked for it. None: the canvas renders `key` now, unless it is the frame shown.
|
||||
/// render was `slow`, only the view differs between the two, and the canvas has asked for the view
|
||||
/// of `key` for less than [`STILL_SECS`]. `still` holds the key last asked for and when the canvas first
|
||||
/// asked for its view. An edit leaves that time as it is: with the view still and edits drawn into
|
||||
/// the frame shown at each step of a drag, the canvas still renders whole once the view has been
|
||||
/// still for [`STILL_SECS`]. None: the canvas renders `key` now, unless it is the frame shown.
|
||||
pub(super) fn still_wait(still: &mut Option<(CacheKey, f64)>, shown: Option<&CacheKey>, key: &CacheKey, slow: bool, now: f64) -> Option<f64> {
|
||||
if still.as_ref().is_none_or(|(k, _)| k != key) {
|
||||
if still.as_ref().is_none_or(|(k, _)| !same_view(k, key)) {
|
||||
*still = Some((key.clone(), now));
|
||||
}
|
||||
let waited = still.as_ref().map_or(0.0, |(_, at)| now - at);
|
||||
@@ -64,6 +66,12 @@ pub(super) fn still_wait(still: &mut Option<(CacheKey, f64)>, shown: Option<&Cac
|
||||
(slow && waiting && shown.is_some_and(|s| s != key && only_view_differs(s, key))).then_some(STILL_SECS - waited)
|
||||
}
|
||||
|
||||
/// Whether two cache keys are of the same document at the same view (zoom, center, rotation,
|
||||
/// canvas size, pixel density and Pixel Preview's document pixels), whatever else differs.
|
||||
fn same_view(a: &CacheKey, b: &CacheKey) -> bool {
|
||||
(a.doc, a.zoom, a.cx, a.cy, a.w, a.h, a.ppp, a.rot, a.pixel) == (b.doc, b.zoom, b.cx, b.cy, b.w, b.h, b.ppp, b.rot, b.pixel)
|
||||
}
|
||||
|
||||
/// Whether two cache keys differ only in the view (zoom, center, rotation, canvas size, pixel
|
||||
/// density and Pixel Preview's document pixels), with Pixel Preview on in both or off in both.
|
||||
pub(super) fn only_view_differs(a: &CacheKey, b: &CacheKey) -> bool {
|
||||
|
||||
@@ -4357,7 +4357,8 @@ fn a_pan_fills_the_area() {
|
||||
/// With the web build's setting (`waits_for_still`, no render worker), a heavy document's canvas
|
||||
/// is not rendered while the view moves: each frame draws the frame shown moved and scaled with
|
||||
/// the view and asks for a frame within STILL_SECS. The canvas renders once the view has been
|
||||
/// still for STILL_SECS, and at once after an edit. With a worker's build settings the same frames render at once, as
|
||||
/// still for STILL_SECS. An edit while the view moves draws the part it changed into the frame
|
||||
/// shown, and one that changes most of the frame renders it whole at once. With a worker's build settings the same frames render at once, as
|
||||
/// before.
|
||||
#[test]
|
||||
fn without_a_worker_a_heavy_canvas_is_reprojected_until_the_view_is_still() {
|
||||
@@ -4421,15 +4422,39 @@ fn without_a_worker_a_heavy_canvas() {
|
||||
let now = app.canvas.key.clone().unwrap();
|
||||
assert_eq!((now.cx, now.zoom), (app.view().unwrap().center.x, app.view().unwrap().zoom), "rendered for the view");
|
||||
assert!((b.min - rect.min).length() < 0.01 && (b.max - rect.max).length() < 0.01, "{b:?} over {rect:?}");
|
||||
// An edit renders at once, even while the view moves.
|
||||
// An edit while the view moves shows at once: the part it changed is drawn into the frame
|
||||
// shown, at the view that frame was rendered for, and the frame stays drawn reprojected until
|
||||
// the view is still (#8688).
|
||||
app.canvas.last_ms = 50.0;
|
||||
app.view_mut().unwrap().center.y += 10.0;
|
||||
frame(&mut app);
|
||||
assert_eq!(app.canvas.key.as_ref(), Some(&now), "waiting");
|
||||
app.session.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 20, "height": 20})).unwrap();
|
||||
app.session.execute("shape.rectangle", &json!({"x": 110, "y": 60, "width": 20, "height": 20})).unwrap();
|
||||
let render_ms = app.canvas.last_ms;
|
||||
let (b, delay) = frame(&mut app);
|
||||
let k = app.canvas.key.clone().unwrap();
|
||||
assert_eq!(k.revision, app.session.active().unwrap().revision, "the edit is drawn");
|
||||
assert_eq!((k.cx, k.cy, k.zoom), (now.cx, now.cy, now.zoom), "at the view of the frame shown");
|
||||
assert_eq!(app.canvas.last_ms, render_ms, "the frame was not rendered whole");
|
||||
let (old, new) = (Xf::new(rect, &View { center: Point::new(now.cx, now.cy), ..*app.view().unwrap() }), Xf::new(rect, app.view().unwrap()));
|
||||
let (a, z) = (new.to_screen(old.to_doc(rect.min)), new.to_screen(old.to_doc(rect.max)));
|
||||
assert!((b.min - a).length() < 0.01 && (b.max - z).length() < 0.01, "{b:?}: the frame shown at {a:?} to {z:?}");
|
||||
assert!(delay <= std::time::Duration::from_secs_f64(STILL_SECS), "a frame within STILL_SECS: {delay:?}");
|
||||
let mut frames = 0;
|
||||
while app.canvas.key.as_ref() == Some(&k) && frames < 60 {
|
||||
frames += 1;
|
||||
frame(&mut app);
|
||||
}
|
||||
let k = app.canvas.key.clone().unwrap();
|
||||
assert_eq!((k.revision, k.cy), (app.session.active().unwrap().revision, app.view().unwrap().center.y), "rendered once still");
|
||||
// An edit that changes more than half of the frame renders whole at once, view and all.
|
||||
app.canvas.last_ms = 50.0;
|
||||
app.view_mut().unwrap().center.y += 10.0;
|
||||
frame(&mut app);
|
||||
app.session.execute("shape.rectangle", &json!({"x": -1000, "y": -1000, "width": 3000, "height": 3000})).unwrap();
|
||||
frame(&mut app);
|
||||
let k = app.canvas.key.clone().unwrap();
|
||||
assert_eq!((k.revision, k.cy), (app.session.active().unwrap().revision, app.view().unwrap().center.y), "rendered after the edit");
|
||||
assert_eq!((k.revision, k.cy), (app.session.active().unwrap().revision, app.view().unwrap().center.y), "rendered whole after the edit");
|
||||
// With a worker's build settings and no worker (VECTORCRAFT_SYNC_RENDER), a heavy document
|
||||
// renders every change of view at once.
|
||||
app.canvas.waits_for_still = false;
|
||||
@@ -4439,6 +4464,48 @@ fn without_a_worker_a_heavy_canvas() {
|
||||
assert_eq!(app.canvas.key.as_ref().map(|k| k.cx), Some(app.view().unwrap().center.x), "rendered at once");
|
||||
}
|
||||
|
||||
/// With the web build's setting (`waits_for_still`, no render worker), a heavy document's view
|
||||
/// that stops moving while a drag goes on editing the document renders whole once the view has
|
||||
/// been still for STILL_SECS: each edit is drawn into the frame shown and does not start the wait
|
||||
/// again.
|
||||
#[test]
|
||||
fn without_a_worker_edits_while_the_view_is_still_do_not_hold_off_the_render() {
|
||||
keeping_color_settings(edits_while_the_view_is_still);
|
||||
}
|
||||
|
||||
fn edits_while_the_view_is_still() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.session.execute("file.new", &json!({"width": 400, "height": 300})).unwrap();
|
||||
app.session.execute("shape.rectangle", &json!({"x": 100, "y": 50, "width": 200, "height": 200})).unwrap();
|
||||
app.canvas.worker_started = true; // no worker, as in the web build
|
||||
app.canvas.waits_for_still = true;
|
||||
let ctx = egui::Context::default();
|
||||
let frame = |app: &mut VectorcraftApp| {
|
||||
let raw = egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0))), ..Default::default() };
|
||||
let mut out = ctx.run_ui(raw, |ui| show(app, ui));
|
||||
out.textures_delta.clear();
|
||||
};
|
||||
frame(&mut app); // the first frame fits the view to the artboard
|
||||
frame(&mut app);
|
||||
app.canvas.last_ms = 50.0;
|
||||
// The view moves once (a drag at an edge of the canvas scrolls it) and then stays still.
|
||||
app.view_mut().unwrap().center.y += 10.0;
|
||||
frame(&mut app);
|
||||
let shown = app.canvas.key.clone().unwrap();
|
||||
assert_ne!(shown.cy, app.view().unwrap().center.y, "waiting");
|
||||
// The drag edits the document on every frame, at 60 fps (egui's input time without a clock).
|
||||
let mut frames = 0;
|
||||
while app.canvas.key.as_ref().is_none_or(|k| k.cy != app.view().unwrap().center.y) && frames < 60 {
|
||||
frames += 1;
|
||||
let x = 110 + (frames % 10) * 5;
|
||||
app.session.execute("shape.rectangle", &json!({"x": x, "y": 60, "width": 4, "height": 4})).unwrap();
|
||||
frame(&mut app);
|
||||
let k = app.canvas.key.as_ref().unwrap();
|
||||
assert_eq!(k.revision, app.session.active().unwrap().revision, "each edit is drawn");
|
||||
}
|
||||
assert!((11..=13).contains(&frames), "rendered whole about STILL_SECS after the view stopped: {frames} frames");
|
||||
}
|
||||
|
||||
/// [`still_wait`] waits while only the view changes on a slow canvas: each change starts
|
||||
/// STILL_SECS again. It does not wait for a light document, a still view, a clock that went
|
||||
/// back, an edit, a switch into Pixel Preview or a canvas with no frame shown.
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
use serde_json::{Map, Value, json};
|
||||
use vectorcraft_tools::settings::SYMBOLISM;
|
||||
|
||||
use super::{DialogResult, DialogSpec, form, set_tool_options_and_close};
|
||||
use super::{DialogResult, DialogSpec, form, modal, set_tool_options_and_close};
|
||||
use crate::state::Dialog;
|
||||
use crate::{VectorcraftApp, widgets};
|
||||
|
||||
@@ -55,6 +55,13 @@ pub fn open(app: &mut VectorcraftApp, tool: &str) -> Value {
|
||||
}
|
||||
|
||||
fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool {
|
||||
// The rows scroll when the window is shorter than they are, so the heading and the buttons
|
||||
// stay in view.
|
||||
modal::scrolled_rows(ui, "symbolism-options-rows", |ui| rows(app, ui, d));
|
||||
false
|
||||
}
|
||||
|
||||
fn rows(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) {
|
||||
let unit = app.session.general_unit();
|
||||
// The tool whose options show below (the eight tools share one toolbar icon, so they are listed
|
||||
// by name).
|
||||
@@ -107,10 +114,9 @@ fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool {
|
||||
}
|
||||
ui.add_space(10.0);
|
||||
form::check(ui, d, "showBrush", tl!("Show Brush Size and Intensity"));
|
||||
false
|
||||
}
|
||||
|
||||
/// The selected symbol sets that can be edited (not locked or hidden).
|
||||
/// The selected symbol sets that can be edited (a locked or hidden one keeps its density).
|
||||
fn selected_sets(app: &VectorcraftApp) -> Vec<u64> {
|
||||
let Some(st) = app.session.active() else { return vec![] };
|
||||
let editable = st.doc.editable();
|
||||
@@ -123,39 +129,42 @@ fn selected_sets(app: &VectorcraftApp) -> Vec<u64> {
|
||||
}
|
||||
|
||||
/// OK: set the brush the Symbolism tools share, after giving a new Symbol Set Density to the
|
||||
/// selected symbol sets. Every option is checked first, so a value the tools refuse (a number out
|
||||
/// of its range included) leaves the symbol sets and the options as they are.
|
||||
/// selected symbol sets. A value outside its range is refused and changes nothing.
|
||||
fn confirm(app: &mut VectorcraftApp, d: &Dialog) -> DialogResult {
|
||||
let mut values: Map<String, Value> =
|
||||
NUMBERS.iter().filter(|k| d.fields.contains_key(**k)).map(|k| (k.to_string(), json!(d.f64(k, 0.0)))).collect();
|
||||
// The checkboxes and choices as the fields hold them, so a value the tools do not have is refused.
|
||||
values.extend(SWITCHES.iter().chain(&SPRAY).chain(&["method"]).filter_map(|k| Some((k.to_string(), d.fields.get(*k)?.clone()))));
|
||||
// An option `tool.setOption` refuses leaves the symbol sets as they are too.
|
||||
// Each value goes to the check as it is stored, so one of the wrong kind is refused rather than
|
||||
// read as 0 or false. A number stored as text is read as the field reads it, and other text is
|
||||
// refused.
|
||||
let stored = |k: &str| match d.fields.get(k) {
|
||||
Some(Value::String(s)) => Some(vectorcraft_doc::Unit::Points.parse(s).map_or_else(|| json!(s), |n| json!(n))),
|
||||
v => v.cloned(),
|
||||
};
|
||||
let mut values: Map<String, Value> = NUMBERS.iter().filter_map(|k| Some((k.to_string(), stored(k)?))).collect();
|
||||
values.extend(SWITCHES.iter().filter_map(|k| Some((k.to_string(), d.fields.get(*k)?.clone()))));
|
||||
values.extend(SPRAY.iter().chain(&["method"]).filter(|k| d.fields.contains_key(**k)).map(|k| (k.to_string(), json!(d.str(k)))));
|
||||
// A tool or a value `tool.setOption` refuses changes no density either: the values go through
|
||||
// both of its checks, the kinds and then each option's range, before the density changes.
|
||||
let tool = d.str("tool");
|
||||
if !SYMBOLISM.contains(&tool.as_str()) {
|
||||
return Err(format!("unknown tool `{tool}`"));
|
||||
}
|
||||
// A number, or text that reads as one (a length with its unit for the diameter).
|
||||
let readable = |v: &Value| match v {
|
||||
Value::Number(_) => true,
|
||||
Value::String(s) => vectorcraft_doc::Unit::Points.parse(s).is_some(),
|
||||
_ => false,
|
||||
};
|
||||
if let Some(k) = NUMBERS.iter().chain(&[DENSITY_WAS]).find(|k| d.fields.get(**k).is_some_and(|v| !readable(v))) {
|
||||
return Err(format!("`{k}` must be a number"));
|
||||
}
|
||||
vectorcraft_tools::symbolism::check_options(&tool, &values)?;
|
||||
vectorcraft_tools::option_check::check_values(&vectorcraft_tools::symbolism::SymbolismTool::new(&tool), &values)?;
|
||||
// The density the sets had when the dialog opened is read as a number too.
|
||||
if stored(DENSITY_WAS).is_some_and(|v| !v.is_number()) {
|
||||
return Err(format!("`{DENSITY_WAS}` must be a number"));
|
||||
}
|
||||
let (from, to) = (d.f64(DENSITY_WAS, 0.0).clamp(1.0, 10.0), d.f64("density", 0.0).clamp(1.0, 10.0));
|
||||
let sets = selected_sets(app);
|
||||
if d.fields.contains_key(DENSITY_WAS) && from != to && !sets.is_empty() {
|
||||
app.run("symbol.setDensity", json!({ "from": from, "to": to, "ids": sets }))?;
|
||||
}
|
||||
set_tool_options_and_close(app, json!({ "tool": d.str("tool"), "values": values }))
|
||||
set_tool_options_and_close(app, json!({ "tool": tool, "values": values }))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use egui_kittest::kittest::Queryable;
|
||||
use vectorcraft_engine::Session;
|
||||
|
||||
fn app() -> VectorcraftApp {
|
||||
@@ -168,6 +177,39 @@ mod tests {
|
||||
crate::tests_labels::painted_text(app, |app, ui| super::super::show(app, ui.ctx()))
|
||||
}
|
||||
|
||||
/// In a short window the rows scroll, and the heading, OK and Cancel stay on the screen.
|
||||
#[test]
|
||||
fn the_buttons_stay_in_view_in_a_short_window() {
|
||||
let mut app = app();
|
||||
app.run("tool.options", json!({"tool": "symbolSprayer"})).unwrap();
|
||||
let mut fonts = false;
|
||||
let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(900.0, 800.0)).build_ui_state(
|
||||
move |ui, app: &mut VectorcraftApp| {
|
||||
if !std::mem::replace(&mut fonts, true) {
|
||||
crate::theme::install_fonts(ui.ctx());
|
||||
return;
|
||||
}
|
||||
super::super::show(app, ui.ctx());
|
||||
},
|
||||
app,
|
||||
);
|
||||
h.run_steps(4);
|
||||
for (physical, zoom) in [(egui::vec2(1366.0, 768.0), 1.5), (egui::vec2(1280.0, 720.0), 1.5), (egui::vec2(800.0, 600.0), 1.0)] {
|
||||
h.ctx.set_zoom_factor(zoom);
|
||||
for _ in 0..12 {
|
||||
h.set_size(physical / zoom);
|
||||
h.run_steps(1);
|
||||
}
|
||||
let screen = h.ctx.content_rect();
|
||||
let heading = h.get_by_role_and_label(egui::accesskit::Role::Label, "Symbolism Tools Options").rect();
|
||||
assert!(screen.contains_rect(heading), "{physical:?} at {zoom}: the heading {heading:?} in {screen:?}");
|
||||
for label in ["OK", "Cancel"] {
|
||||
let rect = h.get_by_label(label).rect();
|
||||
assert!(screen.contains_rect(rect), "{physical:?} at {zoom}: {label} {rect:?} in {screen:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_symbolism_tools_share_the_options_ok_sets() {
|
||||
let mut app = app();
|
||||
@@ -280,6 +322,56 @@ mod tests {
|
||||
app.run("tool.options", json!({"tool": "symbolSprayer"})).unwrap();
|
||||
super::super::confirm(&mut app).unwrap();
|
||||
assert_eq!((width(&app), undo(&app)), (was, steps));
|
||||
// An option that `tool.setOption` refuses changes neither the density nor the set.
|
||||
app.run("tool.options", json!({"tool": "symbolSprayer"})).unwrap();
|
||||
let fields = &mut app.ui.dialog.as_mut().unwrap().fields;
|
||||
fields.insert("density".into(), json!(9));
|
||||
fields.insert("method".into(), json!("smooth"));
|
||||
assert!(super::super::confirm(&mut app).is_err());
|
||||
assert_eq!((width(&app), undo(&app)), (was, steps));
|
||||
assert_eq!(app.session.tool_options_of("symbolSizer")["density"].as_f64(), Some(5.0));
|
||||
// So does a checkbox or a number stored as a value of the wrong kind, or a number outside its
|
||||
// range.
|
||||
for (k, v) in [
|
||||
("diameter", json!(1)),
|
||||
("intensity", json!(11)),
|
||||
("usePressure", json!("invalid")),
|
||||
("proportional", json!(1)),
|
||||
("intensity", json!("strong")),
|
||||
("diameter", json!(true)),
|
||||
("tool", json!("pen")),
|
||||
("tool", json!(null)),
|
||||
] {
|
||||
app.run("tool.options", json!({"tool": "symbolSprayer"})).unwrap();
|
||||
let fields = &mut app.ui.dialog.as_mut().unwrap().fields;
|
||||
fields.insert("density".into(), json!(9));
|
||||
fields.insert(k.into(), v);
|
||||
assert!(super::super::confirm(&mut app).is_err(), "{k}");
|
||||
assert_eq!((width(&app), undo(&app)), (was, steps), "{k}");
|
||||
let o = app.session.tool_options_of("symbolSizer");
|
||||
assert_eq!((o["density"].as_f64(), o["usePressure"].as_bool()), (Some(5.0), Some(false)), "{k}");
|
||||
}
|
||||
// A selected set that is locked keeps its density, and OK still sets the options.
|
||||
let lock = |app: &mut VectorcraftApp, on: bool| {
|
||||
app.session
|
||||
.edit("Lock", |d, _| {
|
||||
d.node_mut(vectorcraft_doc::NodeId(set)).unwrap().locked = on;
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
};
|
||||
lock(&mut app, true);
|
||||
let steps_locked = undo(&app);
|
||||
app.run("tool.options", json!({"tool": "symbolSprayer"})).unwrap();
|
||||
app.ui.dialog.as_mut().unwrap().fields.insert("density".into(), json!(8));
|
||||
super::super::confirm(&mut app).unwrap();
|
||||
assert_eq!((width(&app), undo(&app)), (was, steps_locked));
|
||||
assert_eq!(app.session.tool_options_of("symbolSizer")["density"].as_f64(), Some(8.0));
|
||||
lock(&mut app, false);
|
||||
app.run("tool.options", json!({"tool": "symbolSprayer"})).unwrap();
|
||||
app.ui.dialog.as_mut().unwrap().fields.insert("density".into(), json!(5));
|
||||
super::super::confirm(&mut app).unwrap();
|
||||
let steps = undo(&app);
|
||||
// A higher density packs the set closer, as one undo step.
|
||||
app.run("tool.options", json!({"tool": "symbolSprayer"})).unwrap();
|
||||
app.ui.dialog.as_mut().unwrap().fields.insert("density".into(), json!(9));
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
//! (Small and Large List View), shown on a square or on type; a style with no fill and no stroke
|
||||
//! shows the shape outlined in black and filled with white, under a red slash. Clicking a style applies it to the
|
||||
//! selection (Alt-click adds it on top); Shift-click adds to the panel's selection every style from
|
||||
//! the last one clicked without Shift through this one; Cmd/Ctrl-click adds or removes one;
|
||||
//! double-click opens Graphic Style Options. Dragging a style moves it in the list (dropped on
|
||||
//! the last one clicked without Shift through this one; Cmd/Ctrl-click adds or removes one. The
|
||||
//! style last clicked into the selection is the one the Symbol Styler and the Symbol Sprayer's User
|
||||
//! Defined Style apply. Double-click opens
|
||||
//! Graphic Style Options. Dragging a style moves it in the list (dropped on
|
||||
//! another style with Alt held, replaces that style with its look), applies it
|
||||
//! to the art it is dropped on (`canvas::panel_drop`), or, dropped on New Graphic Style, adds a
|
||||
//! copy of it and of the styles highlighted with it at the end of the list; art dragged off the
|
||||
@@ -552,6 +554,11 @@ fn act(app: &mut VectorcraftApp, ui: &Ui, s: &Shown, ev: Events, picker: bool) {
|
||||
Some(Click::Pick(name, m)) => {
|
||||
let order: Vec<&str> = s.d.graphic_styles.iter().map(|g| g.name.as_str()).collect();
|
||||
let sel = super::swatches::click_selection(ui, "gs-anchor", selected(ui.ctx(), s.d), &order, &name, m);
|
||||
// The style clicked into the selection is the one the Symbol Styler and the Symbol
|
||||
// Sprayer's User Defined Style apply (the two share it).
|
||||
if sel.contains(&name) {
|
||||
app.run("tool.setOption", json!({"tool": "symbolStyler", "values": {"style": name}})).ok();
|
||||
}
|
||||
set_pstate(ui.ctx(), "gs-sel", sel);
|
||||
// A plain click also applies the style (with nothing selected the next object drawn
|
||||
// takes it); Shift and Cmd/Ctrl clicks only select.
|
||||
@@ -1689,15 +1696,23 @@ mod tests {
|
||||
selected(&ctx, &app.session.active().unwrap().doc.clone())
|
||||
};
|
||||
let linked = |app: &VectorcraftApp| app.session.selection_graphic_style().map(|(g, _)| g.name.clone());
|
||||
// A plain click applies the style and selects it alone.
|
||||
let styler = |app: &VectorcraftApp| app.session.tool_options_of("symbolStyler")["style"].as_str().map(str::to_string);
|
||||
// A plain click applies the style and selects it alone; the Symbol Styler takes it.
|
||||
assert_eq!(click(&mut app, 0, egui::Modifiers::NONE), [n[0].clone()]);
|
||||
assert_eq!(linked(&app).as_ref(), Some(&n[0]));
|
||||
assert_eq!(styler(&app).as_ref(), Some(&n[0]));
|
||||
// Shift-click selects from that style to the clicked one, and applies nothing.
|
||||
assert_eq!(click(&mut app, 3, egui::Modifiers::SHIFT), n[..4]);
|
||||
assert_eq!(linked(&app).as_ref(), Some(&n[0]));
|
||||
// Cmd/Ctrl-click removes a selected style and adds it back.
|
||||
assert_eq!(styler(&app).as_ref(), Some(&n[3]));
|
||||
// Cmd/Ctrl-click removes a selected style and adds it back; the Styler keeps its style
|
||||
// while one is removed.
|
||||
assert_eq!(click(&mut app, 2, egui::Modifiers::COMMAND), [n[0].clone(), n[1].clone(), n[3].clone()]);
|
||||
assert_eq!(styler(&app).as_ref(), Some(&n[3]));
|
||||
assert_eq!(click(&mut app, 2, egui::Modifiers::COMMAND), [n[0].clone(), n[1].clone(), n[3].clone(), n[2].clone()]);
|
||||
assert_eq!(styler(&app).as_ref(), Some(&n[2]));
|
||||
// The Symbol Sprayer's User Defined Style applies the same style.
|
||||
assert_eq!(app.session.tool_options_of("symbolSprayer")["style"].as_str(), Some(n[2].as_str()));
|
||||
// Shift-click extends from the style Cmd/Ctrl-clicked last.
|
||||
click(&mut app, 0, egui::Modifiers::NONE);
|
||||
click(&mut app, 2, egui::Modifiers::COMMAND);
|
||||
|
||||
+35
-8
@@ -3892,23 +3892,34 @@ already walks Image Trace. Short agent entry points:
|
||||
[the archived manual](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=118)):
|
||||
`symbol.adjust` takes `method` (`userDefined`, `average` or `random`; not used by `shift`), `usePressure` with
|
||||
`points` as `[x, y, pressure]` (each point's pen pressure, 0..1, is the intensity there), and for `size`
|
||||
`proportional` (true) and `affectsDensity` (false). `symbol.spray` takes `attributes`
|
||||
`proportional` (true) and `affectsDensity` (false). With `tool: style`, the style goes on by the brush's strength at
|
||||
each instance: one sample applies it in full only at the brush's center at intensity 10 or full pressure, and the
|
||||
samples of a stroke add up (two samples at the center at intensity 5 apply it in full). With `alt`, `userDefined`
|
||||
and `random` remove all of an instance's appearance items under the brush at once, whatever the brush's strength.
|
||||
A `style` name the document
|
||||
has no graphic style for counts as none (the document's first style after the default one). The Symbol Styler and the
|
||||
Symbol Sprayer (its User Defined Style) send the style last clicked into the Graphic Styles panel's selection. `tool.setOption` on a symbolism tool refuses a `method` or
|
||||
Symbol Sprayer option that is not one of its names, a non-number `diameter`, `intensity` or `density`, a
|
||||
`diameter` outside 2..2000 or an `intensity` or `density` outside 1..10, a non-boolean switch, and a `symbol` or
|
||||
`style` that is neither a name nor null, and sets none of the values. The options dialog's OK checks the same way
|
||||
before it changes any symbol set's density.
|
||||
`symbol.spray` takes `attributes`
|
||||
`{scrunch?, size?, spin?, screen?, stain?, style?}`, each `average` or `userDefined`, with `color`, `keepModel` and
|
||||
`style` for the User Defined stain and style (with `style: userDefined`, a `style` the document does not have is an
|
||||
error). `symbol.setDensity {from, to, ids?|id?}` gives the selected symbol
|
||||
sets a new Symbol Set Density. VectorCraft's own rules:
|
||||
- `random` gives each instance its own share of the tool's change for the whole stroke, from none of it to twice
|
||||
it (the Spinner: a turn either way), the same each time the stroke is applied.
|
||||
it (the Spinner: a turn either way; the Styler without `shift`: from none to the `userDefined` amount), the same
|
||||
each time the stroke is applied.
|
||||
- `average` moves each instance's value toward the mean of the instances within the brush at that point: the
|
||||
Scruncher its distance from their middle toward their mean distance, the Sizer the geometric mean of their sizes
|
||||
on the page, whatever their symbols, the Spinner their mean direction, the Stainer and the Styler their mean amount, the Screener their mean opacity.
|
||||
`alt` does not reverse it. An instance already at the mean is left as it is, and no undo step is added when
|
||||
no instance changes. The Screener's average, and the opacity a sprayed instance takes as its average, can be
|
||||
below the 5% that the Screener otherwise stops at.
|
||||
- With `userDefined` the Styler gives each instance under the brush the whole style, whatever the intensity or the
|
||||
pen pressure; `random` scales each instance's share by the brush strength there.
|
||||
- With `proportional` false a drag resizes along its own direction (a level drag the width, an upright one the
|
||||
height) and one point resizes both. With `affectsDensity` an instance also moves away from the point as it grows
|
||||
- With `proportional` false a drag resizes along its own direction: the width by the drag's horizontal share and
|
||||
the height by its vertical share (a level drag the width, an upright one the height, a 45° drag both alike), and
|
||||
one point resizes both. With `affectsDensity` an instance also moves away from the point as it grows
|
||||
and toward it as it shrinks.
|
||||
- A sprayed instance's `average` values are the means of the selected set's instances within `radius` of the
|
||||
stroke point: their spacing, size on the page (of any symbol), rotation and opacity, and the stain or style of
|
||||
@@ -3918,15 +3929,31 @@ already walks Image Trace. Short agent entry points:
|
||||
- `symbol.setDensity` moves each instance of a set along the line from the middle of the set's instances, to
|
||||
(1.15 − 0.1·`to`) / (1.15 − 0.1·`from`) of its distance from it (each factor at least 0.1), as one undo step, and
|
||||
adds none when no instance moves and every set already has density `to`. `from` is the density each set was
|
||||
created at or last given, and the `from` passed applies only to a set without one (a group named "Symbol Set" by
|
||||
created at or last given (a set duplicated has its source's, and a pasted set the one its source had at Copy),
|
||||
and the `from` passed applies only to a set without one (a group named "Symbol Set" by
|
||||
hand); every set then has density `to`, also one whose instances do not move (one instance, or each locked). A
|
||||
locked or hidden instance stays where it is. It returns `{ids, count}`: the sets changed and the
|
||||
instances moved.
|
||||
- A `method` or an attribute outside these values, a point's third number that isn't a number (in `symbol.spray`
|
||||
too, which does not use it), a `from` or `to` of `symbol.setDensity` outside 1..10, or no symbol set among its
|
||||
objects, is an error and changes nothing.
|
||||
objects, is an error and changes nothing. `symbol.spray` takes a `density` number outside 1..10 as the nearer end.
|
||||
- Average leaves an instance without a size (a scale of 0) as it is; the other methods change it. A stroke that
|
||||
changes no instance counts none and adds no undo step.
|
||||
- The symbolism tools with Shift held ([the manual](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=199),
|
||||
[the CS6 reference](https://web.archive.org/web/20220911143322/https://helpx.adobe.com/pdf/cs6/illustrator_reference.pdf#page=136)) send
|
||||
`shift: true` with `symbol.adjust`: a Shift-click with the Symbol Shifter brings the instances under the brush
|
||||
forward in the stacking order and Alt+Shift sends them backward; the Symbol Sizer keeps the set's density while it
|
||||
resizes; the Symbol Stainer and the Symbol Styler keep the amount of stain or style and move the color or style
|
||||
toward the current fill or the selected style. VectorCraft's own rules:
|
||||
- The Shifter moves each instance within `radius` of any stroke point one place forward among its siblings (with
|
||||
`alt`, one place backward), past the next one that is not under the brush, once for the whole stroke. It does not
|
||||
move them on the canvas. It returns `{count}`, the instances that moved.
|
||||
- The Sizer keeps each instance's center where it is, even with `affectsDensity`.
|
||||
- The Stainer moves an instance's paint toward `color` by the tool's amount at its distance from the point, and the
|
||||
Styler toward the style by the brush's strength there, whatever `method` is. A paint with no form between it and
|
||||
the new one (a solid color and a pattern) takes the new one at once. An instance without a stain or style is left
|
||||
as it is, and `alt` has no effect.
|
||||
- No undo step is added when nothing moves or changes.
|
||||
- Dynamic symbols: an instance of a symbol whose `type` is `dynamic` changes the appearance of objects in the symbol's
|
||||
art for itself only and stays linked. `symbol.instance.setAppearance {id?, path, fill?, stroke?, opacity?, blend?}`
|
||||
names the object by `path`, child indices in paint order from the art's root down through its groups (`[]` is the
|
||||
|
||||
+3
-2
@@ -1,6 +1,6 @@
|
||||
# Roadmap: milestones and what's next
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-18 · **Change:** minor (Image Trace Ignore Color keeps the canvas View and stays armed on a missed pixel (#8068); M11: a tool drag held near an edge of the canvas scrolls the view, #8551; scores and estimates unchanged; previously: All Tools drawer: a tool the toolbar holds is dimmed in the readable dim text colour, not the disabled colour that was unreadable against the panel, and a hovered dimmed row takes the panel's darker fill so it stays readable, #8294; scores and estimates unchanged; previously: Layers: selected guide rows stay highlighted after the pointer leaves (#7344); scores and estimates unchanged; previously: M4: PDF import: type filled and stroked after a page of type filled only comes in filled and stroked, #8549 follow-up; scores and estimates unchanged; previously: selected Dimension extension-line color and weight in Properties (#7078; four focused UI regressions passed); scores and estimates unchanged; previously: Brush Options Key Color: restore canvas input for the existing one-shot pick, then resume the retained draft and previous tool (#8284; six full-app input regressions passed); scores and estimates unchanged; previously: M4: `.ai` and EPS import: an Art brush in Tints of a swatch-linked stroke color comes in brushed, #8200; scores and estimates unchanged; previously: Ellipse: Up/Down changes Anchors while drawing (#7840); scores and estimates unchanged; previously: Windows/Linux menu access keys and localized cues (#6596); previously: Backquote/~ arrow pattern nudges (#7717); scores and estimates unchanged; previously: Window > Toolbars > Compact Tools offers optional denser main Tools spacing (#7234); default layout, scores and estimates unchanged; previously: Direct Selection: Space during an ordinary path's handle drag repositions its anchor and handles, including a Pen loan (#7237, request 3 only; scores and estimates unchanged); previously: M4: `.ai` and EPS import: clipping paths grouped in a compound path are its subpaths, #8128; scores and estimates unchanged; previously: import: type filled and stroked by a `TJ` whose kerning starts a new line comes in filled and stroked, #8543; PDF Retype phase 1 (#4934): Type › Retype (`type.retype`) turns outlined text that exactly matches an available font back into point text; scores and estimates unchanged; previously: M1: Lock Guides: a selection marquee (Selection, Direct Selection, Group Selection, Enclosing Lasso) leaves out paths made into guides inside groups and compound paths too, as clicks do (#3074), so a group is no longer selected by a locked guide in it; an enclosing marquee measures a group without its locked or hidden guides, and Direct Selection takes no anchor or segment of a guide that can't be picked; a guide in a group still moves with its group (#8538); Production Preflight: output-aware fonts, text overflow, linked files and effective image resolution, clickable findings and automatic rechecking; scores and estimates unchanged; previously: PDF export writes the document language as the catalog's `/Lang`, #3644; M1: an Alt-drag in the Layers panel copies a row above or below its own place, #8237; scores and estimates unchanged; previously: PDF import: a glyph filled only after a glyph filled and stroked comes in filled only, not stroked, #8300; PDF import: translucent type filled and stroked comes in as a filled type object and a stroked one, as the file composites them, and an upright glyph is never kept as the outline of its glyph alone, #8015; PDF import: type filled and stroked by one text-showing operator comes in as one type object, filled and stroked, not a stroked copy over a filled one, #8015; M1: Layers panel Alt-drag shows the copy cursor, #8217; scores and estimates unchanged; previously: Gradient panel: the add-stop strip shows the white arrow with a plus on Windows and X11, #8241; scores and estimates unchanged; previously: Recolor Artwork follow-up (#8031, remaining #4028): native Lab input, picker swatch libraries and Assign-row menus; UI interaction regression coverage; scores and estimates unchanged; previously: Eraser review: hidden Rasterize and Along/Across stroke rows do not block preserving visible gradients; scores and estimates unchanged; previously: Eraser review: ordinary Group/Layer paints and reproducible evaluated gradient placements are preserved; other placements retain existing fitting; scores and estimates unchanged; previously: Eraser: shared fill-only area cutting for fixed and varied tips and the Alt-drag marquee, #6582; scores and estimates unchanged; previously: #8005: the Color spectrum fills a resized panel; scores and estimates unchanged; previously: M7: Check Spelling modal dialog (Edit › Spelling › Check Spelling…), #4936; spell check complete; previously: PDF import: stroked type keeps the line cap, line join and miter limit the file strokes it with, a glyph stroked otherwise than the run it joinLine truncated
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (M5: In the web build, an edit while the view of a heavy document moves (a tool drag held at an edge of the canvas, #8551, or a wheel scroll during a drag) draws only the part it changed into the last frame, which stays drawn moved with the view, instead of rendering the whole canvas each frame (an edit that changes more than half of the frame, or a change of more than the view and the document, still renders it whole at once), and edits that go on once the view is still don't put off its render (#8688); scores and estimates unchanged; previously: Image Trace Ignore Color keeps the canvas View and stays armed on a missed pixel (#8068); M11: a tool drag held near an edge of the canvas scrolls the view, #8551; scores and estimates unchanged; previously: All Tools drawer: a tool the toolbar holds is dimmed in the readable dim text colour, not the disabled colour that was unreadable against the panel, and a hovered dimmed row takes the panel's darker fill so it stays readable, #8294; scores and estimates unchanged; previously: Layers: selected guide rows stay highlighted after the pointer leaves (#7344); scores and estimates unchanged; previously: M4: PDF import: type filled and stroked after a page of type filled only comes in filled and stroked, #8549 follow-up; scores and estimates unchanged; previously: selected Dimension extension-line color and weight in Properties (#7078; four focused UI regressions passed); scores and estimates unchanged; previously: Brush Options Key Color: restore canvas input for the existing one-shot pick, then resume the retained draft and previous tool (#8284; six full-app input regressions passed); scores and estimates unchanged; previously: M4: `.ai` and EPS import: an Art brush in Tints of a swatch-linked stroke color comes in brushed, #8200; scores and estimates unchanged; previously: Ellipse: Up/Down changes Anchors while drawing (#7840); scores and estimates unchanged; previously: Windows/Linux menu access keys and localized cues (#6596); previously: Backquote/~ arrow pattern nudges (#7717); scores and estimates unchanged; previously: Window > Toolbars > Compact Tools offers optional denser main Tools spacing (#7234); default layout, scores and estimates unchanged; previously: Direct Selection: Space during an ordinary path's handle drag repositions its anchor and handles, including a Pen loan (#7237, request 3 only; scores and estimates unchanged); previously: M4: `.ai` and EPS import: clipping paths grouped in a compound path are its subpaths, #8128; scores and estimates unchanged; previously: import: type filled and stroked by a `TJ` whose kerning starts a new line comes in filled and stroked, #8543; PDF Retype phase 1 (#4934): Type › Retype (`type.retype`) turns outlined text that exactly matches an available font back into point text; scores and estimates unchanged; previously: M1: Lock Guides: a selection marquee (Selection, Direct Selection, Group Selection, Enclosing Lasso) leaves out paths made into guides inside groups and compound paths too, as clicks do (#3074), so a group is no longer selected by a locked guide in it; an enclosing marquee measures a group without its locked or hidden guides, and Direct Selection takes no anchor or segment of a guide that can't be picked; a guide in a group still moves with its group (#8538); Production Preflight: output-aware fonts, text overflow, linked files and effective image resolution, clickable findings and automatic rechecking; scores and estimates unchanged; previously: PDF export writes the document language as the catalog's `/Lang`, #3644; M1: an Alt-drag in the Layers panel copies a row above or below its own place, #8237; scores and estimates unchanged; previously: PDF import: a glyph filled only after a glyph filled and stroked comes in filled only, not stroked, #8300; PDF import: translucent type filled and stroked comes in as a filled type object and a stroked one, as the file composites them, and an upright glyph is never kept as the outline of its glyph alone, #8015; PDF import: type filled and stroked by one text-showing operator comes in as one type object, filled and stroked, not a stroked copy over a filled one, #8015; M1: Layers panel Alt-drag shows the copy cursor, #8217; scores and estimates unchanged; previously: Gradient panel: the add-stop strip shows the white arrow with a plus on Windows and X11, #8241; scores and estimates unchanged; previously: Recolor Artwork follow-up (#8031, remaining #4028): native Lab input, picker swatch libraries and Assign-row menus; UI interaction regression coverage; scores and estimates unchanged; previously: Eraser review: hidden Rasterize and Along/Across stroke rows do not block preserving visible gradients; scores and estimates unchanged; previously: Eraser review: ordinary Group/Layer paints and reproducible evaluated gradient placements are preserved; other placements retain exLine truncated
|
||||
>
|
||||
> Oversized artboard import update (2026-11-12): Explicit editing-data import retains a single artboard beyond a capped 14,400 pt PDF page (#6865).
|
||||
>
|
||||
@@ -179,7 +179,7 @@ Gujarati interface follow-up (2026-11-14): the catalog and zero/one plural rule
|
||||
| M2 | Drawing tools + smart guides | ✅ mostly done (Eraser preserves fill outside fixed and varied tip sweeps and Alt-drag marquees on fill-only open paths and keeps their compound holes; clipping masks retain surviving contours or empty geometry in the same node; ordinary Group/Layer paints and evaluated gradient placements are preserved when the stored paint reproduces their appearance; hidden Rasterize and Along/Across stroke rows do not block visible gradients; replacement-art effects, plug-ins/Rasterize, along/across-stroke gradients and placements that cannot be reproduced keep their existing fitting; stroked open paths retain main behavior (#6582); #3380 deletion creates independent selected path pieces and keeps bounds-fitted gradients in place; endpoint highlighting remains open; Polygon/Star exact-size count persistence, with repeated-drag, tool-switch and Cancel regression coverage; Curvature point markers without direction handles (#1236, in part); Direct Selection segment click/Delete preserves neighboring edges, #1278; Flare, Reshape, Live Corners widget dragging and per-corner radii and kinds landed, on any path's corners; Shaper rough-shape recognition and orientation steps, the remaining Pen modifier nuances; Shaper Groups with editable sources and separate fill/stroke edits landed; custom ruler origin with drag preview, active-artboard reset, relative X/Y fields and native round-trip (#1212); construction widget/refinements pending); a shape just drawn moves by its centre point and turns from the zone outside a corner with its tool still active (#5477); Tangent and straight-segment perpendicular snapping use saved Smart Guides Geometric Guides preferences and Control bar quick access (#2537), including the existing Snap to Glyph and Alignment Guides toggles (#6164); no View submenu; Copy and Cut with the Pen or Curvature tool take the anchors a Cmd/Ctrl-lent Direct Selection picked (#6123); Scissors hover and cuts use the Pen's path/align/intersect/anchor snaps, with Alt Add Anchor and cut endpoint selection retained (#6470) | 12–18 |
|
||||
| M3 | Paint & appearance (swatches, color, gradient, stroke, appearance, transparency, styles) | ✅ done (M3.7–M3.98): swatches, groups, libraries, tints, Lab spots and Registration; Eyedropper copies transformed character dimensions (#6404) and styles highlighted text only (atomic transparency rejection); Eyedropper reads visible locked and outside-isolation sources (#1251); Color Picker, Color panel (its spectrum grows with a resized panel, #8005), Color Guide, Color Themes, Edit Colors and Recolor Artwork (screen-bounded Edit chip list, #3416; native Lab entry and swatch libraries in the picker, Assign-row menus, #8031/#4028); gradients that follow every transform, the annotator, linked stops, freeform gradients, focal points, gradients on strokes and Expand; visible strokes when paint is added to inherited None/zero-width art (#1253); stroke geometry, arrowheads, dashes fitted to corners, stroke on type, width profiles and the Width tool (Shift-double-click enables adjoining adjustment in Width Point Edit; finite-arithmetic follow-up regressions and full CI passed ([Validation evidence](target-app-parity.md#evidence-what-ships-today-by-area))), Scale Strokes and preview bounds; Appearance targeting, container appearance, target circles, Expand Appearance; knockout, isolation, blend accuracy, CMYK blending, overprint, Attributes, masks and clipping, Flatten Transparency; graphic styles, links and libraries; CSS library export preserves fractional linear and radial gradient stop positions. Left: freeform gradients in SVG/PDF, mixed spot/process gradients in SVG and PDF gradients mixing a spot color with RGB or Lab stops export as stops or process colors; PDF export writes dithered gradient fills with spot stops, and Perceptual spot gradients with RGB or Lab stops other than white or more than 4,096 stops on their curve, as images in process colors; confirm the Scale Strokes & Effects default; Recolor model selection is available through the engine and MCP only (#2520); the dialog retains its existing controls; Library panels' lists (swatch, Color Book, brush, symbol and graphic style libraries) fill a taller panel above its footer (#2992; scores and estimates unchanged); Graphic Styles list fills a taller panel above its footer (#2992; scores and estimates unchanged); Swatches list fills a taller panel above its footer (#1638; `the_list_fills_a_tall_panel_above_its_footer`; scores and estimates unchanged); | 4–8 |
|
||||
| M4 | Files (native, SVG, PDF, raster, Export for Screens, clipboard interop) | `.ai` and EPS import: clipping paths grouped in a compound path are its subpaths (#8128; estimates unchanged); Production Preflight checks fonts, overflow, links and image resolution with clickable findings and automatic rechecking (VectorCraft addition; estimates unchanged); PDF import: a glyph filled only after a glyph filled and stroked comes in filled only, not stroked (#8300; estimates unchanged); PDF import: type filled and stroked by one text-showing operator comes in as one filled and stroked type object (#8015; not for type filled and stroked at less than full opacity, which still comes in as a filled object and a stroked one, as the file composites them; estimates unchanged); PDF import: type filled and stroked by a `TJ` whose kerning starts a new line part way through comes in filled and stroked, a type object for each part, also where it draws a glyph again where it drew one, in an `ActualText` span too, where it stays one replacement type object on the first glyph's line and in its style; a `TJ` over more than 65 lines (the 64 its fill pass finished, kept back, and the open one) stays a filled object and a stroked one for each part (#8543; estimates unchanged); PDF import: type filled and stroked after a page of type filled only (more than 64 lines) comes in as one filled and stroked type object again, with or without a path between, and a `TJ` over more lines than are kept with a glyph kept as an outline still stays a filled object and a stroked one for each part (#8549 follow-up; estimates unchanged); PDF import: stroked type keeps the file's line cap, line join and miter limit (#7741; estimates unchanged); Rename artboards in Export for Screens (#7275); Explicit editing-data import keeps oversized capped-page artboards (#6865; estimates unchanged); Save refusal continuation (#6146): ordinary Save offers Save As; unchanged format keeps options, changed format opens its Save options; cancellation/automation isolation; focused UI regressions passed, native acceptance pending; PDF authored ActualText preserved once in editable import (#6165; first-glyph line/style, bounded input; estimates unchanged); PDF export keeps harakat and zero-advance Noto Arabic dot glyphs in one compatible batch per layout line, with per-glyph vertical offsets (#6309). `crates/pdf/src/tests/realtext.rs` (`mark_text_*`) checks decoded cluster mappings, mixed Arabic/Latin/digits, contour placement against outline export, vertical columns, differing path rotations and PDF/X-1a/3/4. Editable-text import preserves authored ActualText separately (#6165), with cross-line/style layout limits; separately styled or differently rotated clusters and external viewer search/copy remain outside this export-only evidence. `.ai`/EPS type from the text document keeps its paragraphs' tab stops (#6147); `.ai`/EPS type from the text document keeps auto leading per line, its hyphenation options, and may show more of the last lines the file sets in an area frame of its own, when growing the frame by its lines' deepest descent plus 0.05 pt shows them (#6137); ✅ done (M4.14–M4.98 on 2026-10-05): Save As/Save a Copy/Revert/templates, Data Recovery and background save, SVG import and export fidelity (units, text, symbols, filters, SVGZ, Preserve Editing, SVG Options), shared guarded PDF writer and windowed reader ([pdf-backend.md](pdf-backend.md)), PDF import (colours, layers, masks, editable text, security) and export (presets, marks, bleed, ICC and output intent, raster effects, subset fonts, PDF/X-1a, X-3 and X-4, PDF layers, overprint, page thumbnails, fast web view, PDF 1.3), Place and Links, Package, EPS and DXF in and out (EPS legacy mesh corners, vector opacity masks and raster page comparison verified; closed SPLINE flags round-trip and circular paths export as native CIRCLE/ARC, #1299), EMF/WMF, TIFF/BMP/Targa/PSD/GIF/PNG-8 export, Print and print presets, slices, Save for Web, TIFF in Export for Screens and Asset Export, clipboard flavours, File Info; AF.1–AF.4 add Affinity import (native layers, artboards, vectors, text and images from Affinity 1–3 files; the embedded preview only as a warned fallback; AF.4 expands current `.af` fixtures and every-board round-trip validation); EPS Save and Save As keep an opened EPS as EPS with its page frame and complete editable VectorCraft document (2026-10-26; G9 import fidelity unchanged). Left: DWG (use DXF), PSD placement as layers, overprint read back from PDF, Affinity export, polish; SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts; SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts; PDF import: glyphs inside a marked-content span with an empty `ActualText` come in as outlines in their fill and stroke, adding Line truncated
|
||||
| M5 | Performance | 🟡 background render + caches + MT done; text thread overlays index repeated selection lookups, keeping the first lookup and singleton selections direct (#6543); `vectorcraft-cli bench` and `vectorcraft-cli perf` (budget suite); opaque solid-fill knockout paths draw once in hard-edge/supersampled raster export, with analytical-AA compositing unchanged; file format v2 opens 3× faster (50k paths: 722 → 244 ms); raster effects (glows, shadows, blur, feather) no longer force the whole frame single-threaded (filtered offscreen per effect, verified equal to the single-threaded reference); Craquelure/Mosaic Tiles/Stained Glass distance searches optimized with pixel-invariance checks and the `texture_drag_perf` probe (#1257); effect-heavy demos need a clean-machine benchmark; dirty-region rendering, GPU backend spike pending | 15–25 |
|
||||
| M5 | Performance | 🟡 background render + caches + MT done; text thread overlays index repeated selection lookups, keeping the first lookup and singleton selections direct (#6543); `vectorcraft-cli bench` and `vectorcraft-cli perf` (budget suite); opaque solid-fill knockout paths draw once in hard-edge/supersampled raster export, with analytical-AA compositing unchanged; file format v2 opens 3× faster (50k paths: 722 → 244 ms); raster effects (glows, shadows, blur, feather) no longer force the whole frame single-threaded (filtered offscreen per effect, verified equal to the single-threaded reference); Craquelure/Mosaic Tiles/Stained Glass distance searches optimized with pixel-invariance checks and the `texture_drag_perf` probe (#1257); effect-heavy demos need a clean-machine benchmark; in the web build an edit while the view of a heavy document moves draws only the part it changed into the last frame (#8688); dirty-region rendering, GPU backend spike pending | 15–25 |
|
||||
| M6 | Path operations (Pathfinder, Shape Builder, offset…) | ✅ mostly done (live compound shapes: Make, Alt-click a Shape Mode, member modes, Release, Expand (#4522); single-result Pathfinder names and SVG IDs retained (#1293); Divide open-cutting-path geometry, appearance and history verified (#1307; existing segment cap remains); Simplify preview/counts and rewritten-path component selection verified (#1272; the slider opens at the Auto-Simplify level; a Direct Selection part of a path simplifies on its own); Compound appearance and member fill-rule edits verified (#1197); Boolean precision on almost-horizontal edges fixed and the property tests made deterministic; Shape Builder gap detection, large-offset bug open); Shape Builder Gap Detection shares Live Paint’s spatial gap finder and temporary merge bridges (#2526); Custom is capped at 72 pt in the existing options dialog | 3–6 |
|
||||
| M7 | Type (point/area/path, editing, styles, OpenType, threading, glyphs) | Spell check engine: `text.spelling.check` and `text.spelling.suggest` on craft-proof, the custom dictionary and Ignore All commands, Auto Spell Check with its right-click suggestions, Ignore All and Add to Dictionary, Spelling › Auto Spell Check in the context menu of type, the Edit Custom Dictionary dialog, and the modal Check Spelling dialog (Edit › Spelling › Check Spelling…, `Cmd+I`, `ui.checkSpelling`, #4936); 🟡 Retype phase 1: `type.retype` turns outlined text that exactly matches an available font back into point text (#4934); Right-aligned area type sets the text after a line's last tab against the right edge, the text before it at its stops (#6147); A line a soft return ends is justified as a wrapped line is (#6137); Indian-language pattern hyphenation preserves syllables in both composers (#4947); 🟡 Hanging punctuation keeps its published amounts under Glyph Scaling, and Standard burasagari counts a hung line start as room; Fullwidth `!` / `?` keep an upright fallback in vertical type; Hyphenation… and Justification… per paragraph (#2310, #2755), Auto Leading also driving the Character panel's Leading, the Alt+↑/↓ leading nudge and Fill with Placeholder Text; Document-point character controls after object/group scaling (#1034; optional font-size preservation remains separate), Character/Paragraph Styles (explicit Auto-leading resets and local leading overrides), per-paragraph paragraph attributes, mixed paragraph alignment indication (headless regressions, full integration CI and visual review pass), Area Type Options (with Width/Height, Auto Size and Shrink Text to Fit; overflow reported to agents and vertical Align), type areas resized by their handles and reshaped with Direct Selection, threaded text, Fit Headline, Glyphs (feature-valued alternates and unencoded glyphs applied in one Undo step while keeping Arabic joining, #5514), OpenType panel (including font-defined Stylistic Sets), Find Font (Document, Recent and System replacement sources, #5217), installed system fonts in every font menu (fonts registered with Windows outside its font folders, the XDG and Flatpak host font folders on Linux, and fonts installed while the app runs, listed when it comes back to the front; searchable; the Character and Properties menus show each family's sample of the selected text, preview it live under the pointer or ↑/↓, show recently applied families first (#3515), filter by script and kind, list a family's styles, and star favourites; the Glyphs panel and Find Font's Replace With use the same menu without the live preview) and found by name on open/import (full-name aliases and Missing Fonts searches verified, #1258; Windows font-service QA pending), variable fonts' named instances as styles, CJK names in the UI, input methods (marked text in place, candidate window at the caret; Japanese IME), Text Wrap (offset, invert, both sides of an object; follows edits), Type on a Path effects and Options with draggable start/centre/end brackets (slide, flip), tab stops + Tabs panel (Above Text floats it over the selected text, its ruler at the canvas zoom so stops line up with the columns, #729), inline symbols in text (beyond parity), Hebrew/Arabic bidirectional text, Paragraph Direction, Every-line/Single-line Composer per object (ragged text too) done; paint-only Arabic harakat keep joining with GDEF-mark ownership and Insert Kashidas tatweels on the base letter's paint (`tests::harakat`); tab leaders, vertical type pending | 45–60 |
|
||||
| M8 | Transform & distort (Puppet Warp, Liquify tools, Envelopes, Blends, Perspective Grid) | ✅ done (M8.1–M8.20 on 2026-10-06, fidelity pass): Liquify Tool Options with one shared brush, pen pressure, hold-to-apply, a safe scope and incremental strokes; tool options that last; Puppet Warp rotation, multi-select, Control bar and a rest-shape session that follows Undo; Width tool on compound paths; Envelope dialogs with preview, Reset with Warp/Mesh, full Envelope Options, type/images/symbols/appearance/gradients/patterns distorted on canvas and in every export, warps that keep their frame, Edit Contents, mesh handles and Control bar; Blend Options, anchor-targeted Blend tool, editable spine, keys picked on the canvas, faithful interpolation and knockout; Anchor Point spine conversion/handle editing and selection priority (#2544), with #2425 Shift reshape preserved; Perspective Grid with Define Grid, presets, lock/snap/rulers, widgets, the 1–4 plane switch, movable planes, Perspective Selection scale/copy/perpendicular/Transform Again, and type and symbols truly projected with Edit Text. Left: Anti-Alias and Preserve Shape output, warp-envelope point editing, brush interpolation in blends, Free Transform/Scale/Reflect along a rotated box | 2–4 |
|
||||
@@ -232,6 +232,7 @@ not take the artwork yet. Overflow-menu drag remains separate. Scores and hours
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-19 | minor | M5: In the web build, an edit while the view of a heavy document moves (a tool drag held at an edge of the canvas, #8551, or a wheel scroll during a drag) draws only the part it changed into the last frame, which stays drawn moved with the view, instead of rendering the whole canvas each frame (an edit that changes more than half of the frame, or a change of more than the view and the document, still renders it whole at once), and edits that go on once the view is still don't put off its render (#8688). Scores and estimates unchanged. |
|
||||
| 2026-11-18 | minor | M10/G5: Media Controls joins Basic Shapes, UI Frames, Map Markers, Inventory Icons, Skill Icons and Weather Icons as a seventh built-in symbol library (Play, Pause, Stop, Skip Next, Shuffle, Repeat; original procedural vector symbols generated in code, no default 9-slice); G5 estimate decremented to 2–12 h, milestone estimates unchanged |
|
||||
| 2026-11-18 | minor | M7/G4: Retype phase 1 (#4934): `type.retype` turns outlined text that exactly matches an available font back into point text. Scores and estimates unchanged |
|
||||
| 2026-11-18 | minor | M1: Lock Guides: a selection marquee (Selection, Direct Selection, Group Selection, Enclosing Lasso) leaves out paths made into guides inside groups and compound paths too, as clicks do (#3074), so a group is no longer selected by a locked guide in it; an enclosing marquee measures a group without its locked or hidden guides, and Direct Selection takes no anchor or segment of a guide that can't be picked; a guide in a group still moves with its group (#8538). Scores and estimates unchanged. |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Parity with Adobe Illustrator
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (G12: Brushes panel: item right-click context menu (Brush Options, Duplicate Brush, Delete Brush) with selection handling; scores and estimates unchanged; previously: G12: Links panel row context menu (Relink…, Go To Link, Update Link, Edit Original, Show in Folder, Embed Image / Unembed…) with selection handling; scores and estimates unchanged; previously: Artboard tool: Shift held once a move or Alt-copy drag is under way keeps it to the level, upright or 45° line, #8580; scores and estimates unchanged; previously: Image Trace Ignore Color keeps the canvas View and stays armed on a missed pixel (#8068); a tool drag held near an edge of the canvas scrolls the view, #8551; scores and estimates unchanged; previously: G12: Place: show progress window with Cancel for slow placed files exceeding 0.4 s, part of #5930; scores and estimates unchanged; previously: All Tools drawer: a tool the toolbar holds is dimmed in the readable dim text colour, not the disabled colour that was unreadable against the panel, and a hovered dimmed row takes the panel's darker fill so it stays readable, #8294; scores and estimates unchanged; previously: Layers: selected guide rows stay highlighted after the pointer leaves (#7344); scores and estimates unchanged; previously: PDF import: type filled and stroked after a page of type filled only comes in filled and stroked, #8549 follow-up; scores and estimates unchanged; previously: selected Dimension extension-line color and weight in Properties (#7078; four focused UI regressions passed); scores and estimates unchanged; previously: Brush Options Key Color: restore canvas input for the existing one-shot pick, then resume the retained draft and previous tool (#8284; six full-app input regressions passed); scores and estimates unchanged; previously: #8200: `.ai` and EPS import: an Art brush in Tints of a swatch-linked stroke color comes in brushed, its tints linked to the swatch; scores and estimates unchanged; previously: Ellipse: Up/Down changes Anchors while drawing (#7840); scores and estimates unchanged; previously: Windows/Linux menu access keys and localized cues (#6596); previously: Backquote/~ arrow pattern nudges (#7717); scores and estimates unchanged; previously: Window > Toolbars > Compact Tools offers optional denser main Tools spacing (#7234); default layout, scores and estimates unchanged; previously: Direct Selection: Space during an ordinary path's handle drag repositions its anchor and handles, including a Pen loan (#7237, request 3 only; scores and estimates unchanged); previously: SVG export preserves document units on root width/height for physical units, #864; G11 estimate 8–15 → 6–13 h; previously: Floating panels keep their window level while focus moves between the app's windows, so a press on one panel's bar no longer hands the keyboard to another, #6986; scores and estimates unchanged; previously minor: #8128: `.ai` and EPS import: clipping paths grouped in a compound path are its subpaths, so the compound clipping path clips its clipping group; scores and estimates unchanged; previously: import: type filled and stroked by a `TJ` whose kerning starts a new line comes in filled and stroked, #8543; PDF Retype phase 1 (#4934): Type › Retype (`type.retype`) turns outlined text that exactly matches an available font back into point text; scores and estimates unchanged; previously: Lock Guides: a selection marquee (Selection, Direct Selection, Group Selection, Enclosing Lasso) leaves out paths made into guides inside groups and compound paths too, as clicks do (#3074), so a group is no longer selected by a locked guide in it; an enclosing marquee measures a group without its locked or hidden guides, and Direct Selection takes no anchor or segment of a guide that can't be picked; a guide in a group still moves with its group (#8538); Production Preflight: output-aware fonts, text overflow, linked files and effective image resolution, clickable findings and automatic rechecking; scores and estimates unchanged; previously: PDF export writes the document language as the catalog's `/Lang`, #3644; Layers panel: an Alt-drag copies a row above or below itself, so the top layer dragged up, the bottom layer dragged down and a lone layer are copied, #8237; scores and estimates unchanged; previously: Twist: a strongly twisted path joins its pieces without kinks, #7069; scores and estimates unchanged; previously: PDF import: a glyph filled only after a glyph filled and stroked comes in filled only, not stroked, #8300; PDF import: translucent type filled and stroked comes in as a filled type object and a stroked one, as the file composites them, and an upright glyph is never kept as the outline of its glyph alone, #8015; PDF import: type filled and stroked by one text-showing operator comes in as one type object, filled and stroked, not a stroked copy over a filled one, #8015; LayeLine truncated
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (G12: Brushes panel: item right-click context menu (Brush Options, Duplicate Brush, Delete Brush) with selection handling; scores and estimates unchanged; previously: In the web build, an edit while the view of a heavy document moves (a tool drag held at an edge of the canvas, #8551, or a wheel scroll during a drag) draws only the part it changed into the last frame, which stays drawn moved with the view, instead of rendering the whole canvas each frame, and edits that go on once the view is still don't put off its render (#8688); scores and estimates unchanged; previously: G12: Links panel row context menu (Relink…, Go To Link, Update Link, Edit Original, Show in Folder, Embed Image / Unembed…) with selection handling; scores and estimates unchanged; previously: Artboard tool: Shift held once a move or Alt-copy drag is under way keeps it to the level, upright or 45° line, #8580; scores and estimates unchanged; previously: Image Trace Ignore Color keeps the canvas View and stays armed on a missed pixel (#8068); a tool drag held near an edge of the canvas scrolls the view, #8551; scores and estimates unchanged; previously: G12: Place: show progress window with Cancel for slow placed files exceeding 0.4 s, part of #5930; scores and estimates unchanged; previously: All Tools drawer: a tool the toolbar holds is dimmed in the readable dim text colour, not the disabled colour that was unreadable against the panel, and a hovered dimmed row takes the panel's darker fill so it stays readable, #8294; scores and estimates unchanged; previously: Layers: selected guide rows stay highlighted after the pointer leaves (#7344); scores and estimates unchanged; previously: PDF import: type filled and stroked after a page of type filled only comes in filled and stroked, #8549 follow-up; scores and estimates unchanged; previously: selected Dimension extension-line color and weight in Properties (#7078; four focused UI regressions passed); scores and estimates unchanged; previously: Brush Options Key Color: restore canvas input for the existing one-shot pick, then resume the retained draft and previous tool (#8284; six full-app input regressions passed); scores and estimates unchanged; previously: #8200: `.ai` and EPS import: an Art brush in Tints of a swatch-linked stroke color comes in brushed, its tints linked to the swatch; scores and estimates unchanged; previously: Ellipse: Up/Down changes Anchors while drawing (#7840); scores and estimates unchanged; previously: Windows/Linux menu access keys and localized cues (#6596); previously: Backquote/~ arrow pattern nudges (#7717); scores and estimates unchanged; previously: Window > Toolbars > Compact Tools offers optional denser main Tools spacing (#7234); default layout, scores and estimates unchanged; previously: Direct Selection: Space during an ordinary path's handle drag repositions its anchor and handles, including a Pen loan (#7237, request 3 only; scores and estimates unchanged); previously: SVG export preserves document units on root width/height for physical units, #864; G11 estimate 8–15 → 6–13 h; previously: Floating panels keep their window level while focus moves between the app's windows, so a press on one panel's bar no longer hands the keyboard to another, #6986; scores and estimates unchanged; previously minor: #8128: `.ai` and EPS import: clipping paths grouped in a compound path are its subpaths, so the compound clipping path clips its clipping group; scores and estimates unchanged; previously: import: type filled and stroked by a `TJ` whose kerning starts a new line comes in filled and stroked, #8543; PDF Retype phase 1 (#4934): Type › Retype (`type.retype`) turns outlined text that exactly matches an available font back into point text; scores and estimates unchanged; previously: Lock Guides: a selection marquee (Selection, Direct Selection, Group Selection, Enclosing Lasso) leaves out paths made into guides inside groups and compound paths too, as clicks do (#3074), so a group is no longer selected by a locked guide in it; an enclosing marquee measures a group without its locked or hidden guides, and Direct Selection takes no anchor or segment of a guide that can't be picked; a guide in a group still moves with its group (#8538); Production Preflight: output-aware fonts, text overflow, linked files and effective image resolution, clickable findings and automatic rechecking; scores and estimates unchanged; previously: PDF export writes the document language as the catalog's `/Lang`, #3644; Layers panel: an Alt-drag copies a row above or below itself, so the top layer dragged up, the bottom layer dragged down and a lone layer are copied, #8237; scores and estimates unchanged; previously: Twist: a strongly twisted path joins its pieces without kinks, #7069; scores and estimates unchanged; previously: PDF import: a glyph filled only after a glyph filled and strokLine truncated
|
||||
>
|
||||
> Tech Circuit update (2026-11-14): three original procedural brushes; ten built-in brush libraries (G5).
|
||||
>
|
||||
@@ -1235,7 +1235,8 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
- **The Symbols panel reads its current symbol from the document:** the Symbols panel and its panel menu read the current symbol on each frame without running `symbol.list`, which counts every symbol's instances by walking the whole document. The current symbol they show and act on is the one `symbol.list` reports, and an idle frame of the panel or its menu runs no command, so on macOS the native menu is not brought up to date on every frame while the panel is open. In a document with 200 symbols and 50,000 objects, the read takes 0.035 µs instead of 48.5 ms in a release build (thread CPU time on Linux, median of 7 runs); in a small document the difference is too small to notice. Tests: `tests::brushsym::current_symbol_is_the_current_symbol_list_answers`, `panels::symbols::tests::current_is_the_current_symbol_list_answers`, `panels::symbols::tests::idle_frames_of_the_panel_and_its_menu_run_no_command`; the timing probe is `panels::symbols::tests::current_symbol_read_timing`.
|
||||
- **Expand of symbol instances:** Object › Expand turns selected symbol instances (without effects, not in perspective, in groups or placed documents too) into their art as Break Link to Symbol places it, one level deep, as one undo step; the Expand dialog's Fill and Stroke reach that art (`object.expand`, `crates/engine/src/tests/expand_symbols.rs`; estimated, score unchanged).
|
||||
- **Reset Transformation** ([Transform symbols](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/transform-symbols.html), [Symbols panel options](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/symbols-panel-options.html)): the Symbols panel menu's Reset Transformation and the Control bar's Reset, shown while symbol instances are selected, give the selected instances their symbol's own scale again, without rotation or shear, as one undo step (`symbol.instance.resetTransform`); an instance in perspective is left as it is. VectorCraft's own rules: each instance keeps the center of its bounding box in place, reflection is removed too, and the menu item and the button are enabled only while a selected instance would change. Tests: `tests::brushsym::reset_transformation_restores_the_symbols_scale_and_keeps_the_center`, `reset_transformation_keeps_the_center_of_art_away_from_the_origin`, `reset_transformation_ignores_a_stored_size_that_is_not_positive`, `reset_transformation_leaves_unchanged_instances_and_refuses_bad_ids`, `panels::symbols::tests::reset_transformation_is_enabled_for_a_transformed_instance_and_resets_it`.
|
||||
- **Symbolism Tools Options** ([Symbolism tool options](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/symbolism-tool-options.html), [the archived manual](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=118)): the dialog a double-click on a symbolism tool opens has, besides Diameter, Intensity and Symbol Set Density, Use Pressure Pen (a pen's pressure is the intensity), Method (User Defined, Average or Random) for the Scruncher, Sizer, Spinner, Stainer, Screener and Styler, Show Brush Size and Intensity, the Symbol Sprayer's Scrunch, Size, Spin, Screen, Stain and Style (each Average or User Defined), and the Symbol Sizer's Proportional Resizing and Resizing Affects Density; a new Symbol Set Density spaces the instances of the selected symbol sets (`symbol.setDensity`). VectorCraft's own rules: a Tool row lists the eight tools by name and shows the chosen one's options; Random gives each instance its own share of the change for the whole stroke; Average moves each value toward the mean of the instances under the brush; the starting values are Method User Defined, the Sprayer's six options Average, Proportional Resizing on and Resizing Affects Density off, so only a Sprayer stroke over instances of the selected set changes from before (its new instances take their mean values); the brush shows the intensity as a dashed ring. The Symbol Sprayer does not use Intensity or pen pressure. Tests: `crates/engine/src/tests/symbolism_options.rs`, `symbolism::tests` in `crates/tools`, `dialogs::symbolism_options::tests`.
|
||||
- **Symbolism Tools Options** ([Symbolism tool options](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/symbolism-tool-options.html), [the archived manual](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=118)): the dialog a double-click on a symbolism tool opens has, besides Diameter, Intensity and Symbol Set Density, Use Pressure Pen (a pen's pressure is the intensity), Method (User Defined, Average or Random) for the Scruncher, Sizer, Spinner, Stainer, Screener and Styler, Show Brush Size and Intensity, the Symbol Sprayer's Scrunch, Size, Spin, Screen, Stain and Style (each Average or User Defined), and the Symbol Sizer's Proportional Resizing and Resizing Affects Density; a new Symbol Set Density spaces the instances of the selected symbol sets (`symbol.setDensity`). VectorCraft's own rules: a Tool row lists the eight tools by name and shows the chosen one's options; Random gives each instance its own share of the change for the whole stroke; Average moves each value toward the mean of the instances under the brush; the starting values are Method User Defined, the Sprayer's six options Average, Proportional Resizing on and Resizing Affects Density off; with them, two strokes change from before: a Sprayer stroke over instances of the selected set gives its new instances their mean values, and the Symbol Styler applies the style by the brush's strength, so a click at the brush's center at the default intensity 5 applies it at half opacity instead of in full, and a stroke's samples add up; the brush shows the intensity as a dashed ring. The Symbol Sprayer does not use Intensity or pen pressure. Tests: `crates/engine/src/tests/symbolism_options.rs`, `symbolism::tests` in `crates/tools`, `dialogs::symbolism_options::tests`.
|
||||
- **Symbolism tools with Shift** ([the manual](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=199), [the CS6 reference](https://web.archive.org/web/20220911143322/https://helpx.adobe.com/pdf/cs6/illustrator_reference.pdf#page=136)): a Shift-click with the Symbol Shifter brings the instances under the brush forward in the stacking order and Alt+Shift-click sends them backward; the Symbol Sizer with Shift keeps the set's density while it resizes; the Symbol Stainer and the Symbol Styler with Shift keep the amount of stain or style and move the color or style toward the current fill or the selected style (`symbol.adjust {shift}`). VectorCraft's own rules: the Shifter moves each instance one place among its siblings, once per stroke, without moving it on the canvas; the Sizer keeps each instance's center, even with Resizing Affects Density; a stain or style with no form between it and the new paint (a solid color and a pattern) takes the new paint at once; an instance without a stain or style is left as it is, and Alt has no effect on the Stainer or the Styler with Shift. The selected style is the one last clicked into the Graphic Styles panel's selection. Tests: `crates/engine/src/tests/symbolism_shift.rs`, `symbolism::tests::shift_reaches_the_tools_that_have_a_shift_form`, `panels::graphic_styles::tests::shift_click_selects_a_range_and_cmd_click_adds_or_removes_one_style`.
|
||||
- **The Symbols and Properties panels find selected symbol instances once per revision:** whether the selection or its groups hold a symbol instance (Break Link to Symbol), one with appearance changes of its own (Reset Symbol Instance and the Properties panel's Reset), or one Reset Transformation would change is worked out in one walk of the selected objects for each document revision, and later frames reuse it. The buttons and menu items are enabled as before. With one selected group of 300,000 paths, the two panels' reads took a median 5.1 to 5.7 ms of thread CPU time per frame; the first read after a change now takes about 3 ms and later frames about 5 ns (Linux, opt-level 3, median of 7 runs). In a small document the difference is too small to notice. Tests: `panels::symbols::tests::instance_flags_are_found_once_per_revision_and_match_a_walk_of_the_selection`, `properties_and_symbols_panels_walk_the_selection_once_per_revision`.
|
||||
- **Expand of dimensions:** Object › Expand, Expand Appearance, Create Outlines and Outline Stroke turn a dimension whose art they change into a plain group of that art, which stays as it is through later moves, scales and edits of what it measured; undo gives the live dimension back (`crates/engine/tests/it/dimensions.rs`; VectorCraft's own rule; estimated, score unchanged).
|
||||
- **Brush libraries** ([public source](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/create-new-brush-libraries.html), [import](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/import-brushes-from-brush-libraries-or-other-files.html), [Brushes panel](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/brushes-panel-overview.html)): Window › Brush Libraries, the Brushes panel's Brush Libraries Menu and its menu's Open Brush Library open each library in a library panel of its own, as swatch, graphic style and symbol libraries do. The built-in libraries (Art Ribbons, Ink and Wash, Calligraphic Nibs, Pressure Sensitive, Bristle Brushes, Pattern Borders, Scatter Shapes, Stipple, Game Trails, Energy Beams, Dry Media, Tech Circuit, Engraving, Arrows) are original brushes generated in code (`crates/engine/src/cmd/brushlib.rs`); Striped Ribbon's art is filled with the library's own pattern and Sparkles scatters the library's own symbol; Ink and Wash adds ink and wash brushes (the [help page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/about-brushes.html) lists an Ink brush library of strokes with varied thickness and texture; the names, shapes and opacities are VectorCraft's own): Tapered Ink, an art brush broad near its start that thins to a fine tip; Brush Pen, a calligraphic brush whose size follows the pen pressure; and Soft Wash and Pooling Wash, art brushes of translucent gray layers that take the stroke color as tints; Game Trails adds motion art brushes (Speed Line, Dash Trail, Burst Ray, Zigzag); Energy Beams adds laser and plasma art brushes (Laser Bolt, Plasma Arc, Charge Wave, Spark Trail); Dry Media adds grainy art brushes (Chalk Grain, Graphite Pencil, Wax Crayon, Charcoal Dust); Engraving adds fine-line hatching art brushes (Fine Hatching, Dense Hatching, Tapered Hatching, Broken Hatching). A click on a brush adds it to the document's Brushes as one undo step with every resource its art uses (patterns, symbols, swatches, graphic styles, images), makes it the current brush and, with paths selected, applies it to them in the same step; a brush the document already has is not added again and a different brush of the same name comes in numbered ("Wave 2"). Shift/Cmd-clicks select brushes for Add to Brushes; a brush dragged onto a path is added and applied to it, and one dragged onto the Brushes panel is added. Save Brushes… / the Brushes panel's Save Brush Library… write the document's brushes (or the selected ones) as a `.vectorcraft` library into the `Brushes` folder next to the preferences, listed under User Defined, or to a file; Other Library… reads the brushes of any document VectorCraft opens. Thumbnails, in the library panels, the Brushes panel and Brush Options, render brush art with the patterns and symbols it uses. Copying brushed art now carries the patterns and symbols its brush's art uses too. Tests: `crates/engine/src/tests/brushlib.rs`, `crates/ui-egui/src/panels/tests_brush_libraries.rs`, `panels::brushes::tests::library_brush_previews_show_the_patterns_their_art_uses`, `canvas::tests::a_library_brush_dropped_on_a_path_is_added_and_applied_in_one_step`.
|
||||
@@ -2487,6 +2488,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
When the Layers or Links panel shows another document's rows, the thumbnail thread drops the row thumbnails it has not started for the documents not shown, and it drops all of them when the Layers or Links panel is open after the last document closes. Those rows ask for their thumbnails again when their document shows again, and the thumbnails already made are kept. With 150 rows of 20,000-anchor paths waiting for another document, the 8 rows of such paths of the document shown get their thumbnails in 153 ms instead of 3,265 ms (debug test build, median of three runs).
|
||||
The Links panel keeps its `links.list` rows and Link Info in one shared cache, and a frame that fetches nothing new reads that cache without copying the rows. The cache is replaced when the document or its revision changes, the Show, Sort or Show DCS Transparency Interactions option changes, or the files are looked at again every 2 seconds, and, while an image is selected, when Link Info opens or closes or the first selected image changes. With 2,001 images a frame's cache step takes 0.2 µs instead of 1.79 ms, and with 10,001 images 0.2 µs instead of 12.2 ms (test build, median of 7 wall-clock runs of 1,000 frames, measured while other builds were running).
|
||||
In the web build, while a pan, zoom or rotation changes the view of a document whose last canvas render took more than 8 ms, the canvas draws the last frame moved with the view, and it renders the art again once the view has been still for 0.2 s.
|
||||
In the web build, an edit while that view moves (a tool drag held near an edge of the canvas, which scrolls the view, or a wheel scroll during a drag) draws only the part of the last frame that the edit changed, at the view that frame was rendered for, and the frame stays drawn moved with the view until the view has been still for 0.2 s (#8688). The part of the canvas a pan uncovers shows the pasteboard and the artboards' paper until then, as for a pan without an edit. Edits that go on after the view stops don't start that 0.2 s again: the whole canvas renders 0.2 s after the view stopped. An edit that changes more than half of the frame, or one while more than the view and the document change, renders the whole canvas at once as before. Tests: `canvas::tests::without_a_worker_a_heavy_canvas_is_reprojected_until_the_view_is_still`, `canvas::tests::without_a_worker_edits_while_the_view_is_still_do_not_hold_off_the_render`.
|
||||
An Alt-drag with the Selection, Direct Selection, Group Selection, Rotate, Scale, Reflect or Shear tool copies the selection on its first move, and the moves after it transform those copies; the previews of the Move, Rotate, Scale, Reflect and Shear dialogs with Copy and Preview on copy the selection once in the same way (#1429).
|
||||
An Alt-drag of objects in perspective with the Perspective Selection tool, and an Alt-drag of a plane widget with that tool or the Perspective Grid tool, copy the objects on the first move, and the moves after it move those copies (#1429).
|
||||
With the Perspective Selection tool, Ctrl+Alt-drag (Command+Option-drag on macOS) also copies objects on their perspective plane; Alt/Option-drag continues to do so.
|
||||
@@ -3114,6 +3116,7 @@ Edit › Copy and Cut put the selected ruler guides on the clipboard, with the s
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-19 | minor | Performance: In the web build, an edit while the view of a heavy document moves (a tool drag held at an edge of the canvas, #8551, or a wheel scroll during a drag) draws only the part it changed into the last frame, which stays drawn moved with the view, instead of rendering the whole canvas each frame, and edits that go on once the view is still don't put off its render (#8688). Evidence added; scores and estimates unchanged. |
|
||||
| 2026-11-19 | minor | Artboard tool: Shift held once a move or an Alt-drag copy of an artboard is under way keeps it to the level, upright or 45° line from General › Constrain Angle, and snaps slide it along that line; a Shift-press still draws an artboard inside another or marquee-selects (#2497), #8580. Scores and estimates unchanged. |
|
||||
| 2026-11-18 | minor | Layers panel: context menu on guide rows (Release Guide, Duplicate, Delete Guide, Lock/Unlock, Hide/Show) with one-step undo; regression tests in `crates/ui-egui/src/panels/layers/tests.rs`; scores and estimates unchanged. |
|
||||
| 2026-11-18 | minor | Type advanced: Retype phase 1 (`type.retype`, #4934), exact matches of available fonts become point text again; evidence added; near matches, the ranked font list and images remain; score and hours unchanged |
|
||||
|
||||
Reference in new issue
Block a user