Skip to main content

BinderValue

Trait BinderValue 

Source
pub trait BinderValue:
    Clone
    + Default
    + ValueConverter
    + StatisticValue
    + Debug {
    const DIMENSIONS: usize;
    const BASE_DATA_TYPE: AttributeDataType;
    const INTERPOLATED_DATA_TYPE: AttributeDataType;

    // Required method
    fn attribute_value(&self) -> [f32; 2];
}
Expand description

The value types of data-driven paint properties with a single attribute (float and Color in circle, fill and line): the attribute’s value of a value (attribute_value), and its type.

Required Associated Constants§

Source

const DIMENSIONS: usize

The number of floats attribute_value uses.

Source

const BASE_DATA_TYPE: AttributeDataType

The attribute’s type for a value that doesn’t change with the zoom.

Source

const INTERPOLATED_DATA_TYPE: AttributeDataType

The attribute’s type for a value interpolated between two zooms.

Required Methods§

Source

fn attribute_value(&self) -> [f32; 2]

The attribute’s floats; only the first DIMENSIONS entries are used.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl BinderValue for Color

Source§

fn attribute_value(&self) -> [f32; 2]

Encode a four-component color value into a pair of floats, with 8 bits for each component: for each float we use the upper 8 bits for one component (e.g. (color.r * 255) * 256), and the lower 8 for another.

Also note that colors come in as floats 0..1, so we scale by 255.

Source§

const DIMENSIONS: usize = 2

Source§

const BASE_DATA_TYPE: AttributeDataType = AttributeDataType::Float2

Source§

const INTERPOLATED_DATA_TYPE: AttributeDataType = AttributeDataType::Float4

Source§

impl BinderValue for f32

Source§

const DIMENSIONS: usize = 1

Source§

const BASE_DATA_TYPE: AttributeDataType = AttributeDataType::Float

Source§

const INTERPOLATED_DATA_TYPE: AttributeDataType = AttributeDataType::Float2

Source§

fn attribute_value(&self) -> [f32; 2]

Implementors§