pub enum AlphaFromCoverage {
Linear,
Gamma(f32),
TwoCoverageMinusCoverageSq,
}
Expand description
How to convert font coverage values into alpha and color values.
Variants§
Linear
alpha = coverage
.
Looks good for black-on-white text, i.e. light mode.
Same as Self::Gamma
(1.0)
, but more efficient.
Gamma(f32)
alpha = coverage^gamma
.
TwoCoverageMinusCoverageSq
alpha = 2 * coverage - coverage^2
This looks good for white-on-black text, i.e. dark mode.
Very similar to a gamma of 0.5, but produces sharper text. See https://www.desmos.com/calculator/w0ndf5blmn for a comparison to gamma=0.5.
Implementations§
Source§impl AlphaFromCoverage
impl AlphaFromCoverage
Sourcepub const LIGHT_MODE_DEFAULT: Self = Self::Linear
pub const LIGHT_MODE_DEFAULT: Self = Self::Linear
A good-looking default for light mode (black-on-white text).
Sourcepub const DARK_MODE_DEFAULT: Self = Self::TwoCoverageMinusCoverageSq
pub const DARK_MODE_DEFAULT: Self = Self::TwoCoverageMinusCoverageSq
A good-looking default for dark mode (white-on-black text).
Sourcepub fn alpha_from_coverage(&self, coverage: f32) -> f32
pub fn alpha_from_coverage(&self, coverage: f32) -> f32
Convert coverage to alpha.
pub fn color_from_coverage(&self, coverage: f32) -> Color32
Trait Implementations§
Source§impl Clone for AlphaFromCoverage
impl Clone for AlphaFromCoverage
Source§fn clone(&self) -> AlphaFromCoverage
fn clone(&self) -> AlphaFromCoverage
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for AlphaFromCoverage
impl Debug for AlphaFromCoverage
Source§impl Default for AlphaFromCoverage
impl Default for AlphaFromCoverage
Source§fn default() -> AlphaFromCoverage
fn default() -> AlphaFromCoverage
Returns the “default value” for a type. Read more
Source§impl PartialEq for AlphaFromCoverage
impl PartialEq for AlphaFromCoverage
impl Copy for AlphaFromCoverage
impl StructuralPartialEq for AlphaFromCoverage
Auto Trait Implementations§
impl Freeze for AlphaFromCoverage
impl RefUnwindSafe for AlphaFromCoverage
impl Send for AlphaFromCoverage
impl Sync for AlphaFromCoverage
impl Unpin for AlphaFromCoverage
impl UnwindSafe for AlphaFromCoverage
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
Mutably borrows from an owned value. Read more