-
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
Showing
7 changed files
with
74 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
use crate::core; | ||
use super::FileTab; | ||
use crate::core; | ||
|
||
use rfd::FileDialog; | ||
use std::io::Result; | ||
|
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,12 +1,12 @@ | ||
use crate::gui::theme::shade::Shade; | ||
use crate::gui::theme::shades::Shades; | ||
|
||
/// Holds infomation about the post-processed colors at the highest level | ||
/// The result of Palette mixed with Shade | ||
#[derive(Clone)] | ||
pub struct Colors { | ||
pub accent: Shade, | ||
pub background: Shade, | ||
pub primary: Shade, | ||
pub secondary: Shade, | ||
pub text: Shade, | ||
pub accent: Shades, | ||
pub background: Shades, | ||
pub primary: Shades, | ||
pub secondary: Shades, | ||
pub text: Shades, | ||
} |
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use iced::Color; | ||
use palette::rgb::Rgb; | ||
use palette::{DarkenAssign, FromColor, LightenAssign, Okhsl, Srgb}; | ||
|
||
/// provides post-processing to Pigment's raw colors | ||
#[derive(Clone)] | ||
pub struct Shades { | ||
pub default: Color, | ||
pub light: Color, | ||
pub dark: Color, | ||
} | ||
|
||
impl Shades { | ||
pub fn new(color: Color) -> Self{ | ||
Self { | ||
default: color, | ||
light: lighten(color, 0.5), | ||
dark: darken(color, 0.5), | ||
} | ||
} | ||
} | ||
|
||
// special thanks to Halloy https://github.com/squidowl/halloy | ||
fn to_hsl(color: Color) -> Okhsl { | ||
let mut hsl = Okhsl::from_color(Rgb::from(color)); | ||
if hsl.saturation.is_nan() { | ||
hsl.saturation = Okhsl::max_saturation(); | ||
} | ||
|
||
hsl | ||
} | ||
|
||
fn from_hsl(hsl: Okhsl) -> Color { | ||
Srgb::from_color(hsl).into() | ||
} | ||
|
||
// fn alpha(color: Color, alpha: f32) -> Color { | ||
// Color { a: alpha, ..color } | ||
// } | ||
|
||
fn lighten(color: Color, amount: f32) -> Color { | ||
let mut hsl = to_hsl(color); | ||
|
||
hsl.lighten_fixed_assign(amount); | ||
|
||
from_hsl(hsl) | ||
} | ||
|
||
fn darken(color: Color, amount: f32) -> Color { | ||
let mut hsl = to_hsl(color); | ||
|
||
hsl.darken_fixed_assign(amount); | ||
|
||
from_hsl(hsl) | ||
} |