34 lines
835 B
Rust
34 lines
835 B
Rust
use crate::tuples::{Color, Tuple};
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
pub struct PointLight {
|
|
pub position: Tuple,
|
|
pub intensity: Color,
|
|
}
|
|
|
|
impl PointLight {
|
|
/// Creates a new `PositionLight` at the given `position` and with the given
|
|
/// `intensity`.
|
|
///
|
|
/// # Examples
|
|
/// ```
|
|
/// use rtchallenge::{
|
|
/// lights::PointLight,
|
|
/// tuples::{Color, Tuple},
|
|
/// WHITE,
|
|
/// };
|
|
///
|
|
/// let intensity = WHITE;
|
|
/// let position = Tuple::point(0., 0., 0.);
|
|
/// let light = PointLight::new(position, intensity);
|
|
/// assert_eq!(light.position, position);
|
|
/// assert_eq!(light.intensity, intensity);
|
|
/// ```
|
|
pub fn new(position: Tuple, intensity: Color) -> PointLight {
|
|
PointLight {
|
|
position,
|
|
intensity,
|
|
}
|
|
}
|
|
}
|