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: u32Canvas width in pixels
canvas_height: u32Canvas height in pixels
icon_size: u32Icon size in pixels (height of the icon)
supersample_factor: u32Supersampling factor for antialiasing (default: 2)
icon_color: ColorIcon foreground color
background_color: ColorBackground color (use transparent for no background)
horizontal_anchor: HorizontalAnchorHorizontal anchor position
vertical_anchor: VerticalAnchorVertical anchor position
offset_x: i32Horizontal pixel offset from anchor
offset_y: i32Vertical pixel offset from anchor
rotate: f64Rotation angle in degrees (positive = clockwise, negative = counter-clockwise)
Implementations§
Source§impl RenderConfig
impl RenderConfig
Sourcepub fn canvas_size(self, width: u32, height: u32) -> Self
pub fn canvas_size(self, width: u32, height: u32) -> Self
Set canvas dimensions.
Sourcepub fn supersample(self, factor: u32) -> Self
pub fn supersample(self, factor: u32) -> Self
Set supersampling factor.
Sourcepub fn icon_color(self, color: Color) -> Self
pub fn icon_color(self, color: Color) -> Self
Set icon color.
Sourcepub fn background_color(self, color: Color) -> Self
pub fn background_color(self, color: Color) -> Self
Set background color.
Sourcepub fn anchor(
self,
horizontal: HorizontalAnchor,
vertical: VerticalAnchor,
) -> Self
pub fn anchor( self, horizontal: HorizontalAnchor, vertical: VerticalAnchor, ) -> Self
Set anchor positions.
Sourcepub fn rotate(self, degrees: f64) -> Self
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);Sourcepub fn sanitize_icon_size(self) -> Self
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
impl Clone for RenderConfig
Source§fn clone(&self) -> RenderConfig
fn clone(&self) -> RenderConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RenderConfig
impl Debug for RenderConfig
Auto Trait Implementations§
impl Freeze for RenderConfig
impl RefUnwindSafe for RenderConfig
impl Send for RenderConfig
impl Sync for RenderConfig
impl Unpin for RenderConfig
impl UnsafeUnpin for RenderConfig
impl UnwindSafe for RenderConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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