Move core::Image::clip_bounds to graphics::Image
This commit is contained in:
parent
3cc5bd5dbc
commit
7c11ccb046
16 changed files with 189 additions and 88 deletions
|
|
@ -16,22 +16,17 @@ 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,
|
||||
|
||||
/// The rotation to be applied to the image; on its center.
|
||||
pub rotation: Radians,
|
||||
|
||||
/// The border radius of the [`Image`].
|
||||
///
|
||||
/// Currently, this will only be applied to the `clip_bounds`.
|
||||
pub border_radius: border::Radius,
|
||||
|
||||
/// The opacity of the image.
|
||||
///
|
||||
/// 0 means transparent. 1 means opaque.
|
||||
|
|
@ -49,10 +44,9 @@ 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),
|
||||
border_radius: border::Radius::default(),
|
||||
opacity: 1.0,
|
||||
snap: false,
|
||||
}
|
||||
|
|
@ -307,5 +301,10 @@ pub trait Renderer: crate::Renderer {
|
|||
fn measure_image(&self, handle: &Self::Handle) -> Size<u32>;
|
||||
|
||||
/// Draws an [`Image`] inside the provided `bounds`.
|
||||
fn draw_image(&mut self, image: Image<Self::Handle>, bounds: Rectangle);
|
||||
fn draw_image(
|
||||
&mut self,
|
||||
image: Image<Self::Handle>,
|
||||
bounds: Rectangle,
|
||||
clip_bounds: Rectangle,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -217,7 +217,13 @@ impl image::Renderer for () {
|
|||
Size::default()
|
||||
}
|
||||
|
||||
fn draw_image(&mut self, _image: Image, _bounds: Rectangle) {}
|
||||
fn draw_image(
|
||||
&mut self,
|
||||
_image: Image,
|
||||
_bounds: Rectangle,
|
||||
_clip_bounds: Rectangle,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
impl svg::Renderer for () {
|
||||
|
|
@ -225,5 +231,11 @@ impl svg::Renderer for () {
|
|||
Size::default()
|
||||
}
|
||||
|
||||
fn draw_svg(&mut self, _svg: svg::Svg, _bounds: Rectangle) {}
|
||||
fn draw_svg(
|
||||
&mut self,
|
||||
_svg: svg::Svg,
|
||||
_bounds: Rectangle,
|
||||
_clip_bounds: Rectangle,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,5 +155,5 @@ pub trait Renderer: crate::Renderer {
|
|||
fn measure_svg(&self, handle: &Handle) -> Size<u32>;
|
||||
|
||||
/// Draws an SVG with the given [`Handle`], an optional [`Color`] filter, and inside the provided `bounds`.
|
||||
fn draw_svg(&mut self, svg: Svg, bounds: Rectangle);
|
||||
fn draw_svg(&mut self, svg: Svg, bounds: Rectangle, clip_bounds: Rectangle);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue