mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-26 19:36:16 +00:00
Merge pull request #8989 from dotCooCoo/feat/blob-eraser-size-stylus-wheel
Blob Brush: Size offers Stylus Wheel
This commit is contained in:
@@ -147,7 +147,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Blob Brush",
|
||||
[],
|
||||
None,
|
||||
"{points: [[x,y]…] or [[x,y,pressure]…] (pen pressure 0..1; pen values are checked as path.freehand checks them), size?: pt (10; from 0.1 to 1000), sizeMode?: \"fixed\" (default) | \"pressure\" (Blob Brush Tool Options' Size set to Pressure: the brush is size − sizeVariation wide at the lightest pen pressure and size + sizeVariation at the heaviest, at least 0.1 pt; a stroke without pressure keeps the size), sizeVariation?: pt (0; from 0 to 1000, checked with Fixed too), angle?: ° (0, −180–180: the tip's long axis counter-clockwise from horizontal, kept on the page along the stroke), roundness?: % (100, 0–100: the tip's short axis in percent of its long one, 100 round; 0 is drawn as 0.1), fidelity?: pt (0.01–100; the brush follows the stroke fitted at this tolerance as path.freehand fits a Pencil stroke, and a higher value gives a smoother shape; without it the brush follows every point), merge?: true, mergeOnlySelection?: bool (false: merge with any touching same-color blob; true: only with selected ones), keepSelected?: bool (false: the drawn or merged path is not selected, and the rest of the selection stays; true: it is selected)} filled brush shape, merged with the topmost touching same-color blob and the touching ones next to it in stacking order in its group or layer → {id}. An angle, roundness or fidelity outside its range is rejected with an error, and nothing changes",
|
||||
"{points: [[x,y]…] or [[x,y,pressure]…] or [[x,y,pressure,tiltX,tiltY,rotation,wheel]…] (pen pressure 0..1, finger wheel 0..1; pen values are checked as path.freehand checks them), size?: pt (10; from 0.1 to 1000), sizeMode?: \"fixed\" (default) | \"pressure\" | \"stylusWheel\" (Blob Brush Tool Options' Size set to Pressure: the brush is size − sizeVariation wide at the lightest pen pressure and size + sizeVariation at the heaviest; set to Stylus Wheel: size − sizeVariation wide at one end of an airbrush pen's finger wheel travel, size at the middle and size + sizeVariation at the other end; at least 0.1 pt; a stroke without that reading, and a point without a wheel on Stylus Wheel, keeps the size), sizeVariation?: pt (0; from 0 to 1000, checked with Fixed too), angle?: ° (0, −180–180: the tip's long axis counter-clockwise from horizontal, kept on the page along the stroke), roundness?: % (100, 0–100: the tip's short axis in percent of its long one, 100 round; 0 is drawn as 0.1), fidelity?: pt (0.01–100; the brush follows the stroke fitted at this tolerance as path.freehand fits a Pencil stroke, and a higher value gives a smoother shape; without it the brush follows every point), merge?: true, mergeOnlySelection?: bool (false: merge with any touching same-color blob; true: only with selected ones), keepSelected?: bool (false: the drawn or merged path is not selected, and the rest of the selection stays; true: it is selected)} filled brush shape, merged with the topmost touching same-color blob and the touching ones next to it in stacking order in its group or layer → {id}. An unknown sizeMode, or an angle, roundness or fidelity outside its range, is rejected with an error, and nothing changes",
|
||||
has_doc,
|
||||
blob
|
||||
),
|
||||
|
||||
@@ -236,22 +236,27 @@ impl PenRecord {
|
||||
}
|
||||
}
|
||||
|
||||
/// Blob Brush and Eraser Tool Options' Size set to Pressure (`sizeMode: "pressure"`, with
|
||||
/// `sizeVariation` in points, 0..1000): the stroke's pen pressure along it and the variation, `None`
|
||||
/// for Fixed (the default), no variation or a stroke without pressure (a mouse), which keeps the
|
||||
/// size. A `sizeVariation` outside its range is an error with Fixed too.
|
||||
pub(super) fn size_pressure(p: &Value, samples: &[Sample], cmd: &str) -> Result<Option<(PressureProfile, f64)>> {
|
||||
/// Blob Brush and Eraser Tool Options' Size set to Pressure (`sizeMode: "pressure"`) or, for the
|
||||
/// Blob Brush, Stylus Wheel (`sizeMode: "stylusWheel"`), with `sizeVariation` in points, 0..1000:
|
||||
/// the stroke's pen pressure or airbrush finger wheel along it (0..1, the size less the variation
|
||||
/// at 0 and plus it at 1) and the variation. `None` for Fixed (the default), no variation or a
|
||||
/// stroke without that reading (a mouse, a pen without a wheel), which keeps the size. A
|
||||
/// `sizeVariation` outside its range is an error with Fixed too.
|
||||
pub(super) fn size_profile(p: &Value, samples: &[Sample], cmd: &str) -> Result<Option<(PressureProfile, f64)>> {
|
||||
const MODES: &str = "\"fixed\", \"pressure\" or \"stylusWheel\"";
|
||||
let variation = ranged(p, "sizeVariation", 0.0, SIZE_VARIATIONS, cmd)?;
|
||||
match p.get("sizeMode").filter(|v| !v.is_null()).map(|v| v.as_str().ok_or(v)) {
|
||||
None | Some(Ok("fixed")) => Ok(None),
|
||||
Some(Ok("pressure")) => Ok(stroke_pressure(samples).filter(|_| variation > 0.0).map(|prof| (prof, variation))),
|
||||
Some(Ok(other)) => Err(bad(cmd, format!("sizeMode is \"fixed\" or \"pressure\", not `{other}`"))),
|
||||
Some(Err(other)) => Err(bad(cmd, format!("sizeMode is \"fixed\" or \"pressure\", not {other}"))),
|
||||
}
|
||||
let read = match p.get("sizeMode").filter(|v| !v.is_null()).map(|v| v.as_str().ok_or(v)) {
|
||||
None | Some(Ok("fixed")) => return Ok(None),
|
||||
Some(Ok("pressure")) => stroke_pressure(samples),
|
||||
Some(Ok("stylusWheel")) => stroke_wheel(samples),
|
||||
Some(Ok(other)) => return Err(bad(cmd, format!("sizeMode is {MODES}, not `{other}`"))),
|
||||
Some(Err(other)) => return Err(bad(cmd, format!("sizeMode is {MODES}, not {other}"))),
|
||||
};
|
||||
Ok(read.filter(|_| variation > 0.0).map(|prof| (prof, variation)))
|
||||
}
|
||||
|
||||
/// The area a stroke along `spine` covers with Size set to Pressure: as wide at each point as
|
||||
/// [`vectorcraft_tools::draw2::pressure_size`] gives for the pressure `prof` records there, with
|
||||
/// The area a stroke along `spine` covers with Size set to Pressure or Stylus Wheel: as wide at
|
||||
/// each point as [`vectorcraft_tools::draw2::pressure_size`] gives for the reading `prof` records there, with
|
||||
/// round ends and joins, its overlaps united into one outline.
|
||||
pub(super) fn pressure_region(spine: &PathData, size: f64, variation: f64, prof: &PressureProfile) -> Result<PathData> {
|
||||
let widest = size + variation;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::common::{
|
||||
PenRecord, SIZE_VARIATIONS, SIZES, Sample, center_strokes, dist_to_polyline, fill_targets, has_fill, has_painted_ancestor_stroke,
|
||||
has_painted_stroke, ids_json, path_mut, path_of, points_param, poly_bounds, pressure_region, ranged, replace_with_pieces, samples_param,
|
||||
set_geometry, sibling_with, size_pressure, target_paths, usize_opt,
|
||||
set_geometry, sibling_with, size_profile, target_paths, usize_opt,
|
||||
};
|
||||
use super::{
|
||||
Anchor, AnchorKind, Beside, BezPath, BoolOp, Cap, Document, EngineError, FillRule, Join, NodeId, NodeKind, Paint, ParamCurve, PathData, Point,
|
||||
@@ -314,7 +314,7 @@ pub(super) fn erase_region(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if varies_beyond_size_pressure(&vary) {
|
||||
return erase_varied(s, &samples, [angle, roundness, size], vary);
|
||||
}
|
||||
let pressure = if vary[2].0 == Variation::Pressure { size_pressure(p, &samples, C)? } else { None };
|
||||
let pressure = if vary[2].0 == Variation::Pressure { size_profile(p, &samples, C)? } else { None };
|
||||
let pts: Vec<Point> = samples.into_iter().map(|s| s.pt).collect();
|
||||
let r = size / 2.0;
|
||||
// The tip's short axis (its narrowest with Pressure): an open path is sampled at least every half of it.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::common::{
|
||||
PenRecord, SIZES, Sample, brush_region, path_kind, path_mut, path_of, poly_bounds, pressure_region, ranged, samples_param, size_pressure,
|
||||
PenRecord, SIZES, Sample, brush_region, path_kind, path_mut, path_of, poly_bounds, pressure_region, ranged, samples_param, size_profile,
|
||||
stroke_paint, subpath_len, target_paths, within_input_bound,
|
||||
};
|
||||
use super::{
|
||||
@@ -843,8 +843,8 @@ pub(super) fn blob(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
let tip = vectorcraft_tools::draw2::blob_tip(angle, roundness);
|
||||
let squash = tip.inverse();
|
||||
// Width profiles use distance along the spine, so measure pressure on the same squashed
|
||||
// points that the outline reads for a non-round tip.
|
||||
// Width profiles use distance along the spine, so measure the pressure or wheel on the same
|
||||
// squashed points that the outline reads for a non-round tip.
|
||||
let mapped_samples: Vec<Sample> = if roundness < 100.0 {
|
||||
samples
|
||||
.iter()
|
||||
@@ -857,7 +857,7 @@ pub(super) fn blob(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
} else {
|
||||
samples.clone()
|
||||
};
|
||||
let pressure = size_pressure(p, &mapped_samples, C)?;
|
||||
let pressure = size_profile(p, &mapped_samples, C)?;
|
||||
let pts: Vec<Point> = samples.into_iter().map(|s| s.pt).collect();
|
||||
let mapped_pts: Vec<Point> = mapped_samples.into_iter().map(|s| s.pt).collect();
|
||||
// The widest the brush gets: the area merges look in.
|
||||
@@ -875,12 +875,15 @@ pub(super) fn blob(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
Some(tol) => Some(pressure_region(&spine(Some(tol)), size, *variation, prof)?).filter(|r| !r.is_empty()),
|
||||
None => None,
|
||||
};
|
||||
let dab = || brush_region(&mapped_pts[..1], vectorcraft_tools::draw2::pressure_size(size, *variation, prof.at(0.0)));
|
||||
match fitted {
|
||||
Some(r) => r,
|
||||
None => pressure_region(&spine(None), size, *variation, prof)?,
|
||||
// Samples that all lie at one point give a spine with no length: one dab from the
|
||||
// first reading, as a click paints.
|
||||
None => Some(pressure_region(&spine(None), size, *variation, prof)?).filter(|r| !r.is_empty()).unwrap_or_else(dab),
|
||||
}
|
||||
}
|
||||
// A click: one dab as wide as the pen pressed.
|
||||
// A click: one dab as wide as the pen pressed or the wheel was set.
|
||||
(Some((prof, variation)), false) => brush_region(&mapped_pts, vectorcraft_tools::draw2::pressure_size(size, *variation, prof.at(0.0))),
|
||||
(None, _) => {
|
||||
let fitted = fidelity
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use serde_json::json;
|
||||
use vectorcraft_doc::{NodeId, NodeKind};
|
||||
use vectorcraft_geom::{FillRule, PathData, Point};
|
||||
use vectorcraft_tools::{Mods, PointerEvent, PointerKind, ToolKey};
|
||||
use vectorcraft_tools::{Mods, PenPose, PointerEvent, PointerKind, ToolKey};
|
||||
|
||||
use crate::tooling::{UiRequest, ViewInfo};
|
||||
use crate::*;
|
||||
@@ -738,6 +738,76 @@ fn blob_brush_size_follows_the_pen_pressure() {
|
||||
assert!(inside(&s, drawn, 290.0, 707.0) && !inside(&s, drawn, 110.0, 703.0), "the tool's stroke follows the pen");
|
||||
}
|
||||
|
||||
/// Blob Brush Tool Options' Size set to Stylus Wheel: the brush is Size − Variation wide where an
|
||||
/// airbrush pen's finger wheel was at 0 and Size + Variation where it was at 1, in a drag, a click
|
||||
/// and with a tip that is not round. A stroke without a wheel keeps the Size, pressure does not
|
||||
/// change it, and an unknown mode or a wheel out of its range is refused with nothing painted.
|
||||
#[test]
|
||||
fn blob_brush_size_follows_the_stylus_wheel() {
|
||||
let mut s = session();
|
||||
let inside = |s: &Session, id: NodeId, x: f64, y: f64| {
|
||||
vectorcraft_geom::hit::fill_contains(&path(s, id).to_bezpath(), FillRule::NonZero, Point::new(x, y))
|
||||
};
|
||||
let blob = |s: &mut Session, p: serde_json::Value| NodeId(s.execute("path.blob", &p).unwrap()["id"].as_u64().unwrap());
|
||||
// The wheel at 0 at the left end and at 1 at the right: about 2 pt wide to 18 pt wide.
|
||||
let wheeled = |y: f64, wheel: &dyn Fn(f64) -> serde_json::Value| {
|
||||
(0..=20).map(|i| json!([100.0 + f64::from(i) * 10.0, y, null, null, null, null, wheel(f64::from(i) / 20.0)])).collect::<Vec<_>>()
|
||||
};
|
||||
let tip = json!({"size": 10, "sizeMode": "stylusWheel", "sizeVariation": 8, "merge": false});
|
||||
let a = blob(&mut s, with(&tip, json!({"points": wheeled(100.0, &|w| json!(w))})));
|
||||
assert!(inside(&s, a, 290.0, 107.0) && !inside(&s, a, 110.0, 103.0), "wide where the wheel was at 1, thin where at 0");
|
||||
let b = blob(&mut s, with(&tip, json!({"points": wheeled(200.0, &|w| json!(1.0 - w))})));
|
||||
assert!(inside(&s, b, 110.0, 207.0) && !inside(&s, b, 290.0, 203.0), "the other way round");
|
||||
// No wheel at any point, and pressure without a wheel: 10 pt wide all along.
|
||||
let none = blob(&mut s, with(&tip, json!({"points": wheeled(300.0, &|_| json!(null))})));
|
||||
let pressed = (0..=20).map(|i| json!([100.0 + f64::from(i) * 10.0, 400.0, f64::from(i) / 20.0])).collect::<Vec<_>>();
|
||||
let pressure = blob(&mut s, with(&tip, json!({"points": pressed})));
|
||||
for (id, y) in [(none, 300.0), (pressure, 400.0)] {
|
||||
assert!(inside(&s, id, 110.0, y + 3.0) && inside(&s, id, 290.0, y + 3.0) && !inside(&s, id, 290.0, y + 7.0), "10 pt at y {y}");
|
||||
}
|
||||
// A click paints one dab as wide as the wheel gives.
|
||||
let wide = blob(&mut s, with(&tip, json!({"points": [[100, 500, null, null, null, null, 1]]})));
|
||||
let thin = blob(&mut s, with(&tip, json!({"points": [[300, 500, null, null, null, null, 0]]})));
|
||||
assert!(inside(&s, wide, 100.0, 508.0) && !inside(&s, thin, 300.0, 503.0), "a dab follows the wheel");
|
||||
// A stroke whose samples all lie at one point paints a dab sized from its first reading, with
|
||||
// the wheel and with pressure.
|
||||
let still = blob(&mut s, with(&tip, json!({"points": [[500, 500, null, null, null, null, 1], [500, 500, null, null, null, null, 0]]})));
|
||||
let pressed_still = blob(&mut s, with(&tip, json!({"sizeMode": "pressure", "points": [[700, 500, 1], [700, 500, 0]]})));
|
||||
for (id, x) in [(still, 500.0), (pressed_still, 700.0)] {
|
||||
assert!(inside(&s, id, x, 508.0) && !inside(&s, id, x, 510.0), "a dab from the first reading at x {x}");
|
||||
}
|
||||
// A 25% round tip lying level: about 0.5 pt tall at the left end to 4.5 pt at the right.
|
||||
let flat = blob(&mut s, with(&tip, json!({"roundness": 25, "points": wheeled(600.0, &|w| json!(w))})));
|
||||
assert!(inside(&s, flat, 290.0, 601.9) && !inside(&s, flat, 110.0, 601.0), "a flat tip follows the wheel");
|
||||
// Refused, with the document and its undo steps as they were.
|
||||
let (before, undo) = (paths(&s).len(), s.doc().unwrap().history.undo.len());
|
||||
for (bad, key) in [
|
||||
(json!({"points": wheeled(700.0, &|w| json!(w)), "sizeMode": "tilt", "sizeVariation": 8}), "sizeMode"),
|
||||
(json!({"points": [[0, 700, null, null, null, null, 1.5], [10, 700]], "sizeMode": "stylusWheel", "sizeVariation": 8}), "wheel"),
|
||||
] {
|
||||
let err = s.execute("path.blob", &bad).unwrap_err();
|
||||
assert!(err.to_string().contains(key), "{err}");
|
||||
}
|
||||
assert_eq!((paths(&s).len(), s.doc().unwrap().history.undo.len()), (before, undo), "nothing changed");
|
||||
// The tool records the wheel while its Size varies with it.
|
||||
let v = view();
|
||||
s.select_tool("blobBrush", v).unwrap();
|
||||
s.set_tool_option("sizeMode", &json!("stylusWheel"));
|
||||
s.set_tool_option("sizeVariation", &json!(8));
|
||||
assert_eq!(s.tool_options()["sizeMode"], json!("stylusWheel"));
|
||||
let ev = |kind, i: i32| PointerEvent {
|
||||
pen: Some(PenPose { wheel: Some(i as f32 / 20.0), ..PenPose::default() }),
|
||||
..PointerEvent::new(kind, 100.0 + f64::from(i) * 10.0, 800.0)
|
||||
};
|
||||
s.pointer(&ev(PointerKind::Down, 0), v).unwrap();
|
||||
for i in 1..20 {
|
||||
s.pointer(&ev(PointerKind::Drag, i), v).unwrap();
|
||||
}
|
||||
s.pointer(&ev(PointerKind::Up, 20), v).unwrap();
|
||||
let (drawn, _) = paths(&s).into_iter().find(|(_, p)| p.control_bounds().is_some_and(|b| b.y0 > 750.0)).unwrap();
|
||||
assert!(inside(&s, drawn, 290.0, 807.0) && !inside(&s, drawn, 110.0, 803.0), "the tool's stroke follows the wheel");
|
||||
}
|
||||
|
||||
/// Eraser Tool Options' Size set to Pressure (#3961): the tip is Size − Variation across where the
|
||||
/// pen pressed lightest and Size + Variation where it pressed hardest; Fixed erases at the Size.
|
||||
#[test]
|
||||
|
||||
@@ -537,7 +537,10 @@ fn bad_option_values_are_errors_that_set_nothing() {
|
||||
(json!({"key": "bogus", "value": 1}), "tool `smooth`: unknown option `bogus`"),
|
||||
(json!({"tool": "pencil", "values": {"closeWithin": 5, "fidelity": "x"}}), "tool `pencil`: `fidelity` must be a number from 0.01 to 100"),
|
||||
(json!({"tool": "pencil", "key": "fill", "value": "yes"}), "tool `pencil`: `fill` must be true or false"),
|
||||
(json!({"tool": "blobBrush", "key": "sizeMode", "value": "huge"}), "tool `blobBrush`: `sizeMode` must be one of `fixed`, `pressure`"),
|
||||
(
|
||||
json!({"tool": "blobBrush", "key": "sizeMode", "value": "huge"}),
|
||||
"tool `blobBrush`: `sizeMode` must be one of `fixed`, `pressure`, `stylusWheel`",
|
||||
),
|
||||
(json!({"tool": "eraser", "key": "fidelity", "value": 4}), "tool `eraser`: unknown option `fidelity`"),
|
||||
(json!({"tool": "polygon", "key": "sides", "value": 2}), "tool `polygon`: `sides` must be a whole number from 3 to 1000"),
|
||||
(
|
||||
|
||||
@@ -92,6 +92,11 @@ pub fn pressure_size(size: f64, variation: f64, pressure: f64) -> f64 {
|
||||
/// The narrowest a Blob Brush or Eraser stroke gets, in points (their Size field's minimum).
|
||||
pub const MIN_BRUSH_SIZE: f64 = 0.1;
|
||||
|
||||
/// The modes the Blob Brush's Size takes (`sizeMode`). The Eraser's Size takes every
|
||||
/// [`vectorcraft_brush::Variation`].
|
||||
pub const BLOB_SIZE_MODES: [vectorcraft_brush::Variation; 3] =
|
||||
[vectorcraft_brush::Variation::Fixed, vectorcraft_brush::Variation::Pressure, vectorcraft_brush::Variation::StylusWheel];
|
||||
|
||||
/// A pen's tilt as a lean on the page (each tilt's tangent) and its angle from upright in degrees,
|
||||
/// as Pointer Events' tiltX and tiltY convert to an altitude and an azimuth.
|
||||
fn pen_lean(tilt: [f32; 2]) -> ([f64; 2], f64) {
|
||||
|
||||
@@ -149,9 +149,10 @@ pub struct GestureTool {
|
||||
pub fidelity: f64,
|
||||
/// Brush / eraser diameter in points (the Eraser's across its tip's long axis).
|
||||
pub size: f64,
|
||||
/// Blob Brush and Eraser Tool Options' Size mode: Fixed or Pressure for the Blob Brush (with
|
||||
/// Pressure the tip is `size` − `size_variation` wide at the lightest pen pressure and `size` +
|
||||
/// `size_variation` at the heaviest), and any [`Variation`] for the Eraser.
|
||||
/// Blob Brush and Eraser Tool Options' Size mode: Fixed, Pressure or Stylus Wheel for the Blob
|
||||
/// Brush (with Pressure the tip is `size` − `size_variation` wide at the lightest pen pressure
|
||||
/// and `size` + `size_variation` at the heaviest, and with Stylus Wheel from one end of an
|
||||
/// airbrush pen's finger wheel travel to the other), and any [`Variation`] for the Eraser.
|
||||
pub size_mode: Variation,
|
||||
/// Blob Brush and Eraser Tool Options' Size Variation, in points.
|
||||
pub size_variation: f64,
|
||||
@@ -1010,12 +1011,13 @@ impl GestureTool {
|
||||
}
|
||||
}
|
||||
|
||||
/// Give the Eraser's last stroke sample the pen's tilt and rotation of the event `ev`, a drag
|
||||
/// within a pixel of that sample that adds none: a pen turned or tilted in place turns its tip
|
||||
/// there, in the outline and in what the release erases. The sample keeps its pressure, which
|
||||
/// the area outline of the drag was built with, and its pose when `ev` reads none.
|
||||
/// Give the Eraser's or the Blob Brush's last stroke sample the pen's tilt, rotation and wheel
|
||||
/// of the event `ev`, a drag within a pixel of that sample that adds none: a pen turned or
|
||||
/// tilted in place, or its wheel turned there, changes its tip there, in the outline and in
|
||||
/// what the release erases or paints. The sample keeps its pressure, which the area outline of
|
||||
/// the drag was built with, and its pose when `ev` reads none.
|
||||
fn refresh_last_pose(&mut self, ev: &PointerEvent) {
|
||||
if self.id != "eraser" || self.poses.len() != self.points.len() || ev.pen.is_none() {
|
||||
if !matches!(self.id, "eraser" | "blobBrush") || self.poses.len() != self.points.len() || ev.pen.is_none() {
|
||||
return;
|
||||
}
|
||||
let pose = ev.pen.map(PenPose::sanitized);
|
||||
@@ -1135,8 +1137,8 @@ impl GestureTool {
|
||||
}
|
||||
|
||||
/// The Blob Brush's or the Eraser's tip at the pointer, before and while painting: its outline
|
||||
/// `size` across at its angle and roundness (the Eraser's as the pen varies them while it
|
||||
/// erases, [`Self::tip_now`]), at the zoom, black on a white halo so it reads on
|
||||
/// `size` across at its angle and roundness (as the pen varies them while it erases or
|
||||
/// paints, [`Self::tip_now`]), at the zoom, black on a white halo so it reads on
|
||||
/// any art. Precise cursors show only the crosshair, and smoothing shows no tip.
|
||||
fn tip_outline(&self, cx: &ToolContext) -> Vec<Overlay> {
|
||||
let Some(at) = self.tip_at.filter(|_| !self.smoothing && !cx.precise_cursors) else { return vec![] };
|
||||
@@ -1284,7 +1286,7 @@ impl GestureTool {
|
||||
outline.filter(|o| !o.elements().is_empty())
|
||||
}
|
||||
|
||||
/// Does the tool's Size take Fixed or Pressure (the Blob Brush and the Eraser)?
|
||||
/// Does the tool's Size take a variation mode (the Blob Brush and the Eraser)?
|
||||
fn varies_size(&self) -> bool {
|
||||
matches!(self.id, "blobBrush" | "eraser")
|
||||
}
|
||||
@@ -1374,14 +1376,23 @@ impl GestureTool {
|
||||
/// value on a mode that follows the pen goes from the value less its Variation to the value
|
||||
/// plus it as the pen reads now (the pressure once the pen has pressed less than fully, the
|
||||
/// tilt, rotation and wheel of the last point, and the bearing of the last point the pen leaned 1° or
|
||||
/// more at), as `path.eraseRegion` reads the stroke; before a press, and for Random, Fixed and a
|
||||
/// pen that gives no reading, the values themselves. The Blob Brush's are its own values.
|
||||
/// more at), as `path.eraseRegion` reads the stroke; before a press, and for Random, Fixed, a
|
||||
/// pen that gives no reading and a reading the release does not send (a mode set during the
|
||||
/// drag), the values themselves. The Blob Brush's size follows the pen the
|
||||
/// same way while it paints, as `path.blob` reads the stroke, and its angle and roundness are
|
||||
/// its own values (a roundness of 0 included).
|
||||
fn tip_now(&self) -> [f64; 3] {
|
||||
if self.id != "eraser" || !self.active {
|
||||
if !matches!(self.id, "eraser" | "blobBrush") || !self.active {
|
||||
return [self.angle, self.roundness, self.size];
|
||||
}
|
||||
let pressure = if self.light { self.pressures.last().map_or(0.5, |p| f64::from(*p)) } else { 0.5 };
|
||||
self.tip_for(pressure, self.poses.last().copied().flatten(), self.bearing)
|
||||
// What the release does not read ([`Self::reads_pressures`], [`Self::reads_poses`]) reads ½.
|
||||
let pressure = if self.reads_pressures() { self.pressures.last().map_or(0.5, |p| f64::from(*p)) } else { 0.5 };
|
||||
let (pose, bearing) = if self.reads_poses() { (self.poses.last().copied().flatten(), self.bearing) } else { (None, None) };
|
||||
let tip = self.tip_for(pressure, pose, bearing);
|
||||
if self.id == "blobBrush" {
|
||||
return [self.angle, self.roundness, tip[2]];
|
||||
}
|
||||
tip
|
||||
}
|
||||
|
||||
/// The tip's angle, roundness and size for a pen at `pressure` held as `pose`, leaning toward
|
||||
@@ -2129,10 +2140,10 @@ impl Tool for GestureTool {
|
||||
match key {
|
||||
"fidelity" => self.fidelity = v.as_f64().unwrap_or(self.fidelity).clamp(super::min_fidelity(self.id), 100.0),
|
||||
"size" => self.size = v.as_f64().unwrap_or(self.size).clamp(0.1, 1000.0),
|
||||
// The Blob Brush's Size is Fixed or Pressure; the Eraser's Angle, Roundness and Size
|
||||
// take any mode.
|
||||
// The Blob Brush's Size is Fixed, Pressure or Stylus Wheel; the Eraser's Angle,
|
||||
// Roundness and Size take any mode.
|
||||
"sizeMode" if self.varies_size() => match v.as_str().and_then(Variation::parse) {
|
||||
Some(m) if self.id == "eraser" || matches!(m, Variation::Fixed | Variation::Pressure) => self.size_mode = m,
|
||||
Some(m) if self.id == "eraser" || super::BLOB_SIZE_MODES.contains(&m) => self.size_mode = m,
|
||||
_ => {}
|
||||
},
|
||||
"angleMode" if self.id == "eraser" => self.angle_mode = v.as_str().and_then(Variation::parse).unwrap_or(self.angle_mode),
|
||||
@@ -2183,9 +2194,9 @@ impl Tool for GestureTool {
|
||||
"editWithin" | "closeWithin" => c::number(key, v, 0.0, 100.0),
|
||||
"angleVariation" => c::number(key, v, 0.0, 180.0),
|
||||
"roundnessVariation" => c::number(key, v, 0.0, 100.0),
|
||||
// The Blob Brush's Size is Fixed or Pressure; the Eraser's Angle, Roundness and Size
|
||||
// take any mode (`set_option`).
|
||||
"sizeMode" if self.id != "eraser" => c::one_of(key, v, &[Variation::Fixed.id(), Variation::Pressure.id()]),
|
||||
// The Blob Brush's Size is Fixed, Pressure or Stylus Wheel; the Eraser's Angle,
|
||||
// Roundness and Size take any mode (`set_option`).
|
||||
"sizeMode" if self.id != "eraser" => c::one_of(key, v, &super::BLOB_SIZE_MODES.map(Variation::id)),
|
||||
"sizeMode" | "angleMode" | "roundnessMode" => c::one_of(key, v, &Variation::ALL.map(Variation::id)),
|
||||
"fill" | "altSmooth" | "livePreview" | "liveFit" | "keepSelected" | "mergeOnlySelection" => c::boolean(key, v),
|
||||
_ => Err(c::unknown(key)),
|
||||
|
||||
@@ -3361,7 +3361,10 @@ fn the_eraser_tip_follows_its_variation_modes() {
|
||||
assert_eq!(t.check_option("angleMode", &json!("wheel")), Err(format!("`angleMode` {modes}")));
|
||||
assert_eq!(t.check_option("angleVariation", &json!(181)), Err("`angleVariation` must be a number from 0 to 180".into()));
|
||||
assert_eq!(t.check_option("roundnessVariation", &json!(500)), Err("`roundnessVariation` must be a number from 0 to 100".into()));
|
||||
assert_eq!(GestureTool::new("blobBrush").check_option("sizeMode", &json!("tilt")), Err("`sizeMode` must be one of `fixed`, `pressure`".into()));
|
||||
assert_eq!(
|
||||
GestureTool::new("blobBrush").check_option("sizeMode", &json!("tilt")),
|
||||
Err("`sizeMode` must be one of `fixed`, `pressure`, `stylusWheel`".into())
|
||||
);
|
||||
// A mode it does not have leaves the mode as it was; a Variation is kept within its range.
|
||||
t.set_option("angleMode", &json!("wheel"));
|
||||
t.set_option("roundnessVariation", &json!(500));
|
||||
@@ -3399,7 +3402,7 @@ fn the_eraser_tip_follows_its_variation_modes() {
|
||||
t.pointer(&cx, &PointerEvent { pressure: 0.5, ..PointerEvent::new(PointerKind::Drag, 200.0, 50.0) });
|
||||
near(tip(&t), (190.0, 47.5, 210.0, 52.5));
|
||||
t.pointer(&cx, &PointerEvent { pressure: 0.5, ..PointerEvent::new(PointerKind::Up, 200.0, 50.0) });
|
||||
// The Blob Brush's Size is Fixed or Pressure, and its Angle and Roundness have no menus.
|
||||
// The Blob Brush's Size is Fixed, Pressure or Stylus Wheel, and its Angle and Roundness have no menus.
|
||||
let mut b = GestureTool::new("blobBrush");
|
||||
b.set_option("sizeMode", &json!("tilt"));
|
||||
b.set_option("angleMode", &json!("rotation"));
|
||||
@@ -3409,6 +3412,77 @@ fn the_eraser_tip_follows_its_variation_modes() {
|
||||
assert_eq!(b.options()["sizeMode"], json!("pressure"));
|
||||
}
|
||||
|
||||
/// The Blob Brush's Size on Stylus Wheel follows the wheel the pen recorded, in the tip outline
|
||||
/// while it paints (its roundness kept as set, 0% included) and in the points the release sends;
|
||||
/// a pen that gives no wheel keeps the Size.
|
||||
#[test]
|
||||
fn the_blob_brush_size_follows_the_stylus_wheel() {
|
||||
let (d, _) = doc_with_rect();
|
||||
let s = Selection::default();
|
||||
let p = paint();
|
||||
let cx = cx(&d, &s, &p);
|
||||
let tip = |t: &GestureTool| match &t.overlays(&cx)[..] {
|
||||
[.., Overlay::Path { path, color: [0, 0, 0], width: 1.0, .. }] => vectorcraft_geom::Shape::bounding_box(path),
|
||||
o => panic!("{o:?}"),
|
||||
};
|
||||
let near = |b: vectorcraft_geom::Rect, want: (f64, f64, f64, f64)| {
|
||||
assert!([b.x0 - want.0, b.y0 - want.1, b.x1 - want.2, b.y1 - want.3].iter().all(|e| e.abs() < 0.01), "{b:?} vs {want:?}");
|
||||
};
|
||||
let mut t = GestureTool::new("blobBrush");
|
||||
assert_eq!(t.check_option("sizeMode", &json!("stylusWheel")), Ok(()));
|
||||
for (k, v) in [("size", json!(20)), ("roundness", json!(50)), ("sizeMode", json!("stylusWheel")), ("sizeVariation", json!(8))] {
|
||||
t.set_option(k, &v);
|
||||
}
|
||||
assert_eq!((t.options()["sizeMode"].clone(), t.options()["sizeVariation"].clone()), (json!("stylusWheel"), json!(8.0)));
|
||||
// Before a press the outline is the set tip, 20 by 10 pt.
|
||||
t.pointer(&cx, &PointerEvent::new(PointerKind::Move, 100.0, 50.0));
|
||||
near(tip(&t), (90.0, 45.0, 110.0, 55.0));
|
||||
// The wheel at the far end of its travel gives 28 by 14 pt, and half way 20 by 10.
|
||||
let wheel = |w: Option<f32>| Some(PenPose { tilt: None, rotation: None, wheel: w });
|
||||
t.pointer(&cx, &PointerEvent { pen: wheel(Some(1.0)), ..PointerEvent::new(PointerKind::Down, 100.0, 50.0) });
|
||||
t.pointer(&cx, &PointerEvent { pen: wheel(Some(1.0)), ..PointerEvent::new(PointerKind::Drag, 200.0, 50.0) });
|
||||
near(tip(&t), (186.0, 43.0, 214.0, 57.0));
|
||||
t.pointer(&cx, &PointerEvent { pen: wheel(Some(0.5)), ..PointerEvent::new(PointerKind::Drag, 300.0, 50.0) });
|
||||
near(tip(&t), (290.0, 45.0, 310.0, 55.0));
|
||||
// The wheel turned with the pen held in place: the tip there and the release follow it.
|
||||
t.pointer(&cx, &PointerEvent { pen: wheel(Some(0.0)), ..PointerEvent::new(PointerKind::Drag, 300.0, 50.0) });
|
||||
near(tip(&t), (294.0, 47.0, 306.0, 53.0));
|
||||
let acts = t.pointer(&cx, &PointerEvent { pen: wheel(Some(0.0)), ..PointerEvent::new(PointerKind::Up, 300.0, 50.0) });
|
||||
let Some(Action::Exec(c, v)) = acts.first() else { panic!("{acts:?}") };
|
||||
assert_eq!((c.as_str(), &v["sizeMode"], &v["sizeVariation"]), ("path.blob", &json!("stylusWheel"), &json!(8.0)));
|
||||
assert_eq!(
|
||||
v["points"],
|
||||
json!([[100.0, 50.0, null, null, null, null, 1.0], [200.0, 50.0, null, null, null, null, 1.0], [300.0, 50.0, null, null, null, null, 0.0]])
|
||||
);
|
||||
// A pen without a wheel keeps the set tip.
|
||||
t.pointer(&cx, &PointerEvent { pen: wheel(None), ..PointerEvent::new(PointerKind::Down, 100.0, 50.0) });
|
||||
t.pointer(&cx, &PointerEvent { pen: wheel(None), ..PointerEvent::new(PointerKind::Drag, 200.0, 50.0) });
|
||||
near(tip(&t), (190.0, 45.0, 210.0, 55.0));
|
||||
t.pointer(&cx, &PointerEvent { pen: wheel(None), ..PointerEvent::new(PointerKind::Up, 200.0, 50.0) });
|
||||
// A 0% round tip stays as flat as set while the wheel widens it.
|
||||
t.set_option("roundness", &json!(0));
|
||||
t.pointer(&cx, &PointerEvent { pen: wheel(Some(1.0)), ..PointerEvent::new(PointerKind::Down, 100.0, 50.0) });
|
||||
t.pointer(&cx, &PointerEvent { pen: wheel(Some(1.0)), ..PointerEvent::new(PointerKind::Drag, 200.0, 50.0) });
|
||||
let flat = tip(&t);
|
||||
assert!((flat.width() - 28.0).abs() < 0.01 && flat.height() < 0.1, "{flat:?}");
|
||||
t.pointer(&cx, &PointerEvent { pen: wheel(Some(1.0)), ..PointerEvent::new(PointerKind::Up, 200.0, 50.0) });
|
||||
// Size set from Fixed to Stylus Wheel or Pressure during a drag: the release reads no wheel or
|
||||
// pressure for the points before it, so the tip keeps the Size, as the release paints.
|
||||
t.set_option("roundness", &json!(50));
|
||||
for (mode, pressure) in [("stylusWheel", 1.0), ("pressure", 0.25)] {
|
||||
t.set_option("sizeMode", &json!("fixed"));
|
||||
let ev = |kind, x| PointerEvent { pen: wheel(Some(1.0)), pressure, ..PointerEvent::new(kind, x, 50.0) };
|
||||
t.pointer(&cx, &ev(PointerKind::Down, 100.0));
|
||||
t.pointer(&cx, &ev(PointerKind::Drag, 200.0));
|
||||
t.set_option("sizeMode", &json!(mode));
|
||||
t.pointer(&cx, &ev(PointerKind::Drag, 300.0));
|
||||
near(tip(&t), (290.0, 45.0, 310.0, 55.0));
|
||||
let acts = t.pointer(&cx, &ev(PointerKind::Up, 300.0));
|
||||
let Some(Action::Exec(_, v)) = acts.first() else { panic!("{acts:?}") };
|
||||
assert_eq!(v["points"], json!([[100.0, 50.0], [200.0, 50.0], [300.0, 50.0]]), "{mode}");
|
||||
}
|
||||
}
|
||||
|
||||
/// An Eraser value on Stylus Wheel follows the wheel the pen recorded, in the tip outline while it
|
||||
/// erases and in the points the release sends; a pen that gives no wheel reads half way, the value
|
||||
/// itself.
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
//! with its fill and stroke while it is drawn, or as a thin line until the release), `size`
|
||||
//! (points; Blob Brush and Eraser), and `sizeMode` and `sizeVariation` (points; Blob Brush and
|
||||
//! Eraser: with Pressure the tip is Size − Variation wide at the lightest pen pressure and Size +
|
||||
//! Variation at the heaviest). The Blob Brush's `sizeMode` is `fixed` or `pressure`. The Eraser's
|
||||
//! Variation at the heaviest). The Blob Brush's `sizeMode` is `fixed`, `pressure` or `stylusWheel`. The Eraser's
|
||||
//! Angle, Roundness and Size each have a menu (`angleMode`, `roundnessMode`, `sizeMode`: `fixed`,
|
||||
//! `random`, `pressure`, `tilt`, `bearing` or `rotation`) before the field and a Variation field
|
||||
//! under it (`angleVariation` in degrees, `roundnessVariation` in percent, `sizeVariation`),
|
||||
@@ -251,7 +251,7 @@ fn params(tool: &str, present: &[&str]) -> Vec<Param> {
|
||||
rows.push(Param::custom("tip", "", |ui, fields, _| tip_row(ui, fields, 0.0)).full_width());
|
||||
}
|
||||
if has("sizeMode") {
|
||||
let offered = &[Variation::Fixed, Variation::Pressure];
|
||||
let offered = &vectorcraft_tools::draw2::BLOB_SIZE_MODES;
|
||||
rows.push(variation_param("size", tl!("Size:"), UnitKind::Points, 1, (0.1, 1000.0), (0.0, 1000.0), offered));
|
||||
} else if has("size") {
|
||||
rows.push(Param::number("size", tl!("Size:"), 10.0, 1.0, 1).unit(UnitKind::Points).bounds(Some(0.1), Some(1000.0)));
|
||||
|
||||
@@ -332,3 +332,30 @@ fn the_blob_brush_and_eraser_size_can_follow_the_pen_pressure() {
|
||||
let o = app.session.tool_options_of("pencil");
|
||||
assert!(o.get("sizeMode").is_none() && o.get("sizeVariation").is_none());
|
||||
}
|
||||
|
||||
/// The names and values the window's access tree shows.
|
||||
fn shown_text(app: &mut VectorcraftApp) -> String {
|
||||
crate::dialogs::tests::settle(app);
|
||||
let out = crate::dialogs::tests::frame(app, vec![]);
|
||||
let update = out.platform_output.accesskit_update.expect("an accessibility tree");
|
||||
update.nodes.iter().flat_map(|(_, node)| [node.label(), node.value()]).flatten().collect::<Vec<_>>().join("\n")
|
||||
}
|
||||
|
||||
/// The Blob Brush's Size menu offers Stylus Wheel beside Fixed and Pressure, Fixed still the
|
||||
/// default; the menu shows it once chosen, and OK sets it with the Variation.
|
||||
#[test]
|
||||
fn the_blob_brush_size_offers_the_stylus_wheel() {
|
||||
let mut app = app();
|
||||
app.run("tool.options", json!({"tool": "blobBrush"})).unwrap();
|
||||
assert_eq!(crate::dialogs::tests::fields(&app)["sizeMode"], json!("fixed"), "Fixed by default");
|
||||
crate::dialogs::tests::set(&mut app, "sizeMode", json!("stylusWheel"));
|
||||
crate::dialogs::tests::set(&mut app, "sizeVariation", json!(5));
|
||||
let text = shown_text(&mut app);
|
||||
assert!(text.contains("Stylus Wheel"), "{text}");
|
||||
assert!(crate::dialogs::tests::confirm(&mut app), "OK closes the dialog");
|
||||
let o = app.session.tool_options_of("blobBrush");
|
||||
assert_eq!((o["sizeMode"].clone(), o["sizeVariation"].as_f64()), (json!("stylusWheel"), Some(5.0)));
|
||||
app.run("tool.options", json!({"tool": "blobBrush"})).unwrap();
|
||||
let text = shown_text(&mut app);
|
||||
assert!(text.contains("Stylus Wheel"), "it shows again on the next open: {text}");
|
||||
}
|
||||
|
||||
+17
@@ -7235,6 +7235,23 @@ outline of the area a drag covers takes, at each step, the tip the pen's reading
|
||||
value shows as the value itself there, since the release draws it.
|
||||
`tool.setOption {tool: "eraser"}` takes the same keys, with `sizeVariation` from 0 to 1000.
|
||||
|
||||
`path.blob` (the Blob Brush) takes `sizeMode` with `sizeVariation` (points, 0 to 1000), as the Size menu of Blob Brush
|
||||
Tool Options sets it: `"fixed"` (the default), `"pressure"` or `"stylusWheel"`. Pressure goes from the size less the
|
||||
variation where the pen presses lightest to the size plus it where the pen presses hardest. Stylus Wheel goes from the
|
||||
size less the variation at 0 to the size plus it at 1 of an airbrush pen's finger wheel, the seventh value of each
|
||||
point; a point without a wheel counts as 0.5, the size itself, and a stroke with no wheel reading, such as a mouse
|
||||
drag, paints at the size. With either mode the width is at least 0.1 pt, also where the size less the variation is
|
||||
smaller. Which way the wheel runs and the size itself without a reading are VectorCraft's own rules.
|
||||
With Pressure or Stylus Wheel, a stroke whose points all lie at one place paints one dab sized from its first point's
|
||||
reading, as a single point does.
|
||||
The command refuses another mode with an error that names `sizeMode`, and the document does not change. In the
|
||||
desktop app the Blob Brush's tip outline at the pointer takes the size the pen gives while it paints, and keeps the
|
||||
size when Size is set to Stylus Wheel during the drag, which the release then paints at. A drag that starts on Fixed
|
||||
also keeps the size when Size is set to Pressure. A drag that starts on Stylus Wheel records the pen pressure at each
|
||||
point, so when Size is set to Pressure the tip and the release follow that pressure from the start of the drag, if the
|
||||
pen pressed less than fully anywhere; otherwise they keep the size.
|
||||
`tool.setOption {tool: "blobBrush"}` takes `sizeMode` and `sizeVariation` too.
|
||||
|
||||
`path.eraseRegion {rect: [x, y, width, height]}` takes a rectangle in place of `points` and erases everything inside
|
||||
it from the paths (selected, or all), as an Alt-drag with the Eraser does ([Eraser tool
|
||||
reference](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=133)).
|
||||
|
||||
@@ -1453,8 +1453,8 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
Select ▸ Update Selection replaces the objects of the saved selection last recalled with the selected objects, in one undo step that marks the document changed (`select.update`). After Edit Selection… renames that saved selection, Update Selection replaces it under the new name; after Edit Selection… deletes it, Update Selection is disabled until another saved selection is recalled or the delete is undone. Undo and Redo do not change which saved selection is recalled.
|
||||
- **Drawing modes:** in Draw Inside, a double-click with a selection tool outside the object being drawn into sets the drawing mode to Draw Normal, as Shift+D does. Pastes follow the drawing mode ([drawing modes](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/learn-drawing-basics/drawing-modes-overview.html)) (#3705): in Draw Inside, Paste, Paste in Place and Paste on All Artboards put the copies inside the object drawn into, in one undo step, Paste Remembers Layers aside; in Draw Behind, Paste in Place and Paste on All Artboards put them just below the selection; Paste in Front and Paste in Back ignore the mode. Shift+D cycles Draw Normal → Draw Behind → Draw Inside → Draw Normal, skipping Draw Inside unless one path, compound path or type is selected. With the object drawn into isolated (a double-click on it with the Selection tool), art drawn or pasted inside it takes isolation mode into its clip group, so it can be clicked and isn't dimmed, as art added in isolation mode belongs with what is isolated ([isolation mode](https://helpx.adobe.com/illustrator/desktop/manage-objects/select-objects/isolate-objects.html)) (#3705); undo or redo that removes the isolated object ends isolation mode. While Draw Inside lasts, a dotted open rectangle marks the corners of the object drawn into (#4319). In Draw Behind, New Layer (the Layers panel's button, its menu, Ctrl/Cmd+L and the Layer Options dialog) puts the new layer directly below the current layer, at its level, as [the help page](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=234) describes and [drawing modes](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/learn-drawing-basics/drawing-modes-overview.html) lists; Ctrl/Cmd-click still puts it on top and Ctrl/Cmd+Alt-click below, and New Sublayer is not affected (VectorCraft's own rule). In Draw Behind, an Alt-drag copy made with the Selection or Direct Selection tool goes directly below its original and is selected, as [drawing modes](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/learn-drawing-basics/drawing-modes-overview.html) lists duplicating by Alt-drag among the actions the mode applies to; with several objects, each copy goes below its own original in that original's group or layer, the copy of the clipping path of a clip group or a clipping layer goes directly above it so the clipping path stays the bottom object, and in Draw Normal and Draw Inside, and for the transform dialogs' Copy, Duplicate and Transform Again, copies still go above (VectorCraft's own rules). In Draw Behind, a placed symbol instance (Place Symbol Instance in the Symbols panel, and a symbol dragged onto the canvas from the Symbols panel or a symbol library) goes directly below the selected object, or at the bottom of the current layer with nothing selected, as [drawing modes](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/learn-drawing-basics/drawing-modes-overview.html) describes for placing symbols; below the bottommost of several selected objects, beside the compound path that holds a selected path, and above a clipping path are VectorCraft's own rules. Draw Normal and Draw Inside keep it on top of the current layer.
|
||||
- **Drawing:** Pen, Curvature, anchor tools, Pencil, Paintbrush, Blob Brush, Smooth, Path Eraser, Join. Direction handles dragged with Direct Selection or the Anchor Point tool snap to smart guides, and Shift keeps them at 45° steps from their anchor. The Pen continues any open path from the end clicked, and while drawing, a click on an end of another open path joins the two into one (#776). The Curvature tool edits any selected path, whatever drew it, keeping its shape except where edited (#798): a click on a point makes it current and a drag moves it, re-curving only its two segments; double-click, or Alt-click on any point but an end of an open path, toggles it smooth or corner and Delete removes it; a click on a segment adds a point without changing the shape; with an end of an open path current, clicks go on from it and its other end closes it (`path.curvatureEdit`). An Alt-click on an end of a selected open path makes that end current without changing it, so the next click goes on from it, as [the help page](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/draw-shapes/draw-shapes-with-the-curvature-tool.html) describes for continuing a path; an Alt-click that starts a new path places a corner point, as later Alt-clicks do. Every point a drawing tool places snaps to Smart Guides through one snapper (#506): the Pen's and Curvature tool's anchors, the Pencil's ends, the shape tools' start and dragged corner or radius (Rectangle, Rounded Rectangle, Ellipse, Polygon, Star, Line Segment, Arc, Spiral, the grids), the Type tool's click and frame, a new artboard's corners. A filled Pencil path keeps a stroke of None (#1804, part of #1679). While a Pencil or Paintbrush stroke is drawn back to within Close Paths When Ends Are Within of its start, the cursor shows the closing ring and a release there closes the path, as [Draw straight lines with the Pencil tool](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/draw-shapes/draw-straight-lines-with-the-pencil-tool.html) describes for the Pencil. The [ and ] keys reach the Blob Brush, the Eraser and the Symbolism tools in the app (#1734, part of #1661).
|
||||
Blob Brush and Eraser Tool Options' Size is Fixed or Pressure with a Variation (#4590, #3961): with Pressure a pen stroke is Size − Variation wide where it presses lightest and Size + Variation where it presses hardest, and a mouse stroke keeps the Size.
|
||||
`path.blob` and `path.eraseRegion` refuse a Size outside 0.1 to 1000 pt and a Variation outside 0 to 1000 pt, also with Size set to Fixed, and the drawing commands that read pen values refuse a pressure outside 0 to 1, a tilt outside −90° to 90°, a rotation outside 0° to 360° and a point array of more than six numbers, with an error naming the key; the document, the selection and the undo history stay as they were. The pressure and tilt ranges are those of [Pointer Events](https://www.w3.org/TR/pointerevents3/); the Size, Variation and rotation ranges are VectorCraft's own values (`tests::draw2::pen_values_outside_their_ranges_are_refused`).
|
||||
Blob Brush and Eraser Tool Options' Size is Fixed or Pressure with a Variation (#4590, #3961), and the Blob Brush's Size also offers Stylus Wheel (see Blob Brush Size on the stylus wheel): with Pressure a pen stroke is Size − Variation wide where it presses lightest and Size + Variation where it presses hardest, and a mouse stroke keeps the Size.
|
||||
`path.blob` and `path.eraseRegion` refuse a Size outside 0.1 to 1000 pt and a Variation outside 0 to 1000 pt, also with Size set to Fixed, and the drawing commands that read pen values refuse a pressure outside 0 to 1, a tilt outside −90° to 90°, a rotation outside 0° to 360°, a stylus wheel reading outside 0 to 1 and a point array of more than seven numbers (the wheel is the seventh), with an error naming the key; the document, the selection and the undo history stay as they were. The pressure and tilt ranges are those of [Pointer Events](https://www.w3.org/TR/pointerevents3/); the Size, Variation, rotation and wheel ranges are VectorCraft's own values (`tests::draw2::pen_values_outside_their_ranges_are_refused`).
|
||||
With the Blob Brush, Shift held during a drag keeps the stroke on the horizontal or vertical line through the press point, whichever is nearer to the pointer (90° steps from the Constrain Angle preference), and the points dragged since Shift went down move to the other line when the pointer crosses to it; the points dragged while Shift is up follow the pointer.
|
||||
With the Blob Brush, Alt held before the press, or pressed before the drag has moved, switches to the Smooth tool, as the reference app's [Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) page lists: the cursor shows the Smooth tool (Not Allowed with no path selected that it can act on), the drag shows a thin line and, with a path selected that it can smooth, the dashed band it smooths, without the length label, Shift does not constrain it, and the release smooths the selected paths under the drag (`path.smoothRegion`) instead of painting; with nothing selected the release changes no path. A stroke that has moved keeps painting when Alt goes down.
|
||||
Curvature point markers are circular, with no direction handles. While drawing, its own point feedback replaces generic selection markers; existing paths use the selection overlay, including partial selections and Hide Edges. Anchor Size applies, and Direct Selection and Pen retain their handles. The real egui-frame regressions in `crates/ui-egui/src/canvas.rs` verify marker positions, counts and unchanged documents (#1236, in part); the existing-path interpolation request remains open. The curve through the points (`curvature_spline` in `crates/tools/src/draw2.rs`) makes each stretch of three points follow the circle through them: a smooth point's handles lie along that circle's tangent, each `chord / (3 cos²(α/2))` long (α between handle and chord, capped at 90°), and the ends of an open path mirror their neighbour's tangent in their chord, so a J or a U curves evenly, a turn tighter than 30° comes to a point, and uneven spacing doesn't loop; the rubber band, a dragged or inserted point and `path.convertAnchor` to smooth use the same rule, while the Pencil's fitting keeps its own; `tests/draw2.rs` checks that the rubber band is the path the click makes (#1236, in part). The Smooth tool smooths only the stretch of path under the drag (#1547, fixes #1512). A path the Smooth tool changes stays selected whole, and the anchor points and segments selected on it with Direct Selection are deselected. Selected paths the drag does not change keep their selected anchors, and undo restores the earlier selection (`tests/draw2.rs`, `smoothing_a_path_drops_its_direct_selected_anchors`). While the Smooth tool drags with a path selected that it can smooth, a dashed outline shows the band it smooths: everything within its radius of the drag (12 screen pixels, VectorCraft's own value), round at both ends; Alt smoothing with the Pencil, Paintbrush and Blob Brush shows the same band.
|
||||
@@ -2113,6 +2113,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
Art Brush Options' Width (1% to 1000%) and Pattern Brush Options' Scale (1% to 10000%) each have a slider beside the field, over the same range in whole percents; screen readers name the slider as its row and read the field's value.
|
||||
Art Brush Options' Width has a Fixed or Pressure menu, from the pen tablet options of the Width pop-up menu on the [Brushes](https://web.archive.org/web/20241230205225/https://helpx.adobe.com/illustrator/using/brushes.html) page (archived copy). With Pressure, the art is Width wide at the lightest pen pressure and the second width at the heaviest, following the pressure the Paintbrush recorded along the stroke, and half way between them on a stroke without recorded pressure (`brush.options` `width_mode` and `width_max`); a stroke inside the art takes the width at the middle of its object. The page does not say how the pressure maps to the width; taking the Scatter brush's minimum and maximum rule and the stroke rule are VectorCraft's own. The menu also offers Tilt, Bearing and Rotation: the art goes from Width with the pen lying flat to the second width upright, and from Width at −180° to the second width at 180° of the pen's bearing or barrel rotation, as Scatter Brush Options' modes do, and half way on a stroke without that input; the page does not say which way each runs, so that mapping is VectorCraft's own. Evidence: `tests::art_brush_width_follows_tilt_bearing_and_rotation` (vectorcraft-brush). The menu also offers Stylus Wheel (next item).
|
||||
- **Airbrush stylus wheel:** Calligraphic and Scatter Brush Options offer Stylus Wheel for Size, and Art Brush Options for Width, as the help page lists it (<https://web.archive.org/web/20241230205225/https://helpx.adobe.com/illustrator/using/brushes.html>). The Paintbrush records where an airbrush pen's finger wheel is set along each stroke (kept with the path, saved, joined when a stroke continues a path, and interpolated by blends). A Calligraphic Size goes from size − variation at one end of the wheel's travel to size + variation at the other, a Scatter Size from its first value to its second, and an Art Width from Width to the second width; a stroke without a wheel draws the value half way. The direction of travel and the half-way value for a stroke without a wheel are VectorCraft's own rules. On Linux under X11 and XWayland the app reads the wheel from XInput2's `Abs Wheel` valuator, and on macOS from AppKit's `tangentialPressure`; Windows pointer messages have no field for it, and the web build does not read it yet. `path.freehand` points take it seventh and `pointer_gesture` events take `wheel`, and `.ai` brush definitions read and write it as variation code 3. Evidence: `tests::the_stylus_wheel_varies_sizes_and_widths` (vectorcraft-brush), `tests_brushsym::freehand_points_record_the_stylus_wheel` (vectorcraft-engine), `more_brush_settings_are_read_back` and `a_calligraphic_brushs_pen_channels_come_in_by_their_codes` (vectorcraft-eps), `tablet::tests::an_airbrush_wheel_goes_into_the_feed` and `mac_tablet::tests::an_airbrush_wheel_goes_into_the_feed` (vectorcraft).
|
||||
- **Blob Brush Size on the stylus wheel:** Blob Brush Tool Options' Size menu offers Stylus Wheel beside Fixed and Pressure. The Blob Brush paints with the Calligraphic brush options ([help page](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=273)), whose Size an airbrush pen's wheel can vary ([help page](https://web.archive.org/web/20241230205225/https://helpx.adobe.com/illustrator/using/brushes.html)), and the Eraser's Size menu offers the same wheel choice ([help page](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/modify-paths/erase-paths-using-eraser-tool.html)). With Stylus Wheel a stroke is Size − Variation wide at one end of the wheel's travel, but at least 0.1 pt, and Size + Variation at the other; a point without a wheel counts as half way, and a mouse stroke keeps the Size. A stroke whose points all lie at one place paints one dab sized from its first reading, on Pressure too. While the Blob Brush paints, the tip outline at the pointer takes the size the pen gives, on Pressure too, and keeps the Size when the menu changes to Stylus Wheel during the drag, or to Pressure during a drag that started on Fixed, as the release paints. A drag that started on Stylus Wheel records the pen pressure, so a change to Pressure follows that pressure from the start of the drag when the pen pressed less than fully anywhere. The direction of travel and the half-way value are VectorCraft's own rules. `path.blob` takes `sizeMode: "stylusWheel"` with the wheel seventh in each point. Evidence: `tests::draw2::blob_brush_size_follows_the_stylus_wheel` (vectorcraft-engine), `draw2::gesture::tests::the_blob_brush_size_follows_the_stylus_wheel` (vectorcraft-tools), `dialogs::freehand::tests::the_blob_brush_size_offers_the_stylus_wheel` (vectorcraft-ui-egui).
|
||||
Scatter, Art and Pattern Brush Options have the Tips button for Colorization that the [Brushes](https://web.archive.org/web/20241230205225/https://helpx.adobe.com/illustrator/using/brushes.html) page (archived copy) describes, beside Method. It opens Colorization Tips, which shows each method's name and what it does beside a sample of the brush, as OK would make it, painted with that method on a blue stroke; Hue Shift's sample uses the dialog's Key Color. `ui.dialog.set {field: "tips", value: true}` opens it. Screen readers name the button, the popover and each sample.
|
||||
Hue Shift set by `brush.new` or `brush.options` without a key color takes the color the art's fills and strokes use most, as Brush Options already offers it, following the Brushes page, where the key color defaults to the color that stands out most in the art (<https://web.archive.org/web/20241230205225/https://helpx.adobe.com/illustrator/using/brushes.html>). The page does not state how prominence is measured. Counting the fills and strokes that use each solid color, with the first one found winning a tie and black for art with no solid color, is VectorCraft's own rule. A `brush.options` edit that gives only the method keeps the brush's key color, and one that gives only an art brush's start guide keeps its end guide. Evidence: `tests_brushsym::hue_shift_without_a_key_takes_the_most_used_art_color`, `tests_brushsym::art_brush_options_keep_the_scale_fields_an_edit_leaves_out`.
|
||||
Bristle Brush Options and `brush.new` take a bristle brush name of at most 31 characters, as the Brushes page states for the Bristle Brush Options. The Name field stops taking characters at 31, and `brush.new` and `brush.options` refuse a longer new name with an error that names the limit. The page does not say how the limit counts characters or what happens to longer names already saved; counting characters and the number added to a taken name, keeping longer saved names, and leaving `brush.duplicate` unlimited are VectorCraft's own rules. A bristle brush that a document or a saved file already holds under a longer name keeps it, and the other brush types take a name of any length. Test: `bristle_brush_names_have_at_most_31_characters` in `tests/brushsym.rs`. Public reference: [Brushes](https://web.archive.org/web/20241230205225/https://helpx.adobe.com/illustrator/using/brushes.html) (archived copy).
|
||||
|
||||
Reference in New Issue
Block a user