|
|
|
|
@@ -11,7 +11,7 @@ use graphene_core::raster_types::{CPU, Raster};
|
|
|
|
|
use graphene_core::table::Table;
|
|
|
|
|
use graphene_core_shaders::color::Color;
|
|
|
|
|
use graphene_core_shaders::context::Ctx;
|
|
|
|
|
use graphene_core_shaders::registry::types::{Angle, Percentage, SignedPercentage};
|
|
|
|
|
use graphene_core_shaders::registry::types::{AngleF32, PercentageF32, SignedPercentageF32};
|
|
|
|
|
#[cfg(not(feature = "std"))]
|
|
|
|
|
use num_traits::float::Float;
|
|
|
|
|
|
|
|
|
|
@@ -81,11 +81,11 @@ fn gamma_correction<T: Adjust<Color>>(
|
|
|
|
|
#[default(2.2)]
|
|
|
|
|
#[range((0.01, 10.))]
|
|
|
|
|
#[hard_min(0.0001)]
|
|
|
|
|
gamma: f64,
|
|
|
|
|
gamma: f32,
|
|
|
|
|
inverse: bool,
|
|
|
|
|
) -> T {
|
|
|
|
|
let exponent = if inverse { 1. / gamma } else { gamma };
|
|
|
|
|
input.adjust(|color| color.gamma(exponent as f32));
|
|
|
|
|
input.adjust(|color| color.gamma(exponent));
|
|
|
|
|
input
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -149,14 +149,14 @@ fn brightness_contrast<T: Adjust<Color>>(
|
|
|
|
|
GradientStops,
|
|
|
|
|
)]
|
|
|
|
|
mut input: T,
|
|
|
|
|
brightness: SignedPercentage,
|
|
|
|
|
contrast: SignedPercentage,
|
|
|
|
|
brightness: SignedPercentageF32,
|
|
|
|
|
contrast: SignedPercentageF32,
|
|
|
|
|
use_classic: bool,
|
|
|
|
|
) -> T {
|
|
|
|
|
if use_classic {
|
|
|
|
|
let brightness = brightness as f32 / 255.;
|
|
|
|
|
let brightness = brightness / 255.;
|
|
|
|
|
|
|
|
|
|
let contrast = contrast as f32 / 100.;
|
|
|
|
|
let contrast = contrast / 100.;
|
|
|
|
|
let contrast = if contrast > 0. { (contrast * core::f32::consts::FRAC_PI_2 - 0.01).tan() } else { contrast };
|
|
|
|
|
|
|
|
|
|
let offset = brightness * contrast + brightness - contrast / 2.;
|
|
|
|
|
@@ -173,7 +173,7 @@ fn brightness_contrast<T: Adjust<Color>>(
|
|
|
|
|
// We clamp the brightness before the two curve X-axis points `130 - brightness * 26` and `233 - brightness * 48` intersect.
|
|
|
|
|
// Beyond the point of intersection, the cubic spline fitting becomes invalid and fails an assertion, which we need to avoid.
|
|
|
|
|
// See the intersection of the red lines at x = 103/22*100 = 468.18182 in the graph: https://www.desmos.com/calculator/ekvz4zyd9c
|
|
|
|
|
let brightness = (brightness.abs() / 100.).min(103. / 22. - 0.00001) as f32;
|
|
|
|
|
let brightness = (brightness.abs() / 100.).min(103. / 22. - 0.00001);
|
|
|
|
|
let brightness_curve_points = CubicSplines {
|
|
|
|
|
x: [0., 130. - brightness * 26., 233. - brightness * 48., 255.].map(|x| x / 255.),
|
|
|
|
|
y: [0., 130. + brightness * 51., 233. + brightness * 10., 255.].map(|x| x / 255.),
|
|
|
|
|
@@ -198,7 +198,7 @@ fn brightness_contrast<T: Adjust<Color>>(
|
|
|
|
|
// Unlike with brightness, the X-axis points `64` and `192` don't intersect at any contrast value, because they are constants.
|
|
|
|
|
// So we don't have to worry about clamping the contrast value to avoid invalid cubic spline fitting.
|
|
|
|
|
// See the graph: https://www.desmos.com/calculator/iql9vsca56
|
|
|
|
|
let contrast = contrast as f32 / 100.;
|
|
|
|
|
let contrast = contrast / 100.;
|
|
|
|
|
let contrast_curve_points = CubicSplines {
|
|
|
|
|
x: [0., 64., 192., 255.].map(|x| x / 255.),
|
|
|
|
|
y: [0., 64. - contrast * 30., 192. + contrast * 30., 255.].map(|x| x / 255.),
|
|
|
|
|
@@ -239,23 +239,23 @@ fn levels<T: Adjust<Color>>(
|
|
|
|
|
GradientStops,
|
|
|
|
|
)]
|
|
|
|
|
mut image: T,
|
|
|
|
|
#[default(0.)] shadows: Percentage,
|
|
|
|
|
#[default(50.)] midtones: Percentage,
|
|
|
|
|
#[default(100.)] highlights: Percentage,
|
|
|
|
|
#[default(0.)] output_minimums: Percentage,
|
|
|
|
|
#[default(100.)] output_maximums: Percentage,
|
|
|
|
|
#[default(0.)] shadows: PercentageF32,
|
|
|
|
|
#[default(50.)] midtones: PercentageF32,
|
|
|
|
|
#[default(100.)] highlights: PercentageF32,
|
|
|
|
|
#[default(0.)] output_minimums: PercentageF32,
|
|
|
|
|
#[default(100.)] output_maximums: PercentageF32,
|
|
|
|
|
) -> T {
|
|
|
|
|
image.adjust(|color| {
|
|
|
|
|
let color = color.to_gamma_srgb();
|
|
|
|
|
|
|
|
|
|
// Input Range (Range: 0-1)
|
|
|
|
|
let input_shadows = (shadows / 100.) as f32;
|
|
|
|
|
let input_midtones = (midtones / 100.) as f32;
|
|
|
|
|
let input_highlights = (highlights / 100.) as f32;
|
|
|
|
|
let input_shadows = shadows / 100.;
|
|
|
|
|
let input_midtones = midtones / 100.;
|
|
|
|
|
let input_highlights = highlights / 100.;
|
|
|
|
|
|
|
|
|
|
// Output Range (Range: 0-1)
|
|
|
|
|
let output_minimums = (output_minimums / 100.) as f32;
|
|
|
|
|
let output_maximums = (output_maximums / 100.) as f32;
|
|
|
|
|
let output_minimums = output_minimums / 100.;
|
|
|
|
|
let output_maximums = output_maximums / 100.;
|
|
|
|
|
|
|
|
|
|
// Midtones interpolation factor between minimums and maximums (Range: 0-1)
|
|
|
|
|
let midtones = output_minimums + (output_maximums - output_minimums) * input_midtones;
|
|
|
|
|
@@ -310,22 +310,22 @@ fn black_and_white<T: Adjust<Color>>(
|
|
|
|
|
#[default(Color::BLACK)] tint: Table<Color>,
|
|
|
|
|
#[default(40.)]
|
|
|
|
|
#[range((-200., 300.))]
|
|
|
|
|
reds: Percentage,
|
|
|
|
|
reds: PercentageF32,
|
|
|
|
|
#[default(60.)]
|
|
|
|
|
#[range((-200., 300.))]
|
|
|
|
|
yellows: Percentage,
|
|
|
|
|
yellows: PercentageF32,
|
|
|
|
|
#[default(40.)]
|
|
|
|
|
#[range((-200., 300.))]
|
|
|
|
|
greens: Percentage,
|
|
|
|
|
greens: PercentageF32,
|
|
|
|
|
#[default(60.)]
|
|
|
|
|
#[range((-200., 300.))]
|
|
|
|
|
cyans: Percentage,
|
|
|
|
|
cyans: PercentageF32,
|
|
|
|
|
#[default(20.)]
|
|
|
|
|
#[range((-200., 300.))]
|
|
|
|
|
blues: Percentage,
|
|
|
|
|
blues: PercentageF32,
|
|
|
|
|
#[default(80.)]
|
|
|
|
|
#[range((-200., 300.))]
|
|
|
|
|
magentas: Percentage,
|
|
|
|
|
magentas: PercentageF32,
|
|
|
|
|
) -> T {
|
|
|
|
|
let tint: Option<Color> = tint.into();
|
|
|
|
|
let tint = tint.unwrap_or(Color::BLACK);
|
|
|
|
|
@@ -333,12 +333,12 @@ fn black_and_white<T: Adjust<Color>>(
|
|
|
|
|
image.adjust(|color| {
|
|
|
|
|
let color = color.to_gamma_srgb();
|
|
|
|
|
|
|
|
|
|
let reds = reds as f32 / 100.;
|
|
|
|
|
let yellows = yellows as f32 / 100.;
|
|
|
|
|
let greens = greens as f32 / 100.;
|
|
|
|
|
let cyans = cyans as f32 / 100.;
|
|
|
|
|
let blues = blues as f32 / 100.;
|
|
|
|
|
let magentas = magentas as f32 / 100.;
|
|
|
|
|
let reds = reds / 100.;
|
|
|
|
|
let yellows = yellows / 100.;
|
|
|
|
|
let greens = greens / 100.;
|
|
|
|
|
let cyans = cyans / 100.;
|
|
|
|
|
let blues = blues / 100.;
|
|
|
|
|
let magentas = magentas / 100.;
|
|
|
|
|
|
|
|
|
|
let gray_base = color.r().min(color.g()).min(color.b());
|
|
|
|
|
|
|
|
|
|
@@ -383,9 +383,9 @@ fn hue_saturation<T: Adjust<Color>>(
|
|
|
|
|
GradientStops,
|
|
|
|
|
)]
|
|
|
|
|
mut input: T,
|
|
|
|
|
hue_shift: Angle,
|
|
|
|
|
saturation_shift: SignedPercentage,
|
|
|
|
|
lightness_shift: SignedPercentage,
|
|
|
|
|
hue_shift: AngleF32,
|
|
|
|
|
saturation_shift: SignedPercentageF32,
|
|
|
|
|
lightness_shift: SignedPercentageF32,
|
|
|
|
|
) -> T {
|
|
|
|
|
input.adjust(|color| {
|
|
|
|
|
let color = color.to_gamma_srgb();
|
|
|
|
|
@@ -393,11 +393,11 @@ fn hue_saturation<T: Adjust<Color>>(
|
|
|
|
|
let [hue, saturation, lightness, alpha] = color.to_hsla();
|
|
|
|
|
|
|
|
|
|
let color = Color::from_hsla(
|
|
|
|
|
(hue + hue_shift as f32 / 360.) % 1.,
|
|
|
|
|
(hue + hue_shift / 360.) % 1.,
|
|
|
|
|
// TODO: Improve the way saturation works (it's slightly off)
|
|
|
|
|
(saturation + saturation_shift as f32 / 100.).clamp(0., 1.),
|
|
|
|
|
(saturation + saturation_shift / 100.).clamp(0., 1.),
|
|
|
|
|
// TODO: Fix the way lightness works (it's very off)
|
|
|
|
|
(lightness + lightness_shift as f32 / 100.).clamp(0., 1.),
|
|
|
|
|
(lightness + lightness_shift / 100.).clamp(0., 1.),
|
|
|
|
|
alpha,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@@ -441,13 +441,13 @@ fn threshold<T: Adjust<Color>>(
|
|
|
|
|
GradientStops,
|
|
|
|
|
)]
|
|
|
|
|
mut image: T,
|
|
|
|
|
#[default(50.)] min_luminance: Percentage,
|
|
|
|
|
#[default(100.)] max_luminance: Percentage,
|
|
|
|
|
#[default(50.)] min_luminance: PercentageF32,
|
|
|
|
|
#[default(100.)] max_luminance: PercentageF32,
|
|
|
|
|
luminance_calc: LuminanceCalculation,
|
|
|
|
|
) -> T {
|
|
|
|
|
image.adjust(|color| {
|
|
|
|
|
let min_luminance = Color::srgb_to_linear(min_luminance as f32 / 100.);
|
|
|
|
|
let max_luminance = Color::srgb_to_linear(max_luminance as f32 / 100.);
|
|
|
|
|
let min_luminance = Color::srgb_to_linear(min_luminance / 100.);
|
|
|
|
|
let max_luminance = Color::srgb_to_linear(max_luminance / 100.);
|
|
|
|
|
|
|
|
|
|
let luminance = match luminance_calc {
|
|
|
|
|
LuminanceCalculation::SRGB => color.luminance_srgb(),
|
|
|
|
|
@@ -487,10 +487,10 @@ fn vibrance<T: Adjust<Color>>(
|
|
|
|
|
GradientStops,
|
|
|
|
|
)]
|
|
|
|
|
mut image: T,
|
|
|
|
|
vibrance: SignedPercentage,
|
|
|
|
|
vibrance: SignedPercentageF32,
|
|
|
|
|
) -> T {
|
|
|
|
|
image.adjust(|color| {
|
|
|
|
|
let vibrance = vibrance as f32 / 100.;
|
|
|
|
|
let vibrance = vibrance / 100.;
|
|
|
|
|
// Slow the effect down by half when it's negative, since artifacts begin appearing past -50%.
|
|
|
|
|
// So this scales the 0% to -50% range to 0% to -100%.
|
|
|
|
|
let slowed_vibrance = if vibrance >= 0. { vibrance } else { vibrance * 0.5 };
|
|
|
|
|
@@ -658,55 +658,55 @@ fn channel_mixer<T: Adjust<Color>>(
|
|
|
|
|
|
|
|
|
|
#[default(40.)]
|
|
|
|
|
#[name("Red")]
|
|
|
|
|
monochrome_r: f64,
|
|
|
|
|
monochrome_r: f32,
|
|
|
|
|
#[default(40.)]
|
|
|
|
|
#[name("Green")]
|
|
|
|
|
monochrome_g: f64,
|
|
|
|
|
monochrome_g: f32,
|
|
|
|
|
#[default(20.)]
|
|
|
|
|
#[name("Blue")]
|
|
|
|
|
monochrome_b: f64,
|
|
|
|
|
monochrome_b: f32,
|
|
|
|
|
#[default(0.)]
|
|
|
|
|
#[name("Constant")]
|
|
|
|
|
monochrome_c: f64,
|
|
|
|
|
monochrome_c: f32,
|
|
|
|
|
|
|
|
|
|
#[default(100.)]
|
|
|
|
|
#[name("(Red) Red")]
|
|
|
|
|
red_r: f64,
|
|
|
|
|
red_r: f32,
|
|
|
|
|
#[default(0.)]
|
|
|
|
|
#[name("(Red) Green")]
|
|
|
|
|
red_g: f64,
|
|
|
|
|
red_g: f32,
|
|
|
|
|
#[default(0.)]
|
|
|
|
|
#[name("(Red) Blue")]
|
|
|
|
|
red_b: f64,
|
|
|
|
|
red_b: f32,
|
|
|
|
|
#[default(0.)]
|
|
|
|
|
#[name("(Red) Constant")]
|
|
|
|
|
red_c: f64,
|
|
|
|
|
red_c: f32,
|
|
|
|
|
|
|
|
|
|
#[default(0.)]
|
|
|
|
|
#[name("(Green) Red")]
|
|
|
|
|
green_r: f64,
|
|
|
|
|
green_r: f32,
|
|
|
|
|
#[default(100.)]
|
|
|
|
|
#[name("(Green) Green")]
|
|
|
|
|
green_g: f64,
|
|
|
|
|
green_g: f32,
|
|
|
|
|
#[default(0.)]
|
|
|
|
|
#[name("(Green) Blue")]
|
|
|
|
|
green_b: f64,
|
|
|
|
|
green_b: f32,
|
|
|
|
|
#[default(0.)]
|
|
|
|
|
#[name("(Green) Constant")]
|
|
|
|
|
green_c: f64,
|
|
|
|
|
green_c: f32,
|
|
|
|
|
|
|
|
|
|
#[default(0.)]
|
|
|
|
|
#[name("(Blue) Red")]
|
|
|
|
|
blue_r: f64,
|
|
|
|
|
blue_r: f32,
|
|
|
|
|
#[default(0.)]
|
|
|
|
|
#[name("(Blue) Green")]
|
|
|
|
|
blue_g: f64,
|
|
|
|
|
blue_g: f32,
|
|
|
|
|
#[default(100.)]
|
|
|
|
|
#[name("(Blue) Blue")]
|
|
|
|
|
blue_b: f64,
|
|
|
|
|
blue_b: f32,
|
|
|
|
|
#[default(0.)]
|
|
|
|
|
#[name("(Blue) Constant")]
|
|
|
|
|
blue_c: f64,
|
|
|
|
|
blue_c: f32,
|
|
|
|
|
|
|
|
|
|
// Display-only properties (not used within the node)
|
|
|
|
|
_output_channel: RedGreenBlue,
|
|
|
|
|
@@ -717,15 +717,15 @@ fn channel_mixer<T: Adjust<Color>>(
|
|
|
|
|
let (r, g, b, a) = color.components();
|
|
|
|
|
|
|
|
|
|
let color = if monochrome {
|
|
|
|
|
let (monochrome_r, monochrome_g, monochrome_b, monochrome_c) = (monochrome_r as f32 / 100., monochrome_g as f32 / 100., monochrome_b as f32 / 100., monochrome_c as f32 / 100.);
|
|
|
|
|
let (monochrome_r, monochrome_g, monochrome_b, monochrome_c) = (monochrome_r / 100., monochrome_g / 100., monochrome_b / 100., monochrome_c / 100.);
|
|
|
|
|
|
|
|
|
|
let gray = (r * monochrome_r + g * monochrome_g + b * monochrome_b + monochrome_c).clamp(0., 1.);
|
|
|
|
|
|
|
|
|
|
Color::from_rgbaf32_unchecked(gray, gray, gray, a)
|
|
|
|
|
} else {
|
|
|
|
|
let (red_r, red_g, red_b, red_c) = (red_r as f32 / 100., red_g as f32 / 100., red_b as f32 / 100., red_c as f32 / 100.);
|
|
|
|
|
let (green_r, green_g, green_b, green_c) = (green_r as f32 / 100., green_g as f32 / 100., green_b as f32 / 100., green_c as f32 / 100.);
|
|
|
|
|
let (blue_r, blue_g, blue_b, blue_c) = (blue_r as f32 / 100., blue_g as f32 / 100., blue_b as f32 / 100., blue_c as f32 / 100.);
|
|
|
|
|
let (red_r, red_g, red_b, red_c) = (red_r / 100., red_g / 100., red_b / 100., red_c / 100.);
|
|
|
|
|
let (green_r, green_g, green_b, green_c) = (green_r / 100., green_g / 100., green_b / 100., green_c / 100.);
|
|
|
|
|
let (blue_r, blue_g, blue_b, blue_c) = (blue_r / 100., blue_g / 100., blue_b / 100., blue_c / 100.);
|
|
|
|
|
|
|
|
|
|
let red = (r * red_r + g * red_g + b * red_b + red_c).clamp(0., 1.);
|
|
|
|
|
let green = (r * green_r + g * green_g + b * green_b + green_c).clamp(0., 1.);
|
|
|
|
|
@@ -785,50 +785,50 @@ fn selective_color<T: Adjust<Color>>(
|
|
|
|
|
|
|
|
|
|
mode: RelativeAbsolute,
|
|
|
|
|
|
|
|
|
|
#[name("(Reds) Cyan")] r_c: f64,
|
|
|
|
|
#[name("(Reds) Magenta")] r_m: f64,
|
|
|
|
|
#[name("(Reds) Yellow")] r_y: f64,
|
|
|
|
|
#[name("(Reds) Black")] r_k: f64,
|
|
|
|
|
#[name("(Reds) Cyan")] r_c: f32,
|
|
|
|
|
#[name("(Reds) Magenta")] r_m: f32,
|
|
|
|
|
#[name("(Reds) Yellow")] r_y: f32,
|
|
|
|
|
#[name("(Reds) Black")] r_k: f32,
|
|
|
|
|
|
|
|
|
|
#[name("(Yellows) Cyan")] y_c: f64,
|
|
|
|
|
#[name("(Yellows) Magenta")] y_m: f64,
|
|
|
|
|
#[name("(Yellows) Yellow")] y_y: f64,
|
|
|
|
|
#[name("(Yellows) Black")] y_k: f64,
|
|
|
|
|
#[name("(Yellows) Cyan")] y_c: f32,
|
|
|
|
|
#[name("(Yellows) Magenta")] y_m: f32,
|
|
|
|
|
#[name("(Yellows) Yellow")] y_y: f32,
|
|
|
|
|
#[name("(Yellows) Black")] y_k: f32,
|
|
|
|
|
|
|
|
|
|
#[name("(Greens) Cyan")] g_c: f64,
|
|
|
|
|
#[name("(Greens) Magenta")] g_m: f64,
|
|
|
|
|
#[name("(Greens) Yellow")] g_y: f64,
|
|
|
|
|
#[name("(Greens) Black")] g_k: f64,
|
|
|
|
|
#[name("(Greens) Cyan")] g_c: f32,
|
|
|
|
|
#[name("(Greens) Magenta")] g_m: f32,
|
|
|
|
|
#[name("(Greens) Yellow")] g_y: f32,
|
|
|
|
|
#[name("(Greens) Black")] g_k: f32,
|
|
|
|
|
|
|
|
|
|
#[name("(Cyans) Cyan")] c_c: f64,
|
|
|
|
|
#[name("(Cyans) Magenta")] c_m: f64,
|
|
|
|
|
#[name("(Cyans) Yellow")] c_y: f64,
|
|
|
|
|
#[name("(Cyans) Black")] c_k: f64,
|
|
|
|
|
#[name("(Cyans) Cyan")] c_c: f32,
|
|
|
|
|
#[name("(Cyans) Magenta")] c_m: f32,
|
|
|
|
|
#[name("(Cyans) Yellow")] c_y: f32,
|
|
|
|
|
#[name("(Cyans) Black")] c_k: f32,
|
|
|
|
|
|
|
|
|
|
#[name("(Blues) Cyan")] b_c: f64,
|
|
|
|
|
#[name("(Blues) Magenta")] b_m: f64,
|
|
|
|
|
#[name("(Blues) Yellow")] b_y: f64,
|
|
|
|
|
#[name("(Blues) Black")] b_k: f64,
|
|
|
|
|
#[name("(Blues) Cyan")] b_c: f32,
|
|
|
|
|
#[name("(Blues) Magenta")] b_m: f32,
|
|
|
|
|
#[name("(Blues) Yellow")] b_y: f32,
|
|
|
|
|
#[name("(Blues) Black")] b_k: f32,
|
|
|
|
|
|
|
|
|
|
#[name("(Magentas) Cyan")] m_c: f64,
|
|
|
|
|
#[name("(Magentas) Magenta")] m_m: f64,
|
|
|
|
|
#[name("(Magentas) Yellow")] m_y: f64,
|
|
|
|
|
#[name("(Magentas) Black")] m_k: f64,
|
|
|
|
|
#[name("(Magentas) Cyan")] m_c: f32,
|
|
|
|
|
#[name("(Magentas) Magenta")] m_m: f32,
|
|
|
|
|
#[name("(Magentas) Yellow")] m_y: f32,
|
|
|
|
|
#[name("(Magentas) Black")] m_k: f32,
|
|
|
|
|
|
|
|
|
|
#[name("(Whites) Cyan")] w_c: f64,
|
|
|
|
|
#[name("(Whites) Magenta")] w_m: f64,
|
|
|
|
|
#[name("(Whites) Yellow")] w_y: f64,
|
|
|
|
|
#[name("(Whites) Black")] w_k: f64,
|
|
|
|
|
#[name("(Whites) Cyan")] w_c: f32,
|
|
|
|
|
#[name("(Whites) Magenta")] w_m: f32,
|
|
|
|
|
#[name("(Whites) Yellow")] w_y: f32,
|
|
|
|
|
#[name("(Whites) Black")] w_k: f32,
|
|
|
|
|
|
|
|
|
|
#[name("(Neutrals) Cyan")] n_c: f64,
|
|
|
|
|
#[name("(Neutrals) Magenta")] n_m: f64,
|
|
|
|
|
#[name("(Neutrals) Yellow")] n_y: f64,
|
|
|
|
|
#[name("(Neutrals) Black")] n_k: f64,
|
|
|
|
|
#[name("(Neutrals) Cyan")] n_c: f32,
|
|
|
|
|
#[name("(Neutrals) Magenta")] n_m: f32,
|
|
|
|
|
#[name("(Neutrals) Yellow")] n_y: f32,
|
|
|
|
|
#[name("(Neutrals) Black")] n_k: f32,
|
|
|
|
|
|
|
|
|
|
#[name("(Blacks) Cyan")] k_c: f64,
|
|
|
|
|
#[name("(Blacks) Magenta")] k_m: f64,
|
|
|
|
|
#[name("(Blacks) Yellow")] k_y: f64,
|
|
|
|
|
#[name("(Blacks) Black")] k_k: f64,
|
|
|
|
|
#[name("(Blacks) Cyan")] k_c: f32,
|
|
|
|
|
#[name("(Blacks) Magenta")] k_m: f32,
|
|
|
|
|
#[name("(Blacks) Yellow")] k_y: f32,
|
|
|
|
|
#[name("(Blacks) Black")] k_k: f32,
|
|
|
|
|
|
|
|
|
|
_colors: SelectiveColorChoice,
|
|
|
|
|
) -> T {
|
|
|
|
|
@@ -866,15 +866,15 @@ fn selective_color<T: Adjust<Color>>(
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let (sum_r, sum_g, sum_b) = [
|
|
|
|
|
(SelectiveColorChoice::Reds, (r_c as f32, r_m as f32, r_y as f32, r_k as f32)),
|
|
|
|
|
(SelectiveColorChoice::Yellows, (y_c as f32, y_m as f32, y_y as f32, y_k as f32)),
|
|
|
|
|
(SelectiveColorChoice::Greens, (g_c as f32, g_m as f32, g_y as f32, g_k as f32)),
|
|
|
|
|
(SelectiveColorChoice::Cyans, (c_c as f32, c_m as f32, c_y as f32, c_k as f32)),
|
|
|
|
|
(SelectiveColorChoice::Blues, (b_c as f32, b_m as f32, b_y as f32, b_k as f32)),
|
|
|
|
|
(SelectiveColorChoice::Magentas, (m_c as f32, m_m as f32, m_y as f32, m_k as f32)),
|
|
|
|
|
(SelectiveColorChoice::Whites, (w_c as f32, w_m as f32, w_y as f32, w_k as f32)),
|
|
|
|
|
(SelectiveColorChoice::Neutrals, (n_c as f32, n_m as f32, n_y as f32, n_k as f32)),
|
|
|
|
|
(SelectiveColorChoice::Blacks, (k_c as f32, k_m as f32, k_y as f32, k_k as f32)),
|
|
|
|
|
(SelectiveColorChoice::Reds, (r_c, r_m, r_y, r_k)),
|
|
|
|
|
(SelectiveColorChoice::Yellows, (y_c, y_m, y_y, y_k)),
|
|
|
|
|
(SelectiveColorChoice::Greens, (g_c, g_m, g_y, g_k)),
|
|
|
|
|
(SelectiveColorChoice::Cyans, (c_c, c_m, c_y, c_k)),
|
|
|
|
|
(SelectiveColorChoice::Blues, (b_c, b_m, b_y, b_k)),
|
|
|
|
|
(SelectiveColorChoice::Magentas, (m_c, m_m, m_y, m_k)),
|
|
|
|
|
(SelectiveColorChoice::Whites, (w_c, w_m, w_y, w_k)),
|
|
|
|
|
(SelectiveColorChoice::Neutrals, (n_c, n_m, n_y, n_k)),
|
|
|
|
|
(SelectiveColorChoice::Blacks, (k_c, k_m, k_y, k_k)),
|
|
|
|
|
]
|
|
|
|
|
.into_iter()
|
|
|
|
|
.fold((0., 0., 0.), |acc, (color_parameter_group, (c, m, y, k))| {
|
|
|
|
|
@@ -959,21 +959,21 @@ fn exposure<T: Adjust<Color>>(
|
|
|
|
|
GradientStops,
|
|
|
|
|
)]
|
|
|
|
|
mut input: T,
|
|
|
|
|
exposure: f64,
|
|
|
|
|
offset: f64,
|
|
|
|
|
exposure: f32,
|
|
|
|
|
offset: f32,
|
|
|
|
|
#[default(1.)]
|
|
|
|
|
#[range((0.01, 10.))]
|
|
|
|
|
#[hard_min(0.0001)]
|
|
|
|
|
gamma_correction: f64,
|
|
|
|
|
gamma_correction: f32,
|
|
|
|
|
) -> T {
|
|
|
|
|
input.adjust(|color| {
|
|
|
|
|
let adjusted = color
|
|
|
|
|
// Exposure
|
|
|
|
|
.map_rgb(|c: f32| c * 2_f32.powf(exposure as f32))
|
|
|
|
|
// Offset
|
|
|
|
|
.map_rgb(|c: f32| c + offset as f32)
|
|
|
|
|
// Gamma correction
|
|
|
|
|
.gamma(gamma_correction as f32);
|
|
|
|
|
// Exposure
|
|
|
|
|
.map_rgb(|c: f32| c * 2_f32.powf(exposure))
|
|
|
|
|
// Offset
|
|
|
|
|
.map_rgb(|c: f32| c + offset)
|
|
|
|
|
// Gamma correction
|
|
|
|
|
.gamma(gamma_correction);
|
|
|
|
|
|
|
|
|
|
adjusted.map_rgb(|c: f32| c.clamp(0., 1.))
|
|
|
|
|
});
|
|
|
|
|
|