Skip to main content

LightMap

Struct LightMap 

Source
pub struct LightMap { /* private fields */ }
Expand description

The lights that reach a visual, each with the transform from the space of the visual to the space of the light.

Implementations§

Source§

impl LightMap

Source

pub fn new() -> LightMap

A map without lights.

Source

pub fn add(&mut self, source: LightSource, to_light_space: Matrix)

Adds a light; to_light_space maps the coordinates of the lit visual to those of the coordinate space of the light.

Source

pub fn is_empty(&self) -> bool

Whether the map has no lights.

Source

pub fn lit_at(&self, point: Point, material: &LightingMaterial) -> LightColor

The sum of the lights at point of the lit visual reflected by material, not clamped.

Source

pub fn light_at(&self, point: Point) -> LightColor

The sum of the lights at point of the lit visual, clamped to 0..1.

Source

pub fn size_for(rect: Rect) -> PixelSize

The size of the light map of rect on the grid of 0.4: a cell per LIGHT_MAP_CELL units, at least 2 and at most LIGHT_MAP_MAX_CELLS. The render walk uses size_for_scale.

Source

pub fn size_for_scale(rect: Rect, device_scale: f64) -> PixelSize

The number of samples of the light map of rect along each side, for a visual drawn device_scale device pixels per unit: a sample every LIGHT_MAP_SAMPLE_SPACING device pixels, at least 2 and at most LIGHT_MAP_MAX_SAMPLES.

Source

pub fn factors( &self, rect: Rect, size: PixelSize, material: &LightingMaterial, ) -> Option<MultiplyLayerFactors>

The factors of the multiply layer that lights the content of rect: the light at each sample (reflected by material), over a scale of the brightest channel (at least 1, at most LIGHT_MAP_MAX_SCALE). None when the light is exactly full everywhere, so the layer would change nothing.

Source

pub fn pixels(&self, rect: Rect, size: PixelSize) -> Option<Vec<u8>>

The RGBA pixels (premultiplied, row by row from the top) of the source-atop light map of rect at size (for a drawing context without layer effects): each pixel the LightColor::atop_pixel of the light at the centre of its sample. None when the light is full everywhere, so the map would change nothing.

Source§

impl LightMap

Source

pub fn scene_pixels( &self, rect: Rect, size: PixelSize, material: &LightingMaterial, ) -> Vec<u8> ⓘ

The opaque RGBA pixels (row by row from the top) of the lighting of a scene lighting effect over rect at size: the lights reflected by material, clamped to 1, at the centre of each sample.

Trait Implementations§

Source§

impl Clone for LightMap

Source§

fn clone(&self) -> Self

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 LightMap

Source§

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

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

impl Default for LightMap

Source§

fn default() -> Self

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

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> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.