Struct blit::BlitOptions
source · pub struct BlitOptions {
pub x: i32,
pub y: i32,
pub area: Option<Size>,
pub sub_rect: Option<SubRect>,
pub mask: Option<SubRect>,
pub vertical_slice: Option<Slice>,
pub horizontal_slice: Option<Slice>,
}
Expand description
How, where and which part of the image to render.
Slices can be used to control which part gets scaled using tiling scaling.
Fields§
§x: i32
Horizontal position on the destination buffer.
y: i32
Vertical position on the destination buffer.
area: Option<Size>
Size of the area (width, height)
on the destination buffer.
- When
None
is used, the size of the source buffer or of the subrectangle if set will be used. - When the area is smaller than the source buffer it effectively functions as the width and height parameters of
BlitOptions::sub_rect
. - When the area is bigger than the source buffer the default behaviour will be tiling.
assert_eq!(
BlitOptions::default().with_area((10, 10)).sub_rect((100, 100)),
BlitOptions::default().with_sub_rect((0, 0, 10, 10)).sub_rect((100, 100))
);
sub_rect: Option<SubRect>
Which part of the source buffer to render.
- When
None
is used,(0, 0, source_width, source_height)
is set instead. - With
Some(..)
, the values in the tuple are(x, y, width, height)
.
This is similar to UV coordinates but instead of relative positions in the range of 0..1
this takes absolute positions in the range 0..width
for horizontal positions and 0..height
for vertical positions.
mask: Option<SubRect>
Which part of the target buffer to render.
- When
None
is used,(0, 0, target_width, target_height)
is set instead. - With
Some(..)
, the values in the tuple are(x, y, width, height)
.
vertical_slice: Option<Slice>
Divide the source buffer into multiple vertical sections and repeat the chosen section to fill the area.
This is only used when BlitOptions::area
is set.
horizontal_slice: Option<Slice>
Divide the source buffer into multiple horizontal sections and repeat the chosen section to fill the area.
This is only used when BlitOptions::area
is set.
Implementations§
source§impl BlitOptions
impl BlitOptions
sourcepub fn new() -> Self
pub fn new() -> Self
Setup options for blitting at position (0, 0)
.
When no other fields are changed or methods are called this will render the full source.
sourcepub fn new_position<X, Y>(x: X, y: Y) -> Selfwhere
X: ToPrimitive,
Y: ToPrimitive,
pub fn new_position<X, Y>(x: X, y: Y) -> Selfwhere
X: ToPrimitive,
Y: ToPrimitive,
Setup options for blitting at position (x, y)
.
When no other fields are changed or methods are called this will render the full source.
§Sets field(s)
sourcepub fn new_position_tuple<X, Y>((x, y): (X, Y)) -> Selfwhere
X: ToPrimitive,
Y: ToPrimitive,
pub fn new_position_tuple<X, Y>((x, y): (X, Y)) -> Selfwhere
X: ToPrimitive,
Y: ToPrimitive,
Setup options for blitting at position (x, y)
.
When no other fields are changed or methods are called this will render the full source.
§Sets field(s)
sourcepub fn with_area<S>(self, area: S) -> Self
pub fn with_area<S>(self, area: S) -> Self
Set the size of the area (width, height)
on the destination buffer.
- When the area is smaller than the source buffer it effectively functions as the width and height parameters of
BlitOptions::sub_rect
. - When the area is bigger than the source buffer the default behaviour will be tiling.
§Sets field(s)
sourcepub fn with_mask<R>(self, mask: R) -> Self
pub fn with_mask<R>(self, mask: R) -> Self
Set the size of the area (width, height)
to only show on the destination buffer.
§Sets field(s)
sourcepub fn with_sub_rect<R>(self, sub_rect: R) -> Self
pub fn with_sub_rect<R>(self, sub_rect: R) -> Self
Set which part of the source buffer to render.
- When
None
is used,(0, 0, source_width, source_height)
is set instead. - With
Some(..)
, the values in the tuple are(x, y, width, height)
.
This is similar to UV coordinates but instead of relative positions in the range of 0..1
this takes absolute positions in the range 0..width
for horizontal positions and 0..height
for vertical positions.
§Sets field(s)
BlitOptions::sub_rect
BlitOptions::area
to(width, height)
if it’sNone
sourcepub fn with_slice9<R>(self, center: R) -> Self
pub fn with_slice9<R>(self, center: R) -> Self
Draw as a scalable 9-slice graphic.
The sub-rectangle of the center piece that will be scaled needs to be passed. Note that the rectangle has a width and a height instead of the absolute coordinates the other slice functions accept.
§Sets field(s)
sourcepub fn with_horizontal_slice(self, slice: Slice) -> Self
pub fn with_horizontal_slice(self, slice: Slice) -> Self
Scale a single horizontal piece of the buffer while keeping the other parts the same height.
See crate::slice::Slice
for more information.
§Sets field(s)
sourcepub fn with_vertical_slice(self, slice: Slice) -> Self
pub fn with_vertical_slice(self, slice: Slice) -> Self
Scale a single vertical piece of the buffer while keeping the other parts the same height.
§Sets field(s)
sourcepub fn with_position<X, Y>(self, x: X, y: Y) -> Selfwhere
X: ToPrimitive,
Y: ToPrimitive,
pub fn with_position<X, Y>(self, x: X, y: Y) -> Selfwhere
X: ToPrimitive,
Y: ToPrimitive,
sourcepub fn set_position<P>(&mut self, position: P)
pub fn set_position<P>(&mut self, position: P)
sourcepub fn area<S>(&self, source_size: S) -> Size
pub fn area<S>(&self, source_size: S) -> Size
Get the destination area (width, height)
.
If BlitOptions::area
is None
the size of the source will be returned.
sourcepub fn set_sub_rect<R>(&mut self, sub_rect: R)
pub fn set_sub_rect<R>(&mut self, sub_rect: R)
Set which part of the source buffer to render.
- When
None
is used,(0, 0, source_width, source_height)
is set instead. - With
Some(..)
, the values in the tuple are(x, y, width, height)
.
This is similar to UV coordinates but instead of relative positions in the range of 0..1
this takes absolute positions in the range 0..width
for horizontal positions and 0..height
for vertical positions.
§Sets field(s)
BlitOptions::sub_rect
BlitOptions::area
to(width, height)
if it’sNone
sourcepub fn sub_rect<S>(&self, source_size: S) -> SubRect
pub fn sub_rect<S>(&self, source_size: S) -> SubRect
Get the source area sub rectangle (x, y, width, height)
.
- If
BlitOptions::sub_rect
isNone
the size of the source will be returned with(0, 0)
as the position. - If
BlitOptions::sub_rect
andBlitOptions::area
are set it, thewidth
andheight
will be shrunk to match those of the area.
sourcepub fn set_area<S>(&mut self, area: S)
pub fn set_area<S>(&mut self, area: S)
Set the size of the area (width, height)
on the destination buffer.
- When the area is smaller than the source buffer it effectively functions as the width and height parameters of
BlitOptions::sub_rect
. - When the area is bigger than the source buffer the default behaviour will be tiling.
§Sets field(s)
sourcepub fn set_slice9<R>(&mut self, center: R)
pub fn set_slice9<R>(&mut self, center: R)
Draw as a scalable 9-slice graphic.
The sub-rectangle of the center piece that will be scaled needs to be passed. Note that the rectangle has a width and a height instead of the absolute coordinates the other slice functions accept.
§Sets field(s)
sourcepub fn set_mask<R>(&mut self, mask: R)
pub fn set_mask<R>(&mut self, mask: R)
Set the size of the area (width, height)
to only show on the destination buffer.
§Sets field(s)
sourcepub fn set_horizontal_slice(&mut self, slice: Slice)
pub fn set_horizontal_slice(&mut self, slice: Slice)
Scale a single horizontal piece of the buffer while keeping the other parts the same height.
See crate::slice::Slice
for more information.
§Sets field(s)
sourcepub fn set_vertical_slice(&mut self, slice: Slice)
pub fn set_vertical_slice(&mut self, slice: Slice)
Scale a single vertical piece of the buffer while keeping the other parts the same height.
§Sets field(s)
Trait Implementations§
source§impl Clone for BlitOptions
impl Clone for BlitOptions
source§fn clone(&self) -> BlitOptions
fn clone(&self) -> BlitOptions
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for BlitOptions
impl Debug for BlitOptions
source§impl Default for BlitOptions
impl Default for BlitOptions
source§fn default() -> BlitOptions
fn default() -> BlitOptions
source§impl PartialEq for BlitOptions
impl PartialEq for BlitOptions
source§fn eq(&self, other: &BlitOptions) -> bool
fn eq(&self, other: &BlitOptions) -> bool
self
and other
values to be equal, and is used
by ==
.impl StructuralPartialEq for BlitOptions
Auto Trait Implementations§
impl RefUnwindSafe for BlitOptions
impl Send for BlitOptions
impl Sync for BlitOptions
impl Unpin for BlitOptions
impl UnwindSafe for BlitOptions
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> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.