mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-18 11:14:13 +00:00
Merge pull request #8465 from dotCooCoo/feat/scatter-brush-hue-jitter
Brushes: Scatter Brush Options has Hue Jitter, a per-copy hue turn
This commit is contained in:
@@ -97,6 +97,75 @@ pub fn colorize(n: &mut Node, mode: Colorization, stroke: &Paint) {
|
||||
walk(n, mode, key);
|
||||
}
|
||||
|
||||
/// Mixed into a stroke's seed for its hue jitter, so the amounts come from a sequence of their own
|
||||
/// and a copy's size, spacing, scatter and rotation stay as they were without hue jitter.
|
||||
const HUE_JITTER_SALT: u64 = 0x6875_655f_6a69_7474;
|
||||
|
||||
/// Turn the hue of each of `copies` (a scatter brush's copies, in order along the path) by its
|
||||
/// own amount between −`amount` and `amount` degrees, drawn from `seed` (the stroke's
|
||||
/// [`crate::track::seed_of`]).
|
||||
pub(crate) fn jitter_hues(copies: &mut [Node], amount: f64, seed: u64) {
|
||||
let mut rng = crate::track::Rng::new(seed ^ HUE_JITTER_SALT);
|
||||
for n in copies {
|
||||
let turn = rng.range(-amount, amount) as f32;
|
||||
turn_hues(n, turn);
|
||||
}
|
||||
}
|
||||
|
||||
/// `c` with its hue turned by `degrees`, worked out on its own components so nothing else about it
|
||||
/// changes: RGB in HSB of its values, CMYK over C, M and Y with K kept (as
|
||||
/// [`Color::complement_keep_model`] does), Lab by turning a and b. `None` for a color without a hue:
|
||||
/// white, black and grays, in their own model (Gray, CMYK with no C, M or Y ink).
|
||||
fn turned(c: &Color, degrees: f32) -> Option<Color> {
|
||||
if !degrees.is_finite() || vectorcraft_color::recolor::Neutral::of(c).is_some() {
|
||||
return None;
|
||||
}
|
||||
let turn = |v: [f32; 3]| {
|
||||
let [h, s, b] = vectorcraft_color::rgb_to_hsb(v);
|
||||
(s > 0.0).then(|| vectorcraft_color::hsb_to_rgb([(h + degrees).rem_euclid(360.0), s, b]))
|
||||
};
|
||||
match *c {
|
||||
Color::Rgb { r, g, b } => turn([r, g, b]).map(|[r, g, b]| Color::rgb(r, g, b)),
|
||||
Color::Cmyk { c, m, y, k } => turn([1.0 - c, 1.0 - m, 1.0 - y]).map(|[r, g, b]| Color::cmyk(1.0 - r, 1.0 - g, 1.0 - b, k)),
|
||||
Color::Gray { .. } => None,
|
||||
Color::Lab { l, a, b } => {
|
||||
let (sin, cos) = f64::from(degrees).to_radians().sin_cos();
|
||||
let (a, b) = (f64::from(a), f64::from(b));
|
||||
Some(Color::lab(l, (a * cos - b * sin) as f32, (a * sin + b * cos) as f32))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn turn_paint(p: &mut Paint, degrees: f32) {
|
||||
if let Paint::Solid { color, .. } = p
|
||||
&& let Some(c) = turned(color, degrees)
|
||||
{
|
||||
*p = Paint::solid(c);
|
||||
}
|
||||
}
|
||||
|
||||
/// Turn the hue of the solid fills and strokes under `n`, its type's characters included. A
|
||||
/// mask's colors are its values, so they stay.
|
||||
fn turn_hues(n: &mut Node, degrees: f32) {
|
||||
for it in &mut n.appearance.items {
|
||||
match it {
|
||||
AppearanceItem::Fill(f) => turn_paint(&mut f.paint, degrees),
|
||||
AppearanceItem::Stroke(s) => turn_paint(&mut s.paint, degrees),
|
||||
}
|
||||
}
|
||||
if let NodeKind::Text(t) = &mut n.kind {
|
||||
for r in &mut t.runs {
|
||||
turn_paint(&mut r.style.fill, degrees);
|
||||
turn_paint(&mut r.style.stroke, degrees);
|
||||
}
|
||||
}
|
||||
if let Some(ch) = n.children_mut() {
|
||||
for c in ch.iter_mut() {
|
||||
turn_hues(Arc::make_mut(c), degrees);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Strip the brushes from every stroke under `n`, its masks' art included.
|
||||
fn strip_brushes(n: &mut Node) {
|
||||
for it in &mut n.appearance.items {
|
||||
|
||||
@@ -172,6 +172,7 @@ pub fn defaults() -> &'static [Brush] {
|
||||
rotation: (-180.0, 180.0),
|
||||
rotation_relative_to_path: false,
|
||||
colorization: Colorization::Tints,
|
||||
hue_jitter: 0.0,
|
||||
modes: None,
|
||||
}),
|
||||
},
|
||||
@@ -185,6 +186,7 @@ pub fn defaults() -> &'static [Brush] {
|
||||
rotation: (-35.0, 35.0),
|
||||
rotation_relative_to_path: true,
|
||||
colorization: Colorization::None,
|
||||
hue_jitter: 0.0,
|
||||
modes: None,
|
||||
}),
|
||||
},
|
||||
|
||||
@@ -298,6 +298,12 @@ pub struct Scatter {
|
||||
/// Rotation relative to the path direction (else to the page).
|
||||
pub rotation_relative_to_path: bool,
|
||||
pub colorization: Colorization,
|
||||
/// Hue jitter in degrees, 0 to 180: each copy turns the hue of the solid colors it draws, after
|
||||
/// the colorization, by its own amount between −`hue_jitter` and `hue_jitter`. The stroke's
|
||||
/// path and the brush name fix the amounts, so a stroke draws the same colors every time.
|
||||
/// 0 (brushes saved before there was hue jitter) leaves the colors as they are.
|
||||
#[serde(skip_serializing_if = "is_zero")]
|
||||
pub hue_jitter: f64,
|
||||
/// How size, spacing, scatter and rotation vary between their two values: Fixed takes the
|
||||
/// first, Random any value between them, Pressure the first at the lightest pen pressure and
|
||||
/// the second at the heaviest, Tilt the first with the pen lying flat and the second upright,
|
||||
@@ -318,6 +324,7 @@ impl Default for Scatter {
|
||||
rotation: (0.0, 0.0),
|
||||
rotation_relative_to_path: false,
|
||||
colorization: Colorization::None,
|
||||
hue_jitter: 0.0,
|
||||
modes: None,
|
||||
}
|
||||
}
|
||||
@@ -326,6 +333,8 @@ impl Default for Scatter {
|
||||
impl Scatter {
|
||||
/// The ranges of size (%), spacing (%), scatter (%) and rotation (°).
|
||||
pub const RANGES: [(f64, f64); 4] = [(1.0, 10000.0), (1.0, 10000.0), (-1000.0, 1000.0), (-180.0, 180.0)];
|
||||
/// The range of [`Scatter::hue_jitter`] (°).
|
||||
pub const HUE_JITTER_RANGE: (f64, f64) = (0.0, 180.0);
|
||||
|
||||
/// Size, spacing, scatter and rotation, each as its (first, second) values.
|
||||
pub fn values(&self) -> [(f64, f64); 4] {
|
||||
@@ -624,6 +633,10 @@ fn within_pair((a, b): (f64, f64), range: (f64, f64), fallback: f64) -> (f64, f6
|
||||
(within(a, range, fallback), within(b, range, fallback))
|
||||
}
|
||||
|
||||
fn is_zero(v: &f64) -> bool {
|
||||
*v == 0.0
|
||||
}
|
||||
|
||||
fn valid_tile_frame(frame: Rect) -> bool {
|
||||
[frame.x0, frame.y0, frame.x1, frame.y1].into_iter().all(f64::is_finite)
|
||||
&& frame.width().is_finite()
|
||||
@@ -714,6 +727,7 @@ impl Brush {
|
||||
s.spacing = within_pair(s.spacing, spacing, d.spacing.0);
|
||||
s.scatter = within_pair(s.scatter, scatter, 0.0);
|
||||
s.rotation = within_pair(s.rotation, rotation, 0.0);
|
||||
s.hue_jitter = within(s.hue_jitter, Scatter::HUE_JITTER_RANGE, 0.0);
|
||||
s.colorization.sanitize();
|
||||
}
|
||||
BrushKind::Art(a) => {
|
||||
@@ -1093,6 +1107,12 @@ pub fn stroke_pieces(doc: &Document, brush: &Brush, bp: &BezPath, stroke: &Strok
|
||||
for n in &mut out {
|
||||
colorize(n, colorization, &stroke.paint);
|
||||
}
|
||||
// One piece per copy, in the order the copies run along the path.
|
||||
if let BrushKind::Scatter(s) = &brush.kind
|
||||
&& s.hue_jitter > 0.0
|
||||
{
|
||||
colorize::jitter_hues(&mut out, s.hue_jitter, track::seed_of(bp, &brush.name));
|
||||
}
|
||||
leave_out_brushed(doc, &mut out, &mut Known::new());
|
||||
out
|
||||
}
|
||||
|
||||
@@ -1033,6 +1033,165 @@ fn stain_mixes_type_strokes_too() {
|
||||
assert_eq!(run_paints(&[art]), [(Paint::solid(blue), Paint::solid(blue))]);
|
||||
}
|
||||
|
||||
/// A scatter brush of rectangles filled `fill`, with `colorization` and `hue_jitter`.
|
||||
fn jittered(fill: Color, colorization: Colorization, hue_jitter: f64) -> Brush {
|
||||
let mut art = rect_art(10.0, 4.0);
|
||||
art.appearance.set_fill(Paint::solid(fill));
|
||||
Brush { name: "s".into(), kind: BrushKind::Scatter(Scatter { art, colorization, hue_jitter, ..Default::default() }) }
|
||||
}
|
||||
|
||||
/// The fill color of each copy.
|
||||
fn fill_colors(out: &[Node]) -> Vec<Color> {
|
||||
out.iter().map(|n| n.appearance.fill_paint().color().unwrap()).collect()
|
||||
}
|
||||
|
||||
/// How far hue `h` is from `from`, in degrees, either way round.
|
||||
fn hue_gap(h: f32, from: f32) -> f32 {
|
||||
let d = (h - from).rem_euclid(360.0);
|
||||
d.min(360.0 - d)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hue_jitter_turns_each_copy_the_same_every_time() {
|
||||
let doc = Document::new(1.0, 1.0);
|
||||
let path = line(0.0, 0.0, 200.0, 0.0);
|
||||
let b = jittered(Color::rgb(1.0, 0.0, 0.0), Colorization::None, 90.0);
|
||||
let out = stroke_pieces(&doc, &b, &path, &stroke(1.0));
|
||||
assert_eq!(out.len(), 20);
|
||||
assert_eq!(stroke_pieces(&doc, &b, &path, &stroke(1.0)), out, "the same stroke draws the same colors");
|
||||
let colors = fill_colors(&out);
|
||||
let hues: Vec<f32> = colors.iter().map(|c| c.to_hsb()[0]).collect();
|
||||
assert!(hues.iter().all(|h| hue_gap(*h, 0.0) <= 90.01), "{hues:?}");
|
||||
assert!(hues.iter().any(|h| hue_gap(*h, 0.0) > 10.0), "the copies turn: {hues:?}");
|
||||
let distinct: std::collections::HashSet<String> = colors.iter().map(Color::to_hex).collect();
|
||||
assert!(distinct.len() > 10, "each copy turns by its own amount: {distinct:?}");
|
||||
// Saturation and brightness stay; the copies stay where they were, at their size and angle.
|
||||
assert!(colors.iter().all(|c| near(f64::from(c.to_hsb()[1]), 1.0, 1e-3) && near(f64::from(c.to_hsb()[2]), 1.0, 1e-3)), "{colors:?}");
|
||||
let plain = stroke_pieces(&doc, &jittered(Color::rgb(1.0, 0.0, 0.0), Colorization::None, 0.0), &path, &stroke(1.0));
|
||||
let boxes = |o: &[Node]| o.iter().map(|n| n.geometric_bounds().unwrap()).collect::<Vec<_>>();
|
||||
assert_eq!(boxes(&out), boxes(&plain));
|
||||
// Another path draws other amounts.
|
||||
let other = fill_colors(&stroke_pieces(&doc, &b, &line(0.0, 10.0, 200.0, 10.0), &stroke(1.0)));
|
||||
assert_ne!(other, colors);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hue_jitter_of_zero_changes_nothing() {
|
||||
let red = Color::rgb(1.0, 0.0, 0.0);
|
||||
let out = stroke_pieces(&Document::new(1.0, 1.0), &jittered(red, Colorization::None, 0.0), &line(0.0, 0.0, 200.0, 0.0), &stroke(1.0));
|
||||
assert!(!out.is_empty() && fill_colors(&out).iter().all(|c| *c == red));
|
||||
// A brush without hue jitter is saved as before, and one saved before reads as 0.
|
||||
let v = serde_json::to_value(jittered(red, Colorization::None, 0.0)).unwrap();
|
||||
assert!(v.get("hue_jitter").is_none(), "{v}");
|
||||
let mut old = serde_json::to_value(jittered(red, Colorization::None, 45.0)).unwrap();
|
||||
assert_eq!(old.as_object_mut().unwrap().remove("hue_jitter"), Some(serde_json::json!(45.0)));
|
||||
let BrushKind::Scatter(s) = Brush::from_json(old).unwrap().kind else { panic!("not a scatter brush") };
|
||||
assert_eq!(s.hue_jitter, 0.0, "a brush saved without the key reads as 0");
|
||||
let mut with = v.clone();
|
||||
with["hue_jitter"] = serde_json::json!(45.0);
|
||||
let BrushKind::Scatter(s) = Brush::from_json(with).unwrap().kind else { panic!("not a scatter brush") };
|
||||
assert_eq!(s.hue_jitter, 45.0);
|
||||
// Values outside 0..180 are clamped.
|
||||
for (given, kept) in [(500.0, 180.0), (-20.0, 0.0)] {
|
||||
let mut v = v.clone();
|
||||
v["hue_jitter"] = serde_json::json!(given);
|
||||
let BrushKind::Scatter(s) = Brush::from_json(v).unwrap().kind else { panic!("not a scatter brush") };
|
||||
assert_eq!(s.hue_jitter, kept, "{given}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hue_jitter_turns_after_the_colorization() {
|
||||
let doc = Document::new(1.0, 1.0);
|
||||
let path = line(0.0, 0.0, 200.0, 0.0);
|
||||
// Tints: black art takes the blue stroke color, which then turns.
|
||||
let blue = StrokeLayer::new(Paint::solid(Color::rgb(0.0, 0.0, 1.0)), 1.0);
|
||||
let hues: Vec<f32> =
|
||||
fill_colors(&stroke_pieces(&doc, &jittered(Color::BLACK, Colorization::Tints, 30.0), &path, &blue)).iter().map(|c| c.to_hsb()[0]).collect();
|
||||
assert!(!hues.is_empty() && hues.iter().all(|h| hue_gap(*h, 240.0) <= 30.01), "{hues:?}");
|
||||
assert!(hues.iter().any(|h| hue_gap(*h, 240.0) > 3.0), "{hues:?}");
|
||||
// A gray stroke color has no hue: its tints stay as they are.
|
||||
let gray = StrokeLayer::new(Paint::solid(Color::rgb(0.5, 0.5, 0.5)), 1.0);
|
||||
let turned = stroke_pieces(&doc, &jittered(Color::BLACK, Colorization::Tints, 180.0), &path, &gray);
|
||||
let still = stroke_pieces(&doc, &jittered(Color::BLACK, Colorization::Tints, 0.0), &path, &gray);
|
||||
assert_eq!(fill_colors(&turned), fill_colors(&still));
|
||||
// Nor does black ink alone, nor a gray, as a process stroke color.
|
||||
for key in [Color::cmyk(0.0, 0.0, 0.0, 1.0), Color::cmyk(0.0, 0.0, 0.0, 0.5), Color::gray(0.4)] {
|
||||
let key = StrokeLayer::new(Paint::solid(key), 1.0);
|
||||
let turned = stroke_pieces(&doc, &jittered(Color::BLACK, Colorization::Tints, 180.0), &path, &key);
|
||||
let still = stroke_pieces(&doc, &jittered(Color::BLACK, Colorization::Tints, 0.0), &path, &key);
|
||||
assert_eq!(fill_colors(&turned), fill_colors(&still), "{key:?}");
|
||||
}
|
||||
// A turned process color stays a process color, turned over its C, M and Y with its K kept.
|
||||
let cmyk = fill_colors(&stroke_pieces(&doc, &jittered(Color::cmyk(0.0, 1.0, 1.0, 0.25), Colorization::None, 60.0), &path, &stroke(1.0)));
|
||||
assert!(cmyk.iter().any(|c| *c != Color::cmyk(0.0, 1.0, 1.0, 0.25)), "{cmyk:?}");
|
||||
for c in &cmyk {
|
||||
let Color::Cmyk { c, m, y, k } = *c else { panic!("not CMYK: {c:?}") };
|
||||
assert_eq!(k, 0.25);
|
||||
// Full ink in one channel and none in another, as the color before it.
|
||||
assert!(near(f64::from(c.max(m).max(y)), 1.0, 1e-4) && near(f64::from(c.min(m).min(y)), 0.0, 1e-4), "{c} {m} {y}");
|
||||
}
|
||||
// An RGB color keeps its saturation and brightness in its own values.
|
||||
let rgb = fill_colors(&stroke_pieces(&doc, &jittered(Color::rgb(0.8, 0.2, 0.4), Colorization::None, 90.0), &path, &stroke(1.0)));
|
||||
for c in &rgb {
|
||||
let Color::Rgb { r, g, b } = *c else { panic!("not RGB: {c:?}") };
|
||||
assert!(near(f64::from(r.max(g).max(b)), 0.8, 1e-4) && near(f64::from(r.min(g).min(b)), 0.2, 1e-4), "{c:?}");
|
||||
}
|
||||
// A Lab color keeps its lightness and chroma.
|
||||
let lab = fill_colors(&stroke_pieces(&doc, &jittered(Color::lab(50.0, 40.0, 30.0), Colorization::None, 90.0), &path, &stroke(1.0)));
|
||||
assert!(lab.iter().any(|c| *c != Color::lab(50.0, 40.0, 30.0)), "{lab:?}");
|
||||
for c in &lab {
|
||||
let Color::Lab { l, a, b } = *c else { panic!("not Lab: {c:?}") };
|
||||
assert!(l == 50.0 && near(f64::from(a.hypot(b)), 50.0, 1e-3), "{c:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Hue jitter turns type's characters, the colors Tints and Shades and Hue Shift give, and a color
|
||||
/// linked to a swatch (which loses the link); a pattern paint stays.
|
||||
#[test]
|
||||
fn hue_jitter_turns_type_every_colorization_and_linked_colors() {
|
||||
let doc = Document::new(1.0, 1.0);
|
||||
let path = line(0.0, 0.0, 200.0, 0.0);
|
||||
let red = Paint::solid(Color::rgb(1.0, 0.0, 0.0));
|
||||
let typed = |hue_jitter| Brush {
|
||||
name: "s".into(),
|
||||
kind: BrushKind::Scatter(Scatter { art: type_art(red.clone(), red.clone()), hue_jitter, ..Default::default() }),
|
||||
};
|
||||
let still = run_paints(&stroke_pieces(&doc, &typed(0.0), &path, &stroke(1.0)));
|
||||
let turned = run_paints(&stroke_pieces(&doc, &typed(90.0), &path, &stroke(1.0)));
|
||||
assert!(!still.is_empty() && still.iter().all(|p| *p == (red.clone(), red.clone())), "{still:?}");
|
||||
assert_eq!(turned.len(), still.len());
|
||||
assert!(turned.iter().any(|p| *p != (red.clone(), red.clone())), "the characters turn: {turned:?}");
|
||||
assert!(turned.iter().all(|(f, s)| f == s), "a copy's character fill and stroke turn by the same amount: {turned:?}");
|
||||
// Tints and Shades and Hue Shift: the colors they give turn.
|
||||
let blue = StrokeLayer::new(Paint::solid(Color::rgb(0.0, 0.0, 1.0)), 1.0);
|
||||
for colorization in [Colorization::TintsAndShades, Colorization::HueShift { key: Color::rgb(1.0, 0.0, 0.0) }] {
|
||||
let art = Color::rgb(1.0, 0.0, 0.0);
|
||||
let still = fill_colors(&stroke_pieces(&doc, &jittered(art, colorization, 0.0), &path, &blue));
|
||||
let turned = fill_colors(&stroke_pieces(&doc, &jittered(art, colorization, 45.0), &path, &blue));
|
||||
assert_eq!(turned.len(), still.len());
|
||||
assert_ne!(turned, still, "{colorization:?}");
|
||||
for (t, s) in turned.iter().zip(&still) {
|
||||
assert!(hue_gap(t.to_hsb()[0], s.to_hsb()[0]) <= 45.01, "{colorization:?}: {t:?} from {s:?}");
|
||||
}
|
||||
}
|
||||
// A color linked to a swatch turns and loses the link; a pattern paint stays.
|
||||
let linked = Paint::Solid { color: Color::rgb(1.0, 0.0, 0.0), swatch: Some("Red".into()), tint: 1.0 };
|
||||
let pattern = Paint::Pattern { pattern: "Dots".into(), xf: Affine::IDENTITY };
|
||||
let mut art = rect_art(10.0, 4.0);
|
||||
art.appearance.set_fill(linked.clone());
|
||||
art.appearance.set_stroke(pattern.clone());
|
||||
let b = |hue_jitter| Brush { name: "s".into(), kind: BrushKind::Scatter(Scatter { art: art.clone(), hue_jitter, ..Default::default() }) };
|
||||
let still = stroke_pieces(&doc, &b(0.0), &path, &stroke(1.0));
|
||||
let turned = stroke_pieces(&doc, &b(90.0), &path, &stroke(1.0));
|
||||
assert!(!still.is_empty() && still.iter().all(|n| n.appearance.fill_paint() == linked));
|
||||
assert_eq!(turned.len(), still.len());
|
||||
for n in &turned {
|
||||
assert!(matches!(n.appearance.fill_paint(), Paint::Solid { swatch: None, .. }), "{:?}", n.appearance.fill_paint());
|
||||
assert_eq!(n.appearance.stroke().map(|s| &s.paint), Some(&pattern));
|
||||
}
|
||||
}
|
||||
|
||||
/// An instance whose fill has an opacity of 0 does not stain its symbol's art, so the art keeps its
|
||||
/// swatch links.
|
||||
#[test]
|
||||
|
||||
@@ -165,7 +165,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Brush Options…",
|
||||
[],
|
||||
None,
|
||||
"{name, params?: {…fields to change (brush.get shows them; values outside their ranges are clamped). calligraphic: angle −180..180° (counter-clockwise from level), roundness 0..100%, size 0..1296 pt, variation: [angle°, roundness%, size pt], modes: [fixed|random|pressure|tilt|bearing|rotation for angle, roundness, size] (pressure goes from value − variation at the lightest pen pressure to value + variation at the heaviest; tilt from value − variation with the pen lying flat to value + variation with it upright; bearing and rotation add variation × the pen's bearing (which way it leans, counter-clockwise from leaning right) or its barrel's counter-clockwise rotation over 180°; the angle turns on past ±180°). scatter: size [a, b] 1..10000%, spacing [a, b] 1..10000%, scatter [a, b] −1000..1000%, rotation [a, b] −180..180° (counter-clockwise), modes: [fixed|random|pressure|tilt|bearing|rotation for size, spacing, scatter, rotation] (fixed: a; random: between a and b; pressure: a at the lightest pen pressure to b at the heaviest; tilt: a with the pen lying flat to b upright; bearing and rotation: a at −180° to b at 180°), rotation_relative_to_path. art: width 1..1000%, width_mode: null (fixed)|pressure|tilt|bearing|rotation, width_max 1..1000% (pressure: width at the lightest pen pressure to width_max at the heaviest; tilt: width with the pen lying flat to width_max upright; bearing and rotation: width at −180° to width_max at 180°; half way on a stroke drawn without that input), scale: {mode: proportional|stretch|betweenGuides, start, end: 0..1 of the art length}, direction: leftToRight|rightToLeft|topToBottom|bottomToTop, flip_along, flip_across, overlap. pattern: scale 1..10000%, spacing 0..10000%, fit: stretch|addSpace|approximate, flip_along, flip_across, outer_corner and inner_corner: corner tile art (drawn as the corner that joins a side tile on its right to one below it) or null, outer_source and inner_source: what that kind of corner draws without its art: none|autoCentered|autoBetween|autoSliced|autoOverlap (a tile made from the side tile), or null (the other kind of corner's art); side_tile, outer_corner_tile, inner_corner_tile, start_tile, end_tile: a document pattern name, original, or none (side refuses none); corner tiles also take autoCentered|autoBetween|autoSliced|autoOverlap. Each tile also accepts {pattern: name} to select a swatch whose name is a reserved choice. scatter, art and pattern: colorization: {method: none|tints|tintsAndShades|hueShift, key: colour (hueShift: the art colour that becomes the stroke colour; without a key: the solid color the art's fills and strokes use most, black when they use none)}; colorization and the art brush's scale change only the fields given}, newName? (trimmed; blank: the name is kept; a new bristle brush name has at most 31 characters, and a longer name the brush has is kept)} edit a brush definition (strokes using it update) → {name}",
|
||||
"{name, params?: {…fields to change (brush.get shows them; values outside their ranges are clamped). calligraphic: angle −180..180° (counter-clockwise from level), roundness 0..100%, size 0..1296 pt, variation: [angle°, roundness%, size pt], modes: [fixed|random|pressure|tilt|bearing|rotation for angle, roundness, size] (pressure goes from value − variation at the lightest pen pressure to value + variation at the heaviest; tilt from value − variation with the pen lying flat to value + variation with it upright; bearing and rotation add variation × the pen's bearing (which way it leans, counter-clockwise from leaning right) or its barrel's counter-clockwise rotation over 180°; the angle turns on past ±180°). scatter: size [a, b] 1..10000%, spacing [a, b] 1..10000%, scatter [a, b] −1000..1000%, rotation [a, b] −180..180° (counter-clockwise), modes: [fixed|random|pressure|tilt|bearing|rotation for size, spacing, scatter, rotation] (fixed: a; random: between a and b; pressure: a at the lightest pen pressure to b at the heaviest; tilt: a with the pen lying flat to b upright; bearing and rotation: a at −180° to b at 180°), rotation_relative_to_path, hue_jitter 0..180° (each copy turns the hue of its solid colors, after the colorization, by its own amount up to this far either way, the same on every redraw; colors without a hue stay; 0: off). art: width 1..1000%, width_mode: null (fixed)|pressure|tilt|bearing|rotation, width_max 1..1000% (pressure: width at the lightest pen pressure to width_max at the heaviest; tilt: width with the pen lying flat to width_max upright; bearing and rotation: width at −180° to width_max at 180°; half way on a stroke drawn without that input), scale: {mode: proportional|stretch|betweenGuides, start, end: 0..1 of the art length}, direction: leftToRight|rightToLeft|topToBottom|bottomToTop, flip_along, flip_across, overlap. pattern: scale 1..10000%, spacing 0..10000%, fit: stretch|addSpace|approximate, flip_along, flip_across, outer_corner and inner_corner: corner tile art (drawn as the corner that joins a side tile on its right to one below it) or null, outer_source and inner_source: what that kind of corner draws without its art: none|autoCentered|autoBetween|autoSliced|autoOverlap (a tile made from the side tile), or null (the other kind of corner's art); side_tile, outer_corner_tile, inner_corner_tile, start_tile, end_tile: a document pattern name, original, or none (side refuses none); corner tiles also take autoCentered|autoBetween|autoSliced|autoOverlap. Each tile also accepts {pattern: name} to select a swatch whose name is a reserved choice. scatter, art and pattern: colorization: {method: none|tints|tintsAndShades|hueShift, key: colour (hueShift: the art colour that becomes the stroke colour; without a key: the solid color the art's fills and strokes use most, black when they use none)}; colorization and the art brush's scale change only the fields given}, newName? (trimmed; blank: the name is kept; a new bristle brush name has at most 31 characters, and a longer name the brush has is kept)} edit a brush definition (strokes using it update) → {name}",
|
||||
has_doc,
|
||||
brush_options
|
||||
),
|
||||
|
||||
@@ -32,7 +32,12 @@ pub(super) fn brush_list(s: &mut Session, _: &Value) -> Result<Value> {
|
||||
pub(super) fn brush_get(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let name = name_param(p, "brush.get")?;
|
||||
let b = brush::find(&s.doc()?.doc, name).ok_or_else(|| EngineError::Other(format!("no brush named `{name}`")))?;
|
||||
Ok(serde_json::to_value(b).unwrap_or_default())
|
||||
let mut v = serde_json::to_value(&b).unwrap_or_default();
|
||||
// A scatter brush saves its hue jitter only when it is not 0; brush.get shows it either way.
|
||||
if let (BrushKind::Scatter(sc), Some(o)) = (&b.kind, v.as_object_mut()) {
|
||||
o.entry("hue_jitter").or_insert(json!(sc.hue_jitter));
|
||||
}
|
||||
Ok(v)
|
||||
}
|
||||
|
||||
/// The art `brush.new` takes from `ids` or `id`, else from the selection ([`selection_art`]).
|
||||
|
||||
@@ -1697,6 +1697,46 @@ fn brush_options_set_variation_modes() {
|
||||
assert_eq!(s.execute("brush.get", &json!({"name": "Dots"})).unwrap()["modes"], modes);
|
||||
}
|
||||
|
||||
/// The fill colors of the copies brushed path `id` draws in `doc`, as `#rrggbb`.
|
||||
fn piece_fills(doc: &Document, id: NodeId) -> Vec<String> {
|
||||
let pieces = vectorcraft_brush::node_pieces(doc, doc.node(id).unwrap()).expect("brushed");
|
||||
pieces.iter().map(|n| n.appearance.fill_paint().color().unwrap().to_hex()).collect()
|
||||
}
|
||||
|
||||
/// Scatter Brush Options' `hue_jitter`: shown by `brush.get`, set by `brush.options`, saved with the
|
||||
/// document, and the turned colors drawn the same after Open and written by SVG export.
|
||||
#[test]
|
||||
fn scatter_hue_jitter_saves_and_exports() {
|
||||
let mut s = session();
|
||||
let r = rect(&mut s, 10.0, 200.0, 8.0, 8.0);
|
||||
s.execute("paint.setFill", &json!({"color": "#ff0000"})).unwrap();
|
||||
let name = s.execute("brush.new", &json!({"type": "scatter", "name": "Confetti", "ids": [r.0]})).unwrap()["name"].as_str().unwrap().to_string();
|
||||
let id = line(&mut s);
|
||||
select(&mut s, &[id]);
|
||||
s.execute("brush.apply", &json!({ "name": name })).unwrap();
|
||||
let plain = piece_fills(&s.doc().unwrap().doc, id);
|
||||
assert!(plain.len() > 10 && plain.iter().all(|c| c == "#ff0000"), "{plain:?}");
|
||||
assert_eq!(s.execute("brush.get", &json!({ "name": name })).unwrap()["hue_jitter"], json!(0.0), "brush.get shows the option at 0");
|
||||
s.execute("brush.options", &json!({"name": name, "params": {"hue_jitter": 120}})).unwrap();
|
||||
assert_eq!(s.execute("brush.get", &json!({ "name": name })).unwrap()["hue_jitter"], json!(120.0));
|
||||
let doc = s.doc().unwrap().doc.clone();
|
||||
let turned = piece_fills(&doc, id);
|
||||
assert_eq!(turned.len(), plain.len());
|
||||
let distinct: std::collections::HashSet<&String> = turned.iter().collect();
|
||||
assert!(distinct.len() > 5, "{turned:?}");
|
||||
// Saved and opened again, the stroke draws the same colors.
|
||||
let back = vectorcraft_format::load(&vectorcraft_format::save(&doc, false)).unwrap();
|
||||
assert_eq!(piece_fills(&back, id), turned);
|
||||
// SVG export writes each copy's turned color.
|
||||
let svg = vectorcraft_svg::export(&doc, &Default::default());
|
||||
for c in &distinct {
|
||||
assert!(svg.contains(&format!("fill=\"{c}\"")), "{c} missing from the SVG");
|
||||
}
|
||||
// Back to 0, the copies draw the art's own color.
|
||||
s.execute("brush.options", &json!({"name": name, "params": {"hue_jitter": 0}})).unwrap();
|
||||
assert_eq!(piece_fills(&s.doc().unwrap().doc, id), plain);
|
||||
}
|
||||
|
||||
/// The bounds of the brush art `id`'s strokes draw.
|
||||
fn brushed_bounds(s: &Session, id: NodeId) -> Rect {
|
||||
let st = s.doc().unwrap();
|
||||
|
||||
@@ -10077,6 +10077,7 @@ fn brush_library() -> Vec<vectorcraft_brush::Brush> {
|
||||
rotation: (-45.0, 30.0),
|
||||
rotation_relative_to_path: true,
|
||||
colorization: Colorization::Tints,
|
||||
hue_jitter: 0.0,
|
||||
modes: Some([Variation::Random, Variation::Fixed, Variation::Pressure, Variation::Random]),
|
||||
}),
|
||||
},
|
||||
@@ -10183,6 +10184,22 @@ fn brushes_are_read_back_with_their_settings() {
|
||||
}
|
||||
}
|
||||
|
||||
/// The writer does not write a Scatter brush's hue jitter: the brush would open without it, so it
|
||||
/// is left out of the Brushes panel and reported.
|
||||
#[test]
|
||||
fn a_scatter_brush_with_hue_jitter_is_left_out() {
|
||||
use vectorcraft_brush::BrushKind;
|
||||
let mut lib = brush_library();
|
||||
let BrushKind::Scatter(s) = &mut lib[1].kind else { panic!("scatter") };
|
||||
s.hue_jitter = 60.0;
|
||||
let mut doc = Document::new(300.0, 200.0);
|
||||
vectorcraft_brush::store(&mut doc, &lib);
|
||||
let out = export_ai_editing(&doc, &opts()).unwrap();
|
||||
assert!(out.warnings.iter().any(|w| w == writer::BRUSHES), "{:?}", out.warnings);
|
||||
let back = vectorcraft_brush::library(&read_back(&doc));
|
||||
assert_eq!(back.iter().map(|b| b.name.as_str()).collect::<Vec<_>>(), ["Nib", "Ribbon", "Plain ribbon"]);
|
||||
}
|
||||
|
||||
/// An Art brush's options, without its art.
|
||||
#[derive(Debug, PartialEq)]
|
||||
struct ArtBrushOptions(serde_json::Value);
|
||||
@@ -10512,6 +10529,7 @@ fn more_brush_settings_are_read_back() {
|
||||
rotation: (15.0, 15.0),
|
||||
rotation_relative_to_path: false,
|
||||
colorization: Colorization::None,
|
||||
hue_jitter: 0.0,
|
||||
modes: Some([Variation::Tilt, Variation::Bearing, Variation::Fixed, Variation::Rotation]),
|
||||
};
|
||||
let lib = vec![
|
||||
|
||||
@@ -972,7 +972,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"ui.brushOptions",
|
||||
"Brush Options…",
|
||||
"",
|
||||
"{name?} (default: the selected path's brush, else the current brush) open its Brush Options, what double-clicking a brush in the Brushes panel opens (dialog `brushOptions`): Calligraphic (fields name, angle −180..180, roundness 0..100, size 0..1296 pt, angleMode/roundnessMode/sizeMode: fixed|random|pressure, angleVariation/roundnessVariation/sizeVariation), Bristle (fields name, shape, size, length, density, thickness, opacity, stiffness), Scatter (fields sizeMin/sizeMax/sizeMode, spacingMin/spacingMax/spacingMode, scatterMin/scatterMax/scatterMode, rotationMin/rotationMax/rotationMode with modes fixed|random|pressure, rotationRelativeTo: page|path), Art (fields width %, scaleMode: proportional|stretch|betweenGuides, guideStart/guideEnd % of the art length, direction: leftToRight|rightToLeft|topToBottom|bottomToTop, flipAlong, flipAcross) or Pattern (fields scale %, spacing %, fit: stretch|addSpace|approximate, flipAlong, flipAcross); Scatter, Art and Pattern also colorization: none|tints|tintsAndShades|hueShift, keyColor, and tips: true opens Colorization Tips (what each method does, beside a sample of the brush painted with it), as the Tips button beside Method does; OK runs brush.options",
|
||||
"{name?} (default: the selected path's brush, else the current brush) open its Brush Options, what double-clicking a brush in the Brushes panel opens (dialog `brushOptions`): Calligraphic (fields name, angle −180..180, roundness 0..100, size 0..1296 pt, angleMode/roundnessMode/sizeMode: fixed|random|pressure, angleVariation/roundnessVariation/sizeVariation), Bristle (fields name, shape, size, length, density, thickness, opacity, stiffness), Scatter (fields sizeMin/sizeMax/sizeMode, spacingMin/spacingMax/spacingMode, scatterMin/scatterMax/scatterMode, rotationMin/rotationMax/rotationMode with modes fixed|random|pressure, rotationRelativeTo: page|path, hueJitter 0..180°), Art (fields width %, scaleMode: proportional|stretch|betweenGuides, guideStart/guideEnd % of the art length, direction: leftToRight|rightToLeft|topToBottom|bottomToTop, flipAlong, flipAcross) or Pattern (fields scale %, spacing %, fit: stretch|addSpace|approximate, flipAlong, flipAcross); Scatter, Art and Pattern also colorization: none|tints|tintsAndShades|hueShift, keyColor, and tips: true opens Colorization Tips (what each method does, beside a sample of the brush painted with it), as the Tips button beside Method does; OK runs brush.options",
|
||||
),
|
||||
(
|
||||
"ui.brushObjectOptions",
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
//! open).
|
||||
//! Scatter: per value (`size`, `spacing`, `scatter` %, `rotation` °) `…Min`, `…Max` and `…Mode`
|
||||
//! (`fixed` | `random` | `pressure` | `tilt` | `bearing` | `rotation`), `rotationRelativeTo` (`page` |
|
||||
//! `path`).
|
||||
//! `path`), `hueJitter` (°).
|
||||
//! Art: `width` (%), `widthMode` (`fixed` | `pressure` | `tilt` | `bearing` | `rotation`),
|
||||
//! `widthMax` (the width at the heaviest pen pressure, upright or at 180°, %), `scaleMode` (`proportional` | `stretch` | `betweenGuides`), `guideStart` and
|
||||
//! `guideEnd` (% of the art's length), `direction` (`leftToRight` …), `flipAlong`, `flipAcross`,
|
||||
@@ -187,6 +187,7 @@ pub(super) fn fields(b: &Brush, def: Value, f: &mut Map<String, Value>) {
|
||||
f.insert(mode_key(key), json!(mode.id()));
|
||||
}
|
||||
f.insert("rotationRelativeTo".into(), json!(if s.rotation_relative_to_path { "path" } else { "page" }));
|
||||
f.insert("hueJitter".into(), json!(s.hue_jitter));
|
||||
}
|
||||
BrushKind::Art(a) => {
|
||||
let (mode, start, end) = match a.scale {
|
||||
@@ -268,6 +269,7 @@ pub(super) fn params(d: &Dialog) -> Value {
|
||||
p[*key] = json!([clamped(d, &min_key(key), range), clamped(d, &max_key(key), range)]);
|
||||
}
|
||||
p["modes"] = json!(SCATTER.map(|(key, _)| scatter_mode(d, key).id()));
|
||||
p["hue_jitter"] = json!(clamped(d, "hueJitter", Scatter::HUE_JITTER_RANGE));
|
||||
p
|
||||
}
|
||||
"art" => {
|
||||
@@ -457,6 +459,9 @@ fn scatter_body(ui: &mut egui::Ui, d: &mut Dialog) {
|
||||
ui.add_space(4.0);
|
||||
let relative = [("page", tl!("Page")), ("path", tl!("Path"))];
|
||||
super::form::choice(ui, d, "rotationRelativeTo", tl!("Rotation relative to:"), (LABEL_W, 104.0), &relative);
|
||||
ui.add_space(4.0);
|
||||
// Each copy turns its colors' hue by its own amount up to this many degrees either way.
|
||||
widgets::label_row(ui, tl!("Hue Jitter:"), LABEL_W, |ui| number(ui, d, "hueJitter", Scatter::HUE_JITTER_RANGE, "°", true));
|
||||
}
|
||||
|
||||
fn art_body(ui: &mut egui::Ui, d: &mut Dialog) {
|
||||
|
||||
@@ -153,6 +153,7 @@ fn scatter_options_show_each_value_with_its_mode_and_ok_applies_them() {
|
||||
"Random",
|
||||
"Rotation relative to:",
|
||||
"Page",
|
||||
"Hue Jitter:",
|
||||
"Colorization",
|
||||
"Method:",
|
||||
"Tints",
|
||||
@@ -163,10 +164,11 @@ fn scatter_options_show_each_value_with_its_mode_and_ok_applies_them() {
|
||||
let d = app.ui.dialog.as_ref().unwrap();
|
||||
assert_eq!((d.f64("sizeMin", 0.0), d.f64("sizeMax", 0.0), d.str("sizeMode")), (60.0, 140.0, "random".into()));
|
||||
assert_eq!((d.str("rotationRelativeTo"), d.str("colorization")), ("page".into(), "tints".into()));
|
||||
// Values are kept within their ranges (rotation here); Fixed takes the first value.
|
||||
assert_eq!(d.f64("hueJitter", -1.0), 0.0);
|
||||
// Values are kept within their ranges (rotation and hue jitter here); Fixed takes the first value.
|
||||
set(
|
||||
&mut app,
|
||||
json!({"sizeMode": "fixed", "sizeMin": 5000, "spacingMode": "pressure", "rotationMin": -400, "rotationRelativeTo": "path", "colorization": "hueShift"}),
|
||||
json!({"sizeMode": "fixed", "sizeMin": 5000, "spacingMode": "pressure", "rotationMin": -400, "rotationRelativeTo": "path", "colorization": "hueShift", "hueJitter": 400}),
|
||||
);
|
||||
assert!(shown(&mut app).contains("Hue Shift"));
|
||||
super::super::confirm(&mut app).unwrap();
|
||||
@@ -177,12 +179,14 @@ fn scatter_options_show_each_value_with_its_mode_and_ok_applies_them() {
|
||||
(&json!([5000.0, 140.0]), &json!(-180.0), &json!(["fixed", "pressure", "random", "random"]))
|
||||
);
|
||||
assert_eq!((&def["rotation_relative_to_path"], &def["colorization"]["method"]), (&json!(true), &json!("hueShift")));
|
||||
assert_eq!(def["hue_jitter"], json!(180.0));
|
||||
assert!(def["colorization"]["key"].is_object(), "the art's colour as the key: {def}");
|
||||
assert!(drawn_height(&app, id) > before, "the stroke redraws with the bigger confetti");
|
||||
// Opened again, it shows what was set.
|
||||
app.run("ui.brushOptions", json!({"name": "Confetti"})).unwrap();
|
||||
let d = app.ui.dialog.as_ref().unwrap();
|
||||
assert_eq!((d.str("sizeMode"), d.str("spacingMode"), d.str("colorization")), ("fixed".into(), "pressure".into(), "hueShift".into()));
|
||||
assert_eq!(d.f64("hueJitter", 0.0), 180.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -2172,6 +2172,7 @@ font-technology Variable Променливи
|
||||
Scatter: Разпръскване:
|
||||
Rotation: Завъртане:
|
||||
Rotation relative to: Завъртане спрямо:
|
||||
Hue Jitter: Вариация на оттенъка:
|
||||
Brush Scale Options Опции за мащабиране на четката
|
||||
Scale Proportionately Мащабиране пропорционално
|
||||
Stretch to Fit Stroke Length Разтягане за запълване дължината на щриха
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2412,6 +2412,7 @@ digits Malayalam Malajalam
|
||||
Scatter: Raspršenost:
|
||||
Rotation: Rotacija:
|
||||
Rotation relative to: Rotacija u odnosu na:
|
||||
Hue Jitter: Variranje nijanse:
|
||||
Brush Scale Options Opcije skale četkice
|
||||
Scale Proportionately Skaliraj proporcionalno
|
||||
Stretch to Fit Stroke Length Razvuci da stane u dužinu poteza
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -4043,6 +4043,7 @@ digits Malayalam Malaiàlam
|
||||
Rotate… Gira…
|
||||
Rotation Rotació
|
||||
Rotation relative to: Rotació relativa a:
|
||||
Hue Jitter: Variació del to:
|
||||
Rotation X Rotació X
|
||||
Rotation Y Rotació Y
|
||||
Rotation Z Rotació Z
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2485,6 +2485,7 @@ digits Malayalam Malajálamské
|
||||
Scatter: Rozptyl:
|
||||
Rotation: Otočení:
|
||||
Rotation relative to: Otočení vzhledem k:
|
||||
Hue Jitter: Kolísání odstínu:
|
||||
Brush Scale Options Možnosti velikosti štětce
|
||||
Scale Proportionately Měnit velikost proporcionálně
|
||||
Stretch to Fit Stroke Length Roztáhnout na délku tahu
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5005,6 +5005,7 @@ digits Malayalam Malayalam
|
||||
Scatter: Spredning:
|
||||
Rotation: Rotation:
|
||||
Rotation relative to: Rotation i forhold til:
|
||||
Hue Jitter: Nuancevariation:
|
||||
Brush Scale Options Indstillinger for penselskalering
|
||||
Scale Proportionately Skalér proportionalt
|
||||
Stretch to Fit Stroke Length Stræk til konturens længde
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5727,6 +5727,7 @@ variable-list-end {0}, {1} {0} und {1}
|
||||
Scatter: Streuung:
|
||||
Rotation: Drehung:
|
||||
Rotation relative to: Drehung relativ zu:
|
||||
Hue Jitter: Farbtonvariation:
|
||||
Side Tile Seitenkachel
|
||||
Outer Corner Tile Äußere Eckkachel
|
||||
Inner Corner Tile Innere Eckkachel
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3335,6 +3335,7 @@ theme Appearance Εμφάνιση
|
||||
Art Brush Options Επιλογές πινέλου σχεδίου
|
||||
Pattern Brush Options Επιλογές πινέλου μοτίβου
|
||||
Rotation relative to: Περιστροφή ως προς:
|
||||
Hue Jitter: Διακύμανση απόχρωσης:
|
||||
Brush Scale Options Επιλογές κλιμάκωσης πινέλου
|
||||
Scale Proportionately Αναλογική κλιμάκωση
|
||||
Stretch to Fit Stroke Length Επέκταση για προσαρμογή στο μήκος περιγράμματος
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2261,6 +2261,7 @@ font-technology Variable Variables
|
||||
Scatter: Dispersión:
|
||||
Rotation: Rotación:
|
||||
Rotation relative to: Rotación relativa a:
|
||||
Hue Jitter: Variación del tono:
|
||||
Brush Scale Options Opciones de escala del pincel
|
||||
Scale Proportionately Escalar proporcionalmente
|
||||
Stretch to Fit Stroke Length Estirar para ajustar a la longitud del trazo
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2447,6 +2447,7 @@ digits Malayalam Malajalam
|
||||
Scatter: Sirottelu:
|
||||
Rotation: Kierto:
|
||||
Rotation relative to: Kierto suhteessa:
|
||||
Hue Jitter: Sävyn vaihtelu:
|
||||
Brush Scale Options Siveltimen skaalausasetukset
|
||||
Scale Proportionately Skaalaa suhteellisesti
|
||||
Stretch to Fit Stroke Length Venytä viivan pituuteen
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2249,6 +2249,7 @@ font-technology Variable Variables
|
||||
Scatter: Dispersion :
|
||||
Rotation: Rotation :
|
||||
Rotation relative to: Rotation par rapport à :
|
||||
Hue Jitter: Variation de teinte :
|
||||
Brush Scale Options Options de mise à l’échelle de la forme
|
||||
Scale Proportionately Mettre à l’échelle proportionnellement
|
||||
Stretch to Fit Stroke Length Étirer selon la longueur du contour
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3345,6 +3345,7 @@
|
||||
Rotation Y પરિભ્રમણ Y
|
||||
Rotation Z પરિભ્રમણ Z
|
||||
Rotation relative to: આના સાપેક્ષે પરિભ્રમણ:
|
||||
Hue Jitter: રંગછટામાં ફેરફાર:
|
||||
Rotation: પરિભ્રમણ:
|
||||
Rough Pastels… રફ પેસ્ટલ્સ…
|
||||
Roughen… રફ બનાવો…
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 72 and column 5.
|
@@ -4420,6 +4420,7 @@ antiAlias Sharp शार्प
|
||||
Rotate… घुमाव…
|
||||
Rotation घुमाव
|
||||
Rotation relative to: इसके सापेक्ष:
|
||||
Hue Jitter: रंगत में भिन्नता:
|
||||
Rotation X रोटेशन X
|
||||
Rotation Y रोटेशन वाई
|
||||
Rotation Z रोटेशन Z
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3881,6 +3881,7 @@ mark-style Japanese Japán
|
||||
Rotate… Elforgatás…
|
||||
Rotation Elforgatás
|
||||
Rotation relative to: Elforgatás viszonyítási alapja:
|
||||
Hue Jitter: Színárnyalat-szórás:
|
||||
Rotation X X-elforgatás
|
||||
Rotation Y Y-elforgatás
|
||||
Rotation Z Z-elforgatás
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2235,6 +2235,7 @@ digits Malayalam Malayalam
|
||||
Scatter: Sebaran:
|
||||
Rotation: Rotasi:
|
||||
Rotation relative to: Rotasi relatif terhadap:
|
||||
Hue Jitter: Variasi rona:
|
||||
Brush Scale Options Opsi skala kuas
|
||||
Scale Proportionately Skalakan proporsional
|
||||
Stretch to Fit Stroke Length Regangkan sesuai panjang stroke
|
||||
|
||||
|
@@ -2302,6 +2302,7 @@ file-filter Templates Modelli
|
||||
Scatter: Dispersione:
|
||||
Rotation: Rotazione:
|
||||
Rotation relative to: Rotazione relativa a:
|
||||
Hue Jitter: Variazione tonalità:
|
||||
Brush Scale Options Opzioni di scala del pennello
|
||||
Scale Proportionately Ridimensiona proporzionalmente
|
||||
Stretch to Fit Stroke Length Allunga per adattare alla lunghezza del tratto
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2501,6 +2501,7 @@ antiAlias Sharp シャープ
|
||||
Scatter: 散布:
|
||||
Rotation: 回転:
|
||||
Rotation relative to: 回転の基準:
|
||||
Hue Jitter: 色相のばらつき:
|
||||
Brush Scale Options ブラシ伸縮オプション
|
||||
Scale Proportionately 縦横比を保持して拡大・縮小
|
||||
Stretch to Fit Stroke Length ストロークの長さに合わせて伸縮
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4402,6 +4402,7 @@ digits Malayalam მალაიალამური
|
||||
Scatter: გაფანტვა:
|
||||
Rotation: შემობრუნება:
|
||||
Rotation relative to: შემობრუნების ათვლა:
|
||||
Hue Jitter: ელფერის ვარიაცია:
|
||||
Brush Scale Options ფუნჯის მასშტაბირების პარამეტრები
|
||||
Scale Proportionately პროპორციული მასშტაბირება
|
||||
Stretch to Fit Stroke Length კონტურის სიგრძეზე გაწელვა
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2491,6 +2491,7 @@ antiAlias Sharp 날카롭게
|
||||
Scatter: 흩뿌림:
|
||||
Rotation: 회전:
|
||||
Rotation relative to: 회전 기준:
|
||||
Hue Jitter: 색조 변화:
|
||||
Brush Scale Options 브러시 크기 조절 옵션
|
||||
Scale Proportionately 비율에 맞게 크기 조절
|
||||
Stretch to Fit Stroke Length 선 길이에 맞게 늘이기
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2879,6 +2879,7 @@ digits Malayalam Malayalam
|
||||
Scatter: Verspreiding:
|
||||
Rotation: Rotatie:
|
||||
Rotation relative to: Rotatie ten opzichte van:
|
||||
Hue Jitter: Tintvariatie:
|
||||
Brush Scale Options Opties voor penseelschaling
|
||||
Scale Proportionately Proportioneel schalen
|
||||
Stretch to Fit Stroke Length Uitrekken tot lijnlengte
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2401,6 +2401,7 @@ digits Malayalam Malajalam
|
||||
Scatter: Rozproszenie:
|
||||
Rotation: Obrót:
|
||||
Rotation relative to: Obrót względem:
|
||||
Hue Jitter: Zmienność barwy:
|
||||
Brush Scale Options Opcje skali pędzla
|
||||
Scale Proportionately Skaluj proporcjonalnie
|
||||
Stretch to Fit Stroke Length Rozciągnij do długości obrysu
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3918,6 +3918,7 @@ font-technology Variable Variáveis
|
||||
Scatter: Dispersão:
|
||||
Rotation: Rotação:
|
||||
Rotation relative to: Rotação relativa a:
|
||||
Hue Jitter: Variação de matiz:
|
||||
Brush Scale Options Opções de escala do pincel
|
||||
Scale Proportionately Dimensionar proporcionalmente
|
||||
Stretch to Fit Stroke Length Esticar para ajustar ao comprimento do traço
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2286,6 +2286,7 @@ file-filter Templates Шаблоны
|
||||
Scatter: Рассеивание:
|
||||
Rotation: Поворот:
|
||||
Rotation relative to: Поворот относительно:
|
||||
Hue Jitter: Разброс тона:
|
||||
Brush Scale Options Параметры масштабирования кисти
|
||||
Scale Proportionately Масштабировать пропорционально
|
||||
Stretch to Fit Stroke Length Растянуть по длине обводки
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2193,6 +2193,7 @@ font-technology Variable Variabla
|
||||
Scatter: Spridning:
|
||||
Rotation: Rotation:
|
||||
Rotation relative to: Rotation i förhållande till:
|
||||
Hue Jitter: Nyansvariation:
|
||||
Brush Scale Options Alternativ för penselskala
|
||||
Scale Proportionately Skala proportionellt
|
||||
Stretch to Fit Stroke Length Sträck för att passa konturlängden
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2074,6 +2074,7 @@ font-technology Variable Değişken
|
||||
Scatter: Dağılım:
|
||||
Rotation: Rotasyon:
|
||||
Rotation relative to: Şuna göre rotasyon:
|
||||
Hue Jitter: Renk tonu değişimi:
|
||||
Brush Scale Options Fırça Ölçeği Seçenekleri
|
||||
Scale Proportionately Orantılı Olarak Ölçeklendirin
|
||||
Stretch to Fit Stroke Length Kontur Uzunluğuna Sığacak Şekilde Esnetin
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2294,6 +2294,7 @@ file-filter Templates Шаблони
|
||||
Scatter: Розсіювання:
|
||||
Rotation: Поворот:
|
||||
Rotation relative to: Поворот відносно:
|
||||
Hue Jitter: Розкид відтінку:
|
||||
Brush Scale Options Параметри масштабування пензля
|
||||
Scale Proportionately Масштабувати пропорційно
|
||||
Stretch to Fit Stroke Length Розтягнути за довжиною обведення
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3650,6 +3650,7 @@ mark-style Japanese Kiểu Nhật
|
||||
Rotate… Xoay…
|
||||
Rotation Góc xoay
|
||||
Rotation relative to: Xoay tương đối với:
|
||||
Hue Jitter: Biến thiên sắc độ:
|
||||
Rotation X Xoay X
|
||||
Rotation Y Xoay Y
|
||||
Rotation Z Xoay Z
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2167,6 +2167,7 @@ file-filter Templates 模板
|
||||
Scatter: 散布:
|
||||
Rotation: 旋转:
|
||||
Rotation relative to: 旋转相对于:
|
||||
Hue Jitter: 色相抖动:
|
||||
Brush Scale Options 画笔缩放选项
|
||||
Scale Proportionately 等比缩放
|
||||
Stretch to Fit Stroke Length 伸展以适合描边长度
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3493,6 +3493,7 @@ liquify-list-end {0}, {1} {0}和{1}
|
||||
Scatter: 散佈:
|
||||
Rotation: 旋轉:
|
||||
Rotation relative to: 旋轉相對於:
|
||||
Hue Jitter: 色相抖動:
|
||||
Brush Scale Options 筆刷縮放選項
|
||||
Scale Proportionately 等比例縮放
|
||||
Stretch to Fit Stroke Length 延伸以符合筆畫長度
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -973,7 +973,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"ui.brushOptions",
|
||||
"Brush Options…",
|
||||
"",
|
||||
"{name?} (default: the selected path's brush, else the current brush) open its Brush Options, what double-clicking a brush in the Brushes panel opens (dialog `brushOptions`): Calligraphic (fields name, angle −180..180, roundness 0..100, size 0..1296 pt, angleMode/roundnessMode/sizeMode: fixed|random|pressure, angleVariation/roundnessVariation/sizeVariation), Bristle (fields name, shape, size, length, density, thickness, opacity, stiffness), Scatter (fields sizeMin/sizeMax/sizeMode, spacingMin/spacingMax/spacingMode, scatterMin/scatterMax/scatterMode, rotationMin/rotationMax/rotationMode with modes fixed|random|pressure, rotationRelativeTo: page|path), Art (fields width %, scaleMode: proportional|stretch|betweenGuides, guideStart/guideEnd % of the art length, direction: leftToRight|rightToLeft|topToBottom|bottomToTop, flipAlong, flipAcross) or Pattern (fields scale %, spacing %, fit: stretch|addSpace|approximate, flipAlong, flipAcross); Scatter, Art and Pattern also colorization: none|tints|tintsAndShades|hueShift, keyColor, and tips: true opens Colorization Tips (what each method does, beside a sample of the brush painted with it), as the Tips button beside Method does; OK runs brush.options",
|
||||
"{name?} (default: the selected path's brush, else the current brush) open its Brush Options, what double-clicking a brush in the Brushes panel opens (dialog `brushOptions`): Calligraphic (fields name, angle −180..180, roundness 0..100, size 0..1296 pt, angleMode/roundnessMode/sizeMode: fixed|random|pressure, angleVariation/roundnessVariation/sizeVariation), Bristle (fields name, shape, size, length, density, thickness, opacity, stiffness), Scatter (fields sizeMin/sizeMax/sizeMode, spacingMin/spacingMax/spacingMode, scatterMin/scatterMax/scatterMode, rotationMin/rotationMax/rotationMode with modes fixed|random|pressure, rotationRelativeTo: page|path, hueJitter 0..180°), Art (fields width %, scaleMode: proportional|stretch|betweenGuides, guideStart/guideEnd % of the art length, direction: leftToRight|rightToLeft|topToBottom|bottomToTop, flipAlong, flipAcross) or Pattern (fields scale %, spacing %, fit: stretch|addSpace|approximate, flipAlong, flipAcross); Scatter, Art and Pattern also colorization: none|tints|tintsAndShades|hueShift, keyColor, and tips: true opens Colorization Tips (what each method does, beside a sample of the brush painted with it), as the Tips button beside Method does; OK runs brush.options",
|
||||
),
|
||||
(
|
||||
"ui.brushObjectOptions",
|
||||
|
||||
+15
-1
@@ -3810,7 +3810,21 @@ already walks Image Trace. Short agent entry points:
|
||||
`brush.new` or `brush.options` without a `key` takes the color that the art's fills and strokes use most (on a tie,
|
||||
the one found first), or black when they use no solid color. `brush.options` changes only the fields of
|
||||
`colorization` and of an art brush's `scale` that `params` gives, so `{colorization: {method: "hueShift"}}` keeps a
|
||||
Hue Shift brush's key. `brush.new` and `brush.options` take a bristle brush name of at most 31 characters:
|
||||
Hue Shift brush's key. A scatter brush's `hue_jitter` (0 to 180 degrees, VectorCraft's own range; 0, the
|
||||
default, leaves every copy's colors as the colorization gives them) turns the hue of each copy's solid fills and
|
||||
strokes, its type's characters included, by that copy's own amount between minus and plus that many degrees. The
|
||||
turn comes after the colorization: with None it turns the art's own colors, with Tints and Tints and Shades the
|
||||
tints and shades of the stroke color, and with Hue Shift the shifted colors. Black, white and grays (equal RGB
|
||||
values, a Gray color, CMYK without C, M or Y ink, Lab without a or b) have no hue and stay as they are, so a Tints
|
||||
brush on a black or gray stroke draws its copies unturned. A color turns in its own model: RGB in the HSB of its
|
||||
values, CMYK over its C, M and Y with its K kept, and Lab by turning its a and b, so its saturation and brightness
|
||||
(Lab: lightness and chroma) stay. Gradients and patterns stay as they are, and a turned color loses its swatch
|
||||
link. A symbol instance in the art turns only its own fill, the stain it draws its symbol's art with; the
|
||||
symbol's own colors stay. The amounts depend only on the stroke's path
|
||||
and the brush's name, so a stroke draws the same colors on every redraw, after Save and Open, and in export. Hue
|
||||
jitter does not change where the copies go or their size and rotation. A value outside the range is clamped, as
|
||||
the brush's other values are. A brush saves `hue_jitter` only when it is above 0, and a brush without the key
|
||||
reads as 0; `brush.get` shows it for every scatter brush. `brush.new` and `brush.options` take a bristle brush name of at most 31 characters:
|
||||
`brush.new` refuses a longer one, counting the number it adds to a taken name, and `brush.options` refuses a
|
||||
longer `newName`. `brush.duplicate` does not check the length. A bristle brush that already has a longer name
|
||||
keeps it, and `brush.options` without a new name, or with a `newName` that only trims the white space around the
|
||||
|
||||
@@ -1879,6 +1879,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
Under Tints and Tints and Shades, art in black ink alone goes by its ink amount, and a process or gray stroke color's tints and shades stay in that color's model; these are VectorCraft's own rules.
|
||||
Scale Proportionately art is scaled across by the stroke weight and the Width, as Stretch to Fit Stroke Length and Stretch Between Guides art is, on top of the scale the path length gives it, so a 3 pt stroke draws the art three times as wide as a 1 pt stroke. The [Brushes](https://web.archive.org/web/20241230205225/https://helpx.adobe.com/illustrator/using/brushes.html) page says Scale Proportionately keeps the art's proportions and does not say how the stroke weight applies; that rule is VectorCraft's own. Evidence: `tests::art_brush_proportional_grows_with_weight` (vectorcraft-brush).
|
||||
Type in a scatter brush's art takes the brush's colorization as its paths do: Tints, Tints and Shades and Hue Shift recolor the characters' solid fills and strokes in each copy the brush draws, and Brush Options' Key Color list, whose first color is Hue Shift's default key, counts the characters' fills and their strokes wider than 0. The Brushes page says that a scatter, art or pattern brush takes its colors from the current stroke color and the brush's colorization method (<https://web.archive.org/web/20241230205225/https://helpx.adobe.com/illustrator/using/brushes.html>) and does not mention type there; recoloring the characters' paints like the art's fills and strokes is VectorCraft's own rule. The Symbol Stainer mixes the characters' strokes of type toward the stain as it mixes their fills. Evidence: `tests::scatter_colorization_recolors_type`, `tests::art_colors_list_the_most_used_first`, `tests::stain_mixes_type_strokes_too` (vectorcraft-brush).
|
||||
Scatter Brush Options has Hue Jitter (0° to 180°, 0 by default), VectorCraft's own option: each copy turns the hue of its solid colors, after the colorization, by its own amount up to that far either way. The stroke's path and the brush name fix the amounts, so a stroke draws the same colors every time, and the copies' places, sizes and rotations stay as they are without it. Evidence: `tests::hue_jitter_turns_each_copy_the_same_every_time`, `tests::hue_jitter_of_zero_changes_nothing`, `tests::hue_jitter_turns_after_the_colorization` (vectorcraft-brush), `tests::brushsym::scatter_hue_jitter_saves_and_exports` (vectorcraft-engine).
|
||||
- **Pen tilt, bearing and rotation (part of #764):** Calligraphic and Scatter Brush Options offer Tilt, Bearing and Rotation beside Fixed, Random and Pressure. The Paintbrush records along each stroke how far the pen leans, which way, and how far its barrel is turned (kept with the path, saved, and joined when a stroke continues a path). A Calligraphic value on Tilt goes from value − variation with the pen lying flat to value + variation upright; on Bearing or Rotation it adds variation × the angle over 180°, so Angle on Bearing with a Variation of 180° turns the nib with the way the pen leans. A Scatter value goes from its first value to its second over the same ranges. A stroke without that input draws the brush's own value. On Linux under X11 and XWayland the app reads the tilt and an Art Pen's barrel rotation from XInput2, on macOS it reads them from AppKit's tablet events, and `path.freehand` points and `pointer_gesture` events carry them on every platform. The [Brushes](https://web.archive.org/web/20241230205225/https://helpx.adobe.com/illustrator/using/brushes.html) page defines the three options and does not say which way each one runs; that mapping is VectorCraft's own rule. Evidence: `tests::tilt_maps_to_roundness_along_the_stroke`, `tests::bearing_and_rotation_turn_the_nib`, `tests::scatter_values_follow_tilt_and_bearing` (vectorcraft-brush), `tests_brushsym::paintbrush_records_the_pens_tilt_on_the_stroke` (vectorcraft-engine), `tablet::tests::a_pens_tilt_and_rotation_go_into_the_feed` and `mac_tablet::tests::a_pens_tilt_and_rotation_go_into_the_feed` (vectorcraft).
|
||||
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). Stylus Wheel is not built.
|
||||
|
||||
Reference in New Issue
Block a user