pub struct Rhythm { /* private fields */ }Expand description
The vertical rhythm grid: a stack of rows, each size logical pixels tall.
Implementations§
Source§impl Rhythm
impl Rhythm
Sourcepub const fn new(size: f32) -> Self
pub const fn new(size: f32) -> Self
Create a grid with a finite, positive rhythm-unit size.
§Panics
Panics when size is zero, negative, or non-finite.
Sourcepub fn spacing(&self, n: i32) -> f32
pub fn spacing(&self, n: i32) -> f32
Axis-neutral length of n rhythm units. Use this when the vertical grid
also supplies horizontal indents, gaps, or padding.
Sourcepub fn height(&self, n: i32) -> f32
pub fn height(&self, n: i32) -> f32
Total height of n rhythm units. Equivalent to rhythm-sass rhythm($n);
apply offsets with plain addition: grid.height(5) - 1.0.
Sourcepub fn snap_up(&self, height: f32) -> f32
pub fn snap_up(&self, height: f32) -> f32
The smallest whole number of rhythm rows covering height — the pad
strategy for content whose height is not rhythm-controlled (images,
video, embeds): the block grows to the next grid line and the
remainder, always under one unit, becomes trailing whitespace.
Heights within a few f32 rounding steps of a whole-row height count
as exact, absorbing float error from measured sizes without allowing a
large rhythm unit to hide a visible remainder. Unlike snap, which
rounds a final value to the nearest step of an arbitrary size, this
rounds heights outward to whole rhythm rows.
§Panics
Panics when height is negative or non-finite.
Sourcepub fn snap_down(&self, height: f32) -> f32
pub fn snap_down(&self, height: f32) -> f32
The largest whole number of rhythm rows within height — the crop
strategy: the block shrinks to the previous grid line, cutting less
than one unit and never scaling the content up. Same exactness
tolerance as Self::snap_up.
§Panics
Panics when height is negative or non-finite.
Trait Implementations§
impl Copy for Rhythm
impl StructuralPartialEq for Rhythm
Auto Trait Implementations§
impl Freeze for Rhythm
impl RefUnwindSafe for Rhythm
impl Send for Rhythm
impl Sync for Rhythm
impl Unpin for Rhythm
impl UnsafeUnpin for Rhythm
impl UnwindSafe for Rhythm
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
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,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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