Add border radius support for image

This commit is contained in:
Héctor Ramón Jiménez 2025-10-25 22:53:44 +02:00
parent c896cd8d31
commit 44e68aa4b6
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
15 changed files with 256 additions and 188 deletions

View file

@ -241,9 +241,9 @@ impl From<u8> for Radius {
}
}
impl From<u16> for Radius {
fn from(w: u16) -> Self {
Self::from(f32::from(w))
impl From<u32> for Radius {
fn from(w: u32) -> Self {
Self::from(w as f32)
}
}

View file

@ -1,6 +1,7 @@
//! Load and draw raster graphics.
pub use bytes::Bytes;
use crate::border;
use crate::{Radians, Rectangle, Size};
use rustc_hash::FxHasher;
@ -15,6 +16,16 @@ pub struct Image<H = Handle> {
/// The handle of the image.
pub handle: H,
/// The clip bounds of the [`Image`].
///
/// Anything outside this [`Rectangle`] will not be drawn.
pub clip_bounds: Rectangle,
/// The border radius of the [`Image`].
///
/// Currently, this will only be applied to the `clip_bounds`.
pub border_radius: border::Radius,
/// The filter method of the image.
pub filter_method: FilterMethod,
@ -38,6 +49,8 @@ impl Image<Handle> {
pub fn new(handle: impl Into<Handle>) -> Self {
Self {
handle: handle.into(),
clip_bounds: Rectangle::INFINITE,
border_radius: border::Radius::default(),
filter_method: FilterMethod::default(),
rotation: Radians(0.0),
opacity: 1.0,