pub struct Ink { /* private fields */ }Expand description
A deterministic ink material for strokes and even-odd path fills.
BrushStrokeBuilder::ink uses all effects. InkFill uses dryness, bleed, roughness,
granulation, paper, edge pooling and edge_darkening. Directional
fibers, build_up,
edge_anisotropy and height_map need stroke
geometry (arc length, self-overlap or a nib) and are ignored by fills.
The default is solid ink with seed zero and no dry gaps, feathering, roughness, granulation, directional fibers, paper imprint, or edge pooling. Parameters use layer-local coordinates (except canvas-anchored paper) and are evaluated from geometry, not previous frames. This is a bounded procedural wash, not a fluid or paper-fiber simulation. Both rendering backends share the CPU coverage.
Builders store values; invalid settings are reported when a stroke is built or rendered. Use a stable seed and vary bleed or pigment settings explicitly with frame-local time.
§Example
use motion_content::prelude::*;
use motion_core::prelude::*;
use motion_core::{
DisplayList, RasterLimits, ResourceStore, ValidatedDisplayList, MAX_PATH_VERBS,
MAX_STROKE_VERBS, MAX_SVG_PATH_BYTES, sample_offsets,
};
use motion_render::{Composition, RenderPrepare, RenderOptions, BackendKind, render_still};
use motion_content::vector::ink::*;
let brush = Ink::new(17)
.dryness(0.25)
.fibers(1.0)
.bleed(4.0)
.edge_roughness(1.5)
.granulation(0.4)
.paper(Paper::Procedural { seed: 211, strength: 0.45, scale: 1.5 })
.edge_pooling(0.6, 2.0);
let path = Path2D::parse_svg("M0 0L60 0")?;
let stroke = BrushStroke::builder(path, 24.0, Color::from_hex(0x23272c))
.pressure(0.15, 1.2, 0.05)
.ink_load(1.0, 0.25)
.ink(brush)
.build()?;Implementations§
Source§impl Ink
impl Ink
Sourcepub fn new(seed: u32) -> Self
pub fn new(seed: u32) -> Self
Creates solid ink with a fixed seed and all effects initially disabled.
Sourcepub fn dryness(self, strength: f32) -> Self
pub fn dryness(self, strength: f32) -> Self
Sets dry-brush strength in 0..=1; one permits fully dry gaps.
Zero retains solid coverage unless other material effects are enabled.
Sourcepub fn bleed(self, radius: f32) -> Self
pub fn bleed(self, radius: f32) -> Self
Sets the maximum soft wash extent beyond a fill or stroke edge, in local pixels. Must be finite and nonnegative. Zero disables feathering. The halo has finite support, is affected by the layer transform, and respects clips. Animate this value to suggest absorption without retaining frame history.
Sourcepub fn edge_roughness(self, amplitude: f32) -> Self
pub fn edge_roughness(self, amplitude: f32) -> Self
Sets the maximum inward/outward edge displacement in local pixels. Must be finite and nonnegative. Seeded low-frequency noise shapes the edge; zero preserves the geometric silhouette. It is not a blur radius.
Sourcepub fn granulation(self, strength: f32) -> Self
pub fn granulation(self, strength: f32) -> Self
Sets pigment variation in 0..=1, from uniform to strongly mottled.
This attenuates coverage, not RGB channels or the composition background.
Coarse local noise produces density variation without per-frame randomness.
Sourcepub fn fibers(self, strength: f32) -> Self
pub fn fibers(self, strength: f32) -> Self
Blends axis-oriented dry gaps towards path-following fibers in 0..=1.
One uses full-path arc length and signed distance across the sampled
flattened segment. Requires dryness or depleted BrushStrokeBuilder::ink_load
to expose gaps. Trim preserves the full-path phase. Changing geometry can
change arc length; corners, closed seams, and crossings are not simulated
bristle transport. Zero retains the original local-axis texture. Stroke-only.
Sourcepub fn paper(self, paper: Paper) -> Self
pub fn paper(self, paper: Paper) -> Self
Sets the paper sheet that attenuates pigment coverage, not the background.
Paper::Procedural fibers are seeded noise (strength in 0..=1, scale finite and
positive in paper-space pixels); Paper::Texture repeats a resolved height map and
attenuates by its luma. Either is sampled in paper space: local coordinates mapped by
paper_transform, which is the identity (untransformed design
space) by default. A layer that moves or scales keeps its paper fixed on the canvas only
when the transform equals the node transform. Reuse one Paper on fills and strokes for
one sheet. Setting a paper replaces the previous one. This attenuates alpha only; it is
not a paper height or fluid simulation.
Sourcepub fn paper_transform(self, transform: Transform) -> Self
pub fn paper_transform(self, transform: Transform) -> Self
Supplies the authored local-to-paper coordinates; the identity uses untransformed design space. Must be finite.
Sourcepub fn edge_pooling(self, strength: f32, width: f32) -> Self
pub fn edge_pooling(self, strength: f32, width: f32) -> Self
Adds an inner edge deposit by diluting the body relative to the rim.
Strength must be in 0..=1; width must be finite and positive local pixels.
Applied to the fill boundary or stroke union, not individual segment caps. Does not
expand bounds, change RGB, fill completely dry gaps, or simulate drying.
Sourcepub fn edge_darkening(self, strength: f64) -> Self
pub fn edge_darkening(self, strength: f64) -> Self
Darkens RGB near the geometric rim, in 0..=1. Unlike pooling it changes color, not
alpha.
Sourcepub fn build_up(self, strength: f64) -> Self
pub fn build_up(self, strength: f64) -> Self
Adds density at stroke self-intersections using independent segment coverage, in
0..=1. Stroke-only.
Sourcepub fn edge_anisotropy(self, ratio: f64) -> Self
pub fn edge_anisotropy(self, ratio: f64) -> Self
Scales directional material coordinates; a positive ratio in 0.1..=10. Stroke-only.
Sourcepub fn height_map(self, strength: f64) -> Self
pub fn height_map(self, strength: f64) -> Self
Makes a stroke a grayscale rounded-ridge height drawable for
Optics::Relight { height_from: Luma }; strength in 0..=16. Stroke-only.