Skip to main content

Ink

Struct Ink 

Source
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

Source

pub fn new(seed: u32) -> Self

Creates solid ink with a fixed seed and all effects initially disabled.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn paper_transform(self, transform: Transform) -> Self

Supplies the authored local-to-paper coordinates; the identity uses untransformed design space. Must be finite.

Source

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.

Source

pub fn edge_darkening(self, strength: f64) -> Self

Darkens RGB near the geometric rim, in 0..=1. Unlike pooling it changes color, not alpha.

Source

pub fn build_up(self, strength: f64) -> Self

Adds density at stroke self-intersections using independent segment coverage, in 0..=1. Stroke-only.

Source

pub fn edge_anisotropy(self, ratio: f64) -> Self

Scales directional material coordinates; a positive ratio in 0.1..=10. Stroke-only.

Source

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.

Trait Implementations§

Source§

impl Clone for Ink

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Ink

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Ink

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for Ink

§

impl Freeze for Ink

§

impl Move for Ink

§

impl RefUnwindSafe for Ink

§

impl Send for Ink

§

impl Sync for Ink

§

impl Unpin for Ink

§

impl UnsafeUnpin for Ink

§

impl UnwindSafe for Ink

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.