forked from baskerville/plato
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f1d3410
commit df9b017
Showing
25 changed files
with
790 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,50 @@ | ||
mod standard; | ||
mod natural; | ||
mod fake; | ||
|
||
pub use self::standard::StandardFrontlight; | ||
pub use self::natural::NaturalFrontlight; | ||
pub use self::fake::FakeFrontlight; | ||
use geom::lerp; | ||
|
||
#[derive(Debug, Copy, Clone, Serialize, Deserialize)] | ||
#[serde(untagged)] | ||
pub enum LightLevels { | ||
Standard(f32), | ||
Natural(f32, f32), | ||
pub struct LightLevels { | ||
pub intensity: f32, | ||
pub warmth: f32, | ||
} | ||
|
||
impl LightLevels { | ||
pub fn intensity(&self) -> f32 { | ||
match *self { | ||
LightLevels::Standard(v) => v, | ||
LightLevels::Natural(v, _) => v, | ||
impl Default for LightLevels { | ||
fn default() -> Self { | ||
LightLevels { | ||
intensity: 0.0, | ||
warmth: 0.0, | ||
} | ||
} | ||
} | ||
|
||
pub fn warmth(&self) -> f32 { | ||
match *self { | ||
LightLevels::Standard(_) => 0.0, | ||
LightLevels::Natural(_, v) => v, | ||
impl LightLevels { | ||
pub fn interpolate(&self, other: &Self, t: f32) -> Self { | ||
LightLevels { | ||
intensity: lerp(self.intensity, other.intensity, t), | ||
warmth: lerp(self.warmth, other.warmth, t), | ||
} | ||
} | ||
} | ||
|
||
pub trait Frontlight { | ||
fn set_intensity(&mut self, value: f32); | ||
fn set_warmth(&mut self, value: f32); | ||
fn intensity(&self) -> f32; | ||
fn warmth(&self) -> f32; | ||
fn levels(&self) -> LightLevels; | ||
} | ||
|
||
impl Frontlight for LightLevels { | ||
fn set_intensity(&mut self, value: f32) { | ||
self.intensity = value; | ||
} | ||
|
||
fn set_warmth(&mut self, value: f32) { | ||
self.warmth = value; | ||
} | ||
|
||
fn levels(&self) -> LightLevels { | ||
*self | ||
} | ||
} |
Oops, something went wrong.