Skip to main content

GridScale

Struct GridScale 

Source
pub struct GridScale(/* private fields */);
Expand description

The fraction of the render target every internal grid is drawn at — the post chain’s grid and the attractor’s trail field (ADR-0245).

A validated value: only new and parse make one, and both refuse anything outside MIN..=MAX, NaN included. That is what makes the Eq below honest — a GridScale is never NaN, so it equals itself.

A capacity, not a look value, in the sense the module docs use: it sets how many texels a field holds, and a grid is a resolution rather than a shape (ADR-0037), so the picture’s geometry does not move with it. What does move is sharpness, which is the trade.

Implementations§

Source§

impl GridScale

Source

pub const MIN: f32 = 0.25

The smallest fraction accepted. Below a quarter a 1080p field is under 480x270 and the grid floor (grid::MIN_AXIS) starts deciding the size instead of the scale.

Source

pub const MAX: f32 = 1.0

The largest: the target’s own resolution. A grid is never drawn above it.

Source

pub const FULL: Self

The whole target — every row of the table but Rich on an integrated adapter, and what a headless renderer resolves unless it is told otherwise.

Source

pub fn new(value: f32) -> Option<Self>

value as a scale, or None when it is outside MIN..=MAX or not a number.

Source

pub fn parse(text: &str) -> Result<Self, String>

Parse a scale from its written form — the flag’s value, the environment variable’s, or a settings value. The error names the accepted range, because a caller surfaces it as a usage error verbatim.

Source

pub fn get(self) -> f32

The fraction itself.

Source

pub fn texels(self, px: u32) -> u32

px target pixels, as the texels a grid at this scale asks for before it is quantized: round(px * scale^2), saturating.

Exactly px at FULL, because 1.0 * 1.0 is exact and every u32 is exact in f64 — so a count derived from this at scale 1.0 is the count derived from the target, byte for byte.

Trait Implementations§

Source§

impl Clone for GridScale

Source§

fn clone(&self) -> GridScale

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 Debug for GridScale

Source§

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

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

impl Default for GridScale

Source§

fn default() -> Self

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

impl Display for GridScale

Source§

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

Two decimals — 1.00, 0.75 — the form the overlay and a log line print.

Source§

impl PartialEq for GridScale

Source§

fn eq(&self, other: &GridScale) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for GridScale

Source§

fn partial_cmp(&self, other: &GridScale) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for GridScale

Source§

impl Eq for GridScale

Source§

impl StructuralPartialEq for GridScale

Auto Trait Implementations§

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

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

impl<T> ToSmolStr for T
where T: Display + ?Sized,

§

fn to_smolstr(&self) -> SmolStr

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

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

§

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

§

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

§

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

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

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