Struct RRect
pub struct RRect(/* private fields */);Implementations§
§impl RRect
impl RRect
pub const SIZE_IN_MEMORY: usize
pub fn new() -> RRect
pub fn new() -> RRect
Initializes bounds at (0, 0), the origin, with zero width and height. Initializes corner
radii to (0, 0), and sets the type to Type::Empty.
pub fn get_type(&self) -> SkRRect_Type
pub fn is_empty(&self) -> bool
pub fn is_rect(&self) -> bool
pub fn is_oval(&self) -> bool
pub fn is_simple(&self) -> bool
pub fn is_nine_patch(&self) -> bool
pub fn is_complex(&self) -> bool
pub fn width(&self) -> f32
pub fn width(&self) -> f32
Returns the span on the x-axis. This does not check if the result fits in a 32-bit float; the result may be infinity.
pub fn height(&self) -> f32
pub fn height(&self) -> f32
Returns the span on the y-axis. This does not check if the result fits in a 32-bit float; the result may be infinity.
pub fn simple_radii(&self) -> Point
pub fn simple_radii(&self) -> Point
Returns the top-left corner radii. If the type is Type::Empty, Type::Rect,
Type::Oval, or Type::Simple, returns a value representative of all corner radii. If
the type is Type::NinePatch or Type::Complex, at least one of the remaining three
corners has a different value.
pub fn set_empty(&mut self)
pub fn set_empty(&mut self)
Sets bounds to zero width and height at (0, 0), the origin. Sets corner radii to zero and
sets the type to Type::Empty.
pub fn set_rect(&mut self, rect: impl AsRef<Rect>)
pub fn set_rect(&mut self, rect: impl AsRef<Rect>)
Sets bounds to sorted rect, and sets corner radii to zero. If the set bounds has width and
height, sets the type to Type::Rect; otherwise, sets the type to Type::Empty.
rectbounds to set
pub fn new_empty() -> RRect
pub fn new_empty() -> RRect
Initializes bounds at (0, 0), the origin, with zero width and height. Initializes corner
radii to (0, 0), and sets the type to Type::Empty.
pub fn new_rect(rect: impl AsRef<Rect>) -> RRect
pub fn new_rect(rect: impl AsRef<Rect>) -> RRect
Initializes to a copy of rect bounds and zeroes corner radii.
rectbounds to copy
pub fn new_oval(oval: impl AsRef<Rect>) -> RRect
pub fn new_oval(oval: impl AsRef<Rect>) -> RRect
Initializes to an oval, x-axis radii to half oval.width(), and all y-axis radii to half
oval.height(). If the oval bounds is empty, sets the type to Type::Empty. Otherwise,
sets the type to Type::Oval.
ovalbounds of oval
pub fn new_rect_xy(rect: impl AsRef<Rect>, x_rad: f32, y_rad: f32) -> RRect
pub fn new_rect_xy(rect: impl AsRef<Rect>, x_rad: f32, y_rad: f32) -> RRect
Initializes to a rounded rectangle with the same radii for all four corners. If rect is
empty, sets the type to Type::Empty. Otherwise, if x_rad and y_rad are zero, sets
the type to Type::Rect. Otherwise, if x_rad is at least half rect.width() and
y_rad is at least half rect.height(), sets the type to Type::Oval. Otherwise, sets
the type to Type::Simple.
rectbounds of rounded rectanglex_radx-axis radius of cornersy_rady-axis radius of corners
pub fn new_rect_radii(rect: impl AsRef<Rect>, radii: &[Point; 4]) -> RRect
pub fn new_rect_radii(rect: impl AsRef<Rect>, radii: &[Point; 4]) -> RRect
Initializes to a rounded rectangle with a radii array for individual control of all four corners.
If rect is empty, sets the type to Type::Empty. Otherwise, if one of each corner radii
are zero, sets the type to Type::Rect. Otherwise, if all x-axis radii are equal and at
least half rect.width(), and all y-axis radii are equal at least half rect.height(),
sets the type to Type::Oval. Otherwise, if all x-axis radii are equal, and all y-axis
radii are equal, sets the type to Type::Simple. Otherwise, sets the type to
Type::NinePatch.
rectbounds of rounded rectangleradiicorner x-axis and y-axis radii
pub fn new_nine_patch(
rect: impl AsRef<Rect>,
left_rad: f32,
top_rad: f32,
right_rad: f32,
bottom_rad: f32,
) -> RRect
pub fn new_nine_patch( rect: impl AsRef<Rect>, left_rad: f32, top_rad: f32, right_rad: f32, bottom_rad: f32, ) -> RRect
Initializes bounds to rect. Sets radii to (left_rad, top_rad), (right_rad,
top_rad), (right_rad, bottom_rad), (left_rad, bottom_rad).
If rect is empty, sets the type to Type::Empty. Otherwise, if left_rad and
right_rad are zero, sets the type to Type::Rect. Otherwise, if top_rad and
bottom_rad are zero, sets the type to Type::Rect. Otherwise, if left_rad and
right_rad are equal and at least half rect.width(), and top_rad and bottom_rad are
equal at least half rect.height(), sets the type to Type::Oval. Otherwise, if
left_rad and right_rad are equal, and top_rad and bottom_rad are equal, sets the
type to Type::Simple. Otherwise, sets the type to Type::NinePatch.
Nine patch refers to the nine parts defined by the radii: one center rectangle, four edge patches, and four corner patches.
rectbounds of rounded rectangleleft_radleft-top and left-bottom x-axis radiustop_radleft-top and right-top y-axis radiusright_radright-top and right-bottom x-axis radiusbottom_radleft-bottom and right-bottom y-axis radius
pub fn set_oval(&mut self, oval: impl AsRef<Rect>)
pub fn set_oval(&mut self, oval: impl AsRef<Rect>)
Sets bounds to oval, x-axis radii to half oval.width(), and all y-axis radii to half
oval.height(). If the oval bounds is empty, sets the type to Type::Empty. Otherwise,
sets the type to Type::Oval.
ovalbounds of oval
pub fn set_rect_xy(&mut self, rect: impl AsRef<Rect>, x_rad: f32, y_rad: f32)
pub fn set_rect_xy(&mut self, rect: impl AsRef<Rect>, x_rad: f32, y_rad: f32)
Sets to a rounded rectangle with the same radii for all four corners. If rect is empty,
sets the type to Type::Empty. Otherwise, if x_rad or y_rad is zero, sets the type to
Type::Rect. Otherwise, if x_rad is at least half rect.width() and y_rad is at
least half rect.height(), sets the type to Type::Oval. Otherwise, sets the type to
Type::Simple.
rectbounds of rounded rectanglex_radx-axis radius of cornersy_rady-axis radius of corners
Example (C++): https://fiddle.skia.org/c/@RRect_setRectXY
pub fn set_nine_patch(
&mut self,
rect: impl AsRef<Rect>,
left_rad: f32,
top_rad: f32,
right_rad: f32,
bottom_rad: f32,
)
pub fn set_nine_patch( &mut self, rect: impl AsRef<Rect>, left_rad: f32, top_rad: f32, right_rad: f32, bottom_rad: f32, )
Sets bounds to rect. Sets radii to (left_rad, top_rad), (right_rad, top_rad),
(right_rad, bottom_rad), (left_rad, bottom_rad).
If rect is empty, sets the type to Type::Empty. Otherwise, if left_rad and
right_rad are zero, sets the type to Type::Rect. Otherwise, if top_rad and
bottom_rad are zero, sets the type to Type::Rect. Otherwise, if left_rad and
right_rad are equal and at least half rect.width(), and top_rad and bottom_rad are
equal at least half rect.height(), sets the type to Type::Oval. Otherwise, if
left_rad and right_rad are equal, and top_rad and bottom_rad are equal, sets the
type to Type::Simple. Otherwise, sets the type to Type::NinePatch.
Nine patch refers to the nine parts defined by the radii: one center rectangle, four edge patches, and four corner patches.
rectbounds of rounded rectangleleft_radleft-top and left-bottom x-axis radiustop_radleft-top and right-top y-axis radiusright_radright-top and right-bottom x-axis radiusbottom_radleft-bottom and right-bottom y-axis radius
pub fn set_rect_radii(&mut self, rect: impl AsRef<Rect>, radii: &[Point; 4])
pub fn set_rect_radii(&mut self, rect: impl AsRef<Rect>, radii: &[Point; 4])
Sets bounds to rect. Sets the radii array for individual control of all four corners.
If rect is empty, sets the type to Type::Empty. Otherwise, if one of each corner radii
are zero, sets the type to Type::Rect. Otherwise, if all x-axis radii are equal and at
least half rect.width(), and all y-axis radii are equal at least half rect.height(),
sets the type to Type::Oval. Otherwise, if all x-axis radii are equal, and all y-axis
radii are equal, sets the type to Type::Simple. Otherwise, sets the type to
Type::NinePatch.
rectbounds of rounded rectangleradiicorner x-axis and y-axis radii
Example (C++): https://fiddle.skia.org/c/@RRect_setRectRadii Example (C++): https://fiddle.skia.org/c/@RRect_setRectRadii
pub fn rect(&self) -> &Rect
pub fn rect(&self) -> &Rect
Returns bounds. Bounds may have zero width or zero height. Bounds right is greater than or
equal to left; bounds bottom is greater than or equal to top. Result is identical to
Self::bounds().
pub fn radii(&self, corner: SkRRect_Corner) -> Point
pub fn radii(&self, corner: SkRRect_Corner) -> Point
Returns the scalar pair for the radius of the curve on the x-axis and y-axis for one corner. Both radii may be zero. If not zero, both are positive and finite.
cornercorner to return radii for
pub fn radii_ref(&self) -> &[Point; 4]
pub fn radii_ref(&self) -> &[Point; 4]
Returns the corner radii for all four corners, in the same order as Corner.
pub fn bounds(&self) -> &Rect
pub fn bounds(&self) -> &Rect
Returns bounds. Bounds may have zero width or zero height. Bounds right is greater than or
equal to left; bounds bottom is greater than or equal to top. Result is identical to
Self::rect().
pub fn inset(&mut self, delta: impl Into<Point>)
pub fn inset(&mut self, delta: impl Into<Point>)
Insets bounds by delta, and adjusts radii by delta. delta may be positive, negative,
or zero.
If either corner radius is zero, the corner has no curvature and is unchanged. Otherwise, if
the adjusted radius becomes negative, pins the radius to zero. If delta.x exceeds half the
bounds width, the bounds left and right are set to the bounds x-axis center. If delta.y
exceeds half the bounds height, the bounds top and bottom are set to the bounds y-axis
center.
If delta causes the bounds to become infinite, the bounds is zeroed.
Example (C++): https://fiddle.skia.org/c/@RRect_inset
pub fn with_inset(&self, delta: impl Into<Point>) -> RRect
pub fn with_inset(&self, delta: impl Into<Point>) -> RRect
Copies this rounded rectangle to a new one, then insets the new bounds by delta, and
adjusts the new radii by delta. delta may be positive, negative, or zero.
If either corner radius is zero, the corner has no curvature and is unchanged. Otherwise, if
the adjusted radius becomes negative, pins the radius to zero. If delta.x exceeds half the
new bounds width, the new bounds left and right are set to the new bounds x-axis center. If
delta.y exceeds half the new bounds height, the new bounds top and bottom are set to the
new bounds y-axis center.
If delta causes the new bounds to become infinite, the new bounds is zeroed.
pub fn outset(&mut self, delta: impl Into<Point>)
pub fn outset(&mut self, delta: impl Into<Point>)
Outsets bounds by delta, and adjusts radii by delta. delta may be positive, negative,
or zero.
If either corner radius is zero, the corner has no curvature and is unchanged. Otherwise, if
the adjusted radius becomes negative, pins the radius to zero. If delta.x exceeds half the
bounds width, the bounds left and right are set to the bounds x-axis center. If delta.y
exceeds half the bounds height, the bounds top and bottom are set to the bounds y-axis
center.
If delta causes the bounds to become infinite, the bounds is zeroed.
pub fn with_outset(&self, delta: impl Into<Point>) -> RRect
pub fn with_outset(&self, delta: impl Into<Point>) -> RRect
Copies this rounded rectangle to a new one, then outsets the new bounds by delta, and
adjusts the new radii by delta. delta may be positive, negative, or zero.
If either corner radius is zero, the corner has no curvature and is unchanged. Otherwise, if
the adjusted radius becomes negative, pins the radius to zero. If delta.x exceeds half the
new bounds width, the new bounds left and right are set to the new bounds x-axis center. If
delta.y exceeds half the new bounds height, the new bounds top and bottom are set to the
new bounds y-axis center.
If delta causes the new bounds to become infinite, the new bounds is zeroed.
pub fn with_offset(&self, delta: impl Into<Point>) -> RRect
pub fn with_offset(&self, delta: impl Into<Point>) -> RRect
Returns this rounded rectangle translated by delta, with unchanged corner radii.
pub fn contains_point(&self, point: impl Into<Point>) -> bool
pub fn contains_point(&self, point: impl Into<Point>) -> bool
Returns true if point is inside the bounds and corner radii, and if this rounded rectangle
is not empty.
pub fn contains(&self, rect: impl AsRef<Rect>) -> bool
pub fn contains(&self, rect: impl AsRef<Rect>) -> bool
Returns true if rect is inside the bounds and corner radii, and if this rounded rectangle
and rect are not empty.
rectarea tested for containment
Example (C++): https://fiddle.skia.org/c/@RRect_contains
pub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Returns true if the bounds and radii values are finite and describe a RRect type that
matches Self::get_type(). All RRect methods construct valid types, even if the input
values are not valid. Invalid RRect data can only be generated by corrupting memory.
Example (C++): https://fiddle.skia.org/c/@RRect_isValid
pub fn write_to_memory(&self, buffer: &mut Vec<u8>)
pub fn write_to_memory(&self, buffer: &mut Vec<u8>)
Writes this rounded rectangle to buffer. Writes Self::SIZE_IN_MEMORY bytes, and
returns Self::SIZE_IN_MEMORY, the number of bytes written.
bufferstorage for this rounded rectangle
Example (C++): https://fiddle.skia.org/c/@RRect_writeToMemory
pub fn read_from_memory(&mut self, buffer: &[u8]) -> usize
pub fn read_from_memory(&mut self, buffer: &[u8]) -> usize
Reads this rounded rectangle from buffer, reading Self::SIZE_IN_MEMORY bytes. Returns
Self::SIZE_IN_MEMORY, the bytes read, if buffer.len() is at least
Self::SIZE_IN_MEMORY. Otherwise, returns zero.
buffermemory to read from
Example (C++): https://fiddle.skia.org/c/@RRect_readFromMemory
pub fn transform(&self, matrix: &Matrix) -> Option<RRect>
pub fn transform(&self, matrix: &Matrix) -> Option<RRect>
Transforms this rounded rectangle by matrix and returns it if possible. If the matrix does
not preserve axis-alignment (e.g. rotates, skews, etc.) then this returns None.
pub fn dump(&self, as_hex: impl Into<Option<bool>>)
pub fn dump(&self, as_hex: impl Into<Option<bool>>)
Writes a text representation of this rounded rectangle to standard output. Set as_hex true
to generate exact binary representations of floating point numbers.
as_hextrue if scalar values are written as hexadecimal
Example (C++): https://fiddle.skia.org/c/@RRect_dump
pub fn dump_to_string(&self, as_hex: bool) -> String
pub fn dump_hex(&self)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RRect
impl RefUnwindSafe for RRect
impl Send for RRect
impl Sync for RRect
impl Unpin for RRect
impl UnsafeUnpin for RRect
impl UnwindSafe for RRect
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.