Skip to main content

RRect

Struct RRect 

Source
pub struct RRect(/* private fields */);
Available on crate feature engine only.

Implementations§

Source§

impl RRect

Source

pub const SIZE_IN_MEMORY: usize

Source

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.

Source

pub fn get_type(&self) -> SkRRect_Type

Source

pub fn is_empty(&self) -> bool

Source

pub fn is_rect(&self) -> bool

Source

pub fn is_oval(&self) -> bool

Source

pub fn is_simple(&self) -> bool

Source

pub fn is_nine_patch(&self) -> bool

Source

pub fn is_complex(&self) -> bool

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

  • rect bounds to set
Source

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.

Source

pub fn new_rect(rect: impl AsRef<Rect>) -> RRect

Initializes to a copy of rect bounds and zeroes corner radii.

  • rect bounds to copy
Source

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.

  • oval bounds of oval
Source

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.

  • rect bounds of rounded rectangle
  • x_rad x-axis radius of corners
  • y_rad y-axis radius of corners
Source

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.

  • rect bounds of rounded rectangle
  • radii corner x-axis and y-axis radii
Source

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.

  • rect bounds of rounded rectangle
  • left_rad left-top and left-bottom x-axis radius
  • top_rad left-top and right-top y-axis radius
  • right_rad right-top and right-bottom x-axis radius
  • bottom_rad left-bottom and right-bottom y-axis radius
Source

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.

  • oval bounds of oval
Source

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.

  • rect bounds of rounded rectangle
  • x_rad x-axis radius of corners
  • y_rad y-axis radius of corners

Example (C++): https://fiddle.skia.org/c/@RRect_setRectXY

Source

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.

  • rect bounds of rounded rectangle
  • left_rad left-top and left-bottom x-axis radius
  • top_rad left-top and right-top y-axis radius
  • right_rad right-top and right-bottom x-axis radius
  • bottom_rad left-bottom and right-bottom y-axis radius
Source

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.

  • rect bounds of rounded rectangle
  • radii corner x-axis and y-axis radii

Example (C++): https://fiddle.skia.org/c/@RRect_setRectRadii Example (C++): https://fiddle.skia.org/c/@RRect_setRectRadii

Source

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().

Source

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.

  • corner corner to return radii for
Source

pub fn radii_ref(&self) -> &[Point; 4]

Returns the corner radii for all four corners, in the same order as Corner.

Source

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().

Source

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

Source

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.

Source

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.

Source

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.

Source

pub fn offset(&mut self, delta: impl Into<Point>)

Translates this rounded rectangle by delta.

Source

pub fn with_offset(&self, delta: impl Into<Point>) -> RRect

Returns this rounded rectangle translated by delta, with unchanged corner radii.

Source

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.

Source

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.

  • rect area tested for containment

Example (C++): https://fiddle.skia.org/c/@RRect_contains

Source

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

Source

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.

  • buffer storage for this rounded rectangle

Example (C++): https://fiddle.skia.org/c/@RRect_writeToMemory

Source

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.

  • buffer memory to read from

Example (C++): https://fiddle.skia.org/c/@RRect_readFromMemory

Source

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.

Source

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_hex true if scalar values are written as hexadecimal

Example (C++): https://fiddle.skia.org/c/@RRect_dump

Source

pub fn dump_to_string(&self, as_hex: bool) -> String

Source

pub fn dump_hex(&self)

Trait Implementations§

Source§

impl AsRef<RRect> for RRect

Source§

fn as_ref(&self) -> &RRect

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for RRect

Source§

fn clone(&self) -> RRect

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for RRect

Source§

impl Debug for RRect

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for RRect

Source§

fn default() -> RRect

Returns the “default value” for a type. Read more
Source§

impl PartialEq for RRect

Source§

fn eq(&self, rhs: &RRect) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl Forget for RRect

§

impl Freeze for RRect

§

impl Move 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§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnyEq for T
where T: Any + PartialEq,

Source§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Brush for T
where T: Clone + PartialEq + Default + Debug,

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ComponentProps for T
where T: Any + PartialEq,

Source§

fn changed(&self, other: &(dyn ComponentProps + 'static)) -> bool

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoReadable<T> for T
where T: 'static + PartialEq,

Source§

impl<T> MaybeBoxed<Box<T>> for T

Source§

fn maybe_boxed(self) -> Box<T>

Convert
Source§

impl<T> MaybeBoxed<T> for T

Source§

fn maybe_boxed(self) -> T

Convert
Source§

impl<N, T> NativeTransmutableWrapper<N> for T
where T: NativeTransmutable<N>,

Source§

fn wrap(native: N) -> T

Source§

fn unwrap(self) -> N

Source§

fn inner(&self) -> &N

Source§

fn inner_mut(&mut self) -> &mut N

Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> ResetDiscriminant<T> for T
where T: Copy,

Source§

fn discriminant(&self) -> T

Value based on which equality for the reset will be determined.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more