pub struct Ink { /* private fields */ }Expand description
A deterministic ink material for strokes and even-odd path fills.
BrushStroke::ink uses all effects. InkFill also uses
bounded wash, rough edges and pooling; only directional fibers are stroke-only.
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 during rendering. 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, ResourcePool, ValidatedDisplayList, MAX_PATH_VERBS,
MAX_STROKE_VERBS, MAX_SVG_PATH_BYTES, sample_offsets,
};
use motion_render::{Composition, RenderPrepare, RenderOptions, Renderer, 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(211, 0.45, 1.5)
.edge_pooling(0.6, 2.0);
let path = Path2D::parse_svg("M0 0L60 0")?;
let stroke = BrushStroke::new(path, 24.0, Color::from_hex(0x23272c))
.pressure(0.15, 1.2, 0.05)
.ink_load(1.0, 0.25)
.ink(brush);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 BrushStroke::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.
Sourcepub fn paper(self, seed: u32, strength: f32, scale: f32) -> Self
pub fn paper(self, seed: u32, strength: f32, scale: f32) -> Self
Imprints seeded paper fibers into pigment coverage, not the background.
Strength must be in 0..=1, scale finite and positive in output pixels.
Paper is sampled in canvas coordinates, so moving/scaling a layer does not
move the paper. Reuse seed and scale on fills and strokes for one sheet.
This attenuates alpha only; it is not a paper height or fluid simulation.
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.