Skip to main content

AxialPattern

Struct AxialPattern 

Source
pub struct AxialPattern { /* private fields */ }
Expand description

Linear gradient between two points in device space.

t = dot(p - p0, axis) / |axis|², clamped to [t0, t1] (or extended to the nearest endpoint when extend_start / extend_end is set).

Implementations§

Source§

impl AxialPattern

Source

pub fn new( color0: [u8; 3], color1: [u8; 3], p0x: f64, p0y: f64, p1x: f64, p1y: f64, t0: f64, t1: f64, extend_start: bool, extend_end: bool, ) -> Self

Create an axial gradient.

  • color0, color1: RGB endpoints.
  • (p0x, p0y), (p1x, p1y): axis endpoints in device pixels.
  • t0, t1: parameter range mapping to color0 / color1. May be inverted (t0 > t1).
  • extend_start / extend_end: extend colour beyond axis endpoints.
§Degenerate case

When p0 == p1 (zero-length axis) every pixel returns None from t_for, so fill_span writes zeros (per PDF §8.7.4.5).

Trait Implementations§

Source§

impl Pattern for AxialPattern

Source§

fn fill_span(&self, y: i32, x0: i32, x1: i32, out: &mut [u8])

Fill out with colour bytes for pixels x0..=x1 on scanline y. Read more
Source§

fn is_static_color(&self) -> bool

Return true if this pattern yields the same colour at every coordinate. When true, fill_span will be called once and the result reused across the whole span (optimisation hint only — correctness is not affected).

Auto Trait Implementations§

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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.