Struct pdf_writer::writers::FunctionShading

source ·
pub struct FunctionShading<'a> { /* private fields */ }
Expand description

Writer for a shading dictionary. PDF 1.3+.

This struct is created by Chunk::function_shading and ShadingPattern::function_shading.

Implementations§

source§

impl<'a> FunctionShading<'a>

source

pub fn shading_type(&mut self, kind: FunctionShadingType) -> &mut Self

Write the /ShadingType attribute.

Sets the type of shading. The available and required attributes change depending on this. Required.

source

pub fn color_space(&mut self) -> ColorSpace<'_>

Start writing the /ColorSpace attribute.

Sets the color space of the shading function. May not be a Pattern space. Required.

source

pub fn background( &mut self, background: impl IntoIterator<Item = f32> ) -> &mut Self

Write the /Background attribute.

Sets the background color of the area to be shaded. The background iterator must contain exactly as many elements as the current color space has dimensions.

source

pub fn bbox(&mut self, bbox: Rect) -> &mut Self

Write the /BBox attribute.

Sets the bounding box of the shading in the target coordinate system.

source

pub fn anti_alias(&mut self, anti_alias: bool) -> &mut Self

Write the /AntiAlias attribute.

Sets whether to anti-alias the shading.

source

pub fn domain(&mut self, domain: [f32; 4]) -> &mut Self

Write the /Domain attribute.

Sets the domain of the shading function in a rectangle. Can be used for function, axial, or radial shadings. Will otherwise default to [x_min = 0, x_max = 1, y_min = 0, y_max = 1]

source

pub fn matrix(&mut self, matrix: [f32; 6]) -> &mut Self

Write the /Matrix attribute.

Maps the shading domain rectangle to the target coordinate system. Can be used for function shadings. Will otherwise default to the identity matrix.

source

pub fn function(&mut self, function: Ref) -> &mut Self

Write the /Function attribute.

Sets the function to use for shading. Number of in- and outputs depends on shading type. Required for type 1, 2, and 3, optional otherwise.

source

pub fn coords(&mut self, coords: impl IntoIterator<Item = f32>) -> &mut Self

Write the /Coords attribute.

Sets the coordinates of the start and end of the axis in terms of the target coordinate system. Required for axial (4 items) and radial (6 items; centers and radii) shadings.

source

pub fn extend(&mut self, extend: [bool; 2]) -> &mut Self

Write the /Extend attribute.

Set whether the shading should extend beyond either side of the axis / circles. Can be used for axial and radial shadings.

Methods from Deref<Target = Dict<'a>>§

source

pub fn len(&self) -> i32

The number of written pairs.

source

pub fn is_empty(&self) -> bool

Whether no pairs have been written so far.

source

pub fn insert(&mut self, key: Name<'_>) -> Obj<'_>

Start writing a pair with an arbitrary value.

source

pub fn pair<T: Primitive>(&mut self, key: Name<'_>, value: T) -> &mut Self

Write a pair with a primitive value.

This is a shorthand for dict.insert(key).primitive(value).

source

pub fn pairs<'n, T: Primitive>( &mut self, pairs: impl IntoIterator<Item = (Name<'n>, T)> ) -> &mut Self

Write a sequence of pairs with primitive values.

Trait Implementations§

source§

impl<'a> Deref for FunctionShading<'a>

§

type Target = Dict<'a>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'a> DerefMut for FunctionShading<'a>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<'a, 'any> Rewrite<'a> for FunctionShading<'any>

§

type Output = FunctionShading<'a>

The writer with the rewritten lifetime.
source§

impl<'a> Writer<'a> for FunctionShading<'a>

source§

fn start(obj: Obj<'a>) -> Self

Start writing the object.

Auto Trait Implementations§

§

impl<'a> Freeze for FunctionShading<'a>

§

impl<'a> RefUnwindSafe for FunctionShading<'a>

§

impl<'a> Send for FunctionShading<'a>

§

impl<'a> Sync for FunctionShading<'a>

§

impl<'a> Unpin for FunctionShading<'a>

§

impl<'a> !UnwindSafe for FunctionShading<'a>

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> Finish for T

source§

fn finish(self)

Does nothing but move self, equivalent to drop.
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>,

§

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

§

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.