pub struct CellGeometry {
pub glyph_w: u8,
pub glyph_h: u8,
pub scale: u16,
}Expand description
The pixel geometry of a fixed cell grid: a glyph size and an integer scale.
The single code embodiment of Presenter::cell_size’s
contract: physical pixels, glyph x scale, never DPI-auto-scaled.
Every graphical backend stores one of these and returns cell_size from
Presenter::cell_size, rather than re-deriving glyph_w * scale (and cols * cell_w for the
surface) per backend in its own integer types, which lets the shared rule drift.
Fields§
§glyph_w: u8Glyph width in unscaled font pixels.
glyph_h: u8Glyph height in unscaled font pixels.
scale: u16Integer pixel scale: each glyph pixel becomes a scale x scale block of physical pixels.
Implementations§
Source§impl CellGeometry
impl CellGeometry
Sourcepub const fn new(glyph_w: u8, glyph_h: u8, scale: u16) -> Self
pub const fn new(glyph_w: u8, glyph_h: u8, scale: u16) -> Self
A geometry for glyph_w x glyph_h glyphs drawn at integer scale.
Sourcepub const fn cell_size(&self) -> (u32, u32)
pub const fn cell_size(&self) -> (u32, u32)
Cell size in physical pixels: (glyph_w * scale, glyph_h * scale).
The single embodiment of Presenter::cell_size’s “physical pixels, glyph x scale” contract.
Sourcepub const fn surface_size(&self, cols: u16, rows: u16) -> (u32, u32)
pub const fn surface_size(&self, cols: u16, rows: u16) -> (u32, u32)
Surface size in physical pixels for a cols x rows grid: (cols * cell_w, rows * cell_h).
Sourcepub fn pixel_to_cell(&self, x: f64, y: f64) -> Pos
pub fn pixel_to_cell(&self, x: f64, y: f64) -> Pos
Trait Implementations§
Source§impl Clone for CellGeometry
impl Clone for CellGeometry
Source§fn clone(&self) -> CellGeometry
fn clone(&self) -> CellGeometry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CellGeometry
impl Debug for CellGeometry
Source§impl PartialEq for CellGeometry
impl PartialEq for CellGeometry
Source§fn eq(&self, other: &CellGeometry) -> bool
fn eq(&self, other: &CellGeometry) -> bool
self and other values to be equal, and is used by ==.impl Copy for CellGeometry
impl Eq for CellGeometry
impl StructuralPartialEq for CellGeometry
Auto Trait Implementations§
impl Freeze for CellGeometry
impl RefUnwindSafe for CellGeometry
impl Send for CellGeometry
impl Sync for CellGeometry
impl Unpin for CellGeometry
impl UnsafeUnpin for CellGeometry
impl UnwindSafe for CellGeometry
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>
§impl<C> WithAlpha for Cwhere
C: Copy,
impl<C> WithAlpha for Cwhere
C: Copy,
§fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>
fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>
self with alpha, storing alpha before the color in memory
(see [AlphaFirst]).§fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>
fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>
self with alpha, storing alpha after the color in memory
(see [AlphaLast]).