pub struct Lighting { /* private fields */ }
Expand description
A structure describing the lighting model.
§Example
use ndarray::Array;
use plotlars::{ColorBar, Lighting, Palette, Plot, SurfacePlot, Text};
use polars::prelude::*;
use std::iter;
let n: usize = 100;
let x_base: Vec<f64> = Array::linspace(-10.0, 10.0, n).into_raw_vec();
let y_base: Vec<f64> = Array::linspace(-10.0, 10.0, n).into_raw_vec();
let x = x_base
.iter()
.flat_map(|&xi| iter::repeat(xi).take(n))
.collect::<Vec<_>>();
let y = y_base
.iter()
.cycle()
.take(n * n)
.cloned()
.collect::<Vec<_>>();
let z = x_base
.iter()
.map(|i| {
y_base
.iter()
.map(|j| 1.0 / (j * j + 5.0) * j.sin() + 1.0 / (i * i + 5.0) * i.cos())
.collect::<Vec<_>>()
})
.flatten()
.collect::<Vec<_>>();
let dataset = df![
"x" => &x,
"y" => &y,
"z" => &z,
]
.unwrap();
SurfacePlot::builder()
.data(&dataset)
.x("x")
.y("y")
.z("z")
.plot_title(
Text::from("Surface Plot")
.font("Arial")
.size(18),
)
.color_bar(
&ColorBar::new()
.border_width(1),
)
.color_scale(Palette::Cividis)
.reverse_scale(true)
.lighting(
&Lighting::new()
.position(1, 0, 0)
.ambient(1.0)
.diffuse(1.0)
.fresnel(1.0)
.roughness(1.0)
.specular(1.0),
)
.opacity(0.5)
.build()
.plot();
Implementations§
Source§impl Lighting
impl Lighting
Sourcepub fn position(self, x: i32, y: i32, z: i32) -> Self
pub fn position(self, x: i32, y: i32, z: i32) -> Self
Sets the position of the virtual light source.
§Arguments
x
– Ani32
value representing the x‑coordinate of the light.y
– Ani32
value representing the y‑coordinate of the light.z
– Ani32
value representing the z‑coordinate of the light (positive z points toward the viewer).
Sourcepub fn ambient(self, value: f64) -> Self
pub fn ambient(self, value: f64) -> Self
Sets the ambient light component.
§Arguments
value
– Af64
value in the range 0.0 – 1.0 specifying the uniform tint strength.
Sourcepub fn diffuse(self, value: f64) -> Self
pub fn diffuse(self, value: f64) -> Self
Sets the diffuse light component.
§Arguments
value
– Af64
value in the range 0.0 – 1.0 specifying the Lambertian reflection strength.
Sourcepub fn fresnel(self, value: f64) -> Self
pub fn fresnel(self, value: f64) -> Self
Sets the Fresnel (edge brightness) component.
§Arguments
value
– Af64
value in the range 0.0 – 1.0 specifying the rim‑light intensity.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Lighting
impl RefUnwindSafe for Lighting
impl Send for Lighting
impl Sync for Lighting
impl Unpin for Lighting
impl UnwindSafe for Lighting
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian()
.