mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-25 13:27:56 +00:00
Merge pull request #8740 from storytold/train/carry8044
Color Wheel: HSL Sliders edit a color by hue, saturation and lightness (#8044)
This commit is contained in:
@@ -10,6 +10,7 @@ pub mod freeform;
|
||||
pub mod gradient;
|
||||
pub mod harmony;
|
||||
pub mod libraries;
|
||||
pub mod oklab;
|
||||
pub mod palette_io;
|
||||
pub mod recolor;
|
||||
pub mod swatch;
|
||||
@@ -340,6 +341,49 @@ pub fn hsb_to_rgb([h, s, v]: [f32; 3]) -> [f32; 3] {
|
||||
[r + m, g + m, b + m]
|
||||
}
|
||||
|
||||
/// HSL (hue in degrees 0..360, saturation and lightness 0..1) of RGB numbers 0..1, with no color
|
||||
/// conversion, as CSS Color 4 converts sRGB to HSL
|
||||
/// (<https://www.w3.org/TR/css-color-4/#rgb-to-hsl>). The hue is 0 while the saturation is
|
||||
/// powerless, and a color outside 0..1 that gives a negative saturation turns its hue by 180°. As in
|
||||
/// the specification's conversion, a lightness of 0.00001 or less, a lightness less than 0.00001
|
||||
/// below 1, or a saturation of 0.00001 or less reads as a gray.
|
||||
pub fn rgb_to_hsl([r, g, b]: [f32; 3]) -> [f32; 3] {
|
||||
const EPSILON: f32 = 1e-5;
|
||||
let max = r.max(g).max(b);
|
||||
let min = r.min(g).min(b);
|
||||
let d = max - min;
|
||||
let l = (max + min) / 2.0;
|
||||
if d <= 0.0 {
|
||||
return [0.0, 0.0, l];
|
||||
}
|
||||
let mut s = if l.abs() <= EPSILON || (1.0 - l).abs() < EPSILON { 0.0 } else { (max - l) / l.min(1.0 - l) };
|
||||
let mut h = rgb_to_hsb([r, g, b])[0];
|
||||
if s < 0.0 {
|
||||
h += 180.0;
|
||||
s = -s;
|
||||
}
|
||||
if s <= EPSILON {
|
||||
return [0.0, 0.0, l];
|
||||
}
|
||||
let h = h.rem_euclid(360.0);
|
||||
[if h >= 360.0 { 0.0 } else { h }, s, l]
|
||||
}
|
||||
|
||||
/// RGB numbers 0..1 of HSL `[h, s, l]` (hue in degrees, saturation and lightness 0..1), as CSS
|
||||
/// Color 4 converts HSL to sRGB (<https://www.w3.org/TR/css-color-4/#hsl-to-rgb>): the inverse of
|
||||
/// [`rgb_to_hsl`]. A hue outside 0..360 wraps into that range before the conversion, so -120°
|
||||
/// gives the color of 240° and a hue of 10,000,000,000° the color of 280°. The specification's
|
||||
/// sample code uses JavaScript's remainder operator and gives a different color for a negative hue.
|
||||
pub fn hsl_to_rgb([h, s, l]: [f32; 3]) -> [f32; 3] {
|
||||
let h = h.rem_euclid(360.0);
|
||||
let a = s * l.min(1.0 - l);
|
||||
let f = |n: f32| {
|
||||
let k = (n + h / 30.0).rem_euclid(12.0);
|
||||
l - a * (k - 3.0).min(9.0 - k).clamp(-1.0, 1.0)
|
||||
};
|
||||
[f(0.0), f(8.0), f(4.0)]
|
||||
}
|
||||
|
||||
/// `new` expressed in the colour model of `orig` ([`Color::in_model`]): results of colour operations
|
||||
/// (harmonies, blends, inversions, recolouring) keep the model of the colour they came from.
|
||||
pub fn keep_model(orig: Color, new: Color) -> Color {
|
||||
@@ -499,6 +543,59 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// The HSL examples of CSS Color 4, section 7 (<https://www.w3.org/TR/css-color-4/#the-hsl-notation>),
|
||||
/// the first six rows, and two hues outside 0..360 that wrap into that range.
|
||||
#[test]
|
||||
fn hsl_follows_css_color_4() {
|
||||
for (hsl, hex) in [
|
||||
([0.0, 1.0, 0.5], "#ff0000"),
|
||||
([120.0, 1.0, 0.5], "#00ff00"),
|
||||
([120.0, 1.0, 0.25], "#008000"),
|
||||
([120.0, 1.0, 0.75], "#80ff80"),
|
||||
([240.0, 1.0, 0.5], "#0000ff"),
|
||||
([60.0, 1.0, 0.5], "#ffff00"),
|
||||
([360.0, 1.0, 0.5], "#ff0000"),
|
||||
([-120.0, 1.0, 0.5], "#0000ff"),
|
||||
] {
|
||||
let [r, g, b] = hsl_to_rgb(hsl);
|
||||
assert_eq!(Color::rgb(r, g, b).to_hex(), hex, "{hsl:?}");
|
||||
}
|
||||
let [h, s, l] = rgb_to_hsl([1.0, 0.5, 0.0]);
|
||||
assert!((h - 30.0).abs() < 1e-4 && (s - 1.0).abs() < 1e-6 && (l - 0.5).abs() < 1e-6, "{h} {s} {l}");
|
||||
let [h, s, l] = rgb_to_hsl(Color::rgb8(255, 128, 0).to_rgb_uncalibrated());
|
||||
assert!((h - 30.0).abs() < 0.2 && (s - 1.0).abs() < 1e-6 && (l - 0.5).abs() < 1e-3, "{h} {s} {l}");
|
||||
// A gray has no hue: the hue is 0 and the saturation 0, at any lightness.
|
||||
for v in [0.0, 0.25, 0.5, 1.0] {
|
||||
assert_eq!(rgb_to_hsl([v, v, v]), [0.0, 0.0, v]);
|
||||
}
|
||||
// Black and white keep any hue and saturation they are given.
|
||||
assert_eq!(hsl_to_rgb([200.0, 0.7, 0.0]), [0.0, 0.0, 0.0]);
|
||||
assert_eq!(hsl_to_rgb([200.0, 0.7, 1.0]), [1.0, 1.0, 1.0]);
|
||||
// A color past the gamut that gives a negative saturation turns its hue by 180°.
|
||||
let [h, s, _] = rgb_to_hsl([1.2, 1.5, 1.4]);
|
||||
assert!(s > 0.0 && (h - (160.0 + 180.0)).abs() < 1e-3, "{h} {s}");
|
||||
// A huge hue wraps before the channels are worked out: 10,000,000,000° is 280°.
|
||||
let (huge, wrapped) = (hsl_to_rgb([10_000_000_000.0, 1.0, 0.5]), hsl_to_rgb([280.0, 1.0, 0.5]));
|
||||
assert!((0..3).all(|i| (huge[i] - wrapped[i]).abs() < 1e-6), "{huge:?} {wrapped:?}");
|
||||
}
|
||||
|
||||
/// The 216 web colors go to HSL and back to the same 8-bit color.
|
||||
#[test]
|
||||
fn hsl_roundtrip() {
|
||||
let steps = [0x00, 0x33, 0x66, 0x99, 0xcc, 0xff];
|
||||
for r in steps {
|
||||
for g in steps {
|
||||
for b in steps {
|
||||
let c = Color::rgb8(r, g, b);
|
||||
let [h, s, l] = rgb_to_hsl(c.to_rgb_uncalibrated());
|
||||
assert!((0.0..360.0).contains(&h) && (0.0..=1.0).contains(&s) && (0.0..=1.0).contains(&l), "{}", c.to_hex());
|
||||
let back = hsl_to_rgb([h, s, l]).map(|v| (v * 255.0).round() as u8);
|
||||
assert_eq!(back, [r, g, b], "{}", c.to_hex());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cmyk_conversions() {
|
||||
assert_eq!(Color::cmyk(0.0, 0.0, 0.0, 1.0).to_rgb_uncalibrated(), [0.0, 0.0, 0.0]);
|
||||
|
||||
@@ -99,18 +99,24 @@ pub fn builtin_library(id: &str) -> Option<Arc<SwatchLibrary>> {
|
||||
|
||||
// ---------- colour construction ----------
|
||||
|
||||
/// sRGB (0..=1, gamma encoded) of OKLab `(l, a, b)`, unclamped.
|
||||
/// sRGB (0..=1, gamma encoded) of OKLab `(l, a, b)`, unclamped. A linear channel below
|
||||
/// −0.0031308 is encoded with the curve's sign turned, as CSS Color 4's extended sRGB does
|
||||
/// (<https://www.w3.org/TR/css-color-4/#color-conversion-code>).
|
||||
pub(crate) fn oklab_to_srgb(l: f64, a: f64, b: f64) -> [f64; 3] {
|
||||
oklab_to_linear_srgb(l, a, b).map(|v| if v.abs() <= 0.003_130_8 { 12.92 * v } else { v.signum() * (1.055 * v.abs().powf(1.0 / 2.4) - 0.055) })
|
||||
}
|
||||
|
||||
/// Linear sRGB of OKLab `(l, a, b)`, unclamped.
|
||||
pub(crate) fn oklab_to_linear_srgb(l: f64, a: f64, b: f64) -> [f64; 3] {
|
||||
let l_ = l + 0.396_337_777_4 * a + 0.215_803_757_3 * b;
|
||||
let m_ = l - 0.105_561_345_8 * a - 0.063_854_172_8 * b;
|
||||
let s_ = l - 0.089_484_177_5 * a - 1.291_485_548_0 * b;
|
||||
let (l3, m3, s3) = (l_ * l_ * l_, m_ * m_ * m_, s_ * s_ * s_);
|
||||
let lin = [
|
||||
[
|
||||
4.076_741_662_1 * l3 - 3.307_711_591_3 * m3 + 0.230_969_929_2 * s3,
|
||||
-1.268_438_004_6 * l3 + 2.609_757_401_1 * m3 - 0.341_319_396_5 * s3,
|
||||
-0.004_196_086_3 * l3 - 0.703_418_614_7 * m3 + 1.707_614_701_0 * s3,
|
||||
];
|
||||
lin.map(|v| if v <= 0.003_130_8 { 12.92 * v } else { 1.055 * v.powf(1.0 / 2.4) - 0.055 })
|
||||
]
|
||||
}
|
||||
|
||||
/// OKLab `[l, a, b]` of a colour's display RGB.
|
||||
@@ -118,11 +124,13 @@ pub fn to_oklab(c: &Color) -> [f64; 3] {
|
||||
srgb_to_oklab(c.to_rgb_uncalibrated())
|
||||
}
|
||||
|
||||
/// OKLab `[l, a, b]` of sRGB `rgb` (0..=1, gamma encoded).
|
||||
/// OKLab `[l, a, b]` of sRGB `rgb` (0..=1, gamma encoded). A channel below −0.04045 is decoded
|
||||
/// with the curve's sign turned, as CSS Color 4's extended sRGB does
|
||||
/// (<https://www.w3.org/TR/css-color-4/#color-conversion-code>).
|
||||
pub(crate) fn srgb_to_oklab(rgb: [f32; 3]) -> [f64; 3] {
|
||||
let [r, g, b] = rgb.map(|v| {
|
||||
let v = f64::from(v);
|
||||
if v <= 0.040_45 { v / 12.92 } else { ((v + 0.055) / 1.055).powf(2.4) }
|
||||
if v.abs() <= 0.040_45 { v / 12.92 } else { v.signum() * ((v.abs() + 0.055) / 1.055).powf(2.4) }
|
||||
});
|
||||
let l = (0.412_221_470_8 * r + 0.536_332_536_3 * g + 0.051_445_992_9 * b).cbrt();
|
||||
let m = (0.211_903_498_2 * r + 0.680_699_545_1 * g + 0.107_396_956_6 * b).cbrt();
|
||||
|
||||
@@ -0,0 +1,266 @@
|
||||
//! OKLCH, the polar form of Oklab, as CSS Color 4 defines it
|
||||
//! (<https://www.w3.org/TR/css-color-4/#specifying-oklab-oklch>): lightness L from 0 to 1, chroma
|
||||
//! C (CSS reads 100% as 0.4) and hue H in degrees from the positive `a` axis. The conversions take
|
||||
//! and give gamma-encoded sRGB through the Oklab matrices of [`crate::libraries`].
|
||||
|
||||
use crate::libraries::{oklab_to_linear_srgb, oklab_to_srgb, srgb_to_oklab};
|
||||
|
||||
/// The chroma CSS reads as 100%.
|
||||
pub const CHROMA_FULL: f64 = 0.4;
|
||||
|
||||
/// Chroma at or below which the hue is powerless (CSS Color 4's ε); [`to_oklch`] gives hue 0 there.
|
||||
pub const POWERLESS_CHROMA: f64 = 0.000_004;
|
||||
|
||||
/// How far outside 0..=1 an sRGB component may be and still count as inside the gamut.
|
||||
const GAMUT_SLACK: f64 = 1e-4;
|
||||
|
||||
/// OKLCH `[l, c, h°]` of sRGB `rgb` (gamma encoded). Values outside 0..=1 are converted as they
|
||||
/// are. The hue is in 0..360, and 0 while the chroma is powerless.
|
||||
pub fn to_oklch(rgb: [f32; 3]) -> [f64; 3] {
|
||||
let [l, a, b] = srgb_to_oklab(rgb);
|
||||
let c = a.hypot(b);
|
||||
if c <= POWERLESS_CHROMA {
|
||||
return [l, 0.0, 0.0];
|
||||
}
|
||||
[l, c, b.atan2(a).to_degrees().rem_euclid(360.0)]
|
||||
}
|
||||
|
||||
/// sRGB (gamma encoded) of OKLCH `(l, c, h°)`, unclamped.
|
||||
pub fn oklch_to_srgb(l: f64, c: f64, h: f64) -> [f64; 3] {
|
||||
let (sin, cos) = h.to_radians().sin_cos();
|
||||
oklab_to_srgb(l, c * cos, c * sin)
|
||||
}
|
||||
|
||||
/// Whether sRGB `rgb` lies inside the sRGB gamut.
|
||||
pub fn in_srgb(rgb: [f64; 3]) -> bool {
|
||||
rgb.iter().all(|v| (-GAMUT_SLACK..=1.0 + GAMUT_SLACK).contains(v))
|
||||
}
|
||||
|
||||
/// The largest chroma sRGB holds at lightness `l` and hue `h°`: 0 at or outside black and white.
|
||||
pub fn max_chroma(l: f64, h: f64) -> f64 {
|
||||
largest_fitting_chroma(l, h, f64::INFINITY)
|
||||
}
|
||||
|
||||
/// The largest chroma no more than `limit` that sRGB holds at lightness `l` and hue `h°`: 0 at or
|
||||
/// outside black and white.
|
||||
///
|
||||
/// The chromas sRGB holds along the ray can come in several stretches: at the lightness and hue of
|
||||
/// blue the ray leaves sRGB at a chroma of about 0.266 and comes back at blue itself, about 0.313,
|
||||
/// and near black the gamut slack opens stretches of its own. Each linear sRGB channel is a cubic
|
||||
/// in the chroma, so every stretch ends where a channel's cubic meets a bound of the gamut. The
|
||||
/// search finds each such chroma between the cubic's turning points and takes the largest one that
|
||||
/// fits.
|
||||
fn largest_fitting_chroma(l: f64, h: f64, limit: f64) -> f64 {
|
||||
if !(l > 0.0 && l < 1.0) || !h.is_finite() {
|
||||
return 0.0;
|
||||
}
|
||||
let top = limit.min(0.5);
|
||||
if top <= 0.0 {
|
||||
return 0.0;
|
||||
}
|
||||
let fits = |c: f64| in_srgb(oklch_to_srgb(l, c, h));
|
||||
if fits(top) {
|
||||
return top;
|
||||
}
|
||||
let (sin, cos) = h.to_radians().sin_cos();
|
||||
let lin = |c: f64| oklab_to_linear_srgb(l, c * cos, c * sin);
|
||||
// The linear channels at chromas 0, s, 2s and 3s give each cubic's coefficients in t = c / s.
|
||||
let s = top / 3.0;
|
||||
let y = [lin(0.0), lin(s), lin(2.0 * s), lin(3.0 * s)];
|
||||
let bounds = [-GAMUT_SLACK / 12.92, ((1.0 + GAMUT_SLACK + 0.055) / 1.055).powf(2.4)];
|
||||
let mut ends = vec![0.0];
|
||||
for ch in 0..3 {
|
||||
let [y0, y1, y2, y3] = [y[0][ch], y[1][ch], y[2][ch], y[3][ch]];
|
||||
let (d1, d2, d3) = (y1 - y0, y2 - 2.0 * y1 + y0, y3 - 3.0 * y2 + 3.0 * y1 - y0);
|
||||
let k = [y0, d1 - d2 / 2.0 + d3 / 3.0, d2 / 2.0 - d3 / 2.0, d3 / 6.0];
|
||||
let p = |t: f64| ((k[3] * t + k[2]) * t + k[1]) * t + k[0];
|
||||
// The cubic rises or falls on each stretch between its turning points.
|
||||
let mut cuts = vec![0.0, 3.0];
|
||||
cuts.extend(turning_points(3.0 * k[3], 2.0 * k[2], k[1]).into_iter().filter(|t| *t > 0.0 && *t < 3.0));
|
||||
cuts.sort_by(f64::total_cmp);
|
||||
ends.extend(cuts.iter().map(|t| t * s));
|
||||
for w in cuts.windows(2) {
|
||||
for bound in bounds {
|
||||
let (mut a, mut b) = (w[0], w[1]);
|
||||
let fa = p(a) - bound;
|
||||
if fa * (p(b) - bound) > 0.0 {
|
||||
continue;
|
||||
}
|
||||
for _ in 0..60 {
|
||||
let mid = (a + b) / 2.0;
|
||||
if (p(mid) - bound) * fa > 0.0 { a = mid } else { b = mid }
|
||||
}
|
||||
ends.extend([a * s, b * s]);
|
||||
}
|
||||
}
|
||||
}
|
||||
ends.sort_by(|a, b| b.total_cmp(a));
|
||||
ends.into_iter().flat_map(|c| [c, c - 1e-9]).find(|c| (0.0..=top).contains(c) && fits(*c)).unwrap_or(0.0)
|
||||
}
|
||||
|
||||
/// The real roots of `a t² + b t + c`.
|
||||
fn turning_points(a: f64, b: f64, c: f64) -> Vec<f64> {
|
||||
if a.abs() < 1e-15 {
|
||||
return if b.abs() < 1e-15 { Vec::new() } else { vec![-c / b] };
|
||||
}
|
||||
let disc = b * b - 4.0 * a * c;
|
||||
if disc < 0.0 {
|
||||
return Vec::new();
|
||||
}
|
||||
let r = disc.sqrt();
|
||||
vec![(-b - r) / (2.0 * a), (-b + r) / (2.0 * a)]
|
||||
}
|
||||
|
||||
/// The sRGB color (gamma encoded, 0..=1) of OKLCH `(l, c, h°)`, and whether its chroma was lowered:
|
||||
/// a color outside sRGB keeps its lightness and hue and takes the largest chroma below it that
|
||||
/// fits. Lightness is clamped to 0..=1 and chroma to 0 or more.
|
||||
pub fn from_oklch(l: f64, c: f64, h: f64) -> ([f32; 3], bool) {
|
||||
let l = if l.is_nan() { 0.0 } else { l.clamp(0.0, 1.0) };
|
||||
let c = if c.is_nan() { 0.0 } else { c.max(0.0) };
|
||||
let h = if h.is_finite() { h } else { 0.0 };
|
||||
let exact = oklch_to_srgb(l, c, h);
|
||||
let (rgb, lowered) = if in_srgb(exact) { (exact, false) } else { (oklch_to_srgb(l, largest_fitting_chroma(l, h, c), h), true) };
|
||||
(rgb.map(|v| v.clamp(0.0, 1.0) as f32), lowered)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn eight(rgb: [f32; 3]) -> [u8; 3] {
|
||||
rgb.map(|v| (v * 255.0).round() as u8)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn red_has_the_oklch_of_the_oklab_matrices_and_converts_back() {
|
||||
let [l, c, h] = to_oklch([1.0, 0.0, 0.0]);
|
||||
assert!((l - 0.6280).abs() < 5e-5 && (c - 0.2577).abs() < 5e-5 && (h - 29.23).abs() < 5e-3, "{l} {c} {h}");
|
||||
let (rgb, lowered) = from_oklch(l, c, h);
|
||||
assert_eq!((eight(rgb), lowered), ([255, 0, 0], false));
|
||||
}
|
||||
|
||||
/// CSS Color 4's examples convert to the hue its oklab() and oklch() forms give.
|
||||
#[test]
|
||||
fn the_polar_form_matches_the_css_examples() {
|
||||
for ([l, a, b], [cl, cc, ch]) in
|
||||
[([0.40101, 0.1147, 0.0453], [0.40101, 0.12332, 21.555]), ([0.65125, -0.0320, 0.1274], [0.65125, 0.13138, 104.097])]
|
||||
{
|
||||
let rgb = oklab_to_srgb(l, a, b).map(|v| v as f32);
|
||||
let [ol, oc, oh] = to_oklch(rgb);
|
||||
assert!((ol - cl).abs() < 1e-4 && (oc - cc).abs() < 1e-4 && (oh - ch).abs() < 0.05, "{ol} {oc} {oh}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_216_web_colors_round_trip() {
|
||||
let steps = [0u8, 0x33, 0x66, 0x99, 0xcc, 0xff];
|
||||
for r in steps {
|
||||
for g in steps {
|
||||
for b in steps {
|
||||
let rgb = [r, g, b].map(|v| f32::from(v) / 255.0);
|
||||
let [l, c, h] = to_oklch(rgb);
|
||||
assert_eq!(eight(from_oklch(l, c, h).0), [r, g, b], "{l} {c} {h}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn grays_have_no_chroma_and_hue_zero() {
|
||||
for v in [0.0, 0.5, 1.0] {
|
||||
let [_, c, h] = to_oklch([v, v, v]);
|
||||
assert!(c <= POWERLESS_CHROMA && h == 0.0, "{c} {h}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A chroma past the gamut gives a color inside it with the same lightness and hue, and says so.
|
||||
#[test]
|
||||
fn a_chroma_past_the_gamut_is_lowered_keeping_lightness_and_hue() {
|
||||
let (l, h) = (0.7, 150.0);
|
||||
let max = max_chroma(l, h);
|
||||
assert!(max > 0.05 && max < CHROMA_FULL, "{max}");
|
||||
assert!(in_srgb(oklch_to_srgb(l, max, h)) && !in_srgb(oklch_to_srgb(l, max + 1e-3, h)));
|
||||
let (rgb, lowered) = from_oklch(l, CHROMA_FULL, h);
|
||||
assert!(lowered);
|
||||
let [ol, oc, oh] = to_oklch(rgb);
|
||||
assert!((ol - l).abs() < 2e-3 && (oh - h).abs() < 1.0 && (oc - max).abs() < 2e-3, "{ol} {oc} {oh}");
|
||||
assert!(!from_oklch(l, max * 0.5, h).1);
|
||||
}
|
||||
|
||||
/// At the lightness and hue of blue the ray leaves sRGB and comes back at blue itself, so the
|
||||
/// largest chroma is blue's, and a chroma past it gives blue.
|
||||
#[test]
|
||||
fn the_largest_chroma_at_blues_hue_is_blues() {
|
||||
let [l, c, h] = to_oklch([0.0, 0.0, 1.0]);
|
||||
let max = max_chroma(l, h);
|
||||
assert!((max - c).abs() < 1e-4 && in_srgb(oklch_to_srgb(l, max, h)), "{max} {c}");
|
||||
let (rgb, lowered) = from_oklch(l, CHROMA_FULL, h);
|
||||
assert_eq!((eight(rgb), lowered), ([0, 0, 255], true));
|
||||
// A chroma between the two stretches takes the end of the first one, inside sRGB.
|
||||
let (rgb, lowered) = from_oklch(l, 0.29, h);
|
||||
let [_, gc, _] = to_oklch(rgb);
|
||||
assert!(lowered && gc < 0.27 && in_srgb(oklch_to_srgb(l, gc, h)), "{gc}");
|
||||
// A hue just past blue's: a narrow second stretch ends just below the line from black to blue.
|
||||
let (l, h) = (0.44, 264.06);
|
||||
let max = max_chroma(l, h);
|
||||
assert!(max > 0.304 && max < 0.305 && in_srgb(oklch_to_srgb(l, max, h)), "{max}");
|
||||
let [_, got, _] = to_oklch(from_oklch(l, 0.35, h).0);
|
||||
assert!(got > 0.303, "{got}");
|
||||
// A darker blue on the line from black to blue.
|
||||
let [l, c, h] = to_oklch([0.0, 0.0, 0.25]);
|
||||
assert!((max_chroma(l, h) - c).abs() < 1e-4, "{} {c}", max_chroma(l, h));
|
||||
}
|
||||
|
||||
/// Just below blue's lightness the line from black to blue passes a chroma of 0.3125, where a
|
||||
/// search from 0 to 0.5 lands first. A chroma asked for below that line still gives a color
|
||||
/// inside sRGB with the lightness and hue asked for.
|
||||
#[test]
|
||||
fn a_chroma_below_the_line_from_black_to_blue_stays_inside_srgb() {
|
||||
let [bl, bc, h] = to_oklch([0.0, 0.0, 1.0]);
|
||||
let l = bl * 0.3125 / bc;
|
||||
let (rgb, lowered) = from_oklch(l, 0.29, h);
|
||||
let [gl, gc, gh] = to_oklch(rgb);
|
||||
assert!(lowered && gc < 0.29 && in_srgb(oklch_to_srgb(l, gc, h)), "{gc}");
|
||||
assert!((gl - l).abs() < 2e-3 && (gh - h).abs() < 1.0, "{gl} {gh}");
|
||||
}
|
||||
|
||||
/// sRGB channels below 0 go through the transfer curve with its sign turned, as CSS Color 4's
|
||||
/// extended sRGB does, in both directions.
|
||||
#[test]
|
||||
fn negative_channels_use_the_signed_transfer_curve() {
|
||||
let linear = -((0.5_f64 + 0.055) / 1.055).powf(2.4);
|
||||
let [l, c, _] = to_oklch([-0.5; 3]);
|
||||
assert!((l - linear.cbrt()).abs() < 1e-4 && c <= POWERLESS_CHROMA, "{l} {c}");
|
||||
for v in oklch_to_srgb(linear.cbrt(), 0.0, 0.0) {
|
||||
assert!((v + 0.5).abs() < 1e-4, "{v}");
|
||||
}
|
||||
// Small values near 0 keep the straight part of the curve.
|
||||
let [l, _, _] = to_oklch([-0.01; 3]);
|
||||
assert!((l - (-0.01_f64 / 12.92).cbrt()).abs() < 1e-4, "{l}");
|
||||
}
|
||||
|
||||
/// The largest chroma fits and is at least the largest one a scan in steps of 0.0005 finds, at
|
||||
/// every hue and at lightnesses near black too, where the ray can come back into sRGB away from
|
||||
/// any primary color's hue (L 0.02 and H 242° fit up to about 0.022 after leaving near 0.012).
|
||||
#[test]
|
||||
fn the_largest_chroma_is_never_below_a_scan_of_the_ray() {
|
||||
let scan = |l: f64, h: f64| (0..=1000).map(|i| f64::from(i) * 0.0005).filter(|c| in_srgb(oklch_to_srgb(l, *c, h))).fold(0.0, f64::max);
|
||||
assert!(max_chroma(0.02, 242.0) > 0.02, "{}", max_chroma(0.02, 242.0));
|
||||
for l in [0.005, 0.02, 0.05, 0.1, 0.3, 0.44, 0.6, 0.8, 0.95, 0.99] {
|
||||
for h in (0..72).map(|i| f64::from(i) * 5.0 + 2.0) {
|
||||
let max = max_chroma(l, h);
|
||||
assert!(in_srgb(oklch_to_srgb(l, max, h)) && max >= scan(l, h), "L {l} H {h}: {max} < {}", scan(l, h));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn black_white_and_bad_numbers_hold_no_chroma() {
|
||||
assert_eq!(max_chroma(0.0, 30.0), 0.0);
|
||||
assert_eq!(max_chroma(1.0, 30.0), 0.0);
|
||||
assert_eq!(max_chroma(f64::NAN, 30.0), 0.0);
|
||||
assert_eq!(max_chroma(0.5, f64::INFINITY), 0.0);
|
||||
assert_eq!(eight(from_oklch(f64::NAN, f64::NAN, f64::NAN).0), [0, 0, 0]);
|
||||
assert_eq!(eight(from_oklch(2.0, -1.0, 0.0).0), [255, 255, 255]);
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Convert Color",
|
||||
[],
|
||||
None,
|
||||
"{color (#rrggbbaa and #rgba are refused), to: \"rgb\"|\"cmyk\"|\"gray\"|\"lab\", intent?} → {model, values, hex, lab: [L,a,b], outOfGamut, deltaE}",
|
||||
"{color (#rrggbbaa and #rgba are refused), to: \"rgb\"|\"cmyk\"|\"gray\"|\"lab\"|\"oklch\", intent?} → {model, values, hex, lab: [L,a,b], outOfGamut, deltaE}; oklch values are [L (0..100 %), C, H (0..360°)] of the color's display sRGB (CSS Color 4 OKLCH: https://www.w3.org/TR/css-color-4/#specifying-oklab-oklch), with H 0 for a gray; a color outside sRGB (a Lab color, a CMYK color or an RGB color in a wider working RGB space) is clipped to sRGB first",
|
||||
always,
|
||||
convert_color
|
||||
),
|
||||
@@ -1362,10 +1362,15 @@ fn convert_color(_: &mut Session, p: &Value) -> Result<Value> {
|
||||
let intent = intent_param(p, C)?.unwrap_or(c.settings().intent);
|
||||
let lab = c.lab(&col);
|
||||
let (model, vals) = match text_param(p, "to", C)?.unwrap_or("rgb") {
|
||||
"rgb" => ("rgb", values(&c.convert(&col, Model::Rgb, intent))),
|
||||
"cmyk" => ("cmyk", values(&c.convert(&col, Model::Cmyk, intent))),
|
||||
"gray" | "grayscale" => ("gray", values(&c.convert(&col, Model::Gray, intent))),
|
||||
"lab" => ("lab", vec![lab.l, lab.a, lab.b]),
|
||||
"rgb" => ("rgb", json!(values(&c.convert(&col, Model::Rgb, intent)))),
|
||||
"cmyk" => ("cmyk", json!(values(&c.convert(&col, Model::Cmyk, intent)))),
|
||||
"gray" | "grayscale" => ("gray", json!(values(&c.convert(&col, Model::Gray, intent)))),
|
||||
"lab" => ("lab", json!([lab.l, lab.a, lab.b])),
|
||||
"oklch" => {
|
||||
// RGB numbers past 0..1 ([2, 2, 2]) display clipped, as `hex` reports them.
|
||||
let [l, ch, h] = vectorcraft_color::oklab::to_oklch(c.display_rgb(&col).map(|v| v.clamp(0.0, 1.0)));
|
||||
("oklch", json!([l * 100.0, ch, h]))
|
||||
}
|
||||
other => return Err(bad(C, format!("unknown model `{other}`"))),
|
||||
};
|
||||
let de = c.gamut_error(&col);
|
||||
|
||||
@@ -318,6 +318,45 @@ fn convert_query_and_intents() {
|
||||
assert!(s.execute("color.convert", &json!({"color": "#808080", "intent": "vivid"})).is_err());
|
||||
}
|
||||
|
||||
/// `to: "oklch"` answers the OKLCH of the color's display sRGB, which converts back to the color;
|
||||
/// a CMYK color's display color, not its naive separation, sets them.
|
||||
#[test]
|
||||
fn convert_to_oklch_answers_lightness_chroma_and_hue() {
|
||||
let _g = GLOBAL.lock().unwrap_or_else(|e| e.into_inner());
|
||||
let mut s = session();
|
||||
let r = s.execute("color.convert", &json!({"color": "#ff0000", "to": "oklch"})).unwrap();
|
||||
assert_eq!(r["model"], "oklch");
|
||||
let v: Vec<f64> = r["values"].as_array().unwrap().iter().map(|v| v.as_f64().unwrap()).collect();
|
||||
assert!((v[0] - 62.80).abs() < 0.005 && (v[1] - 0.2577).abs() < 5e-5 && (v[2] - 29.23).abs() < 0.005, "{r}");
|
||||
let (rgb, lowered) = vectorcraft_color::oklab::from_oklch(v[0] / 100.0, v[1], v[2]);
|
||||
assert!(!lowered);
|
||||
assert_eq!(Color::rgb(rgb[0], rgb[1], rgb[2]).to_hex(), "#ff0000");
|
||||
assert_eq!(r["hex"], "#ff0000");
|
||||
let gray = s.execute("color.convert", &json!({"color": "#808080", "to": "oklch"})).unwrap();
|
||||
assert_eq!(gray["values"][2], 0.0, "{gray}");
|
||||
let ink = json!({"c": 1.0, "m": 0.0, "y": 0.0, "k": 0.0});
|
||||
let cyan = s.execute("color.convert", &json!({"color": ink, "to": "oklch"})).unwrap();
|
||||
let shown = vectorcraft_color::oklab::to_oklch(cms::active().display_rgb(&Color::cmyk(1.0, 0.0, 0.0, 0.0)));
|
||||
let naive = vectorcraft_color::oklab::to_oklch([0.0, 1.0, 1.0]);
|
||||
let c: Vec<f64> = cyan["values"].as_array().unwrap().iter().map(|v| v.as_f64().unwrap()).collect();
|
||||
let got = [c[0] / 100.0, c[1], c[2]];
|
||||
assert!((0..3).all(|i| (got[i] - shown[i]).abs() < 1e-9) && shown[1] > 0.05, "{cyan} {shown:?}");
|
||||
assert!((got[0] - naive[0]).abs() > 0.02, "{cyan} {naive:?}");
|
||||
// A Lab color outside sRGB answers the OKLCH of its color clipped to sRGB.
|
||||
let vivid = s.execute("color.convert", &json!({"color": {"l": 50.0, "a": 100.0, "b": 0.0}, "to": "oklch"})).unwrap();
|
||||
let w: Vec<f64> = vivid["values"].as_array().unwrap().iter().map(|v| v.as_f64().unwrap()).collect();
|
||||
let shown = cms::active().display_rgb(&Color::lab(50.0, 100.0, 0.0)).map(|v| v.clamp(0.0, 1.0));
|
||||
let clipped = vectorcraft_color::oklab::to_oklch(shown);
|
||||
assert!((w[0] / 100.0 - clipped[0]).abs() < 1e-9 && (w[1] - clipped[1]).abs() < 1e-9, "{vivid} {clipped:?}");
|
||||
assert!((w[2] - clipped[2]).abs() < 1e-9 && (0.0..360.0).contains(&w[2]), "{vivid} {clipped:?}");
|
||||
assert!(vectorcraft_color::oklab::in_srgb(vectorcraft_color::oklab::oklch_to_srgb(w[0] / 100.0, w[1], w[2])), "{vivid}");
|
||||
// RGB numbers past 0..1 answer the OKLCH of the clipped color `hex` reports: white.
|
||||
let past = s.execute("color.convert", &json!({"color": [2.0, 2.0, 2.0], "to": "oklch"})).unwrap();
|
||||
assert_eq!(past["hex"], "#ffffff");
|
||||
let l = past["values"][0].as_f64().unwrap();
|
||||
assert!((l - 100.0).abs() < 0.01 && past["values"][1].as_f64().unwrap() < 1e-3, "{past}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn assign_profile_is_stored_and_undoable() {
|
||||
let _g = GLOBAL.lock().unwrap_or_else(|e| e.into_inner());
|
||||
|
||||
@@ -1573,7 +1573,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"ui.colorWheel",
|
||||
"Color Wheel Options",
|
||||
"",
|
||||
"{view?: wheel|box, channel?: hue|saturation|brightness|red|green|blue, harmony?: bool, harmonyRule?: complementary|splitComplementary|leftComplement|rightComplement|analogous|analogous2|triad|tetrad|tetrad2|tetrad3|compound|compound2|highContrast|highContrast3|pentagram, vision?: bool} show the Color Wheel panel's wheel or its box, as the panel menu's Wheel View and Box View do, and pick the box's channel, as Box Channel does: the box is a color field with the channel's strip at its right, and the field shows the other two components (hue: saturation across and brightness up; saturation: hue across and brightness up; brightness: hue across and saturation up; red: blue across and green up; green: blue across and red up; blue: red across and green up); harmony shows a marker on the wheel's ring for each other color of harmonyRule (the Color Guide's rule of that id; a rule's label is taken too), as Show Harmony and Harmony Rule do, and a click on a marker applies its color; vision shows Show Color Vision Preview's row under the wheel or the box, four chips with the current color as simulated for protanopia, deuteranopia and tritanopia (the simulations of view.proofSetup's protanopia, deuteranopia and tritanopia targets) and for achromatopsia (the gray with the color's CIE L*), each named with its hex value in its tooltip and to screen readers, and taking the keyboard focus; a click or a key on a chip does not apply its color; keys left out or null keep their values ({} reads them), params that are not an object, another key or a value off the list are an error and change nothing, the settings are kept with the preferences, and the command does not open the panel (window.panel {panel: \"colorWheel\"} does) (ui.inspect: ui.color_wheel) → {view, channel, harmony, harmonyRule, vision}",
|
||||
"{view?: wheel|box, channel?: hue|saturation|brightness|red|green|blue, sliders?: none|oklch|hsl, harmony?: bool, harmonyRule?: complementary|splitComplementary|leftComplement|rightComplement|analogous|analogous2|triad|tetrad|tetrad2|tetrad3|compound|compound2|highContrast|highContrast3|pentagram, vision?: bool} show the Color Wheel panel's wheel or its box, as the panel menu's Wheel View and Box View do, pick the box's channel, as Box Channel does, and show no slider rows under the wheel or the box (none), OKLCH Sliders (oklch) or HSL Sliders (hsl), as the menu items of those names do: the box is a color field with the channel's strip at its right, and the field shows the other two components (hue: saturation across and brightness up; saturation: hue across and brightness up; brightness: hue across and saturation up; red: blue across and green up; green: blue across and red up; blue: red across and green up); OKLCH Sliders edit lightness 0 to 100 %, chroma 0 to 100 % of 0.4 and hue 0 to 360°, CSS Color 4's OKLCH of the display sRGB, and a color outside sRGB keeps L and H and takes the largest chroma that fits; HSL Sliders edit hue 0 to 360°, saturation 0 to 100 % and lightness 0 to 100 %, CSS Color 4's HSL of the display sRGB; harmony shows a marker on the wheel's ring for each other color of harmonyRule (the Color Guide's rule of that id; a rule's label is taken too), as Show Harmony and Harmony Rule do, and a click on a marker applies its color; vision shows Show Color Vision Preview's row under the wheel or the box, four chips with the current color as simulated for protanopia, deuteranopia and tritanopia (the simulations of view.proofSetup's protanopia, deuteranopia and tritanopia targets) and for achromatopsia (the gray with the color's CIE L*), each named with its hex value in its tooltip and to screen readers, and taking the keyboard focus; a click or a key on a chip does not apply its color; keys left out or null keep their values ({} reads them), params that are not an object, another key or a value off the list are an error and change nothing, oklch is an error while the working RGB space is not sRGB, the settings are kept with the preferences, and the command does not open the panel (window.panel {panel: \"colorWheel\"} does) (ui.inspect: ui.color_wheel) → {view, channel, sliders, harmony, harmonyRule, vision}",
|
||||
),
|
||||
(
|
||||
"ui.savePdfDialog",
|
||||
|
||||
@@ -1960,6 +1960,11 @@ font-technology Variable Променливи
|
||||
Knife Нож
|
||||
Knockout Group Група с изрязване
|
||||
Lab Lab
|
||||
OKLCH Sliders Плъзгачи OKLCH
|
||||
HSL Sliders Плъзгачи HSL
|
||||
Chroma Хрома
|
||||
The largest chroma sRGB holds at this lightness and hue Най-голямата хрома, която sRGB побира при тази светлина и този оттенък
|
||||
OKLCH needs sRGB as the working RGB space OKLCH изисква sRGB като работно RGB пространство
|
||||
Lab Spot Colors: Спот цветове по Lab:
|
||||
Lab Values Стойности по Lab
|
||||
Landscape Пейзаж
|
||||
@@ -4755,6 +4760,8 @@ axis Both И двете
|
||||
@msg `aspect` must be a number (%) `aspect` трябва да бъде число (%)
|
||||
@msg `at` must be [x, y] `at` трябва да бъде [x, y]
|
||||
@msg `color` must be a colour `color` трябва да бъде цвят
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` трябва да бъде none, oklch или hsl
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH изисква sRGB като работно RGB пространство
|
||||
@msg `command` must be a command whose menu item opens a dialog (see ui.menuDialog) `command` трябва да бъде команда, чийто елемент от менюто отваря диалогов прозорец (вижте ui.menuDialog)
|
||||
@msg `freeform.points` must be an array `freeform.points` трябва да бъде масив
|
||||
@msg `freeform.lines` must be an array `freeform.lines` трябва да бъде масив
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4551,6 +4551,11 @@ axis Both Obje
|
||||
Image Slika
|
||||
Ink Tinta
|
||||
Lab Lab
|
||||
OKLCH Sliders OKLCH klizači
|
||||
HSL Sliders HSL klizači
|
||||
Chroma Hroma
|
||||
The largest chroma sRGB holds at this lightness and hue Najveća hroma koju sRGB obuhvata pri ovoj svjetloći i nijansi
|
||||
OKLCH needs sRGB as the working RGB space OKLCH zahtijeva sRGB kao radni RGB prostor
|
||||
Medium Srednje
|
||||
Name Naziv
|
||||
None Ništa
|
||||
@@ -5203,6 +5208,8 @@ imageTrace Outline Obris
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` mora biti grayscale, rgb, hsb, cmyk ili websafe
|
||||
@msg `view` must be wheel or box `view` mora biti wheel ili box
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` mora biti hue, saturation, brightness, red, green ili blue
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` mora biti none, oklch ili hsl
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH zahtijeva sRGB kao radni RGB prostor
|
||||
@msg `{k}` must be [x, y] `{k}` mora biti [x, y]
|
||||
@msg `{name}` has no options `{name}` nema opcija
|
||||
@msg `{name}` is a built-in workspace; choose another name `{name}` je ugrađeni radni prostor; odaberite drugi naziv
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2499,6 +2499,11 @@ digits Malayalam Malaiàlam
|
||||
Knife Ganivet
|
||||
Knockout Group Grup knockout
|
||||
Lab Lab
|
||||
OKLCH Sliders Controls lliscants OKLCH
|
||||
HSL Sliders Controls lliscants HSL
|
||||
Chroma Croma
|
||||
The largest chroma sRGB holds at this lightness and hue El croma més gran que sRGB admet amb aquesta lluminositat i aquest to
|
||||
OKLCH needs sRGB as the working RGB space OKLCH necessita sRGB com a espai RGB de treball
|
||||
Lab Spot Colors Colors directes Lab
|
||||
Lab Spot Colors: Colors directes Lab:
|
||||
Lab Values Valors Lab
|
||||
@@ -6146,6 +6151,8 @@ digits Malayalam Malaiàlam
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` ha de ser grayscale, rgb, hsb, cmyk o websafe
|
||||
@msg `view` must be wheel or box `view` ha de ser wheel o box
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` ha de ser hue, saturation, brightness, red, green o blue
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` ha de ser none, oklch o hsl
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH necessita sRGB com a espai RGB de treball
|
||||
@msg `name` is empty `name` és buit
|
||||
@msg `newName` is empty `newName` és buit
|
||||
@msg `pathfinder` must be an object `pathfinder` ha de ser un objecte
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4660,6 +4660,11 @@ axis Both Obě
|
||||
Image Obraz
|
||||
Ink Inkoust
|
||||
Lab Lab
|
||||
OKLCH Sliders Posuvníky OKLCH
|
||||
HSL Sliders Posuvníky HSL
|
||||
Chroma Chroma
|
||||
The largest chroma sRGB holds at this lightness and hue Největší chroma, kterou sRGB obsáhne při této světlosti a odstínu
|
||||
OKLCH needs sRGB as the working RGB space OKLCH vyžaduje sRGB jako pracovní prostor RGB
|
||||
Medium Střední
|
||||
Name Název
|
||||
None Žádné
|
||||
@@ -5498,6 +5503,8 @@ liquify-list-end {0}, {1} {0} a {1}
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` musí být grayscale, rgb, hsb, cmyk nebo websafe
|
||||
@msg `view` must be wheel or box `view` musí být wheel nebo box
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` musí být hue, saturation, brightness, red, green nebo blue
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` musí být none, oklch nebo hsl
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH vyžaduje sRGB jako pracovní prostor RGB
|
||||
@msg `{k}` must be [x, y] `{k}` musí být [x, y]
|
||||
@msg `{name}` has no options `{name}` nemá žádné možnosti
|
||||
@msg `{name}` is a built-in workspace; choose another name `{name}` je vestavěný pracovní prostor; zvolte jiný název
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -7105,6 +7105,11 @@ axis Both Begge
|
||||
Image Billede
|
||||
Ink Blæk
|
||||
Lab Lab
|
||||
OKLCH Sliders OKLCH-skydere
|
||||
HSL Sliders HSL-skydere
|
||||
Chroma Kroma
|
||||
The largest chroma sRGB holds at this lightness and hue Den største kroma, sRGB kan rumme ved denne lyshed og farvetone
|
||||
OKLCH needs sRGB as the working RGB space OKLCH kræver sRGB som RGB-arbejdsfarverum
|
||||
Medium Medium
|
||||
Name Navn
|
||||
None Ingen
|
||||
@@ -9109,6 +9114,8 @@ variable-list-end {0}, {1} {0} og {1}
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` skal være grayscale, rgb, hsb, cmyk eller websafe
|
||||
@msg `view` must be wheel or box `view` skal være wheel eller box
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` skal være hue, saturation, brightness, red, green eller blue
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` skal være none, oklch eller hsl
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH kræver sRGB som RGB-arbejdsfarverum
|
||||
@msg the Color Picker is not open farvevælgeren er ikke åben
|
||||
@msg the screen color sampler is already open skærmfarvesampleren er allerede åben
|
||||
@msg this system has no screen color sampler dette system har ingen skærmfarvesampler
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2040,6 +2040,11 @@ file-filter Templates Vorlagen
|
||||
Knife Messer
|
||||
Knockout Group Aussparungsgruppe
|
||||
Lab Lab
|
||||
OKLCH Sliders OKLCH-Regler
|
||||
HSL Sliders HSL-Regler
|
||||
Chroma Chroma
|
||||
The largest chroma sRGB holds at this lightness and hue Das größte Chroma, das sRGB bei dieser Helligkeit und diesem Farbton enthält
|
||||
OKLCH needs sRGB as the working RGB space OKLCH erfordert sRGB als RGB-Arbeitsfarbraum
|
||||
Lab Spot Colors: Lab-Volltonfarben:
|
||||
Lab Values Lab-Werte
|
||||
Landscape Querformat
|
||||
@@ -5074,6 +5079,8 @@ liquify-list-end {0}, {1} {0} und {1}
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` muss grayscale, rgb, hsb, cmyk oder websafe sein
|
||||
@msg `view` must be wheel or box `view` muss wheel oder box sein
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` muss hue, saturation, brightness, red, green oder blue sein
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` muss none, oklch oder hsl sein
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH erfordert sRGB als RGB-Arbeitsfarbraum
|
||||
@msg `{k}` must be [x, y] `{k}` muss [x, y] sein
|
||||
@msg `{name}` has no options `{name}` hat keine Optionen
|
||||
@msg `{name}` is a built-in workspace; choose another name `{name}` ist ein integrierter Arbeitsbereich; wählen Sie einen anderen Namen
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1935,6 +1935,11 @@ font-technology Variable Μεταβλητές
|
||||
Knife Μαχαίρι (Knife)
|
||||
Knockout Group Ομάδα διάτρησης
|
||||
Lab Lab
|
||||
OKLCH Sliders Ρυθμιστικά OKLCH
|
||||
HSL Sliders Ρυθμιστικά HSL
|
||||
Chroma Χρωματική ένταση
|
||||
The largest chroma sRGB holds at this lightness and hue Η μεγαλύτερη χρωματική ένταση που χωρά το sRGB σε αυτή τη φωτεινότητα και απόχρωση
|
||||
OKLCH needs sRGB as the working RGB space Το OKLCH απαιτεί sRGB ως χώρο εργασίας RGB
|
||||
Lab Spot Colors: Πλακάτα χρώματα Lab:
|
||||
Lab Values Τιμές Lab
|
||||
Landscape Οριζόντιος προσανατολισμός
|
||||
@@ -6985,6 +6990,8 @@ effect Points Σημεία
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe το `mode` πρέπει να είναι grayscale, rgb, hsb, cmyk ή websafe
|
||||
@msg `view` must be wheel or box το `view` πρέπει να είναι wheel ή box
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue το `channel` πρέπει να είναι hue, saturation, brightness, red, green ή blue
|
||||
@msg `sliders` must be none, oklch or hsl Το `sliders` πρέπει να είναι none, oklch ή hsl
|
||||
@msg OKLCH needs sRGB as the working RGB space Το OKLCH απαιτεί sRGB ως χώρο εργασίας RGB
|
||||
@msg `{key}` must be an array of these names: {_1} το `{key}` πρέπει να είναι πίνακας με αυτά τα ονόματα: {_1}
|
||||
@msg choose a destination folder επιλέξτε φάκελο προορισμού
|
||||
@msg choose a source folder επιλέξτε φάκελο προέλευσης
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2039,6 +2039,11 @@ font-technology Variable Variables
|
||||
Knife Cuchilla
|
||||
Knockout Group Grupo de exclusión
|
||||
Lab Lab
|
||||
OKLCH Sliders Controles deslizantes OKLCH
|
||||
HSL Sliders Controles deslizantes HSL
|
||||
Chroma Croma
|
||||
The largest chroma sRGB holds at this lightness and hue El croma más alto que admite sRGB con esta luminosidad y este tono
|
||||
OKLCH needs sRGB as the working RGB space OKLCH necesita sRGB como espacio de trabajo RGB
|
||||
Lab Spot Colors: Tintas planas Lab:
|
||||
Lab Values Valores Lab
|
||||
Landscape Horizontal
|
||||
@@ -5186,6 +5191,8 @@ liquify-list-end {0}, {1} {0}, {1}
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` debe ser grayscale, rgb, hsb, cmyk o websafe
|
||||
@msg `view` must be wheel or box `view` debe ser wheel o box
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` debe ser hue, saturation, brightness, red, green o blue
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` debe ser none, oklch o hsl
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH necesita sRGB como espacio de trabajo RGB
|
||||
@msg `{k}` must be [x, y] `{k}` debe ser [x, y]
|
||||
@msg `{name}` has no options `{name}` no tiene opciones
|
||||
@msg `{name}` is a built-in workspace; choose another name `{name}` es un espacio de trabajo integrado; elige otro nombre
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4570,6 +4570,11 @@ axis Both Molemmat
|
||||
Image Kuva
|
||||
Ink Muste
|
||||
Lab Lab
|
||||
OKLCH Sliders OKLCH-liukusäätimet
|
||||
HSL Sliders HSL-liukusäätimet
|
||||
Chroma Kroma
|
||||
The largest chroma sRGB holds at this lightness and hue Suurin kroma, jonka sRGB sisältää tällä vaaleudella ja sävyllä
|
||||
OKLCH needs sRGB as the working RGB space OKLCH vaatii sRGB:n RGB-työväriavaruudeksi
|
||||
Medium Keskitaso
|
||||
Name Nimi
|
||||
None Ei mitään
|
||||
@@ -6990,6 +6995,8 @@ mark-style Japanese Japanilainen
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode`-arvon on oltava grayscale, rgb, hsb, cmyk tai websafe
|
||||
@msg `view` must be wheel or box `view`-arvon on oltava wheel tai box
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel`-arvon on oltava hue, saturation, brightness, red, green tai blue
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` on oltava none, oklch tai hsl
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH vaatii sRGB:n RGB-työväriavaruudeksi
|
||||
@msg `{key}` must be an array of these names: {_1} `{key}`-arvon on oltava taulukko, jossa on näitä nimiä: {_1}
|
||||
@msg choose a destination folder valitse kohdekansio
|
||||
@msg choose a source folder valitse lähdekansio
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2029,6 +2029,11 @@ font-technology Variable Variables
|
||||
Knife Cutter
|
||||
Knockout Group Groupe perçant
|
||||
Lab Lab
|
||||
OKLCH Sliders Curseurs OKLCH
|
||||
HSL Sliders Curseurs HSL
|
||||
Chroma Chroma
|
||||
The largest chroma sRGB holds at this lightness and hue Le plus grand chroma que sRGB contient à cette luminosité et cette teinte
|
||||
OKLCH needs sRGB as the working RGB space OKLCH nécessite sRGB comme espace de travail RGB
|
||||
Lab Spot Colors: Tons directs Lab :
|
||||
Lab Values Valeurs Lab
|
||||
Landscape Paysage
|
||||
@@ -5145,6 +5150,8 @@ liquify-list-end {0}, {1} {0} et {1}
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` doit valoir grayscale, rgb, hsb, cmyk ou websafe
|
||||
@msg `view` must be wheel or box `view` doit valoir wheel ou box
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` doit valoir hue, saturation, brightness, red, green ou blue
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` doit valoir none, oklch ou hsl
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH nécessite sRGB comme espace de travail RGB
|
||||
@msg `{k}` must be [x, y] `{k}` doit être [x, y]
|
||||
@msg `{name}` has no options `{name}` n’a pas d’options
|
||||
@msg `{name}` is a built-in workspace; choose another name `{name}` est un espace de travail intégré ; choisissez un autre nom
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2040,6 +2040,12 @@
|
||||
Knife નાઇફ
|
||||
Knockout Group નૉકઆઉટ ગ્રૂપ
|
||||
LZW Compression LZW કમ્પ્રેશન
|
||||
OKLCH Sliders OKLCH સ્લાઇડર્સ
|
||||
HSL Sliders HSL સ્લાઇડર્સ
|
||||
Chroma ક્રોમા
|
||||
The largest chroma sRGB holds at this lightness and hue આ લાઇટનેસ અને હ્યૂ પર sRGB સમાવી શકે તે સૌથી વધુ ક્રોમા
|
||||
OKLCH needs sRGB as the working RGB space OKLCH માટે કાર્યકારી RGB સ્પેસ તરીકે sRGB જરૂરી છે
|
||||
Lightness લાઇટનેસ
|
||||
Lab Spot Colors: Lab સ્પોટ રંગો:
|
||||
Landscape લેન્ડસ્કેપ
|
||||
Language ભાષા
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 72 and column 5.
|
@@ -3001,6 +3001,11 @@ arrowhead Feather पंख
|
||||
Knife चाकू
|
||||
Knockout Group नॉकआउट समूह
|
||||
Lab Lab
|
||||
OKLCH Sliders OKLCH स्लाइडर्स
|
||||
HSL Sliders HSL स्लाइडर्स
|
||||
Chroma क्रोमा
|
||||
The largest chroma sRGB holds at this lightness and hue इस लाइटनेस और ह्यू पर sRGB में आने वाला सबसे अधिक क्रोमा
|
||||
OKLCH needs sRGB as the working RGB space OKLCH के लिए वर्किंग RGB स्पेस sRGB होना चाहिए
|
||||
Lab Spot Colors लैब स्पॉट रंग
|
||||
Lab Spot Colors: लैब स्पॉट रंग:
|
||||
Lab Values लैब मूल्य
|
||||
@@ -7066,6 +7071,8 @@ arrowhead Feather पंख
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` को grayscale, rgb, hsb, cmyk या websafe होना चाहिए
|
||||
@msg `view` must be wheel or box `view` को wheel या box होना चाहिए
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` को hue, saturation, brightness, red, green या blue होना चाहिए
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` none, oklch या hsl होना चाहिए
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH के लिए वर्किंग RGB स्पेस sRGB होना चाहिए
|
||||
@msg `mode` must be one of {_1} `mode` को {_1} में से एक होना चाहिए
|
||||
@msg `mojikumi` must be "none", "yakumonoHankaku", "gyomatsuYakumonoHankaku", "gyomatsuYakumonoZenkaku", "yakumonoZenkaku" or "lineEndHalf" `mojikumi` "none", "yakumonoHankaku", "gyomatsuYakumonoHankaku", "gyomatsuYakumonoZenkaku", "yakumonoZenkaku" या "lineEndHalf" होना चाहिए।
|
||||
@msg `name` is empty `name` खाली है
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2521,6 +2521,11 @@ file-filter Templates Sablonok
|
||||
Knife Kés
|
||||
Knockout Group Kiütő csoport
|
||||
Lab Lab
|
||||
OKLCH Sliders OKLCH csúszkák
|
||||
HSL Sliders HSL csúszkák
|
||||
Chroma Króma
|
||||
The largest chroma sRGB holds at this lightness and hue A legnagyobb króma, amelyet az sRGB ezen a világosságon és színárnyalaton tartalmaz
|
||||
OKLCH needs sRGB as the working RGB space Az OKLCH-hoz sRGB munka-RGB-színtér szükséges
|
||||
Lab Spot Colors Lab-direktszínek
|
||||
Lab Spot Colors: Lab-direktszínek:
|
||||
Lab Values Lab-értékek
|
||||
@@ -5525,6 +5530,8 @@ imageTrace Outline Körvonal
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode`: grayscale, rgb, hsb, cmyk vagy websafe kell
|
||||
@msg `view` must be wheel or box `view`: wheel vagy box kell
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel`: hue, saturation, brightness, red, green vagy blue kell
|
||||
@msg `sliders` must be none, oklch or hsl A `sliders` értéke none, oklch vagy hsl lehet
|
||||
@msg OKLCH needs sRGB as the working RGB space Az OKLCH-hoz sRGB munka-RGB-színtér szükséges
|
||||
@msg `{k}` must be [x, y] `{k}`: [x, y] kell
|
||||
@msg `{name}` has no options ennek nincsenek beállításai: `{name}`
|
||||
@msg `{name}` is a built-in workspace; choose another name beépített munkaterület: `{name}`; válassz másik nevet
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4971,6 +4971,11 @@ axis Both Keduanya
|
||||
Image Gambar
|
||||
Ink Tinta
|
||||
Lab Lab
|
||||
OKLCH Sliders Penggeser OKLCH
|
||||
HSL Sliders Penggeser HSL
|
||||
Chroma Kroma
|
||||
The largest chroma sRGB holds at this lightness and hue Kroma terbesar yang dapat dimuat sRGB pada kecerahan dan rona ini
|
||||
OKLCH needs sRGB as the working RGB space OKLCH memerlukan sRGB sebagai ruang RGB kerja
|
||||
Medium Sedang
|
||||
Name Nama
|
||||
None Nihil
|
||||
@@ -6899,6 +6904,8 @@ mark-style Japanese Jepang
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` harus grayscale, rgb, hsb, cmyk atau websafe
|
||||
@msg `view` must be wheel or box `view` harus wheel atau box
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` harus hue, saturation, brightness, red, green atau blue
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` harus none, oklch, atau hsl
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH memerlukan sRGB sebagai ruang RGB kerja
|
||||
@msg the Color Picker is not open Pemilih Warna tidak terbuka
|
||||
@msg the screen color sampler is already open pengambil warna layar sudah terbuka
|
||||
@msg this system has no screen color sampler sistem ini tidak memiliki pengambil warna layar
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2080,6 +2080,11 @@ file-filter Templates Modelli
|
||||
Knife Coltello
|
||||
Knockout Group Gruppo con foratura
|
||||
Lab Lab
|
||||
OKLCH Sliders Cursori OKLCH
|
||||
HSL Sliders Cursori HSL
|
||||
Chroma Croma
|
||||
The largest chroma sRGB holds at this lightness and hue Il croma più alto che sRGB contiene con questa luminosità e tonalità
|
||||
OKLCH needs sRGB as the working RGB space OKLCH richiede sRGB come spazio di lavoro RGB
|
||||
Lab Spot Colors: Colori spot Lab:
|
||||
Lab Values Valori Lab
|
||||
Landscape Orizzontale
|
||||
@@ -5212,6 +5217,8 @@ liquify-list-end {0}, {1} {0} e {1}
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` deve essere grayscale, rgb, hsb, cmyk o websafe
|
||||
@msg `view` must be wheel or box `view` deve essere wheel o box
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` deve essere hue, saturation, brightness, red, green o blue
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` deve essere none, oklch o hsl
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH richiede sRGB come spazio di lavoro RGB
|
||||
@msg `{k}` must be [x, y] `{k}` deve essere [x, y]
|
||||
@msg `{name}` has no options `{name}` non ha opzioni
|
||||
@msg `{name}` is a built-in workspace; choose another name `{name}` è un'area di lavoro integrata; scegli un altro nome
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4418,6 +4418,11 @@ file-filter Templates テンプレート
|
||||
Keep the pasted color as a new swatch with a numbered name. ペーストしたカラーを、番号付きの名前で新規スウォッチとして残します。
|
||||
Keep: 保持:
|
||||
Lab Lab
|
||||
OKLCH Sliders OKLCH スライダー
|
||||
HSL Sliders HSL スライダー
|
||||
Chroma クロマ
|
||||
The largest chroma sRGB holds at this lightness and hue この明度と色相で sRGB に収まる最大のクロマ
|
||||
OKLCH needs sRGB as the working RGB space OKLCH には作業用 RGB スペースとして sRGB が必要です
|
||||
Lab Values Lab 値
|
||||
Large List View 大きいリスト表示
|
||||
Large Thumbnail View 大きいサムネール表示
|
||||
@@ -5642,6 +5647,8 @@ variable-list-end {0}, {1} {0}、{1}
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` には grayscale、rgb、hsb、cmyk、websafe のいずれかを指定してください
|
||||
@msg `view` must be wheel or box `view` には wheel、box のいずれかを指定してください
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` には hue、saturation、brightness、red、green、blue のいずれかを指定してください
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` には none、oklch、hsl のいずれかを指定してください
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH には作業用 RGB スペースとして sRGB が必要です
|
||||
@msg `{key}` must be true or false `{key}` には true または false を指定してください
|
||||
@msg `top` and `below` can't both be true `top` と `below` を同時に true にすることはできません
|
||||
@msg `select` must be true or false `select` には true または false を指定してください
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6365,6 +6365,11 @@ axis Both ორივე
|
||||
Image გამოსახულება
|
||||
Ink მელანი
|
||||
Lab Lab
|
||||
OKLCH Sliders OKLCH სლაიდერები
|
||||
HSL Sliders HSL სლაიდერები
|
||||
Chroma ქრომა
|
||||
The largest chroma sRGB holds at this lightness and hue უდიდესი ქრომა, რომელსაც sRGB იტევს ამ სიღიავესა და ფერის ტონზე
|
||||
OKLCH needs sRGB as the working RGB space OKLCH-ს სამუშაო RGB სივრცედ sRGB სჭირდება
|
||||
Medium საშუალო
|
||||
Name სახელი
|
||||
None არცერთი
|
||||
@@ -8776,6 +8781,8 @@ liquify-list-end {0}, {1} {0} და {1}
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` უნდა იყოს grayscale, rgb, hsb, cmyk ან websafe
|
||||
@msg `view` must be wheel or box `view` უნდა იყოს wheel ან box
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` უნდა იყოს hue, saturation, brightness, red, green ან blue
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` უნდა იყოს none, oklch ან hsl
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH-ს სამუშაო RGB სივრცედ sRGB სჭირდება
|
||||
@msg this is a PostScript file (an .ai saved in an older format or without PDF compatibility, or an EPS file), not a PDF: File › Open and File › Place read it as EPS ეს PostScript ფაილია (ძველ ფორმატში ან PDF-თან თავსებადობის გარეშე შენახული .ai, ან EPS ფაილი) და არა PDF: ფაილი › გახსნა და ფაილი › განთავსება მას EPS-ად კითხულობს
|
||||
# Upstream sync 2026-10-16 (3): Intertwine, symbol registration, gradient span, data sets, Batch.
|
||||
Intertwine გადახლართვა
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4408,6 +4408,11 @@ file-filter Templates 템플릿
|
||||
Keep the pasted color as a new swatch with a numbered name. 붙여넣은 색상을 번호가 붙은 이름의 새 견본으로 보관합니다.
|
||||
Keep: 유지:
|
||||
Lab Lab
|
||||
OKLCH Sliders OKLCH 슬라이더
|
||||
HSL Sliders HSL 슬라이더
|
||||
Chroma 크로마
|
||||
The largest chroma sRGB holds at this lightness and hue 이 명도와 색조에서 sRGB가 담을 수 있는 최대 크로마
|
||||
OKLCH needs sRGB as the working RGB space OKLCH를 사용하려면 작업 RGB 공간이 sRGB여야 합니다
|
||||
Lab Values Lab 값
|
||||
Large List View 큰 목록 보기
|
||||
Large Thumbnail View 큰 축소판 보기
|
||||
@@ -5571,6 +5576,8 @@ variable-list-end {0}, {1} {0} 및 {1}
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode`은(는) grayscale, rgb, hsb, cmyk, websafe 중 하나여야 합니다
|
||||
@msg `view` must be wheel or box `view`은(는) wheel, box 중 하나여야 합니다
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel`은(는) hue, saturation, brightness, red, green, blue 중 하나여야 합니다
|
||||
@msg `sliders` must be none, oklch or hsl `sliders`는 none, oklch 또는 hsl이어야 합니다
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH를 사용하려면 작업 RGB 공간이 sRGB여야 합니다
|
||||
@msg `{key}` must be true or false `{key}`은(는) true 또는 false여야 합니다
|
||||
@msg `top` and `below` can't both be true `top`과 `below`를 동시에 true로 지정할 수 없습니다
|
||||
@msg `select` must be true or false `select`은(는) true 또는 false여야 합니다
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4976,6 +4976,11 @@ axis Both Beide
|
||||
Image Afbeelding
|
||||
Ink Inkt
|
||||
Lab Lab
|
||||
OKLCH Sliders OKLCH-schuifregelaars
|
||||
HSL Sliders HSL-schuifregelaars
|
||||
Chroma Chroma
|
||||
The largest chroma sRGB holds at this lightness and hue De grootste chroma die sRGB bij deze helderheid en tint bevat
|
||||
OKLCH needs sRGB as the working RGB space OKLCH vereist sRGB als werk-RGB-ruimte
|
||||
Medium Gemiddeld
|
||||
Name Naam
|
||||
None Geen
|
||||
@@ -8892,6 +8897,8 @@ mark-style Japanese Japans
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` moet grayscale, rgb, hsb, cmyk of websafe zijn
|
||||
@msg `view` must be wheel or box `view` moet wheel of box zijn
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` moet hue, saturation, brightness, red, green of blue zijn
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` moet none, oklch of hsl zijn
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH vereist sRGB als werk-RGB-ruimte
|
||||
@msg the Color Picker is not open de kleurenkiezer is niet open
|
||||
@msg the screen color sampler is already open de schermkleurkiezer is al open
|
||||
@msg this system has no screen color sampler dit systeem heeft geen schermkleurkiezer
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4503,6 +4503,11 @@ axis Both Obie
|
||||
Image Obraz
|
||||
Ink Farba
|
||||
Lab Lab
|
||||
OKLCH Sliders Suwaki OKLCH
|
||||
HSL Sliders Suwaki HSL
|
||||
Chroma Chroma
|
||||
The largest chroma sRGB holds at this lightness and hue Największa chroma, jaką sRGB mieści przy tej jasności i barwie
|
||||
OKLCH needs sRGB as the working RGB space OKLCH wymaga sRGB jako roboczej przestrzeni RGB
|
||||
Medium Średni
|
||||
Name Nazwa
|
||||
None Brak
|
||||
@@ -5315,6 +5320,8 @@ liquify-list-end {0}, {1} {0} i {1}
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` musi mieć wartość grayscale, rgb, hsb, cmyk lub websafe
|
||||
@msg `view` must be wheel or box `view` musi mieć wartość wheel lub box
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` musi mieć wartość hue, saturation, brightness, red, green lub blue
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` musi mieć wartość none, oklch lub hsl
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH wymaga sRGB jako roboczej przestrzeni RGB
|
||||
@msg `{k}` must be [x, y] `{k}` musi mieć postać [x, y]
|
||||
@msg `{name}` has no options `{name}` nie ma opcji
|
||||
@msg `{name}` is a built-in workspace; choose another name `{name}` to wbudowany obszar roboczy; wybierz inną nazwę
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5720,6 +5720,11 @@ variable-list-end {0}, {1} {0} e {1}
|
||||
@plural agrees with {n} default shortcut|agrees with {n} default shortcuts coincide com {n} atalho padrão|coincide com {n} atalhos padrão
|
||||
@plural {n} part of the file wasn't read|{n} parts of the file weren't read {n} parte do arquivo não foi lida|{n} partes do arquivo não foram lidas
|
||||
Lab Lab
|
||||
OKLCH Sliders Controles Deslizantes OKLCH
|
||||
HSL Sliders Controles Deslizantes HSL
|
||||
Chroma Croma
|
||||
The largest chroma sRGB holds at this lightness and hue O maior croma que o sRGB comporta nesta luminosidade e neste tom
|
||||
OKLCH needs sRGB as the working RGB space OKLCH requer sRGB como espaço de trabalho RGB
|
||||
Lab Values Valores Lab
|
||||
Large List View Exibição em Lista Grande
|
||||
Large Thumbnail View Exibição em Miniaturas Grandes
|
||||
@@ -6931,6 +6936,8 @@ mark-style Japanese Japonesas
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` deve ser grayscale, rgb, hsb, cmyk ou websafe
|
||||
@msg `view` must be wheel or box `view` deve ser wheel ou box
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` deve ser hue, saturation, brightness, red, green ou blue
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` deve ser none, oklch ou hsl
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH requer sRGB como espaço de trabalho RGB
|
||||
@msg the image can't be read as a texture a imagem não pode ser lida como textura
|
||||
|
||||
# User Interface › Accent Color
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2066,6 +2066,11 @@ file-filter Templates Шаблоны
|
||||
Knife Нож
|
||||
Knockout Group Группа с вырезанием
|
||||
Lab Lab
|
||||
OKLCH Sliders Ползунки OKLCH
|
||||
HSL Sliders Ползунки HSL
|
||||
Chroma Хрома
|
||||
The largest chroma sRGB holds at this lightness and hue Наибольшая хрома, которую вмещает sRGB при этой светлоте и оттенке
|
||||
OKLCH needs sRGB as the working RGB space Для OKLCH рабочим пространством RGB должно быть sRGB
|
||||
Lab Spot Colors: Плашечные цвета Lab:
|
||||
Lab Values Значения Lab
|
||||
Landscape Альбомная
|
||||
@@ -5208,6 +5213,8 @@ liquify-list-end {0}, {1} {0} и {1}
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` должно быть grayscale, rgb, hsb, cmyk или websafe
|
||||
@msg `view` must be wheel or box `view` должно быть wheel или box
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` должно быть hue, saturation, brightness, red, green или blue
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` должен быть none, oklch или hsl
|
||||
@msg OKLCH needs sRGB as the working RGB space Для OKLCH рабочим пространством RGB должно быть sRGB
|
||||
@msg `{k}` must be [x, y] `{k}` должно быть [x, y]
|
||||
@msg `{name}` has no options `{name}` не имеет параметров
|
||||
@msg `{name}` is a built-in workspace; choose another name `{name}` — встроенная рабочая среда; выберите другое имя
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1982,6 +1982,11 @@ font-technology Variable Variabla
|
||||
Knife Kniv
|
||||
Knockout Group Utsparningsgrupp
|
||||
Lab Lab
|
||||
OKLCH Sliders OKLCH-reglage
|
||||
HSL Sliders HSL-reglage
|
||||
Chroma Kroma
|
||||
The largest chroma sRGB holds at this lightness and hue Den största kroma som sRGB rymmer vid denna ljushet och nyans
|
||||
OKLCH needs sRGB as the working RGB space OKLCH kräver sRGB som RGB-arbetsfärgrymd
|
||||
Lab Spot Colors: Lab-dekorfärger:
|
||||
Lab Values Lab-värden
|
||||
Landscape Liggande
|
||||
@@ -6971,6 +6976,8 @@ theme Appearance Utseende
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` måste vara grayscale, rgb, hsb, cmyk eller websafe
|
||||
@msg `view` must be wheel or box `view` måste vara wheel eller box
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` måste vara hue, saturation, brightness, red, green eller blue
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` måste vara none, oklch eller hsl
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH kräver sRGB som RGB-arbetsfärgrymd
|
||||
@msg `{key}` must be an array of these names: {_1} `{key}` måste vara en lista med dessa namn: {_1}
|
||||
@msg choose a destination folder välj en målmapp
|
||||
@msg choose a source folder välj en källmapp
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1861,6 +1861,11 @@ font-technology Variable Değişken
|
||||
Knife Bıçak
|
||||
Knockout Group Nakavt Grubu
|
||||
Lab Laboratuvar
|
||||
OKLCH Sliders OKLCH Kaydırıcıları
|
||||
HSL Sliders HSL Kaydırıcıları
|
||||
Chroma Kroma
|
||||
The largest chroma sRGB holds at this lightness and hue sRGB'nin bu açıklık ve renk tonunda alabileceği en yüksek kroma
|
||||
OKLCH needs sRGB as the working RGB space OKLCH, çalışma RGB alanı olarak sRGB gerektirir
|
||||
Lab Spot Colors: Laboratuvar Spot Renkleri:
|
||||
Lab Values Laboratuvar Değerleri
|
||||
Landscape Manzara
|
||||
@@ -4913,6 +4918,8 @@ liquify-list-end {0}, {1} {0} ve {1}
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` grayscale, rgb, hsb, cmyk veya websafe olmalıdır
|
||||
@msg `view` must be wheel or box `view` wheel veya box olmalıdır
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` hue, saturation, brightness, red, green veya blue olmalıdır
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` none, oklch veya hsl olmalıdır
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH, çalışma RGB alanı olarak sRGB gerektirir
|
||||
@msg `{k}` must be [x, y] `{k}` [x, y] olmalıdır
|
||||
@msg `{name}` has no options `{name}`nin seçeneği yok
|
||||
@msg `{name}` is a built-in workspace; choose another name `{name}` yerleşik bir çalışma alanıdır; başka bir isim seç
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2074,6 +2074,11 @@ file-filter Templates Шаблони
|
||||
Knife Ніж
|
||||
Knockout Group Група з вирізуванням
|
||||
Lab Lab
|
||||
OKLCH Sliders Повзунки OKLCH
|
||||
HSL Sliders Повзунки HSL
|
||||
Chroma Хрома
|
||||
The largest chroma sRGB holds at this lightness and hue Найбільша хрома, яку вміщує sRGB за цієї світлоти й відтінку
|
||||
OKLCH needs sRGB as the working RGB space Для OKLCH робочим простором RGB має бути sRGB
|
||||
Lab Spot Colors: Плашкові кольори Lab:
|
||||
Lab Values Значення Lab
|
||||
Landscape Альбомна
|
||||
@@ -5196,6 +5201,8 @@ liquify-list-end {0}, {1} {0} і {1}
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` має бути grayscale, rgb, hsb, cmyk або websafe
|
||||
@msg `view` must be wheel or box `view` має бути wheel або box
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` має бути hue, saturation, brightness, red, green або blue
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` має бути none, oklch або hsl
|
||||
@msg OKLCH needs sRGB as the working RGB space Для OKLCH робочим простором RGB має бути sRGB
|
||||
@msg `{k}` must be [x, y] `{k}` має бути [x, y]
|
||||
@msg `{name}` has no options `{name}` не має параметрів
|
||||
@msg `{name}` is a built-in workspace; choose another name `{name}` - вбудоване робоче середовище; виберіть інше ім’я
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2372,6 +2372,11 @@ digits Hindi Hindi
|
||||
Knife Dao
|
||||
Knockout Group Nhóm Knockout
|
||||
Lab Lab
|
||||
OKLCH Sliders Thanh trượt OKLCH
|
||||
HSL Sliders Thanh trượt HSL
|
||||
Chroma Độ tươi màu
|
||||
The largest chroma sRGB holds at this lightness and hue Độ tươi màu lớn nhất mà sRGB chứa được ở độ sáng và sắc độ này
|
||||
OKLCH needs sRGB as the working RGB space OKLCH cần sRGB làm không gian RGB làm việc
|
||||
Lab Spot Colors: Màu đặc Lab:
|
||||
Lab Values Giá trị Lab
|
||||
Landscape Ngang
|
||||
@@ -5194,6 +5199,8 @@ theme Appearance Giao diện
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` phải là grayscale, rgb, hsb, cmyk hoặc websafe
|
||||
@msg `view` must be wheel or box `view` phải là wheel hoặc box
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` phải là hue, saturation, brightness, red, green hoặc blue
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` phải là none, oklch hoặc hsl
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH cần sRGB làm không gian RGB làm việc
|
||||
@msg `{k}` must be [x, y] `{k}` phải là [x, y]
|
||||
@msg `{name}` has no options `{name}` không có tùy chọn
|
||||
@msg `{name}` is a built-in workspace; choose another name `{name}` là không gian làm việc tích hợp sẵn; hãy chọn tên khác
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1956,6 +1956,11 @@ file-filter Templates 模板
|
||||
Knife 刻刀
|
||||
Knockout Group 挖空组
|
||||
Lab Lab
|
||||
OKLCH Sliders OKLCH 滑块
|
||||
HSL Sliders HSL 滑块
|
||||
Chroma 色度
|
||||
The largest chroma sRGB holds at this lightness and hue sRGB 在此亮度和色相下可容纳的最大色度
|
||||
OKLCH needs sRGB as the working RGB space OKLCH 需要将 sRGB 用作 RGB 工作空间
|
||||
Lab Spot Colors: Lab 专色:
|
||||
Lab Values Lab 值
|
||||
Landscape 横向
|
||||
@@ -5311,6 +5316,8 @@ imageTrace Outline 轮廓
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` 必须是 grayscale、rgb、hsb、cmyk 或 websafe
|
||||
@msg `view` must be wheel or box `view` 必须是 wheel 或 box
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` 必须是 hue、saturation、brightness、red、green 或 blue
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` 必须是 none、oklch 或 hsl
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH 需要将 sRGB 用作 RGB 工作空间
|
||||
@msg `{key}` must be true or false `{key}` 必须是 true 或 false
|
||||
@msg `top` and `below` can't both be true `top` 和 `below` 不能同时为 true
|
||||
@msg `select` must be true or false `select` 必须是 true 或 false
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2685,6 +2685,8 @@ file-filter Templates 範本
|
||||
@msg `mode` must be grayscale, rgb, hsb, cmyk or websafe `mode` 必須是 grayscale、rgb、hsb、cmyk 或 websafe
|
||||
@msg `view` must be wheel or box `view` 必須是 wheel 或 box
|
||||
@msg `channel` must be hue, saturation, brightness, red, green or blue `channel` 必須是 hue、saturation、brightness、red、green 或 blue
|
||||
@msg `sliders` must be none, oklch or hsl `sliders` 必須是 none、oklch 或 hsl
|
||||
@msg OKLCH needs sRGB as the working RGB space OKLCH 需要將 sRGB 用作 RGB 工作空間
|
||||
@msg `{key}` must be true or false `{key}` 必須是 true 或 false
|
||||
@msg `top` and `below` can't both be true `top` 和 `below` 不能同時為 true
|
||||
@msg `select` must be true or false `select` 必須是 true 或 false
|
||||
@@ -3341,6 +3343,11 @@ liquify-list-end {0}, {1} {0}和{1}
|
||||
Knife 美工刀
|
||||
Knockout Group 去底群組
|
||||
Lab Lab
|
||||
OKLCH Sliders OKLCH 滑桿
|
||||
HSL Sliders HSL 滑桿
|
||||
Chroma 色度
|
||||
The largest chroma sRGB holds at this lightness and hue sRGB 在此亮度和色相下可容納的最大色度
|
||||
OKLCH needs sRGB as the working RGB space OKLCH 需要將 sRGB 用作 RGB 工作空間
|
||||
Lab Spot Colors: Lab 特別色:
|
||||
Lab Values Lab 值
|
||||
Landscape 橫向
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1574,7 +1574,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"ui.colorWheel",
|
||||
"Color Wheel Options",
|
||||
"",
|
||||
"{view?: wheel|box, channel?: hue|saturation|brightness|red|green|blue, harmony?: bool, harmonyRule?: complementary|splitComplementary|leftComplement|rightComplement|analogous|analogous2|triad|tetrad|tetrad2|tetrad3|compound|compound2|highContrast|highContrast3|pentagram, vision?: bool} show the Color Wheel panel's wheel or its box, as the panel menu's Wheel View and Box View do, and pick the box's channel, as Box Channel does: the box is a color field with the channel's strip at its right, and the field shows the other two components (hue: saturation across and brightness up; saturation: hue across and brightness up; brightness: hue across and saturation up; red: blue across and green up; green: blue across and red up; blue: red across and green up); harmony shows a marker on the wheel's ring for each other color of harmonyRule (the Color Guide's rule of that id; a rule's label is taken too), as Show Harmony and Harmony Rule do, and a click on a marker applies its color; vision shows Show Color Vision Preview's row under the wheel or the box, four chips with the current color as simulated for protanopia, deuteranopia and tritanopia (the simulations of view.proofSetup's protanopia, deuteranopia and tritanopia targets) and for achromatopsia (the gray with the color's CIE L*), each named with its hex value in its tooltip and to screen readers, and taking the keyboard focus; a click or a key on a chip does not apply its color; keys left out or null keep their values ({} reads them), params that are not an object, another key or a value off the list are an error and change nothing, the settings are kept with the preferences, and the command does not open the panel (window.panel {panel: \"colorWheel\"} does) (ui.inspect: ui.color_wheel) → {view, channel, harmony, harmonyRule, vision}",
|
||||
"{view?: wheel|box, channel?: hue|saturation|brightness|red|green|blue, sliders?: none|oklch|hsl, harmony?: bool, harmonyRule?: complementary|splitComplementary|leftComplement|rightComplement|analogous|analogous2|triad|tetrad|tetrad2|tetrad3|compound|compound2|highContrast|highContrast3|pentagram, vision?: bool} show the Color Wheel panel's wheel or its box, as the panel menu's Wheel View and Box View do, pick the box's channel, as Box Channel does, and show no slider rows under the wheel or the box (none), OKLCH Sliders (oklch) or HSL Sliders (hsl), as the menu items of those names do: the box is a color field with the channel's strip at its right, and the field shows the other two components (hue: saturation across and brightness up; saturation: hue across and brightness up; brightness: hue across and saturation up; red: blue across and green up; green: blue across and red up; blue: red across and green up); OKLCH Sliders edit lightness 0 to 100 %, chroma 0 to 100 % of 0.4 and hue 0 to 360°, CSS Color 4's OKLCH of the display sRGB, and a color outside sRGB keeps L and H and takes the largest chroma that fits; HSL Sliders edit hue 0 to 360°, saturation 0 to 100 % and lightness 0 to 100 %, CSS Color 4's HSL of the display sRGB; harmony shows a marker on the wheel's ring for each other color of harmonyRule (the Color Guide's rule of that id; a rule's label is taken too), as Show Harmony and Harmony Rule do, and a click on a marker applies its color; vision shows Show Color Vision Preview's row under the wheel or the box, four chips with the current color as simulated for protanopia, deuteranopia and tritanopia (the simulations of view.proofSetup's protanopia, deuteranopia and tritanopia targets) and for achromatopsia (the gray with the color's CIE L*), each named with its hex value in its tooltip and to screen readers, and taking the keyboard focus; a click or a key on a chip does not apply its color; keys left out or null keep their values ({} reads them), params that are not an object, another key or a value off the list are an error and change nothing, oklch is an error while the working RGB space is not sRGB, the settings are kept with the preferences, and the command does not open the panel (window.panel {panel: \"colorWheel\"} does) (ui.inspect: ui.color_wheel) → {view, channel, sliders, harmony, harmonyRule, vision}",
|
||||
),
|
||||
(
|
||||
"ui.savePdfDialog",
|
||||
|
||||
@@ -22,15 +22,25 @@
|
||||
//! Setup uses, and for achromatopsia as the gray with the color's CIE L*. The chips only show the
|
||||
//! simulation.
|
||||
//!
|
||||
//! The view, the channel, Show Harmony, Harmony Rule and Show Color Vision Preview are kept with
|
||||
//! the preferences (`ui.colorWheel`).
|
||||
//! Panel menu › OKLCH Sliders shows L, C and H rows under the wheel or the box that edit the color
|
||||
//! by OKLCH lightness, chroma and hue (CSS Color 4:
|
||||
//! <https://www.w3.org/TR/css-color-4/#specifying-oklab-oklch>), while the active document's RGB
|
||||
//! space ([`cms::active`]: the profile assigned to the document, else the working RGB space of the
|
||||
//! color settings) is sRGB. Panel menu › HSL Sliders shows H, S and L rows in their place that edit the color by the
|
||||
//! hue, saturation and lightness of CSS Color 4's HSL
|
||||
//! (<https://www.w3.org/TR/css-color-4/#the-hsl-notation>). The choice is kept with the
|
||||
//! preferences too.
|
||||
//!
|
||||
//! The view, the channel, the slider rows, Show Harmony, Harmony Rule and Show Color Vision
|
||||
//! Preview are kept with the preferences (`ui.colorWheel`).
|
||||
|
||||
use egui::{Rect, Sense, Stroke, StrokeKind, Ui, UiBuilder, vec2};
|
||||
use egui::{Color32, Rect, Sense, Stroke, StrokeKind, Ui, UiBuilder, pos2, vec2};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_color::cms::{self, Cms, ProofSetup, ProofTarget};
|
||||
use vectorcraft_color::harmony::Harmony;
|
||||
use vectorcraft_color::{Color, Paint, hsb_to_rgb, rgb_to_hsb};
|
||||
use vectorcraft_color::oklab::{self, CHROMA_FULL};
|
||||
use vectorcraft_color::{Color, Paint, hsb_to_rgb, hsl_to_rgb, rgb_to_hsb, rgb_to_hsl};
|
||||
use vectorcraft_doc::{ColorMode, NodeId};
|
||||
|
||||
use super::color::{Target, apply, wheel_target};
|
||||
@@ -82,6 +92,8 @@ pub struct Settings {
|
||||
pub view: View,
|
||||
#[serde(serialize_with = "serialize_channel", deserialize_with = "deserialize_channel")]
|
||||
pub channel: Channel,
|
||||
#[serde(deserialize_with = "deserialize_sliders")]
|
||||
pub sliders: Sliders,
|
||||
/// Show Harmony: markers on the ring for the other colors of `harmony_rule`.
|
||||
#[serde(deserialize_with = "deserialize_flag")]
|
||||
pub harmony: bool,
|
||||
@@ -94,9 +106,50 @@ pub struct Settings {
|
||||
pub vision: bool,
|
||||
}
|
||||
|
||||
/// The slider rows under the wheel or the box (panel menu, `ui.colorWheel {sliders}`).
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum Sliders {
|
||||
#[default]
|
||||
None,
|
||||
/// OKLCH Sliders: lightness, chroma and hue.
|
||||
Oklch,
|
||||
/// HSL Sliders: hue, saturation and lightness.
|
||||
Hsl,
|
||||
}
|
||||
|
||||
impl Sliders {
|
||||
pub const ALL: [Sliders; 3] = [Sliders::None, Sliders::Oklch, Sliders::Hsl];
|
||||
|
||||
/// The id `ui.colorWheel` and the preferences use.
|
||||
pub fn id(self) -> &'static str {
|
||||
match self {
|
||||
Sliders::None => "none",
|
||||
Sliders::Oklch => "oklch",
|
||||
Sliders::Hsl => "hsl",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse(s: &str) -> Option<Self> {
|
||||
Self::ALL.into_iter().find(|v| v.id() == s)
|
||||
}
|
||||
}
|
||||
|
||||
fn deserialize_sliders<'de, D: serde::Deserializer<'de>>(d: D) -> Result<Sliders, D::Error> {
|
||||
let v = <Value as Deserialize>::deserialize(d)?;
|
||||
Ok(v.as_str().and_then(Sliders::parse).unwrap_or_default())
|
||||
}
|
||||
|
||||
impl Default for Settings {
|
||||
fn default() -> Self {
|
||||
Self { view: View::default(), channel: Channel::default(), harmony: false, harmony_rule: Harmony::Complementary, vision: false }
|
||||
Self {
|
||||
view: View::default(),
|
||||
channel: Channel::default(),
|
||||
sliders: Sliders::default(),
|
||||
harmony: false,
|
||||
harmony_rule: Harmony::Complementary,
|
||||
vision: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,12 +199,22 @@ pub fn deserialize_settings<'de, D: serde::Deserializer<'de>>(d: D) -> Result<Se
|
||||
Ok(serde_json::from_value(v).unwrap_or_default())
|
||||
}
|
||||
|
||||
/// `ui.colorWheel {view?, channel?, harmony?, harmonyRule?, vision?}`: show the wheel or the box,
|
||||
/// pick the box's channel, show the colors of a harmony rule on the wheel, and show or hide the
|
||||
/// color vision row. Keys left out or null keep their values; params that are not an object,
|
||||
/// another key or a value off the list are an error and change nothing. → the settings.
|
||||
/// `ui.colorWheel {view?, channel?, sliders?, harmony?, harmonyRule?, vision?}`: show the wheel or
|
||||
/// the box, pick the box's channel, show OKLCH Sliders, HSL Sliders or neither, show the colors of
|
||||
/// a harmony rule on the wheel, and show or hide the color vision row. Keys left out or null keep
|
||||
/// their values; params that are not an object, another key or a value off the list are an error
|
||||
/// and change nothing.
|
||||
/// `sliders: "oklch"` is an error while the active document's RGB space (its assigned profile,
|
||||
/// else the working RGB space) is not sRGB. → the settings.
|
||||
pub(crate) fn command(app: &mut VectorcraftApp, p: &Value) -> Result<Value, String> {
|
||||
const KEYS: [&str; 5] = ["view", "channel", "harmony", "harmonyRule", "vision"];
|
||||
set(&mut app.ui.color_wheel, p, &cms::active())?;
|
||||
Ok(json!(app.ui.color_wheel))
|
||||
}
|
||||
|
||||
/// Set the keys of `ui.colorWheel` params `p` in `settings`, with the color settings `cms`; on an
|
||||
/// error `settings` stay as they were.
|
||||
pub(crate) fn set(settings: &mut Settings, p: &Value, cms: &Cms) -> Result<(), String> {
|
||||
const KEYS: [&str; 6] = ["view", "channel", "sliders", "harmony", "harmonyRule", "vision"];
|
||||
match p {
|
||||
Value::Null => {}
|
||||
Value::Object(o) => {
|
||||
@@ -161,7 +224,7 @@ pub(crate) fn command(app: &mut VectorcraftApp, p: &Value) -> Result<Value, Stri
|
||||
}
|
||||
got => return Err(format!("the params must be an object, not {got}")),
|
||||
}
|
||||
let mut set = app.ui.color_wheel.clone();
|
||||
let mut set = settings.clone();
|
||||
match p.get("view") {
|
||||
None | Some(Value::Null) => {}
|
||||
Some(v) => set.view = v.as_str().and_then(View::parse).ok_or("`view` must be wheel or box")?,
|
||||
@@ -170,6 +233,16 @@ pub(crate) fn command(app: &mut VectorcraftApp, p: &Value) -> Result<Value, Stri
|
||||
None | Some(Value::Null) => {}
|
||||
Some(v) => set.channel = v.as_str().and_then(Channel::parse).ok_or("`channel` must be hue, saturation, brightness, red, green or blue")?,
|
||||
}
|
||||
match p.get("sliders") {
|
||||
None | Some(Value::Null) => {}
|
||||
Some(v) => {
|
||||
let sliders = v.as_str().and_then(Sliders::parse).ok_or("`sliders` must be none, oklch or hsl")?;
|
||||
if sliders == Sliders::Oklch && !cms.rgb_is_srgb() {
|
||||
return Err(OKLCH_NEEDS_SRGB.to_string());
|
||||
}
|
||||
set.sliders = sliders;
|
||||
}
|
||||
}
|
||||
let key = "harmony";
|
||||
match p.get(key) {
|
||||
None | Some(Value::Null) => {}
|
||||
@@ -188,12 +261,13 @@ pub(crate) fn command(app: &mut VectorcraftApp, p: &Value) -> Result<Value, Stri
|
||||
if let Some(on) = crate::menus::opt_bool(p, "vision")? {
|
||||
set.vision = on;
|
||||
}
|
||||
app.ui.color_wheel = set;
|
||||
Ok(json!(app.ui.color_wheel))
|
||||
*settings = set;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The panel menu: Wheel View and Box View, and Box Channel while the box shows; Show Harmony
|
||||
/// and Harmony Rule while the wheel shows; and Show Color Vision Preview.
|
||||
/// The panel menu: Wheel View and Box View, and Box Channel while the box shows; HSL Sliders and
|
||||
/// OKLCH Sliders; Show Harmony and Harmony Rule while the wheel shows; and Show Color Vision
|
||||
/// Preview.
|
||||
pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
let set = app.ui.color_wheel.clone();
|
||||
for (label, view) in [(tl!("Wheel View"), View::Wheel), (tl!("Box View"), View::Box)] {
|
||||
@@ -211,6 +285,22 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
});
|
||||
});
|
||||
ui.separator();
|
||||
let on = set.sliders == Sliders::Hsl;
|
||||
if menu_item(ui, tl!("HSL Sliders"), true, on) {
|
||||
let sliders = if on { Sliders::None } else { Sliders::Hsl };
|
||||
if let Err(e) = app.run("ui.colorWheel", json!({ "sliders": sliders.id() })) {
|
||||
app.status(e);
|
||||
}
|
||||
}
|
||||
let on = set.sliders == Sliders::Oklch;
|
||||
// While the rows show, the item stays enabled so that they can be hidden.
|
||||
let enabled = on || cms::active().rgb_is_srgb();
|
||||
if widgets::menu_item_hint(ui, tl!("OKLCH Sliders"), enabled, on, tl!("OKLCH needs sRGB as the working RGB space")) {
|
||||
let sliders = if on { Sliders::None } else { Sliders::Oklch };
|
||||
if let Err(e) = app.run("ui.colorWheel", json!({ "sliders": sliders.id() })) {
|
||||
app.status(e);
|
||||
}
|
||||
}
|
||||
if menu_item(ui, tl!("Show Harmony"), set.view == View::Wheel, set.harmony) {
|
||||
command(app, &json!({ "harmony": !set.harmony })).ok();
|
||||
}
|
||||
@@ -299,6 +389,16 @@ fn show_box(ui: &mut Ui, ch: Channel, hsb: [f32; 3], marked: bool, size: f32) ->
|
||||
|
||||
/// Panel state: the HSB picked last, its [`Owner`] and the display sRGB of the color it stored.
|
||||
const MEMORY: &str = "color-wheel-hsb";
|
||||
/// Panel state: the OKLCH the slider rows asked for last, the [`Owner`] of the color they stored
|
||||
/// and its display sRGB.
|
||||
const OKLCH_MEMORY: &str = "color-wheel-oklch";
|
||||
/// Panel state: the slider rows whose drag previews on an open interaction, until it is released.
|
||||
const ROWS_LIVE: &str = "color-wheel-rows-live";
|
||||
/// The message for OKLCH Sliders while the active document's RGB space is not sRGB.
|
||||
const OKLCH_NEEDS_SRGB: &str = "OKLCH needs sRGB as the working RGB space";
|
||||
/// Panel state: the HSL the slider rows asked for last, the [`Owner`] of the color they stored and
|
||||
/// its display sRGB.
|
||||
const HSL_MEMORY: &str = "color-wheel-hsl";
|
||||
/// The height of the color vision chips and the space between them.
|
||||
const VISION_CHIP: f32 = 16.0;
|
||||
const VISION_GAP: f32 = 3.0;
|
||||
@@ -399,6 +499,28 @@ impl Owner {
|
||||
}
|
||||
}
|
||||
|
||||
/// The components remembered under `key` for the target's `color`: the display sRGB the color had
|
||||
/// when they were stored, and the components. A record whose owner or display color differs from
|
||||
/// what the panel shows now is dropped, so that it does not come back when the same color returns
|
||||
/// later.
|
||||
fn recall<T: Clone + Send + Sync + 'static>(
|
||||
app: &VectorcraftApp,
|
||||
ui: &Ui,
|
||||
key: &str,
|
||||
tgt: &Target,
|
||||
color: Option<Color>,
|
||||
cms: &Cms,
|
||||
) -> Option<([f32; 3], T)> {
|
||||
let (owner, shown, v) = pstate::<Option<(Owner, [f32; 3], T)>>(ui.ctx(), key)?;
|
||||
match color {
|
||||
Some(c) if owner == Owner::of(app, tgt, c) && cms.display_rgb(&c) == shown => Some((shown, v)),
|
||||
_ => {
|
||||
set_pstate(ui.ctx(), key, None::<(Owner, [f32; 3], T)>);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The HSB a color shows on the wheel: that of its display sRGB through `cms`.
|
||||
pub(crate) fn display_hsb(cms: &Cms, c: &Color) -> [f32; 3] {
|
||||
rgb_to_hsb(cms.display_rgb(c))
|
||||
@@ -416,7 +538,12 @@ pub(crate) fn remembered_hsb(cms: &Cms, c: &Color, shown: [f32; 3], hsb: [f32; 3
|
||||
/// model with the color settings. Anything else (no color, a Gray color, a tint of a global swatch)
|
||||
/// becomes a process color in the document's color mode: managed CMYK when `cmyk_doc`, else RGB.
|
||||
pub(crate) fn stored(cms: &Cms, hsb: [f32; 3], was: Option<&Color>, cmyk_doc: bool) -> Color {
|
||||
let [r, g, b] = cms.srgb_to_rgb(hsb_to_rgb(hsb));
|
||||
stored_srgb(cms, hsb_to_rgb(hsb), was, cmyk_doc)
|
||||
}
|
||||
|
||||
/// [`stored`] for a pick of display sRGB `srgb`.
|
||||
pub(crate) fn stored_srgb(cms: &Cms, srgb: [f32; 3], was: Option<&Color>, cmyk_doc: bool) -> Color {
|
||||
let [r, g, b] = cms.srgb_to_rgb(srgb);
|
||||
let rgb = Color::rgb(r, g, b);
|
||||
let cmyk = || {
|
||||
let [c, m, y, k] = cms.to_cmyk(&rgb, cms.settings().intent);
|
||||
@@ -450,14 +577,215 @@ fn replaced(app: &VectorcraftApp, tgt: &Target, behind: bool) -> Option<Color> {
|
||||
}
|
||||
}
|
||||
|
||||
/// The OKLCH `[l, c, h°]` the rows show for `c` through `cms` when `lch` was asked for last and `c`
|
||||
/// then displayed as the sRGB `shown`: `lch` while `c` still displays as `shown` (a chroma past the
|
||||
/// gamut and the hue of a gray stay), else `c`'s own.
|
||||
pub(crate) fn remembered_oklch(cms: &Cms, c: &Color, shown: [f32; 3], lch: [f64; 3]) -> [f64; 3] {
|
||||
if cms.display_rgb(c) == shown { lch } else { oklab::to_oklch(clipped_rgb(cms, c)) }
|
||||
}
|
||||
|
||||
/// The display sRGB of `c` through `cms` clipped to sRGB: the color the slider rows show and edit
|
||||
/// for a color outside sRGB.
|
||||
fn clipped_rgb(cms: &Cms, c: &Color) -> [f32; 3] {
|
||||
cms.display_rgb(c).map(|v| v.clamp(0.0, 1.0))
|
||||
}
|
||||
|
||||
/// The color a track shows at OKLCH `lch`: the color itself inside sRGB, and outside it dimmed.
|
||||
/// A color outside sRGB shows at the largest chroma that fits at its L and H, the color a pick
|
||||
/// there stores. With `max_chroma` (the C track, whose L and H stay fixed) that chroma is given
|
||||
/// for the colors past it; without it, or in a gap below it where the ray leaves sRGB and comes
|
||||
/// back, it is found for each color.
|
||||
pub(crate) fn oklch_track(lch: [f64; 3], max_chroma: Option<f64>) -> Color32 {
|
||||
let exact = oklab::oklch_to_srgb(lch[0], lch[1], lch[2]);
|
||||
let (rgb, outside) = match max_chroma {
|
||||
Some(m) if lch[1] > m => (oklab::oklch_to_srgb(lch[0], m, lch[2]), true),
|
||||
Some(_) if oklab::in_srgb(exact) => (exact, false),
|
||||
_ => {
|
||||
let (rgb, lowered) = oklab::from_oklch(lch[0], lch[1], lch[2]);
|
||||
(rgb.map(f64::from), lowered)
|
||||
}
|
||||
};
|
||||
let [r, g, b] = rgb.map(|v| (v.clamp(0.0, 1.0) * 255.0).round() as u8);
|
||||
let c = Color32::from_rgb(r, g, b);
|
||||
if outside { c.gamma_multiply(0.3) } else { c }
|
||||
}
|
||||
|
||||
/// Where the C track's tick sits, from 0 at its left to 1 at its right: at the largest chroma
|
||||
/// `max_chroma`, of the track's 0 to 0.4.
|
||||
pub(crate) fn chroma_tick(max_chroma: f64) -> f32 {
|
||||
(max_chroma / CHROMA_FULL).clamp(0.0, 1.0) as f32
|
||||
}
|
||||
|
||||
/// The L, C and H rows of OKLCH Sliders for the target's `color` through `cms`: lightness from 0 to
|
||||
/// 100 %, chroma from 0 to 100 % of 0.4 (as CSS reads a chroma percentage) and hue from 0 to 360°.
|
||||
/// Each track shows the colors its slider reaches and dims the part outside sRGB, and a tick on the
|
||||
/// C track marks the largest chroma sRGB holds at the row's L and H. The rows are gray with no
|
||||
/// color to edit and while the working RGB space is not sRGB. Returns the OKLCH a drag, an arrow
|
||||
/// key, a screen reader or a field asks for, and its phase.
|
||||
pub(crate) fn oklch_rows(app: &VectorcraftApp, ui: &mut Ui, tgt: &Target, color: Option<Color>, cms: &Cms) -> Option<([f64; 3], Live)> {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let enabled = color.is_some() && cms.rgb_is_srgb();
|
||||
let lch = match (color, recall::<[f64; 3]>(app, ui, OKLCH_MEMORY, tgt, color, cms)) {
|
||||
(Some(c), Some((shown, lch))) => remembered_oklch(cms, &c, shown, lch),
|
||||
(Some(c), _) => oklab::to_oklch(clipped_rgb(cms, &c)),
|
||||
(None, _) => [0.0; 3],
|
||||
};
|
||||
// Each row: its letter, its screen-reader name, the end of its range and the field's suffix.
|
||||
let rows = [("L", tl!("Lightness"), 100.0, "%"), ("C", tl!("Chroma"), 100.0, "%"), ("H", tl!("Hue"), 360.0, "°")];
|
||||
let shown = [lch[0] * 100.0, lch[1] / CHROMA_FULL * 100.0, lch[2]];
|
||||
// The OKLCH with row `i` set to `v` in the row's units.
|
||||
let with = |i: usize, v: f64| {
|
||||
let mut out = lch;
|
||||
match i {
|
||||
0 => out[0] = (v / 100.0).clamp(0.0, 1.0),
|
||||
1 => out[1] = (v / 100.0 * CHROMA_FULL).clamp(0.0, CHROMA_FULL),
|
||||
_ => out[2] = v.clamp(0.0, 360.0),
|
||||
}
|
||||
out
|
||||
};
|
||||
let mut out = None;
|
||||
// The L and H tracks search the gamut for each color outside sRGB, so their colors are kept
|
||||
// until the other two components change.
|
||||
let mut tracks = pstate::<[Option<([u64; 3], Vec<Color32>)>; 3]>(ui.ctx(), OKLCH_TRACKS);
|
||||
ui.add_enabled_ui(enabled, |ui| {
|
||||
let field_w = 48.0;
|
||||
let slider_w = (ui.available_width() - field_w - 12.0 - 3.0 * ui.spacing().item_spacing.x).max(60.0);
|
||||
// The C track's L and H stay fixed, so its largest chroma is found once per frame.
|
||||
let max_c = if enabled { oklab::max_chroma(lch[0], lch[2]) } else { 0.0 };
|
||||
for (i, (letter, name, max, suffix)) in rows.into_iter().enumerate() {
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_sized(vec2(12.0, 22.0), egui::Label::new(egui::RichText::new(letter).size(12.5).color(t.text)));
|
||||
let v = shown[i].clamp(0.0, max);
|
||||
let at = |x: f32| with(i, f64::from(x) * max);
|
||||
let mut key = lch.map(f64::to_bits);
|
||||
key[i] = 0;
|
||||
let colors = match &tracks[i] {
|
||||
Some((k, colors)) if i != 1 && enabled && *k == key => colors.clone(),
|
||||
_ if i != 1 && enabled => {
|
||||
let last = (TRACK_SAMPLES - 1) as f32;
|
||||
let colors: Vec<Color32> = (0..TRACK_SAMPLES).map(|s| oklch_track(at(s as f32 / last), None)).collect();
|
||||
tracks[i] = Some((key, colors.clone()));
|
||||
colors
|
||||
}
|
||||
_ => Vec::new(),
|
||||
};
|
||||
let track = |x: f32| match colors.get((x.clamp(0.0, 1.0) * (TRACK_SAMPLES - 1) as f32).round() as usize) {
|
||||
Some(c) => *c,
|
||||
None if enabled => oklch_track(at(x), (i == 1).then_some(max_c)),
|
||||
None => t.input,
|
||||
};
|
||||
let value = SliderValue::field(v, 0.0..=max, suffix, 0);
|
||||
let (dragged, phase, keyed) =
|
||||
widgets::color_slider_stepped(ui, ("color-wheel-oklch", i), name, Some(value), (v / max) as f32, slider_w, &track);
|
||||
// The tick goes on the bar of the rail as the row laid it out.
|
||||
let rail = (i == 1 && enabled).then(|| ui.ctx().read_response(widgets::id_with(ui.scope_id(), ("color-wheel-oklch", i)))).flatten();
|
||||
if let Some(rail) = rail {
|
||||
let bar = widgets::color_rail_bar(rail.rect);
|
||||
let x = bar.left() + chroma_tick(max_c) * bar.width();
|
||||
ui.painter().line_segment([pos2(x, bar.top() - 3.0), pos2(x, bar.bottom())], Stroke::new(1.5, t.text));
|
||||
let tip = Rect::from_x_y_ranges(x - 3.0..=x + 3.0, bar.top() - 3.0..=bar.bottom());
|
||||
ui.interact(tip, ui.scope_id().with("color-wheel-oklch-tick"), egui::Sense::hover())
|
||||
.on_hover_text(tl!("The largest chroma sRGB holds at this lightness and hue"));
|
||||
}
|
||||
if let Some(x) = dragged {
|
||||
out = Some((at(x), phase));
|
||||
}
|
||||
if let Some(k) = keyed {
|
||||
out = Some((with(i, k), Live::Released));
|
||||
}
|
||||
if let Some(f) = widgets::plain_field_named(ui, ("color-wheel-oklch-field", i), Some(name), v, suffix, 0, field_w) {
|
||||
out = Some((with(i, f), Live::Released));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
set_pstate(ui.ctx(), OKLCH_TRACKS, tracks);
|
||||
out.filter(|_| enabled)
|
||||
}
|
||||
|
||||
/// Panel state: the colors of the L and H tracks of OKLCH Sliders, each with the OKLCH (its own
|
||||
/// component left out) they were drawn for.
|
||||
const OKLCH_TRACKS: &str = "color-wheel-oklch-tracks";
|
||||
/// How many colors along a cached track.
|
||||
const TRACK_SAMPLES: usize = 128;
|
||||
|
||||
/// The HSL `[h°, s, l]` the rows show for `c` through `cms` when `hsl` was asked for last and `c`
|
||||
/// then displayed as the sRGB `shown`: `hsl` while `c` still displays as `shown` (the hue of a gray
|
||||
/// and the saturation of black and white stay), else `c`'s own.
|
||||
pub(crate) fn remembered_hsl(cms: &Cms, c: &Color, shown: [f32; 3], hsl: [f32; 3]) -> [f32; 3] {
|
||||
if cms.display_rgb(c) == shown { hsl } else { rgb_to_hsl(clipped_rgb(cms, c)) }
|
||||
}
|
||||
|
||||
/// The color a track shows at HSL `hsl`.
|
||||
fn hsl32(hsl: [f32; 3]) -> Color32 {
|
||||
let [r, g, b] = hsl_to_rgb(hsl).map(|v| (v.clamp(0.0, 1.0) * 255.0).round() as u8);
|
||||
Color32::from_rgb(r, g, b)
|
||||
}
|
||||
|
||||
/// The H, S and L rows of HSL Sliders for the target's `color` through `cms`: hue from 0 to 360°,
|
||||
/// saturation and lightness from 0 to 100 %, CSS Color 4's HSL of the display sRGB. Each track
|
||||
/// shows the colors its slider reaches. The rows are gray with no color to edit. Returns the HSL a
|
||||
/// drag, an arrow key, a screen reader or a field asks for, and its phase.
|
||||
pub(crate) fn hsl_rows(app: &VectorcraftApp, ui: &mut Ui, tgt: &Target, color: Option<Color>, cms: &Cms) -> Option<([f32; 3], Live)> {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let enabled = color.is_some();
|
||||
let hsl = match (color, recall::<[f32; 3]>(app, ui, HSL_MEMORY, tgt, color, cms)) {
|
||||
(Some(c), Some((shown, hsl))) => remembered_hsl(cms, &c, shown, hsl),
|
||||
(Some(c), _) => rgb_to_hsl(clipped_rgb(cms, &c)),
|
||||
(None, _) => [0.0; 3],
|
||||
};
|
||||
// Each row: its letter, its screen-reader name, the end of its range and the field's suffix. The
|
||||
// names start with "HSL" so that they differ from the box strip's HSB Hue and Saturation.
|
||||
let hsl_name = |name: &str| format!("HSL {name}");
|
||||
let rows =
|
||||
[("H", hsl_name(tl!("Hue")), 360.0, "°"), ("S", hsl_name(tl!("Saturation")), 100.0, "%"), ("L", hsl_name(tl!("Lightness")), 100.0, "%")];
|
||||
let shown = [f64::from(hsl[0]), f64::from(hsl[1]) * 100.0, f64::from(hsl[2]) * 100.0];
|
||||
// The HSL with row `i` set to `v` in the row's units.
|
||||
let with = |i: usize, v: f64| {
|
||||
let mut out = hsl;
|
||||
match i {
|
||||
0 => out[0] = v.clamp(0.0, 360.0) as f32,
|
||||
1 => out[1] = (v / 100.0).clamp(0.0, 1.0) as f32,
|
||||
_ => out[2] = (v / 100.0).clamp(0.0, 1.0) as f32,
|
||||
}
|
||||
out
|
||||
};
|
||||
let mut out = None;
|
||||
ui.add_enabled_ui(enabled, |ui| {
|
||||
let field_w = 48.0;
|
||||
let slider_w = (ui.available_width() - field_w - 12.0 - 3.0 * ui.spacing().item_spacing.x).max(60.0);
|
||||
for (i, (letter, name, max, suffix)) in rows.into_iter().enumerate() {
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_sized(vec2(12.0, 22.0), egui::Label::new(egui::RichText::new(letter).size(12.5).color(t.text)));
|
||||
let v = shown[i].clamp(0.0, max);
|
||||
let at = |x: f32| with(i, f64::from(x) * max);
|
||||
let track = |x: f32| if enabled { hsl32(at(x)) } else { t.input };
|
||||
let value = SliderValue::field(v, 0.0..=max, suffix, 0);
|
||||
let (dragged, phase, keyed) =
|
||||
widgets::color_slider_stepped(ui, ("color-wheel-hsl", i), &name, Some(value), (v / max) as f32, slider_w, &track);
|
||||
if let Some(x) = dragged {
|
||||
out = Some((at(x), phase));
|
||||
}
|
||||
if let Some(k) = keyed {
|
||||
out = Some((with(i, k), Live::Released));
|
||||
}
|
||||
if let Some(f) = widgets::plain_field_named(ui, ("color-wheel-hsl-field", i), Some(&name), v, suffix, 0, field_w) {
|
||||
out = Some((with(i, f), Live::Released));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
out.filter(|_| enabled)
|
||||
}
|
||||
|
||||
pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
let tgt = wheel_target(app, ui);
|
||||
let color = tgt.color();
|
||||
let cms = cms::active();
|
||||
// With None, a pattern or a "?" proxy the wheel shows the last solid color without markers,
|
||||
// and a click, an arrow key or a screen reader's action applies the picked color.
|
||||
let hsb = match (color, pstate::<Option<(Owner, [f32; 3], [f32; 3])>>(ui.ctx(), MEMORY)) {
|
||||
(Some(c), Some((owner, shown, hsb))) if owner == Owner::of(app, &tgt, c) => remembered_hsb(&cms, &c, shown, hsb),
|
||||
let hsb = match (color, recall::<[f32; 3]>(app, ui, MEMORY, &tgt, color, &cms)) {
|
||||
(Some(c), Some((shown, hsb))) => remembered_hsb(&cms, &c, shown, hsb),
|
||||
(c, _) => display_hsb(&cms, &c.unwrap_or(app.session.last_solid)),
|
||||
};
|
||||
let marked = color.is_some();
|
||||
@@ -512,16 +840,80 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
pick = Some(([hsb[0], x, 1.0 - y], field_phase));
|
||||
}
|
||||
});
|
||||
let (mut picked_lch, mut picked_hsl) = (None, None);
|
||||
match app.ui.color_wheel.sliders {
|
||||
Sliders::None => {}
|
||||
Sliders::Oklch => {
|
||||
ui.add_space(4.0);
|
||||
picked_lch = oklch_rows(app, ui, &tgt, color, &cms);
|
||||
}
|
||||
Sliders::Hsl => {
|
||||
ui.add_space(4.0);
|
||||
picked_hsl = hsl_rows(app, ui, &tgt, color, &cms);
|
||||
}
|
||||
}
|
||||
// A row drag whose rows were hidden or replaced (`ui.colorWheel {sliders}`), or turned gray
|
||||
// (OKLCH rows after the working RGB space stops being sRGB), reports no release: its preview is
|
||||
// kept as one undo step and the interaction ends.
|
||||
let live = pstate::<Option<Sliders>>(ui.ctx(), ROWS_LIVE);
|
||||
if live.is_some_and(|rows| rows != app.ui.color_wheel.sliders || (rows == Sliders::Oklch && !cms.rgb_is_srgb())) {
|
||||
if app.session.in_interaction()
|
||||
&& let Err(e) = app.session.commit_interaction()
|
||||
{
|
||||
app.status(e.to_string());
|
||||
}
|
||||
app.sync_views();
|
||||
set_pstate(ui.ctx(), ROWS_LIVE, None::<Sliders>);
|
||||
}
|
||||
if app.ui.color_wheel.vision {
|
||||
ui.add_space(4.0);
|
||||
vision_row(ui, &cms, color.as_ref());
|
||||
}
|
||||
let Some((hsb, phase)) = pick else { return };
|
||||
let behind = super::alt_held(ui);
|
||||
let cmyk_doc = app.session.active().is_some_and(|d| d.doc.color_mode == ColorMode::Cmyk);
|
||||
let rows = match (picked_hsl, picked_lch) {
|
||||
(Some((hsl, phase)), _) => Some((hsl_to_rgb(hsl), phase, HSL_MEMORY, Remembered::Hsl(hsl))),
|
||||
(_, Some((lch, phase))) => Some((oklab::from_oklch(lch[0], lch[1], lch[2]).0, phase, OKLCH_MEMORY, Remembered::Oklch(lch))),
|
||||
_ => None,
|
||||
};
|
||||
if let Some((srgb, phase, key, asked)) = rows {
|
||||
// A hue on a gray, or a saturation on black or white, leaves the displayed color as it is:
|
||||
// the rows keep what they were given, and the paint (a Gray color too) stays unchanged.
|
||||
let current = color.filter(|c| {
|
||||
let d = cms.display_rgb(c);
|
||||
!behind && live.is_none() && (0..3).all(|i| (d[i] - srgb[i]).abs() <= 1e-5)
|
||||
});
|
||||
if let Some(c) = current {
|
||||
asked.remember(ui, key, Owner::of(app, &tgt, c), cms.display_rgb(&c));
|
||||
return;
|
||||
}
|
||||
let c = stored_srgb(&cms, srgb, replaced(app, &tgt, behind).as_ref(), cmyk_doc);
|
||||
apply(app, &tgt, c, phase, behind);
|
||||
set_pstate(ui.ctx(), ROWS_LIVE, (phase == Live::Dragging).then_some(app.ui.color_wheel.sliders));
|
||||
if !behind {
|
||||
asked.remember(ui, key, Owner::of(app, &tgt, c), cms.display_rgb(&c));
|
||||
}
|
||||
return;
|
||||
}
|
||||
let Some((hsb, phase)) = pick else { return };
|
||||
let c = stored(&cms, hsb, replaced(app, &tgt, behind).as_ref(), cmyk_doc);
|
||||
apply(app, &tgt, c, phase, behind);
|
||||
if !behind {
|
||||
set_pstate(ui.ctx(), MEMORY, Some((Owner::of(app, &tgt, c), cms.display_rgb(&c), hsb)));
|
||||
}
|
||||
}
|
||||
|
||||
/// What a slider row asked for, kept under its memory key.
|
||||
enum Remembered {
|
||||
Hsl([f32; 3]),
|
||||
Oklch([f64; 3]),
|
||||
}
|
||||
|
||||
impl Remembered {
|
||||
fn remember(self, ui: &Ui, key: &str, owner: Owner, shown: [f32; 3]) {
|
||||
match self {
|
||||
Remembered::Hsl(v) => set_pstate(ui.ctx(), key, Some((owner, shown, v))),
|
||||
Remembered::Oklch(v) => set_pstate(ui.ctx(), key, Some((owner, shown, v))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,9 @@ use vectorcraft_color::cms::{self, Cms, ColorSettings, delta_e2000};
|
||||
use vectorcraft_color::{Color, Paint};
|
||||
use vectorcraft_engine::Session;
|
||||
|
||||
use super::color_wheel::{ID, display_hsb, remembered_hsb, show, stored};
|
||||
use super::color_wheel::{
|
||||
ID, Settings, Sliders, chroma_tick, display_hsb, oklch_rows, oklch_track, remembered_hsb, remembered_hsl, remembered_oklch, set, show, stored,
|
||||
};
|
||||
use crate::VectorcraftApp;
|
||||
|
||||
/// An app with a selected rectangle filled with `fill`.
|
||||
@@ -581,3 +583,573 @@ fn the_color_pickers_field_takes_the_arrow_keys() {
|
||||
assert!(near(stepped, [after[0], after[1] + 0.01, after[2]], [1e-3, 1e-4, 1e-4]), "{after:?} → {stepped:?}");
|
||||
assert!(h.state().ui.dialog.is_some(), "the dialog stays open");
|
||||
}
|
||||
|
||||
/// The panel with OKLCH Sliders shown, in a flyout tall enough for the rows.
|
||||
fn oklch_harness(mut app: VectorcraftApp) -> Harness<'static, VectorcraftApp> {
|
||||
app.run("ui.colorWheel", json!({"sliders": "oklch"})).unwrap();
|
||||
oklch_harness_shown(app)
|
||||
}
|
||||
|
||||
/// The panel in a flyout tall enough for the rows, with the app's settings as they are.
|
||||
fn oklch_harness_shown(app: VectorcraftApp) -> Harness<'static, VectorcraftApp> {
|
||||
let mut h = Harness::builder().with_size(vec2(260.0, 420.0)).build_ui_state(
|
||||
|ui, app: &mut VectorcraftApp| {
|
||||
show(app, ui);
|
||||
crate::shortcuts::handle(app, ui.ctx());
|
||||
},
|
||||
app,
|
||||
);
|
||||
h.run_steps(2);
|
||||
h
|
||||
}
|
||||
|
||||
/// The slider row named `name` (its number field has the same name).
|
||||
fn oklch_slider<'a>(h: &'a Harness<'static, VectorcraftApp>, name: &'a str) -> egui_kittest::Node<'a> {
|
||||
h.query_all_by_label(name).find(|n| n.accesskit_node().role() == egui::accesskit::Role::Slider).expect("a slider row")
|
||||
}
|
||||
|
||||
/// The point at `t` (0..1) along the bar of a slider row.
|
||||
fn on_rail(rail: Rect, t: f32) -> Pos2 {
|
||||
Pos2::new(rail.left() + 4.0 + t * (rail.width() - 8.0), rail.top() + 7.0)
|
||||
}
|
||||
|
||||
fn fill_oklch(app: &VectorcraftApp) -> [f64; 3] {
|
||||
vectorcraft_color::oklab::to_oklch(cms::active().display_rgb(&fill(app)))
|
||||
}
|
||||
|
||||
/// `ui.colorWheel {sliders: "oklch"}` shows L, C and H rows with the fill's OKLCH, and the panel
|
||||
/// keeps the setting with the preferences.
|
||||
#[test]
|
||||
fn oklch_sliders_show_the_fills_lightness_chroma_and_hue() {
|
||||
let h = oklch_harness(app(json!("#ff0000")));
|
||||
assert_eq!(h.state().ui.color_wheel.sliders, Sliders::Oklch);
|
||||
let value = |name: &str| oklch_slider(&h, name).accesskit_node().numeric_value().unwrap();
|
||||
assert_eq!((value("Lightness"), value("Chroma"), value("Hue")), (63.0, 64.0, 29.0));
|
||||
let saved = serde_json::to_value(&h.state().ui).unwrap();
|
||||
assert_eq!(saved["color_wheel"]["sliders"], json!("oklch"));
|
||||
}
|
||||
|
||||
/// A drag on L past the chroma sRGB holds stores the largest chroma that fits at the same hue, and
|
||||
/// the C row keeps the chroma asked for, so dragging L back brings it back.
|
||||
#[test]
|
||||
fn a_drag_on_lightness_keeps_the_chroma_asked_for() {
|
||||
let mut h = oklch_harness(app(json!("#0000ff")));
|
||||
let [l0, c0, h0] = fill_oklch(h.state());
|
||||
let rail = oklch_slider(&h, "Lightness").rect();
|
||||
drag(&mut h, &[on_rail(rail, l0 as f32), on_rail(rail, 0.9)], Modifiers::NONE);
|
||||
let [l1, c1, h1] = fill_oklch(h.state());
|
||||
assert!((l1 - 0.9).abs() < 0.01 && c1 < c0 - 0.1 && (h1 - h0).abs() < 1.0, "{:?} → {:?}", [l0, c0, h0], [l1, c1, h1]);
|
||||
let chroma = oklch_slider(&h, "Chroma").accesskit_node().numeric_value().unwrap();
|
||||
assert_eq!(chroma, (c0 / 0.4 * 100.0).round(), "the C row keeps the requested chroma");
|
||||
drag(&mut h, &[on_rail(rail, 0.9), on_rail(rail, l0 as f32)], Modifiers::NONE);
|
||||
let [l2, c2, _] = fill_oklch(h.state());
|
||||
assert!((l2 - l0).abs() < 0.01 && (c2 - c0).abs() < 0.01, "{:?} → {:?}", [l0, c0], [l2, c2]);
|
||||
}
|
||||
|
||||
/// A press on a row gives it the keyboard focus, and → raises it by one unit as one undo step.
|
||||
/// Each row reports its range and the adjust actions to screen readers.
|
||||
#[test]
|
||||
fn the_oklch_rows_take_the_arrow_keys_and_screen_readers_actions() {
|
||||
let mut h = oklch_harness(app(json!("#808080")));
|
||||
for (name, max) in [("Lightness", 100.0), ("Chroma", 100.0), ("Hue", 360.0)] {
|
||||
let node = oklch_slider(&h, name).accesskit_node();
|
||||
assert_eq!((node.min_numeric_value(), node.max_numeric_value(), node.numeric_value_step()), (Some(0.0), Some(max), Some(1.0)), "{name}");
|
||||
assert!([Action::Increment, Action::Decrement, Action::SetValue].iter().all(|a| node.data().supports_action(*a)), "{name}");
|
||||
}
|
||||
let rail = oklch_slider(&h, "Lightness").rect();
|
||||
let l = fill_oklch(h.state())[0];
|
||||
click(&mut h, on_rail(rail, l as f32), Modifiers::NONE);
|
||||
let before = fill_oklch(h.state())[0];
|
||||
let undo = undo_len(h.state());
|
||||
key(&mut h, egui::Key::ArrowRight, Modifiers::NONE);
|
||||
let after = fill_oklch(h.state())[0];
|
||||
assert!((after - ((before * 100.0).round() + 1.0) / 100.0).abs() < 0.003, "{before} → {after}");
|
||||
assert_eq!(undo_len(h.state()), undo + 1, "one undo step");
|
||||
let (gray, undo) = (fill(h.state()), undo_len(h.state()));
|
||||
let (target_node, target_tree) = oklch_slider(&h, "Hue").accesskit_node().locate();
|
||||
let data = Some(ActionData::NumericValue(200.0));
|
||||
h.event(Event::AccessKitActionRequest(ActionRequest { target_node, target_tree, action: Action::SetValue, data }));
|
||||
// The frame that takes the request draws the row before it applies it.
|
||||
h.run_steps(2);
|
||||
assert_eq!(oklch_slider(&h, "Hue").accesskit_node().numeric_value(), Some(200.0), "a gray keeps the hue it was given");
|
||||
assert_eq!((fill(h.state()), undo_len(h.state())), (gray, undo), "a hue on a gray changes nothing and records no undo step");
|
||||
}
|
||||
|
||||
/// Each track dims the colors outside sRGB, and the C track's tick sits at the largest chroma sRGB
|
||||
/// holds, along the track's 0 to 0.4.
|
||||
#[test]
|
||||
fn the_oklch_tracks_dim_the_colors_outside_srgb_and_the_tick_marks_the_largest_chroma() {
|
||||
let (l, h) = (0.7, 150.0);
|
||||
let max = vectorcraft_color::oklab::max_chroma(l, h);
|
||||
for max_chroma in [Some(max), None] {
|
||||
assert_eq!(oklch_track([l, max * 0.5, h], max_chroma).a(), 255, "{max_chroma:?}: inside sRGB");
|
||||
assert!(oklch_track([l, 0.4, h], max_chroma).a() < 255, "{max_chroma:?}: outside sRGB is dimmed");
|
||||
}
|
||||
// Near white, an L or H track shows the color a pick there stores: the largest chroma that fits,
|
||||
// not each channel clamped on its own.
|
||||
let (stored, lowered) = vectorcraft_color::oklab::from_oklch(0.98, 0.2, h);
|
||||
let [r, g, b] = stored.map(|v| (f64::from(v).clamp(0.0, 1.0) * 255.0).round() as u8);
|
||||
assert!(lowered);
|
||||
assert_eq!(oklch_track([0.98, 0.2, h], None), egui::Color32::from_rgb(r, g, b).gamma_multiply(0.3));
|
||||
// At blue's L and H the ray leaves sRGB below the largest chroma and comes back at blue: the C
|
||||
// track dims that gap and shows the color a pick there stores.
|
||||
let [bl, _, bh] = vectorcraft_color::oklab::to_oklch([0.0, 0.0, 1.0]);
|
||||
let blue_max = vectorcraft_color::oklab::max_chroma(bl, bh);
|
||||
let (stored, lowered) = vectorcraft_color::oklab::from_oklch(bl, 0.29, bh);
|
||||
let [r, g, b] = stored.map(|v| (f64::from(v).clamp(0.0, 1.0) * 255.0).round() as u8);
|
||||
assert!(lowered && blue_max > 0.3);
|
||||
assert_eq!(oklch_track([bl, 0.29, bh], Some(blue_max)), egui::Color32::from_rgb(r, g, b).gamma_multiply(0.3));
|
||||
assert_eq!(oklch_track([bl, blue_max, bh], Some(blue_max)).a(), 255, "blue itself is inside sRGB");
|
||||
assert!((chroma_tick(max) - (max / 0.4) as f32).abs() < 1e-6 && chroma_tick(max) > 0.1 && chroma_tick(max) < 1.0);
|
||||
assert_eq!((chroma_tick(0.0), chroma_tick(0.5)), (0.0, 1.0));
|
||||
}
|
||||
|
||||
/// After Edit › Color Settings picks a working RGB space other than sRGB, Panel menu › OKLCH Sliders
|
||||
/// is gray and `ui.colorWheel {sliders: "oklch"}` answers an error; rows already shown are gray.
|
||||
#[test]
|
||||
fn oklch_sliders_are_gray_after_the_working_space_changes() {
|
||||
const CHILD: &str = "VECTORCRAFT_TEST_COLOR_WHEEL_P3";
|
||||
if std::env::var_os(CHILD).is_none() {
|
||||
// Color settings are process-wide: change them in a separate test process.
|
||||
let output = std::process::Command::new(std::env::current_exe().unwrap())
|
||||
.args(["--exact", "panels::tests_color_wheel::oklch_sliders_are_gray_after_the_working_space_changes", "--nocapture"])
|
||||
.env(CHILD, "1")
|
||||
.output()
|
||||
.unwrap();
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
assert!(
|
||||
output.status.success() && stdout.contains("test result: ok. 1 passed; 0 failed;"),
|
||||
"isolated working space test failed:\n{stdout}\n{}",
|
||||
String::from_utf8_lossy(&output.stderr),
|
||||
);
|
||||
return;
|
||||
}
|
||||
let mut app = app(json!("#ff0000"));
|
||||
app.run("edit.colorSettings", json!({"rgb": cms::DISPLAY_P3})).unwrap();
|
||||
assert_eq!(app.run("ui.colorWheel", json!({"sliders": "oklch"})).unwrap_err(), "OKLCH needs sRGB as the working RGB space");
|
||||
assert_eq!(app.ui.color_wheel.sliders, Sliders::None);
|
||||
let mut fonts = false;
|
||||
let mut h = Harness::builder().with_size(vec2(260.0, 200.0)).build_ui_state(
|
||||
move |ui, app: &mut VectorcraftApp| {
|
||||
if !fonts {
|
||||
crate::theme::install_fonts(ui.ctx());
|
||||
fonts = true;
|
||||
return;
|
||||
}
|
||||
super::color_wheel::menu(app, ui);
|
||||
},
|
||||
app,
|
||||
);
|
||||
h.run_steps(3);
|
||||
assert!(h.get_by_label(" OKLCH Sliders").accesskit_node().is_disabled());
|
||||
// The color settings stay with the process, so a new app works in Display P3 as well.
|
||||
let mut app = self::app(json!("#ff0000"));
|
||||
app.ui.color_wheel.sliders = Sliders::Oklch;
|
||||
let h = oklch_harness_shown(app);
|
||||
assert!(oklch_slider(&h, "Lightness").accesskit_node().is_disabled());
|
||||
}
|
||||
|
||||
/// A drag on an OKLCH row during which Edit › Color Settings picks a working RGB space other than
|
||||
/// sRGB keeps the color the drag previewed as one undo step and leaves no interaction open, though
|
||||
/// the gray rows report no release.
|
||||
#[test]
|
||||
fn a_working_space_change_during_an_oklch_drag_keeps_its_color_as_one_undo_step() {
|
||||
const CHILD: &str = "VECTORCRAFT_TEST_COLOR_WHEEL_P3_DRAG";
|
||||
if std::env::var_os(CHILD).is_none() {
|
||||
// Color settings are process-wide: change them in a separate test process.
|
||||
let output = std::process::Command::new(std::env::current_exe().unwrap())
|
||||
.args([
|
||||
"--exact",
|
||||
"panels::tests_color_wheel::a_working_space_change_during_an_oklch_drag_keeps_its_color_as_one_undo_step",
|
||||
"--nocapture",
|
||||
])
|
||||
.env(CHILD, "1")
|
||||
.output()
|
||||
.unwrap();
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
assert!(
|
||||
output.status.success() && stdout.contains("test result: ok. 1 passed; 0 failed;"),
|
||||
"isolated working space test failed:\n{stdout}\n{}",
|
||||
String::from_utf8_lossy(&output.stderr),
|
||||
);
|
||||
return;
|
||||
}
|
||||
let mut h = oklch_harness(app(json!("#ff8000")));
|
||||
let rail = oklch_slider(&h, "Lightness").rect();
|
||||
let undo = undo_len(h.state());
|
||||
press(&mut h, on_rail(rail, 0.5), true, Modifiers::NONE);
|
||||
for _ in 0..2 {
|
||||
h.event(Event::PointerMoved(on_rail(rail, 0.25)));
|
||||
h.run_steps(1);
|
||||
}
|
||||
assert!(h.state().session.in_interaction(), "the drag previews");
|
||||
let previewed = fill(h.state());
|
||||
h.state_mut().run("edit.colorSettings", json!({"rgb": cms::DISPLAY_P3})).unwrap();
|
||||
h.run_steps(2);
|
||||
assert!(oklch_slider(&h, "Lightness").accesskit_node().is_disabled());
|
||||
press(&mut h, on_rail(rail, 0.25), false, Modifiers::NONE);
|
||||
assert!(!h.state().session.in_interaction(), "the interaction ended");
|
||||
assert_eq!((fill(h.state()), undo_len(h.state())), (previewed, undo + 1));
|
||||
}
|
||||
|
||||
/// A CMYK fill's L, C and H are those of its display color, not of its naive separation.
|
||||
#[test]
|
||||
fn a_cmyk_fills_oklch_is_that_of_its_display_color() {
|
||||
let h = oklch_harness(app(json!({"c": 1.0, "m": 0.0, "y": 0.0, "k": 0.0})));
|
||||
let shown = vectorcraft_color::oklab::to_oklch(cms::active().display_rgb(&Color::cmyk(1.0, 0.0, 0.0, 0.0)));
|
||||
let naive = vectorcraft_color::oklab::to_oklch([0.0, 1.0, 1.0]);
|
||||
let lightness = oklch_slider(&h, "Lightness").accesskit_node().numeric_value().unwrap();
|
||||
assert_eq!(lightness, (shown[0] * 100.0).round());
|
||||
assert_ne!(lightness, (naive[0] * 100.0).round());
|
||||
}
|
||||
|
||||
/// Panel menu › OKLCH Sliders shows the rows and, checked, hides them.
|
||||
#[test]
|
||||
fn the_panel_menu_shows_and_hides_the_oklch_rows() {
|
||||
let mut fonts = false;
|
||||
let mut h = Harness::builder().with_size(vec2(260.0, 200.0)).build_ui_state(
|
||||
move |ui, app: &mut VectorcraftApp| {
|
||||
// The fonts, which hold the check mark, take effect from the next frame.
|
||||
if !fonts {
|
||||
crate::theme::install_fonts(ui.ctx());
|
||||
fonts = true;
|
||||
return;
|
||||
}
|
||||
super::color_wheel::menu(app, ui);
|
||||
},
|
||||
app(json!("#ff0000")),
|
||||
);
|
||||
h.run_steps(3);
|
||||
h.get_by_label(" OKLCH Sliders").click();
|
||||
h.run_steps(2);
|
||||
assert_eq!(h.state().ui.color_wheel.sliders, Sliders::Oklch);
|
||||
h.get_by_label("✓ OKLCH Sliders").click();
|
||||
h.run_steps(2);
|
||||
assert_eq!(h.state().ui.color_wheel.sliders, Sliders::None);
|
||||
}
|
||||
|
||||
/// In a working RGB space other than sRGB, `sliders: "oklch"` is an error and the rows are gray;
|
||||
/// the error leaves the settings as they were.
|
||||
#[test]
|
||||
fn oklch_sliders_need_srgb_as_the_working_space() {
|
||||
let p3 = Cms::new(&ColorSettings { rgb: cms::DISPLAY_P3.into(), ..ColorSettings::default() }).unwrap();
|
||||
let mut settings = Settings::default();
|
||||
assert_eq!(set(&mut settings, &json!({"sliders": "oklch"}), &p3).unwrap_err(), "OKLCH needs sRGB as the working RGB space");
|
||||
assert_eq!(settings.sliders, Sliders::None);
|
||||
set(&mut settings, &json!({"sliders": "oklch"}), &Cms::default()).unwrap();
|
||||
assert_eq!(settings.sliders, Sliders::Oklch);
|
||||
set(&mut settings, &json!({"sliders": "none"}), &p3).unwrap();
|
||||
assert_eq!(settings.sliders, Sliders::None, "the rows can be hidden in any working space");
|
||||
let mut h = Harness::builder().with_size(vec2(260.0, 200.0)).build_ui_state(
|
||||
move |ui, app: &mut VectorcraftApp| {
|
||||
let tgt = super::color::wheel_target(app, ui);
|
||||
let color = tgt.color();
|
||||
let picked = oklch_rows(app, ui, &tgt, color, &p3);
|
||||
assert!(picked.is_none(), "a gray row picks nothing: {picked:?}");
|
||||
},
|
||||
app(json!("#ff0000")),
|
||||
);
|
||||
h.run_steps(2);
|
||||
assert!(oklch_slider(&h, "Lightness").accesskit_node().is_disabled());
|
||||
let rail = oklch_slider(&h, "Lightness").rect();
|
||||
click(&mut h, on_rail(rail, 0.2), Modifiers::NONE);
|
||||
key(&mut h, egui::Key::ArrowRight, Modifiers::NONE);
|
||||
set_slider_value(&mut h, "Lightness", 20.0);
|
||||
}
|
||||
|
||||
/// The rows show what they asked for while the color displays as it did, and the color's own
|
||||
/// OKLCH after the color settings change its display.
|
||||
#[test]
|
||||
fn the_remembered_oklch_follows_a_change_of_working_space() {
|
||||
let srgb = Cms::default();
|
||||
let p3 = Cms::new(&ColorSettings { rgb: cms::DISPLAY_P3.into(), ..ColorSettings::default() }).unwrap();
|
||||
let c = Color::rgb(0.5, 0.3, 0.2);
|
||||
let asked = [0.5, 0.3, 40.0];
|
||||
let shown = srgb.display_rgb(&c);
|
||||
assert_eq!(remembered_oklch(&srgb, &c, shown, asked), asked);
|
||||
assert_eq!(remembered_oklch(&p3, &c, shown, asked), vectorcraft_color::oklab::to_oklch(p3.display_rgb(&c)));
|
||||
}
|
||||
|
||||
/// The panel with HSL Sliders shown, in a flyout tall enough for the rows. `oklch_slider` and
|
||||
/// `oklch_harness_shown` find and draw any slider row, the HSL rows included.
|
||||
fn hsl_harness(mut app: VectorcraftApp) -> Harness<'static, VectorcraftApp> {
|
||||
app.run("ui.colorWheel", json!({"sliders": "hsl"})).unwrap();
|
||||
oklch_harness_shown(app)
|
||||
}
|
||||
|
||||
fn fill_hsl(app: &VectorcraftApp) -> [f32; 3] {
|
||||
vectorcraft_color::rgb_to_hsl(cms::active().display_rgb(&fill(app)))
|
||||
}
|
||||
|
||||
/// Sets the slider row named `name` to `v` as a screen reader does.
|
||||
fn set_slider_value(h: &mut Harness<'static, VectorcraftApp>, name: &str, v: f64) {
|
||||
let (target_node, target_tree) = oklch_slider(h, name).accesskit_node().locate();
|
||||
let data = Some(ActionData::NumericValue(v));
|
||||
h.event(Event::AccessKitActionRequest(ActionRequest { target_node, target_tree, action: Action::SetValue, data }));
|
||||
// The frame that takes the request draws the row before it applies it.
|
||||
h.run_steps(2);
|
||||
}
|
||||
|
||||
/// `ui.colorWheel {sliders: "hsl"}` shows H, S and L rows with the fill's HSL, CSS Color 4's
|
||||
/// `hsl()` of its display sRGB, and the panel keeps the setting with the preferences.
|
||||
#[test]
|
||||
fn hsl_sliders_show_the_fills_hue_saturation_and_lightness() {
|
||||
let h = hsl_harness(app(json!("#ff8000")));
|
||||
assert_eq!(h.state().ui.color_wheel.sliders, Sliders::Hsl);
|
||||
let value = |name: &str| oklch_slider(&h, name).accesskit_node().numeric_value().unwrap();
|
||||
assert_eq!((value("HSL Hue"), value("HSL Saturation"), value("HSL Lightness")), (30.0, 100.0, 50.0));
|
||||
assert!(h.query_by_label("Chroma").is_none(), "OKLCH Sliders are hidden");
|
||||
let saved = serde_json::to_value(&h.state().ui).unwrap();
|
||||
assert_eq!(saved["color_wheel"]["sliders"], json!("hsl"));
|
||||
}
|
||||
|
||||
/// In Box View with the Saturation channel, screen readers tell the box strip's HSB saturation
|
||||
/// from the S row's HSL saturation by their names.
|
||||
#[test]
|
||||
fn the_hsl_rows_names_differ_from_the_box_strips() {
|
||||
let mut app = app(json!("#996633"));
|
||||
app.run("ui.colorWheel", json!({"view": "box", "channel": "saturation"})).unwrap();
|
||||
let h = hsl_harness(app);
|
||||
let sliders = |name: &str| h.query_all_by_label(name).filter(|n| n.accesskit_node().role() == egui::accesskit::Role::Slider).count();
|
||||
assert_eq!((sliders("Saturation"), sliders("HSL Saturation")), (1, 1));
|
||||
let strip = oklch_slider(&h, "Saturation").accesskit_node().numeric_value().unwrap();
|
||||
let row = oklch_slider(&h, "HSL Saturation").accesskit_node().numeric_value().unwrap();
|
||||
assert_ne!(strip, row, "HSB and HSL saturation differ for this color");
|
||||
}
|
||||
|
||||
/// A drag on L changes the lightness and keeps the hue and the saturation.
|
||||
#[test]
|
||||
fn a_drag_on_hsl_lightness_keeps_the_hue_and_saturation() {
|
||||
let mut h = hsl_harness(app(json!("#ff8000")));
|
||||
let rail = oklch_slider(&h, "HSL Lightness").rect();
|
||||
let undo = undo_len(h.state());
|
||||
drag(&mut h, &[on_rail(rail, 0.5), on_rail(rail, 0.25)], Modifiers::NONE);
|
||||
assert!(near(fill_hsl(h.state()), [30.0, 1.0, 0.25], [1.0, 0.01, 0.01]), "{:?}", fill_hsl(h.state()));
|
||||
assert_eq!(undo_len(h.state()), undo + 1, "a drag is one undo step");
|
||||
}
|
||||
|
||||
/// A press on S gives it the keyboard focus, and → raises it by 1 % as one undo step. Each row
|
||||
/// reports its range and the adjust actions to screen readers.
|
||||
#[test]
|
||||
fn the_hsl_rows_take_the_arrow_keys_and_screen_readers_actions() {
|
||||
let mut h = hsl_harness(app(json!("#996633")));
|
||||
for (name, max) in [("HSL Hue", 360.0), ("HSL Saturation", 100.0), ("HSL Lightness", 100.0)] {
|
||||
let node = oklch_slider(&h, name).accesskit_node();
|
||||
assert_eq!((node.min_numeric_value(), node.max_numeric_value(), node.numeric_value_step()), (Some(0.0), Some(max), Some(1.0)), "{name}");
|
||||
assert!([Action::Increment, Action::Decrement, Action::SetValue].iter().all(|a| node.data().supports_action(*a)), "{name}");
|
||||
}
|
||||
let rail = oklch_slider(&h, "HSL Saturation").rect();
|
||||
let s = fill_hsl(h.state())[1];
|
||||
click(&mut h, on_rail(rail, s), Modifiers::NONE);
|
||||
let before = fill_hsl(h.state());
|
||||
let undo = undo_len(h.state());
|
||||
key(&mut h, egui::Key::ArrowRight, Modifiers::NONE);
|
||||
let after = fill_hsl(h.state());
|
||||
let raised = ((before[1] * 100.0).round() + 1.0) / 100.0;
|
||||
assert!(near(after, [before[0], raised, before[2]], [1.0, 0.008, 0.003]), "{before:?} → {after:?}");
|
||||
assert_eq!(undo_len(h.state()), undo + 1, "one undo step");
|
||||
}
|
||||
|
||||
/// A gray has no hue: a hue given to it stays on the H row while the color is unchanged, and a
|
||||
/// saturation picked next uses that hue.
|
||||
#[test]
|
||||
fn a_gray_keeps_the_hsl_hue_it_was_given() {
|
||||
let mut h = hsl_harness(app(json!("#808080")));
|
||||
let (gray, undo) = (fill(h.state()), undo_len(h.state()));
|
||||
set_slider_value(&mut h, "HSL Hue", 200.0);
|
||||
assert_eq!(oklch_slider(&h, "HSL Hue").accesskit_node().numeric_value(), Some(200.0), "a gray keeps the hue it was given");
|
||||
assert_eq!((fill(h.state()), undo_len(h.state())), (gray, undo), "a hue on a gray changes nothing and records no undo step");
|
||||
set_slider_value(&mut h, "HSL Saturation", 60.0);
|
||||
let got = fill_hsl(h.state());
|
||||
assert!(near(got, [200.0, 0.6, 0.5], [1.0, 0.01, 0.01]), "{got:?}");
|
||||
}
|
||||
|
||||
/// In a working RGB space wider than sRGB, an HSL pick goes from display sRGB into that space
|
||||
/// through the color settings: the fill displays the HSL asked for, and its stored RGB numbers are
|
||||
/// those of the working space, not the sRGB numbers of that HSL.
|
||||
#[test]
|
||||
fn an_hsl_pick_in_display_p3_goes_into_the_working_space() {
|
||||
const CHILD: &str = "VECTORCRAFT_TEST_COLOR_WHEEL_HSL_P3";
|
||||
if std::env::var_os(CHILD).is_none() {
|
||||
// Color settings are process-wide: change them in a separate test process.
|
||||
let output = std::process::Command::new(std::env::current_exe().unwrap())
|
||||
.args(["--exact", "panels::tests_color_wheel::an_hsl_pick_in_display_p3_goes_into_the_working_space", "--nocapture"])
|
||||
.env(CHILD, "1")
|
||||
.output()
|
||||
.unwrap();
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
assert!(
|
||||
output.status.success() && stdout.contains("test result: ok. 1 passed; 0 failed;"),
|
||||
"isolated working space test failed:\n{stdout}\n{}",
|
||||
String::from_utf8_lossy(&output.stderr),
|
||||
);
|
||||
return;
|
||||
}
|
||||
let mut app = app(json!("#996633"));
|
||||
app.run("edit.colorSettings", json!({"rgb": cms::DISPLAY_P3})).unwrap();
|
||||
let mut h = hsl_harness(app);
|
||||
let [hue, sat, _] = fill_hsl(h.state());
|
||||
let undo = undo_len(h.state());
|
||||
set_slider_value(&mut h, "HSL Lightness", 60.0);
|
||||
let asked = [hue, sat, 0.6];
|
||||
assert!(near(fill_hsl(h.state()), asked, [0.5, 0.005, 0.005]), "{asked:?} → {:?}", fill_hsl(h.state()));
|
||||
assert_eq!(undo_len(h.state()), undo + 1, "one undo step");
|
||||
let Color::Rgb { r, g, b } = fill(h.state()) else { panic!("an RGB fill stays RGB") };
|
||||
let srgb = vectorcraft_color::hsl_to_rgb(asked);
|
||||
assert!((0..3).any(|i| ([r, g, b][i] - srgb[i]).abs() > 0.01), "{:?} is stored as the sRGB numbers {srgb:?}", [r, g, b]);
|
||||
}
|
||||
|
||||
/// Panel menu › HSL Sliders shows the H, S and L rows in place of OKLCH Sliders and, checked,
|
||||
/// hides them; it is offered in any working RGB space.
|
||||
#[test]
|
||||
fn the_panel_menu_shows_and_hides_the_hsl_rows() {
|
||||
let mut fonts = false;
|
||||
let mut app = app(json!("#ff0000"));
|
||||
app.run("ui.colorWheel", json!({"sliders": "oklch"})).unwrap();
|
||||
let mut h = Harness::builder().with_size(vec2(260.0, 200.0)).build_ui_state(
|
||||
move |ui, app: &mut VectorcraftApp| {
|
||||
// The fonts, which hold the check mark, take effect from the next frame.
|
||||
if !fonts {
|
||||
crate::theme::install_fonts(ui.ctx());
|
||||
fonts = true;
|
||||
return;
|
||||
}
|
||||
super::color_wheel::menu(app, ui);
|
||||
},
|
||||
app,
|
||||
);
|
||||
h.run_steps(3);
|
||||
h.get_by_label(" HSL Sliders").click();
|
||||
h.run_steps(2);
|
||||
assert_eq!(h.state().ui.color_wheel.sliders, Sliders::Hsl);
|
||||
assert!(h.query_by_label("✓ OKLCH Sliders").is_none(), "the two slider sets show one at a time");
|
||||
h.get_by_label("✓ HSL Sliders").click();
|
||||
h.run_steps(2);
|
||||
assert_eq!(h.state().ui.color_wheel.sliders, Sliders::None);
|
||||
let p3 = Cms::new(&ColorSettings { rgb: cms::DISPLAY_P3.into(), ..ColorSettings::default() }).unwrap();
|
||||
let mut settings = Settings::default();
|
||||
set(&mut settings, &json!({"sliders": "hsl"}), &p3).unwrap();
|
||||
assert_eq!(settings.sliders, Sliders::Hsl, "HSL needs no particular working space");
|
||||
}
|
||||
|
||||
/// The rows show what they asked for while the color displays as it did, and the color's own HSL
|
||||
/// after the color settings change its display.
|
||||
#[test]
|
||||
fn the_remembered_hsl_follows_a_change_of_working_space() {
|
||||
let srgb = Cms::default();
|
||||
let p3 = Cms::new(&ColorSettings { rgb: cms::DISPLAY_P3.into(), ..ColorSettings::default() }).unwrap();
|
||||
let c = Color::rgb(0.5, 0.3, 0.2);
|
||||
let asked = [20.0, 0.43, 0.35];
|
||||
let shown = srgb.display_rgb(&c);
|
||||
assert_eq!(remembered_hsl(&srgb, &c, shown, asked), asked);
|
||||
assert_eq!(remembered_hsl(&p3, &c, shown, asked), vectorcraft_color::rgb_to_hsl(p3.display_rgb(&c)));
|
||||
}
|
||||
|
||||
/// Saved settings are read key by key: a value this version does not know (one a newer version
|
||||
/// wrote) gives the default, and the other preferences still load.
|
||||
#[test]
|
||||
fn saved_color_wheel_settings_are_read_leniently() {
|
||||
let mut saved = serde_json::to_value(crate::UiState::default()).unwrap();
|
||||
saved["color_rgb_percent"] = json!(true);
|
||||
for (value, sliders) in [
|
||||
(json!({"sliders": "oklch"}), Sliders::Oklch),
|
||||
(json!({"sliders": "hsl"}), Sliders::Hsl),
|
||||
(json!({"sliders": "hwb", "view": "box"}), Sliders::None),
|
||||
(json!(5), Sliders::None),
|
||||
] {
|
||||
saved["color_wheel"] = value.clone();
|
||||
let ui: crate::UiState = serde_json::from_value(saved.clone()).unwrap();
|
||||
assert_eq!((ui.color_wheel.sliders, ui.color_rgb_percent), (sliders, true), "{value}");
|
||||
}
|
||||
}
|
||||
|
||||
/// `ui.colorWheel {sliders}` sets the rows and keeps the view and the channel, and an unknown
|
||||
/// `sliders` value is an error that changes nothing.
|
||||
#[test]
|
||||
fn ui_color_wheel_sets_and_reads_the_sliders() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.run("ui.colorWheel", json!({"view": "box", "channel": "red"})).unwrap();
|
||||
assert_eq!(app.run("ui.colorWheel", json!({})).unwrap()["sliders"], json!("none"));
|
||||
assert_eq!(app.run("ui.colorWheel", json!({"sliders": "hwb"})).unwrap_err(), "`sliders` must be none, oklch or hsl");
|
||||
let got = app.run("ui.colorWheel", json!({"sliders": "oklch"})).unwrap();
|
||||
let want = json!({"view": "box", "channel": "red", "harmony": false, "harmonyRule": "complementary", "vision": false, "sliders": "oklch"});
|
||||
assert_eq!(got, want);
|
||||
let e = app.run("ui.colorWheel", json!({"view": "wheel", "sliders": "hwb"})).unwrap_err();
|
||||
assert_eq!(e, "`sliders` must be none, oklch or hsl");
|
||||
assert_eq!(app.ui.color_wheel.view, crate::panels::color_wheel::View::Box, "an error changes nothing");
|
||||
}
|
||||
|
||||
/// A hue given to a Gray color does not change how it displays, so its paint stays a Gray color
|
||||
/// and no undo step is recorded; the hue row keeps the hue.
|
||||
#[test]
|
||||
fn a_hue_on_a_gray_color_leaves_its_paint_gray() {
|
||||
for (rows, hue) in [("hsl", "HSL Hue"), ("oklch", "Hue")] {
|
||||
let mut app = app(json!({"gray": 0.5}));
|
||||
app.run("ui.colorWheel", json!({"sliders": rows})).unwrap();
|
||||
let mut h = oklch_harness_shown(app);
|
||||
let (gray, undo) = (fill(h.state()), undo_len(h.state()));
|
||||
assert!(matches!(gray, Color::Gray { .. }), "{gray:?}");
|
||||
set_slider_value(&mut h, hue, 200.0);
|
||||
assert_eq!(oklch_slider(&h, hue).accesskit_node().numeric_value(), Some(200.0), "{rows}");
|
||||
assert_eq!((fill(h.state()), undo_len(h.state())), (gray, undo), "{rows}: the Gray fill stays as it was");
|
||||
}
|
||||
}
|
||||
|
||||
/// For a fill outside sRGB, the HSL and OKLCH rows show the components of its display color
|
||||
/// clipped to sRGB, the color the panel shows, not of the unclipped one.
|
||||
#[test]
|
||||
fn the_rows_show_a_color_outside_srgb_clipped_to_srgb() {
|
||||
let rgb = json!([1.6, 0.2, -0.4]);
|
||||
let raw = cms::active().display_rgb(&fill(&app(rgb.clone())));
|
||||
let clipped = raw.map(|v| v.clamp(0.0, 1.0));
|
||||
assert_ne!(raw, clipped, "the fill lies outside sRGB");
|
||||
let want_hsl = (f64::from(vectorcraft_color::rgb_to_hsl(clipped)[2]) * 100.0).round();
|
||||
assert_ne!(want_hsl, (f64::from(vectorcraft_color::rgb_to_hsl(raw)[2]) * 100.0).round(), "the unclipped lightness differs");
|
||||
let h = hsl_harness(app(rgb.clone()));
|
||||
assert_eq!(oklch_slider(&h, "HSL Lightness").accesskit_node().numeric_value(), Some(want_hsl));
|
||||
let want_l = (vectorcraft_color::oklab::to_oklch(clipped)[0] * 100.0).round();
|
||||
assert_ne!(want_l, (vectorcraft_color::oklab::to_oklch(raw)[0] * 100.0).round(), "the unclipped OKLCH lightness differs");
|
||||
let h = oklch_harness(app(rgb));
|
||||
assert_eq!(oklch_slider(&h, "Lightness").accesskit_node().numeric_value(), Some(want_l));
|
||||
}
|
||||
|
||||
/// The hue given to a gray is dropped once the panel shows another color, so the same gray applied
|
||||
/// again later shows its own hue, 0°.
|
||||
#[test]
|
||||
fn a_remembered_hue_is_dropped_after_the_paint_changes() {
|
||||
for (rows, hue) in [("hsl", "HSL Hue"), ("oklch", "Hue")] {
|
||||
let mut app = app(json!("#808080"));
|
||||
app.run("ui.colorWheel", json!({"sliders": rows})).unwrap();
|
||||
let mut h = oklch_harness_shown(app);
|
||||
set_slider_value(&mut h, hue, 240.0);
|
||||
assert_eq!(oklch_slider(&h, hue).accesskit_node().numeric_value(), Some(240.0), "{rows}");
|
||||
h.state_mut().run("paint.setFill", json!({"color": "#ff0000"})).unwrap();
|
||||
h.run_steps(2);
|
||||
h.state_mut().run("paint.setFill", json!({"color": "#808080"})).unwrap();
|
||||
h.run_steps(2);
|
||||
assert_eq!(oklch_slider(&h, hue).accesskit_node().numeric_value(), Some(0.0), "{rows}: the gray's own hue");
|
||||
}
|
||||
}
|
||||
|
||||
/// Hiding the rows, or showing the other rows, during a drag on a row keeps the color the drag
|
||||
/// previewed as one undo step and leaves no interaction open.
|
||||
#[test]
|
||||
fn hiding_the_rows_during_a_drag_keeps_its_color_as_one_undo_step() {
|
||||
for rows in ["none", "oklch"] {
|
||||
let mut h = hsl_harness(app(json!("#ff8000")));
|
||||
let rail = oklch_slider(&h, "HSL Lightness").rect();
|
||||
let undo = undo_len(h.state());
|
||||
press(&mut h, on_rail(rail, 0.5), true, Modifiers::NONE);
|
||||
for _ in 0..2 {
|
||||
h.event(Event::PointerMoved(on_rail(rail, 0.25)));
|
||||
h.run_steps(1);
|
||||
}
|
||||
assert!(h.state().session.in_interaction(), "{rows}: the drag previews");
|
||||
let previewed = fill(h.state());
|
||||
h.state_mut().run("ui.colorWheel", json!({"sliders": rows})).unwrap();
|
||||
h.run_steps(2);
|
||||
press(&mut h, on_rail(rail, 0.25), false, Modifiers::NONE);
|
||||
assert!(!h.state().session.in_interaction(), "{rows}: the interaction ended");
|
||||
assert_eq!((fill(h.state()), undo_len(h.state())), (previewed, undo + 1), "{rows}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ fn the_strip_takes_the_arrow_keys_and_screen_readers_actions() {
|
||||
#[test]
|
||||
fn ui_color_wheel_sets_and_reads_the_view_and_the_channel() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
let harmony = json!({"harmony": false, "harmonyRule": "complementary", "vision": false});
|
||||
let harmony = json!({"sliders": "none", "harmony": false, "harmonyRule": "complementary", "vision": false});
|
||||
let with = |v: serde_json::Value| {
|
||||
let mut v = v;
|
||||
v.as_object_mut().unwrap().extend(harmony.as_object().unwrap().clone());
|
||||
@@ -217,9 +217,9 @@ fn ui_color_wheel_rejects_other_params() {
|
||||
let e = app.run("ui.colorWheel", json!([1])).unwrap_err();
|
||||
assert_eq!(e, "the params must be an object, not [1]");
|
||||
let e = app.run("ui.colorWheel", json!({"veiw": "wheel"})).unwrap_err();
|
||||
assert_eq!(e, "unknown parameter `veiw`; the command takes: view, channel, harmony, harmonyRule, vision");
|
||||
assert_eq!(e, "unknown parameter `veiw`; the command takes: view, channel, sliders, harmony, harmonyRule, vision");
|
||||
let e = app.run("ui.colorWheel", json!({"view": "wheel", "chanel": "blue"})).unwrap_err();
|
||||
assert_eq!(e, "unknown parameter `chanel`; the command takes: view, channel, harmony, harmonyRule, vision");
|
||||
assert_eq!(e, "unknown parameter `chanel`; the command takes: view, channel, sliders, harmony, harmonyRule, vision");
|
||||
assert_eq!(app.ui.color_wheel, Settings { view: View::Box, channel: Channel::Red, ..Default::default() }, "an error changes nothing");
|
||||
}
|
||||
|
||||
|
||||
@@ -225,8 +225,7 @@ fn the_panel_menu_turns_the_row_on_and_off() {
|
||||
#[test]
|
||||
fn ui_color_wheel_sets_and_reads_the_settings() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
let settings =
|
||||
|view: &str, vision: bool| json!({"view": view, "channel": "hue", "harmony": false, "harmonyRule": "complementary", "vision": vision});
|
||||
let settings = |view: &str, vision: bool| json!({"view": view, "channel": "hue", "harmony": false, "harmonyRule": "complementary", "vision": vision, "sliders": "none"});
|
||||
assert_eq!(app.run("ui.colorWheel", json!({})).unwrap(), settings("wheel", false));
|
||||
assert_eq!(app.run("ui.colorWheel", json!({"vision": true})).unwrap(), settings("wheel", true));
|
||||
assert_eq!(crate::control::inspect(&app, &egui::Context::default())["ui"]["color_wheel"]["vision"], true);
|
||||
@@ -237,7 +236,7 @@ fn ui_color_wheel_sets_and_reads_the_settings() {
|
||||
assert_eq!(app.run("ui.colorWheel", json!(5)).unwrap_err(), "the params must be an object, not 5");
|
||||
assert_eq!(
|
||||
app.run("ui.colorWheel", json!({"visoin": false})).unwrap_err(),
|
||||
"unknown parameter `visoin`; the command takes: view, channel, harmony, harmonyRule, vision"
|
||||
"unknown parameter `visoin`; the command takes: view, channel, sliders, harmony, harmonyRule, vision"
|
||||
);
|
||||
assert!(app.ui.color_wheel.vision);
|
||||
assert_eq!(app.run("ui.colorWheel", json!({"vision": null})).unwrap()["vision"], true);
|
||||
|
||||
@@ -825,8 +825,8 @@ pub struct UiState {
|
||||
/// of an RGB field, `ui.colorPanel`, [`crate::panels::color::deserialize_rgb_percent`]).
|
||||
#[serde(default, deserialize_with = "crate::panels::color::deserialize_rgb_percent")]
|
||||
pub color_rgb_percent: bool,
|
||||
/// Color Wheel panel: the wheel or the box, the box's channel, and the color vision row
|
||||
/// (`ui.colorWheel`, [`crate::panels::color_wheel::deserialize_settings`]).
|
||||
/// Color Wheel panel: the wheel or the box, the box's channel, the slider rows and the color
|
||||
/// vision row (`ui.colorWheel`, [`crate::panels::color_wheel::deserialize_settings`]).
|
||||
#[serde(default, deserialize_with = "crate::panels::color_wheel::deserialize_settings")]
|
||||
pub color_wheel: crate::panels::color_wheel::Settings,
|
||||
/// Swatches panel: Show Recent Colors in its panel menu, which draws the panel's Recent Colors
|
||||
|
||||
@@ -27,8 +27,8 @@ pub use blend::{
|
||||
reference_point_named,
|
||||
};
|
||||
pub use buttons::{
|
||||
SPLIT_ARROW, flat_button, flat_button_fit, icon_button, icon_button_enabled, menu_item, menu_item_name, paint_icon_button, primary_button,
|
||||
primary_button_enabled, secondary_button, split_button, split_button_named, toggle_icon,
|
||||
SPLIT_ARROW, flat_button, flat_button_fit, icon_button, icon_button_enabled, menu_item, menu_item_hint, menu_item_name, paint_icon_button,
|
||||
primary_button, primary_button_enabled, secondary_button, split_button, split_button_named, toggle_icon,
|
||||
};
|
||||
pub(crate) use buttons::{
|
||||
button_width, flat_button_fit_width, icon_button_info, menu_item_response, paint_icon_button_named, primary_button_width, secondary_button_width,
|
||||
@@ -42,7 +42,7 @@ pub use color::{
|
||||
color_slider_valued, harmony_wheel, hex_field, hex_field_named, hsb32, hue_ring, recolor_wheel, region_texture, ring_markers, ring_square,
|
||||
segment_color, segment_color_on, segmented_wheel, stepped_area, wheel_of,
|
||||
};
|
||||
pub(crate) use color::{HEX_FIELD_CHARS, focus_by_pointer, hex_text, pointer_phase};
|
||||
pub(crate) use color::{HEX_FIELD_CHARS, color_rail_bar, focus_by_pointer, hex_text, pointer_phase};
|
||||
pub use drag::{
|
||||
PanelDrag, RowClick, SwatchRows, apply_row_click, art_drag_doc, art_drop, doc_preview, drag_art, drag_ghost, drag_source, drop_target_outline,
|
||||
ghost_row, row_click,
|
||||
|
||||
@@ -230,3 +230,13 @@ fn menu_item_name_response(ui: &mut Ui, label: &str, enabled: bool, checked: boo
|
||||
let text = if checked { format!("✓ {label}") } else { format!(" {label}") };
|
||||
ui.add_enabled(enabled, egui::Button::new(egui::RichText::new(text).size(12.5)).frame_when_inactive(false))
|
||||
}
|
||||
|
||||
/// [`menu_item`] that shows `hint` under the pointer while the row is disabled, to say why it is
|
||||
/// gray.
|
||||
pub fn menu_item_hint(ui: &mut Ui, label: &str, enabled: bool, checked: bool, hint: &str) -> bool {
|
||||
let label = tl!(label);
|
||||
let text = if checked { format!("✓ {label}") } else { format!(" {label}") };
|
||||
ui.add_enabled(enabled, egui::Button::new(egui::RichText::new(text).size(12.5)).frame_when_inactive(false))
|
||||
.on_disabled_hover_text(tl!(hint))
|
||||
.clicked()
|
||||
}
|
||||
|
||||
@@ -279,6 +279,11 @@ fn rail_step(ui: &Ui, id: egui::Id, focused: bool, always: bool, s: &SliderValue
|
||||
(v != from || (end && v != s.value) || (always && asked)).then_some(if exact { v } else { round_to(v, STEP_DECIMALS).clamp(lo, hi) })
|
||||
}
|
||||
|
||||
/// The colored bar inside the rail `rect` of [`color_slider_stepped`] and its siblings.
|
||||
pub(crate) fn color_rail_bar(rect: Rect) -> Rect {
|
||||
Rect::from_min_size(pos2(rect.left() + 4.0, rect.top() + 4.0), vec2(rect.width() - 8.0, 7.0))
|
||||
}
|
||||
|
||||
/// The rail of [`color_slider_valued`] with the id `id`: its response, the new value from 0 to 1
|
||||
/// that a click or drag gives and the phase.
|
||||
fn color_rail(
|
||||
@@ -292,7 +297,7 @@ fn color_rail(
|
||||
) -> (Response, Option<f32>, Live) {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let (rect, _) = ui.allocate_exact_size(vec2(width, 22.0), Sense::hover());
|
||||
let bar = Rect::from_min_size(pos2(rect.left() + 4.0, rect.top() + 4.0), vec2(width - 8.0, 7.0));
|
||||
let bar = color_rail_bar(rect);
|
||||
let resp = ui.interact(rect, id, Sense::click_and_drag());
|
||||
gradient_strip(ui, bar, (bar.width() / 2.0).ceil().max(2.0) as usize, false, track);
|
||||
ui.painter().rect_stroke(bar, 0.0, Stroke::new(1.0, t.border), StrokeKind::Outside);
|
||||
|
||||
@@ -276,6 +276,9 @@ point (the first stop or point when none is selected). `ui.colorWheel {view?, ch
|
||||
shows the wheel or the box (a color field with a channel strip at its right), picks the box's channel, shows the
|
||||
other colors of a harmony rule as markers on the wheel's ring, and shows or hides the color vision row; it returns
|
||||
the settings, and `ui.inspect` reports them as `ui.color_wheel`.
|
||||
The key `sliders` shows OKLCH Sliders, HSL Sliders or
|
||||
neither (`"oklch"`, `"hsl"` or `"none"`; `"oklch"` is an error while the active document's RGB space, its assigned
|
||||
profile or else the working RGB space, is not sRGB), and the settings carry it too.
|
||||
|
||||
Edit Colors dialogs: `ui.colorBalanceDialog` opens Adjust Colors (`colorBalance`: fields `mode` `gray`/`rgb`/`cmyk`/
|
||||
`global`, the channels `r` `g` `b` / `c` `m` `y` `k` / `gray` / `tint` (global mode) from −100 to 100, `convert`, `fill`, `stroke`,
|
||||
|
||||
+11
@@ -689,6 +689,17 @@ each have a hue of their own (not `monochromatic`, `shades`, `complementary2`, `
|
||||
`highContrast2`). Keys left out keep their values. Params that are not an object, another key or a value off
|
||||
the list return an error and change nothing. The command returns `{view, channel, harmony, harmonyRule, vision}`,
|
||||
and the settings are kept with the preferences.
|
||||
|
||||
`ui.colorWheel {"sliders": "oklch"}` shows the Color Wheel panel's OKLCH Sliders (L, C and H rows under the wheel or
|
||||
the box), and `"none"` hides them in any RGB space. `"oklch"` is an error while the active document's RGB space is
|
||||
not sRGB: the profile assigned to the document when it has one, else the working RGB space of Edit › Color Settings.
|
||||
`ui.colorWheel {"sliders": "hsl"}` shows HSL Sliders in their place: H, S and L rows with the hue (0 to 360°),
|
||||
saturation and lightness (0 to 100 %) of the color's display sRGB, as CSS Color 4's `hsl()` defines them.
|
||||
`color.convert {"color": "#ff0000", "to": "oklch"}` answers the color's OKLCH as `[L %, C, H°]` of its display sRGB.
|
||||
A color outside sRGB (a Lab or CMYK color, an RGB color in a wider RGB space, or RGB numbers past 0 to 1) is clipped
|
||||
to sRGB first.
|
||||
The answer of `ui.colorWheel` and the settings also carry `sliders`.
|
||||
|
||||
`ui.colorWheel {"vision": true}` turns on the Color Wheel panel's Show Color Vision Preview, as its panel menu
|
||||
does: a row of four chips under the wheel or the box shows the current color through the protanopia, deuteranopia
|
||||
and tritanopia simulations of `view.proofSetup`, and for achromatopsia as the gray with the color's CIE L*. Each
|
||||
|
||||
@@ -1947,6 +1947,8 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
- **Colorized images (#1466):** a fill color applied to a selected grayscale or 1-bit image (`paint.setFill`) colorizes it with black, white, a process color or a spot color, and refuses a process color when the image has an alpha channel ([Convert color modes](https://web.archive.org/web/20251220223850/https://helpx.adobe.com/illustrator/desktop/manage-colors/select-and-adjust-colors/convert-color-modes.html), "Colorize Grayscale or 1-bit images"); black and white are accepted there too. The canvas draws each pixel in the color as far as the pixel is dark, with white pixels transparent; PDF export writes the image in the color (a spot color as its ink, Registration in every ink) with the image as its soft mask; Separations Preview and printed separations show it on its color's plates; native files keep the color. EPS and SVG write the image's own pixels.
|
||||
- **Missing library files:** a persistent swatch or graphic style library panel whose file is gone at startup reopens and stays in the preferences, showing the file's path with Locate Library… (`ui.libraryPanel.locate`), which reads the file from where it is now into the same panel.
|
||||
- **Swatch library and Recolor Artwork parameters:** the `swatch.library.*` commands, `swatch.resetDefaults`, the graphic style library save, load and add, the `recolor.*` commands and `color.harmony`'s `limitTo` refuse parameters of the wrong form, such as `names: "Grays"`, `limitTo: 5` or `includeImages: "false"`. Errors name the parameter, except that a `limitTo` that is not a string, such as `5`, gets an unknown-library error. A `null` counts as left out except for `recolor.apply`'s `model`, which must be a string when given.
|
||||
- **OKLCH Sliders (Color Wheel panel):** as VectorCraft's own addition, the Color Wheel panel's menu item OKLCH Sliders (`ui.colorWheel {sliders: "oklch"}`, kept with the preferences) shows L, C and H rows under the wheel or the box that edit the color by the OKLCH lightness (0 to 100 %), chroma (0 to 100 % of 0.4) and hue (0 to 360°) of its display sRGB, as CSS Color 4 defines them (https://www.w3.org/TR/css-color-4/#specifying-oklab-oklch). Each track dims the colors outside sRGB, and a tick on the C track marks the largest chroma sRGB holds at the row's L and H; a color outside sRGB keeps L and H and takes the largest chroma that fits, and the C row keeps the chroma asked for. The rows take the arrow keys after a click and report their names, values, ranges and adjust actions to screen readers. While the active document's RGB space (its assigned profile, else the working RGB space of Edit › Color Settings) is not sRGB, the unchecked item is gray and `ui.colorWheel {sliders: "oklch"}` answers an error; rows shown before the space changed are gray, and the checked item still hides them. `color.convert {color, to: "oklch"}` answers the same L, C and H for a color inside sRGB. For a color outside sRGB, it clips the display RGB to 0 to 1 first, so its L, C and H can differ from the rows' values. Evidence: `crates/color/src/oklab.rs` tests; `convert_to_oklch_answers_lightness_chroma_and_hue` in `crates/engine/src/tests/colormgmt.rs`; the OKLCH tests in `crates/ui-egui/src/panels/tests_color_wheel.rs`, `the_oklch_tracks_dim_the_colors_outside_srgb_and_the_tick_marks_the_largest_chroma` and `oklch_sliders_are_gray_after_the_working_space_changes` among them. Scores and estimates are unchanged.
|
||||
- **HSL Sliders (Color Wheel panel):** as VectorCraft's own addition, the Color Wheel panel's menu item HSL Sliders (`ui.colorWheel {sliders: "hsl"}`, kept with the preferences) shows H, S and L rows in place of OKLCH Sliders that edit the color by the hue (0 to 360°), saturation and lightness (0 to 100 %) of its display sRGB, as CSS Color 4 defines HSL (https://www.w3.org/TR/css-color-4/#the-hsl-notation). A pick goes from display sRGB into the working RGB space as the wheel's picks do, and the rows keep the hue of a gray. The rows take the arrow keys after a click and report their names, values, ranges and adjust actions to screen readers. Evidence: `hsl_follows_css_color_4` and `hsl_roundtrip` in `crates/color/src/lib.rs`; the HSL tests in `crates/ui-egui/src/panels/tests_color_wheel.rs`, `a_gray_keeps_the_hsl_hue_it_was_given` among them. Scores and estimates are unchanged.
|
||||
- **Color Wheel panel (part of #978):** Window › Color Wheel shows the Fill and Stroke proxy beside a hue ring around a square with saturation across and brightness up. It edits what the Color panel's sliders edit (the active proxy's color, the selected gradient stop or freeform point) through the same paint commands, and a drag is one undo step. Alt paints the other proxy, and Shift steps the ring by 45°. A pick goes from display sRGB into the working RGB space; an RGB, CMYK or Lab color keeps its model, and a Gray color or a tint of a global swatch becomes a process color in the document's color mode. A click gives the ring or the square the keyboard focus, and the arrow keys then step the color; both report their names and values to screen readers, and the Color Picker's color field takes the same keys. The panel menu's Box View puts a box in the wheel's place: a color field with a channel strip at its right for Hue, Saturation, Brightness, Red, Green or Blue (Box Channel), on the Color Picker's axes, kept with the preferences (`ui.colorWheel`); the strip and the Color Picker's channel slider take the arrow keys after a click. The panel menu's Show Harmony marks the other colors of a harmony rule (Harmony Rule) on the ring; the markers follow the current color, and a click on a marker applies its color (`ui.colorWheel {harmony, harmonyRule}`). Scores and estimates are unchanged.
|
||||
- **Colour:** a Color Picker (colour field, H/S/B/R/G/B channel slider, HSB/RGB/Lab/CMYK fields, hex, web-only snapping, out-of-gamut correction); the Color panel shows a selected colour in its own model and, with nothing selected, the new-art defaults in the mode picked last, which it keeps between sessions; Alt-click paints the other proxy; proxies look through groups and show "?" for mixed paint; Invert, Complement, Apply Last Color (`,`) and Apply Last Gradient (`.`) keep the colour model; every paint command feeds the recent colours. The Color Guide has 21 harmony rules, Steps and Variation options and Limit to Library. Adjust Color Balance (its Global mode shifts tints) and Saturate preview live; Edit Colors and Recolor also reach meshes, images and patterns. Recolor Artwork has colour reduction, five recolour methods, presets, Limit to Library, a colour-wheel Edit tab and Edit Color Group; a local Color Themes panel saves five-colour themes. Fill/Stroke chips open swatch and mixer popovers (the Properties panel has the Control bar's Fill and Stroke chips, Stroke link and weight spinner, with nothing selected too), panels have Illustrator's Window menu keys (Align Shift+F7, Transform Shift+F8, Pathfinder Cmd+Shift+F9, Layers F7, Character Cmd+T…; every panel can be given one in Edit › Keyboard Shortcuts), and Eyedropper Options pick up and apply chosen attributes (Alt and Shift+Alt, image pixels). An ICC CMYK profile converts straight into the RGB working space (not through sRGB, so a wider space such as Wide Gamut RGB keeps colours sRGB can't hold) with the colour settings' black-point compensation, on the canvas and in RGB exports alike (the built-in Generic CMYK compensates both ways, so RGB black separated to a rich black displays as black again). Fills and strokes can overprint (Attributes panel, Overprint Black options), and CMYK documents blend in inks on screen, in PDF and when flattening. Document Color Mode converts the art, symbols, pattern tiles and swatches through the colour settings: Gray stays Gray, RGB grays separate into light grays in cyan, magenta and yellow only, darker four-color grays and a rich black, or go on the black plate only with `grays: "black"` (also for `document.open {colorMode}`).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user