pub struct Corners {
pub tl: f32,
pub tr: f32,
pub br: f32,
pub bl: f32,
}Expand description
Per-corner radii for a rounded rect, ordered top-left → top-right →
bottom-right → bottom-left (clockwise from top-left, matching CSS
border-radius’s long form). All four values are independent
pixel radii — set any subset to 0.0 for a square corner, or use
the top, bottom,
left, right shortcuts for the
common asymmetric cases.
The renderer caps each corner against the inscribed-circle limit
min(width, height) / 2, mirroring tiny-skia / browser behaviour:
passing absurdly large values is a “make this side a pill” idiom
rather than an error.
f32 and (f32, f32, f32, f32) both convert via From so any
API taking impl Into<Corners> accepts a uniform radius literal
(.radius( 16.0 )), an explicit set (.radius( ( 16.0, 16.0, 0.0, 0.0 ) )), or a constructed value (.radius( Corners::top( 16.0 ) )) interchangeably.
Fields§
§tl: f32Top-left corner radius in pixels.
tr: f32Top-right corner radius in pixels.
br: f32Bottom-right corner radius in pixels.
bl: f32Bottom-left corner radius in pixels.
Implementations§
Source§impl Corners
impl Corners
Sourcepub const fn all(r: f32) -> Self
pub const fn all(r: f32) -> Self
Uniform radius on every corner — equivalent to r.into() and
the most common construction.
Sourcepub const fn top(r: f32) -> Self
pub const fn top(r: f32) -> Self
Rounded top corners, square bottom corners. Matches the CSS
shorthand border-radius: r r 0 0 and the typical “card sits
flush against the bottom of the screen” pattern (docks,
bottom-anchored modals).
Sourcepub const fn bottom(r: f32) -> Self
pub const fn bottom(r: f32) -> Self
Rounded bottom corners, square top corners. Mirror of
top for top-anchored chrome.
Sourcepub fn is_zero(&self) -> bool
pub fn is_zero(&self) -> bool
true when every corner is <= 0 — the renderer can take
the fast straight-rect path.
Sourcepub fn is_uniform(&self) -> bool
pub fn is_uniform(&self) -> bool
true when every corner has the same radius. Used by the
software path to fall back to the single-radius cubic builder
when the asymmetric path would produce an identical curve.
Sourcepub fn max(&self) -> f32
pub fn max(&self) -> f32
The largest of the four radii. Useful for sizing the shader quad’s anti-alias pad — the worst-case AA band has to cover the steepest curve.
Sourcepub fn clamp_to_size(&self, width: f32, height: f32) -> Self
pub fn clamp_to_size(&self, width: f32, height: f32) -> Self
Cap every corner to min(width, height) / 2, the inscribed-
circle limit a rounded box can’t exceed without degenerating.
Mirrors the clamp the GLES shader applies internally; software
path callers use it before building the path so the cubic
control points stay inside the rect.
Sourcepub fn to_uniform(&self) -> [f32; 4]
pub fn to_uniform(&self) -> [f32; 4]
Pack as [ tl, tr, br, bl ] for glUniform4fv. Order
matches the vec4 u_radii convention every fragment shader
in gles_render::shaders reads.
Trait Implementations§
impl Copy for Corners
impl StructuralPartialEq for Corners
Auto Trait Implementations§
impl Freeze for Corners
impl RefUnwindSafe for Corners
impl Send for Corners
impl Sync for Corners
impl Unpin for Corners
impl UnwindSafe for Corners
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> 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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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