Skip to main content

RenderConfig

Struct RenderConfig 

Source
pub struct RenderConfig {
    pub canvas_width: u32,
    pub canvas_height: u32,
    pub icon_size: u32,
    pub supersample_factor: u32,
    pub icon_color: Color,
    pub background_color: Color,
    pub horizontal_anchor: HorizontalAnchor,
    pub vertical_anchor: VerticalAnchor,
    pub offset_x: i32,
    pub offset_y: i32,
    pub rotate: f64,
}
Expand description

Configuration for rendering an icon.

Fields§

§canvas_width: u32

Canvas width in pixels

§canvas_height: u32

Canvas height in pixels

§icon_size: u32

Icon size in pixels (height of the icon)

§supersample_factor: u32

Supersampling factor for antialiasing (default: 2)

§icon_color: Color

Icon foreground color

§background_color: Color

Background color (use transparent for no background)

§horizontal_anchor: HorizontalAnchor

Horizontal anchor position

§vertical_anchor: VerticalAnchor

Vertical anchor position

§offset_x: i32

Horizontal pixel offset from anchor

§offset_y: i32

Vertical pixel offset from anchor

§rotate: f64

Rotation angle in degrees (positive = clockwise, negative = counter-clockwise)

Implementations§

Source§

impl RenderConfig

Source

pub fn new() -> Self

Create a new config with default values.

Source

pub fn canvas_size(self, width: u32, height: u32) -> Self

Set canvas dimensions.

Source

pub fn icon_size(self, size: u32) -> Self

Set icon size.

Source

pub fn supersample(self, factor: u32) -> Self

Set supersampling factor.

Source

pub fn icon_color(self, color: Color) -> Self

Set icon color.

Source

pub fn background_color(self, color: Color) -> Self

Set background color.

Source

pub fn anchor( self, horizontal: HorizontalAnchor, vertical: VerticalAnchor, ) -> Self

Set anchor positions.

Source

pub fn offset(self, x: i32, y: i32) -> Self

Set pixel offset from anchor.

Source

pub fn rotate(self, degrees: f64) -> Self

Set rotation angle in degrees.

Positive values rotate clockwise, negative values rotate counter-clockwise. The rotation is applied around the center of the icon before compositing.

§Arguments
  • degrees - Rotation angle in degrees
§Examples
use icon_to_image::RenderConfig;

// Rotate 45 degrees clockwise
let config = RenderConfig::new().rotate(45.0);

// Rotate 90 degrees counter-clockwise
let config = RenderConfig::new().rotate(-90.0);
Source

pub fn sanitize_icon_size(self) -> Self

Apply sanity check to icon_size, clamping to 95% of smaller canvas dimension if it exceeds either canvas dimension.

This prevents icons from being larger than the canvas, which would cause rendering issues.

Trait Implementations§

Source§

impl Clone for RenderConfig

Source§

fn clone(&self) -> RenderConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RenderConfig

Source§

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

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

impl Default for RenderConfig

Source§

fn default() -> Self

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

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = 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.