Skip to main content

PlaceholderStyle

Struct PlaceholderStyle 

Source
pub struct PlaceholderStyle {
    pub background_color: [f32; 4],
    pub skeleton_line_color: [f32; 4],
    pub animate: bool,
    pub shimmer_speed: f32,
    pub shimmer_amplitude: f32,
}
Expand description

Visual configuration for loading-placeholder tiles.

A single instance is stored on MapState and applies to all sources. All colours use linear RGBA [f32; 4].

Fields§

§background_color: [f32; 4]

Background fill colour for the placeholder quad.

Default: light grey [0.90, 0.90, 0.90, 1.0].

§skeleton_line_color: [f32; 4]

Colour of optional skeleton-chrome lines drawn inside the placeholder to hint at future geometry (roads, blocks, etc.).

Set the alpha to 0 to disable skeleton lines entirely.

Default: slightly darker grey [0.82, 0.82, 0.82, 1.0].

§animate: bool

Whether the pulsing shimmer animation is enabled.

When true, renderers modulate the placeholder opacity using LoadingPlaceholder::animation_phase.

Default: true.

§shimmer_speed: f32

Speed of the shimmer animation in cycles per second.

Higher values produce a faster pulse. Ignored when animate is false.

Default: 1.2 Hz.

§shimmer_amplitude: f32

Peak-to-trough opacity amplitude of the shimmer effect.

A value of 0.15 means the opacity oscillates between 1.0 - 0.15 = 0.85 and 1.0.

Default: 0.15.

Implementations§

Source§

impl PlaceholderStyle

Source

pub fn new() -> Self

Create a placeholder style with the default settings.

Source

pub fn with_background_color(self, color: [f32; 4]) -> Self

Builder: set the background fill colour.

Source

pub fn with_skeleton_line_color(self, color: [f32; 4]) -> Self

Builder: set the skeleton line colour.

Source

pub fn with_animate(self, animate: bool) -> Self

Builder: enable or disable shimmer animation.

Source

pub fn with_shimmer_speed(self, speed: f32) -> Self

Builder: set the shimmer animation speed in Hz.

Source

pub fn with_shimmer_amplitude(self, amplitude: f32) -> Self

Builder: set the shimmer amplitude.

Source

pub fn shimmer_opacity(&self, phase: f32) -> f32

Compute the shimmer opacity multiplier for a given animation phase.

Returns a value in [1.0 - amplitude, 1.0] when animate is true, or 1.0 when disabled.

Trait Implementations§

Source§

impl Clone for PlaceholderStyle

Source§

fn clone(&self) -> PlaceholderStyle

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PlaceholderStyle

Source§

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

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

impl Default for PlaceholderStyle

Source§

fn default() -> Self

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

impl PartialEq for PlaceholderStyle

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 StructuralPartialEq for PlaceholderStyle

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