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.

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

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 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.

Source

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.

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.

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 Copy for Ink

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 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.