diff --git a/src/light/ambient_light.rs b/src/light/ambient_light.rs index a6668a7..6e8a75f 100644 --- a/src/light/ambient_light.rs +++ b/src/light/ambient_light.rs @@ -10,6 +10,16 @@ pub struct AmbientLight { } impl AmbientLight { + /// Creates a new `AmbientLight`. + /// + /// # Examples + /// + /// ``` + /// # use pathtracer::light::AmbientLight; + /// # use pathtracer::core::color::LinearColor; + /// # + /// let amb_light = AmbientLight::new(LinearColor::new(1.0, 0.0, 1.0)); + /// ``` pub fn new(color: LinearColor) -> Self { AmbientLight { color } } diff --git a/src/light/directional_light.rs b/src/light/directional_light.rs index 0168340..a3a44a0 100644 --- a/src/light/directional_light.rs +++ b/src/light/directional_light.rs @@ -12,6 +12,20 @@ pub struct DirectionalLight { } impl DirectionalLight { + /// Creates a new `DirectionalLight`. + /// + /// # Examples + /// + /// ``` + /// # use pathtracer::light::DirectionalLight; + /// # use pathtracer::core::color::LinearColor; + /// # use pathtracer::Vector; + /// # + /// let dir_light = DirectionalLight::new( + /// Vector::new(1.0, 0.0, 0.0), + /// LinearColor::new(1.0, 0.0, 1.0), + /// ); + /// ``` pub fn new(direction: Vector, color: LinearColor) -> Self { DirectionalLight { direction: direction.normalize(), diff --git a/src/light/mod.rs b/src/light/mod.rs index 2096101..0405a8a 100644 --- a/src/light/mod.rs +++ b/src/light/mod.rs @@ -1,3 +1,5 @@ +//! Various light implementations + use super::core::LinearColor; use super::{Point, Vector}; diff --git a/src/light/point_light.rs b/src/light/point_light.rs index 281c99c..3fb00d5 100644 --- a/src/light/point_light.rs +++ b/src/light/point_light.rs @@ -11,6 +11,20 @@ pub struct PointLight { } impl PointLight { + /// Creates a new `PointLight`. + /// + /// # Examples + /// + /// ``` + /// # use pathtracer::light::PointLight; + /// # use pathtracer::core::color::LinearColor; + /// # use pathtracer::Point; + /// # + /// let dir_light = PointLight::new( + /// Point::origin(), + /// LinearColor::new(1.0, 0.0, 1.0), + /// ); + /// ``` pub fn new(position: Point, color: LinearColor) -> Self { PointLight { position, color } } diff --git a/src/light/spot_light.rs b/src/light/spot_light.rs index 9676ce7..9fa80ff 100644 --- a/src/light/spot_light.rs +++ b/src/light/spot_light.rs @@ -4,6 +4,7 @@ use crate::{Point, Vector}; use serde::{Deserialize, Deserializer}; /// Represent a light emanating from a directed light-source, outputting rays in a cone. +/// /// The illumination cone cannot have an FOV over 180°. #[derive(Debug, PartialEq)] pub struct SpotLight {