Merge pull request #7630 from dotCooCoo/feat/color-wheel-gamut

Color Wheel: Show Out-of-Gamut Colors grays out the colors the CMYK space cannot print
This commit is contained in:
BFlat authored and GitHub committed 2026-11-20 03:33:43 +07:00
commit 87ba058584
42 files changed
+493 -42

No files matched your search

+1 -1
View File
@@ -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, 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}",
"{view?: wheel|box, channel?: hue|saturation|brightness|red|green|blue, sliders?: none|oklch|hsl, gamut?: bool, 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; gamut true grays out the parts of the wheel's square and the box's field whose colors the CMYK space cannot print (the out-of-gamut warning's test, as color.gamutCheck answers it), as Show Out-of-Gamut Colors does, and false shows them again; the shading is approximate: each cell of a 16 by 16 grid over the square or the field is grayed out or not by the color at its center, so a grayed cell can hold printable colors and a clear cell can hold colors that cannot print; 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, gamut, harmony, harmonyRule, vision}",
),
(
"ui.savePdfDialog",
+1
View File
@@ -586,6 +586,7 @@ font-technology Variable Променливи
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View Изглед „Колело“
Box View Изглед „Квадрат“
Show Out-of-Gamut Colors Показване на цветовете извън цветовата гама
Box Channel Канал на квадрата
Color box Цветови квадрат
Color Wheel Options Опции на цветното колело
Can't render this file because it is too large.
+1
View File
@@ -819,6 +819,7 @@
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View Prikaz kotača
Box View Prikaz kvadrata
Show Out-of-Gamut Colors Prikaži boje izvan gamuta
Box Channel Kanal kvadrata
Color box Kvadrat boje
Color Wheel Options Opcije kotača boja
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -887,6 +887,7 @@ arrowhead Target Diana
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View Visualització de roda
Box View Visualització de quadre
Show Out-of-Gamut Colors Mostra els colors fora de gama
Box Channel Canal del quadre
Color box Quadre de color
Color Wheel Options Opcions de la roda de colors
Can't render this file because it is too large.
+1
View File
@@ -831,6 +831,7 @@
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View Zobrazení kola
Box View Zobrazení čtverce
Show Out-of-Gamut Colors Zobrazit barvy mimo gamut
Box Channel Kanál čtverce
Color box Barevný čtverec
Color Wheel Options Možnosti barevného kola
Can't render this file because it is too large.
+1
View File
@@ -3528,6 +3528,7 @@ liquify-list-end {0}, {1} {0} og {1}
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View Hjulvisning
Box View Kvadratvisning
Show Out-of-Gamut Colors Vis farver uden for gamut
Box Channel Kvadratets kanal
Color box Farvekvadrat
Color Wheel Options Indstillinger for farvehjul
Can't render this file because it is too large.
+1
View File
@@ -590,6 +590,7 @@ font-technology Variable Variabel
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View Kreisansicht
Box View Quadratansicht
Show Out-of-Gamut Colors Farben außerhalb des Farbumfangs einblenden
Box Channel Kanal des Quadrats
Color box Farbquadrat
Color Wheel Options Optionen für den Farbkreis
Can't render this file because it is too large.
+1
View File
@@ -565,6 +565,7 @@ font-technology Variable Μεταβλητές
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View Προβολή τροχού
Box View Προβολή τετραγώνου
Show Out-of-Gamut Colors Εμφάνιση χρωμάτων εκτός χρωματικής γκάμας
Box Channel Κανάλι τετραγώνου
Color box Τετράγωνο χρώματος
Color Wheel Options Επιλογές χρωματικού τροχού
Can't render this file because it is too large.
+1
View File
@@ -610,6 +610,7 @@ font-technology Variable Variables
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View Vista de rueda
Box View Vista de cuadro
Show Out-of-Gamut Colors Mostrar colores fuera de gama
Box Channel Canal del cuadro
Color box Cuadro de color
Color Wheel Options Opciones de la rueda de color
Can't render this file because it is too large.
+1
View File
@@ -817,6 +817,7 @@
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View Ympyränäkymä
Box View Ruutunäkymä
Show Out-of-Gamut Colors Näytä väriavaruuden ulkopuoliset värit
Box Channel Ruudun kanava
Color box Väriruutu
Color Wheel Options Väriympyrän asetukset
Can't render this file because it is too large.
+1
View File
@@ -611,6 +611,7 @@ font-technology Variable Variables
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View Affichage roue
Box View Affichage carré
Show Out-of-Gamut Colors Afficher les couleurs hors gamme
Box Channel Couche du carré
Color box Carré de couleur
Color Wheel Options Options de la roue chromatique
Can't render this file because it is too large.
+1
View File
@@ -4815,6 +4815,7 @@ arrowhead Feather પીંછું
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View વ્હીલ વ્યૂ
Box View બૉક્સ વ્યૂ
Show Out-of-Gamut Colors ગેમટ બહારના રંગો બતાવો
Box Channel બૉક્સ ચેનલ
Color box રંગ બૉક્સ
Color Wheel Options રંગ વ્હીલ વિકલ્પો
Can't render this file because it contains an unexpected character in line 72 and column 5.
+1
View File
@@ -1273,6 +1273,7 @@ arrowhead Feather पंख
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View व्हील व्यू
Box View बॉक्स व्यू
Show Out-of-Gamut Colors गैमट से बाहर के रंग दिखाएँ
Box Channel बॉक्स चैनल
Color box कलर बॉक्स
Color Wheel Options कलर व्हील ऑप्शन्स
Can't render this file because it is too large.
+1
View File
@@ -814,6 +814,7 @@ arrowhead Target Céltábla
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View Körnézet
Box View Négyzetnézet
Show Out-of-Gamut Colors Színtartományon kívüli színek megjelenítése
Box Channel Négyzet csatornája
Color box Színnégyzet
Color Wheel Options Színkör beállításai
Can't render this file because it is too large.
+1
View File
@@ -1405,6 +1405,7 @@
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View Tampilan roda
Box View Tampilan kotak
Show Out-of-Gamut Colors Tampilkan warna di luar gamut
Box Channel Saluran kotak
Color box Kotak warna
Color Wheel Options Opsi roda warna
Can't render this file because it is too large.
+1
View File
@@ -612,6 +612,7 @@ font-technology Variable Variabili
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View Vista ruota
Box View Vista riquadro
Show Out-of-Gamut Colors Mostra colori fuori gamma
Box Channel Canale del riquadro
Color box Riquadro colore
Color Wheel Options Opzioni ruota dei colori
Can't render this file because it is too large.
+1
View File
@@ -868,6 +868,7 @@ digits Malayalam マラヤーラム数字
{name1} {value1}, {name2} {value2} {name1} {value1}、{name2} {value2}
Wheel View ホイール表示
Box View ボックス表示
Show Out-of-Gamut Colors 色域外のカラーを表示
Box Channel ボックスのチャンネル
Color box カラーボックス
Color Wheel Options カラーホイールオプション
Can't render this file because it is too large.
+1
View File
@@ -2941,6 +2941,7 @@
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View წრის ხედი
Box View კვადრატის ხედი
Show Out-of-Gamut Colors ფერთა გამის გარეთ მყოფი ფერების ჩვენება
Box Channel კვადრატის არხი
Color box ფერის კვადრატი
Color Wheel Options ფერთა წრის პარამეტრები
Can't render this file because it is too large.
+1
View File
@@ -861,6 +861,7 @@ digits Malayalam 말라얄람어
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View 휠 보기
Box View 상자 보기
Show Out-of-Gamut Colors 색상 범위를 벗어난 색상 표시
Box Channel 상자 채널
Color box 색상 상자
Color Wheel Options 색상환 옵션
Can't render this file because it is too large.
+1
View File
@@ -1397,6 +1397,7 @@ liquify-list-end {0}, {1} {0} en {1}
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View Wielweergave
Box View Vakweergave
Show Out-of-Gamut Colors Kleuren buiten gamut tonen
Box Channel Kanaal van het vak
Color box Kleurvak
Color Wheel Options Opties voor kleurenwiel
Can't render this file because it is too large.
+1
View File
@@ -780,6 +780,7 @@
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View Widok koła
Box View Widok kwadratu
Show Out-of-Gamut Colors Pokaż kolory poza gamutem
Box Channel Kanał kwadratu
Color box Kwadrat koloru
Color Wheel Options Opcje koła kolorów
Can't render this file because it is too large.
+1
View File
@@ -549,6 +549,7 @@ antiAlias Sharp Nítido
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View Exibição em Roda
Box View Exibição em Caixa
Show Out-of-Gamut Colors Mostrar Cores Fora do Gamut
Box Channel Canal da Caixa
Color box Caixa de cor
Color Wheel Options Opções da Roda de Cores
Can't render this file because it is too large.
+1
View File
@@ -608,6 +608,7 @@ font-technology Variable Вариативные
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View Вид «Круг»
Box View Вид «Квадрат»
Show Out-of-Gamut Colors Показать цвета вне цветового охвата
Box Channel Канал квадрата
Color box Цветовой квадрат
Color Wheel Options Параметры цветового круга
Can't render this file because it is too large.
+1
View File
@@ -593,6 +593,7 @@ font-technology Variable Variabla
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View Hjulvy
Box View Rutvy
Show Out-of-Gamut Colors Visa färger utanför färgomfånget
Box Channel Rutans kanal
Color box Färgruta
Color Wheel Options Alternativ för färghjulet
Can't render this file because it is too large.
+1
View File
@@ -591,6 +591,7 @@ font-technology Variable Değişken
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View Tekerlek Görünümü
Box View Kutu Görünümü
Show Out-of-Gamut Colors Gamut Dışı Renkleri Göster
Box Channel Kutu Kanalı
Color box Renk kutusu
Color Wheel Options Renk Tekerleği Seçenekleri
Can't render this file because it is too large.
+1
View File
@@ -606,6 +606,7 @@ font-technology Variable Варіативні
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View Вигляд «Коло»
Box View Вигляд «Квадрат»
Show Out-of-Gamut Colors Показати кольори поза колірним охопленням
Box Channel Канал квадрата
Color box Колірний квадрат
Color Wheel Options Параметри колірного кола
Can't render this file because it is too large.
+1
View File
@@ -725,6 +725,7 @@ font-technology Variable Biến thiên
{name1} {value1}, {name2} {value2} {name1} {value1}, {name2} {value2}
Wheel View Hiển thị bánh xe
Box View Hiển thị hộp
Show Out-of-Gamut Colors Hiện màu ngoài dải màu
Box Channel Kênh của hộp
Color box Hộp màu
Color Wheel Options Tùy chọn bánh xe màu
Can't render this file because it is too large.
+1
View File
@@ -557,6 +557,7 @@ antiAlias Sharp 锐利
{name1} {value1}, {name2} {value2} {name1} {value1},{name2} {value2}
Wheel View 色轮视图
Box View 方块视图
Show Out-of-Gamut Colors 显示超出色域的颜色
Box Channel 方块色版
Color box 颜色方块
Color Wheel Options 色轮选项
Can't render this file because it is too large.
+1
View File
@@ -574,6 +574,7 @@ font-technology Variable 可變
{name1} {value1}, {name2} {value2} {name1} {value1},{name2} {value2}
Wheel View 色輪檢視
Box View 方塊檢視
Show Out-of-Gamut Colors 顯示超出色域的顏色
Box Channel 方塊色版
Color box 顏色方塊
Color Wheel Options 色輪選項
Can't render this file because it is too large.
+1 -1
View File
@@ -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, 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}",
"{view?: wheel|box, channel?: hue|saturation|brightness|red|green|blue, sliders?: none|oklch|hsl, gamut?: bool, 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; gamut true grays out the parts of the wheel's square and the box's field whose colors the CMYK space cannot print (the out-of-gamut warning's test, as color.gamutCheck answers it), as Show Out-of-Gamut Colors does, and false shows them again; the shading is approximate: each cell of a 16 by 16 grid over the square or the field is grayed out or not by the color at its center, so a grayed cell can hold printable colors and a clear cell can hold colors that cannot print; 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, gamut, harmony, harmonyRule, vision}",
),
(
"ui.savePdfDialog",
+2
View File
@@ -819,6 +819,8 @@ mod tests_color_wheel;
#[cfg(test)]
mod tests_color_wheel_box;
#[cfg(test)]
mod tests_color_wheel_gamut;
#[cfg(test)]
mod tests_color_wheel_harmony;
#[cfg(test)]
mod tests_color_wheel_vision;
+101 -18
View File
@@ -12,6 +12,11 @@
//! Brightness, Red, Green or Blue). The field shows the other two components on the Color
//! Picker's axes.
//!
//! Show Out-of-Gamut Colors grays out the cells of the wheel's square and the box's field whose
//! colors the CMYK space cannot print, by the out-of-gamut warning's test ([`Cms::out_of_gamut`]),
//! on a [`GAMUT_CELLS`] by [`GAMUT_CELLS`] grid kept until the channel, its value, the color
//! settings or the loaded profiles change.
//!
//! Show Harmony puts a marker on the ring for each other color of the harmony rule picked under
//! Harmony Rule (the Color Guide's rules whose colors each have a hue of their own), filled with
//! that color. The markers follow the current color, and a click on one applies its color as a
@@ -31,13 +36,13 @@
//! (<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`).
//! The view, the channel, the slider rows, Show Out-of-Gamut Colors, Show Harmony, Harmony Rule
//! and Show Color Vision Preview are kept with the preferences (`ui.colorWheel`).
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::cms::{self, Cms, ColorSettings, ProofSetup, ProofTarget};
use vectorcraft_color::harmony::Harmony;
use vectorcraft_color::oklab::{self, CHROMA_FULL};
use vectorcraft_color::{Color, Paint, hsb_to_rgb, hsl_to_rgb, rgb_to_hsb, rgb_to_hsl};
@@ -94,6 +99,9 @@ pub struct Settings {
pub channel: Channel,
#[serde(deserialize_with = "deserialize_sliders")]
pub sliders: Sliders,
/// Show Out-of-Gamut Colors: gray out the colors the CMYK space cannot print.
#[serde(deserialize_with = "deserialize_flag")]
pub gamut: bool,
/// Show Harmony: markers on the ring for the other colors of `harmony_rule`.
#[serde(deserialize_with = "deserialize_flag")]
pub harmony: bool,
@@ -146,6 +154,7 @@ impl Default for Settings {
view: View::default(),
channel: Channel::default(),
sliders: Sliders::default(),
gamut: false,
harmony: false,
harmony_rule: Harmony::Complementary,
vision: false,
@@ -199,11 +208,11 @@ 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?, 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.
/// `ui.colorWheel {view?, channel?, sliders?, gamut?, harmony?, harmonyRule?, vision?}`: show the
/// wheel or the box, pick the box's channel, show OKLCH Sliders, HSL Sliders or neither, show or
/// hide the out-of-gamut shading, 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> {
@@ -214,7 +223,7 @@ pub(crate) fn command(app: &mut VectorcraftApp, p: &Value) -> Result<Value, Stri
/// 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"];
const KEYS: [&str; 7] = ["view", "channel", "sliders", "gamut", "harmony", "harmonyRule", "vision"];
match p {
Value::Null => {}
Value::Object(o) => {
@@ -243,6 +252,11 @@ pub(crate) fn set(settings: &mut Settings, p: &Value, cms: &Cms) -> Result<(), S
set.sliders = sliders;
}
}
let key = "gamut";
match p.get(key) {
None | Some(Value::Null) => {}
Some(v) => set.gamut = v.as_bool().ok_or_else(|| format!("`{key}` must be true or false"))?,
}
let key = "harmony";
match p.get(key) {
None | Some(Value::Null) => {}
@@ -265,9 +279,9 @@ pub(crate) fn set(settings: &mut Settings, p: &Value, cms: &Cms) -> Result<(), S
Ok(())
}
/// 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.
/// The panel menu: Wheel View and Box View, and Box Channel while the box shows; Show Out-of-Gamut
/// Colors; 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)] {
@@ -285,6 +299,9 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
});
});
ui.separator();
if menu_item(ui, tl!("Show Out-of-Gamut Colors"), true, set.gamut) {
command(app, &json!({ "gamut": !set.gamut })).ok();
}
let on = set.sliders == Sliders::Hsl;
if menu_item(ui, tl!("HSL Sliders"), true, on) {
let sliders = if on { Sliders::None } else { Sliders::Hsl };
@@ -318,6 +335,64 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
}
}
/// The cells across and down of the grid the out-of-gamut shading tests.
pub(crate) const GAMUT_CELLS: usize = 16;
/// The cells of a field whose colors are out of the CMYK gamut, a row per [`GAMUT_CELLS`] from the
/// top: bit `i` of a row is its cell `i` from the left.
pub(crate) type GamutGrid = [u16; GAMUT_CELLS];
/// The out-of-gamut cells of the box of channel `ch` at strip value `z` through `cms`, each tested
/// at its center by the out-of-gamut warning's test ([`Cms::out_of_gamut`]) on the working-RGB
/// color of a pick there, before any conversion to CMYK or Lab in [`stored`]. The wheel's square is
/// the box of [`Channel::Hue`] at the ring's hue.
pub(crate) fn gamut_grid(cms: &Cms, ch: Channel, z: f32) -> GamutGrid {
let n = GAMUT_CELLS as f32;
let mut grid = [0; GAMUT_CELLS];
for (row, bits) in grid.iter_mut().enumerate() {
for col in 0..GAMUT_CELLS {
let (x, y) = ((col as f32 + 0.5) / n, (row as f32 + 0.5) / n);
// A gray has no hue, and the hue a gray keeps does not change its color.
let [r, g, b] = cms.srgb_to_rgb(hsb_to_rgb(box_pick(ch, z, x, y, [0.0; 3])));
if cms.out_of_gamut(&Color::rgb(r, g, b)) {
*bits |= 1 << col;
}
}
}
grid
}
/// What the out-of-gamut grid depends on: the channel, its value's bits, the color settings and
/// [`cms::profiles_generation`], which changes when a profile is loaded again under the same name.
pub(crate) type GamutKey = (Channel, u32, ColorSettings, u64);
/// The grid for `key` from `slot`, computed with `compute` and kept in `slot` when `slot` holds
/// another key's.
pub(crate) fn cached_grid(slot: &mut Option<(GamutKey, GamutGrid)>, key: GamutKey, compute: impl FnOnce() -> GamutGrid) -> GamutGrid {
match slot {
Some((k, grid)) if *k == key => *grid,
_ => {
let grid = compute();
*slot = Some((key, grid));
grid
}
}
}
/// Panel state: the out-of-gamut grid drawn last and its [`GamutKey`].
pub(crate) const GAMUT: &str = "color-wheel-gamut";
/// The out-of-gamut grid of channel `ch` at value `z` through `cms`, kept in the panel state so a
/// frame with the same channel, value, color settings and loaded profiles does not test the colors
/// again.
fn gamut_shade(ui: &Ui, cms: &Cms, ch: Channel, z: f32) -> GamutGrid {
let mut slot = pstate::<Option<(GamutKey, GamutGrid)>>(ui.ctx(), GAMUT);
let key = (ch, z.to_bits(), cms.settings().clone(), cms::profiles_generation());
let grid = cached_grid(&mut slot, key, || gamut_grid(cms, ch, z));
set_pstate(ui.ctx(), GAMUT, slot);
grid
}
/// The display values of HSB `hsb` in `ch`'s space, from 0 to 1: hue, saturation and brightness,
/// or red, green and blue.
fn box_values(ch: Channel, hsb: [f32; 3]) -> [f32; 3] {
@@ -362,16 +437,19 @@ fn strip_number(ch: Channel, hsb: [f32; 3]) -> (f64, &'static str, f64) {
}
/// The box in a `size` × `size` area: the field of channel `ch` and its strip, on HSB `hsb`, with
/// markers when `marked`. Returns the HSB a click, a drag, a key or a screen reader's action picks,
/// and its phase.
fn show_box(ui: &mut Ui, ch: Channel, hsb: [f32; 3], marked: bool, size: f32) -> Option<([f32; 3], Live)> {
/// markers when `marked` and the field's out-of-gamut cells grayed out when `gamut`. Returns the
/// HSB a click, a drag, a key or a screen reader's action picks, and its phase.
fn show_box(ui: &mut Ui, ch: Channel, hsb: [f32; 3], marked: bool, size: f32, gamut: Option<&Cms>) -> Option<([f32; 3], Live)> {
let (z, x, y) = box_pos(ch, hsb);
let mut pick = None;
let grid = gamut.map(|cms| gamut_shade(ui, cms, ch, z));
let shade = grid.as_ref().map_or(&[][..], |g| &g[..]);
ui.horizontal_top(|ui| {
ui.spacing_mut().item_spacing.x = STRIP_GAP;
let field = vec2((size - STRIP_GAP - STRIP).max(1.0), size);
let at = |x: f32, y: f32| widgets::hsb32(box_pick(ch, z, x, y, hsb));
if let (Some((x, y)), phase) = widgets::color_field(ui, "color-wheel-box", (tl!("Color box"), ch.field_axes()), field, (x, y), marked, &at) {
let labels = (tl!("Color box"), ch.field_axes());
if let (Some((x, y)), phase) = widgets::color_field_shaded(ui, "color-wheel-box", labels, field, (x, y), marked, (&at, shade)) {
pick = Some((box_pick(ch, z, x, y, hsb), phase));
}
// The hue strip shows the whole spectrum; the others change only their own component.
@@ -789,6 +867,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
(c, _) => display_hsb(&cms, &c.unwrap_or(app.session.last_solid)),
};
let marked = color.is_some();
let gamut = app.ui.color_wheel.gamut.then_some(&*cms);
let mut pick: Option<([f32; 3], Live)> = None;
ui.horizontal_top(|ui| {
ui.vertical(|ui| {
@@ -797,7 +876,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
});
let size = ui.available_width().min(MAX_WHEEL);
if app.ui.color_wheel.view == View::Box {
pick = show_box(ui, app.ui.color_wheel.channel, hsb, marked, size);
pick = show_box(ui, app.ui.color_wheel.channel, hsb, marked, size, gamut);
return;
}
let ring = widgets::hue_ring(ui, "color-wheel-ring", tl!("Hue ring"), size, hsb[0], marked);
@@ -807,7 +886,11 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
[FieldAxis { name: tl!("Saturation"), units: 100.0, suffix: "%" }, FieldAxis { name: tl!("Brightness"), units: 100.0, suffix: "%" }];
let at = |x: f32, y: f32| widgets::hsb32([hsb[0], x, 1.0 - y]);
let name = tl!("Saturation and brightness");
let (field, field_phase) = widgets::color_field(&mut field_ui, "field", (name, axes), square.size(), (hsb[1], 1.0 - hsb[2]), marked, &at);
// The square is the hue box at the ring's hue, so it shares the box's grid.
let grid = gamut.map(|cms| gamut_shade(ui, cms, Channel::Hue, box_pos(Channel::Hue, hsb).0));
let shade = grid.as_ref().map_or(&[][..], |g| &g[..]);
let pos = (hsb[1], 1.0 - hsb[2]);
let (field, field_phase) = widgets::color_field_shaded(&mut field_ui, "field", (name, axes), square.size(), pos, marked, (&at, shade));
// Show Harmony: the rule's other colors for the current one, which follow it. While a press
// is held on a marker, the ring's drag under it picks nothing.
let set = &app.ui.color_wheel;
@@ -1072,7 +1072,7 @@ fn ui_color_wheel_sets_and_reads_the_sliders() {
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"});
let want = json!({"view": "box", "channel": "red", "gamut": false, "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");
@@ -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!({"sliders": "none", "harmony": false, "harmonyRule": "complementary", "vision": false});
let harmony = json!({"sliders": "none", "gamut": false, "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, sliders, harmony, harmonyRule, vision");
assert_eq!(e, "unknown parameter `veiw`; the command takes: view, channel, sliders, gamut, 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, sliders, harmony, harmonyRule, vision");
assert_eq!(e, "unknown parameter `chanel`; the command takes: view, channel, sliders, gamut, harmony, harmonyRule, vision");
assert_eq!(app.ui.color_wheel, Settings { view: View::Box, channel: Channel::Red, ..Default::default() }, "an error changes nothing");
}
@@ -277,7 +277,7 @@ fn ui_color_wheel_answers_junk_params_without_a_panic() {
#[test]
fn the_settings_are_kept_and_read_leniently() {
let ui = crate::UiState {
color_wheel: Settings { view: View::Box, channel: Channel::Blue, vision: true, ..Default::default() },
color_wheel: Settings { view: View::Box, channel: Channel::Blue, gamut: true, vision: true, ..Default::default() },
color_rgb_percent: true,
..Default::default()
};
@@ -0,0 +1,265 @@
//! The Color Wheel panel's Show Out-of-Gamut Colors: the grid of out-of-gamut cells, its cache, the
//! wheel's square and the box sharing it, `ui.colorWheel {gamut}`, the panel menu and the saved
//! setting.
use egui::vec2;
use egui_kittest::Harness;
use egui_kittest::kittest::Queryable;
use serde_json::json;
use vectorcraft_color::cms::{self, Cms, ColorSettings};
use vectorcraft_color::{Color, hsb_to_rgb};
use vectorcraft_engine::Session;
use super::color_wheel::{GAMUT, GAMUT_CELLS, GamutGrid, GamutKey, Settings, View, box_pick, cached_grid, gamut_grid, show};
use crate::VectorcraftApp;
use crate::dialogs::color_picker::Channel;
/// Whether cell `col` of row `row` (from the top-left) of `grid` is out of gamut.
fn marked(grid: &GamutGrid, col: usize, row: usize) -> bool {
(grid[row] >> col) & 1 == 1
}
/// An app with a selected rectangle filled with `fill`, its Color Wheel panel on `view` with Show
/// Out-of-Gamut Colors set to `gamut`.
fn app(fill: &str, view: &str, gamut: bool) -> VectorcraftApp {
let mut app = VectorcraftApp::new(Session::new(), Default::default());
app.run("file.new", json!({"width": 200, "height": 200})).unwrap();
app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 50, "height": 50})).unwrap();
app.run("paint.setFill", json!({"color": fill})).unwrap();
app.run("ui.colorWheel", json!({"view": view, "channel": "hue", "gamut": gamut})).unwrap();
app
}
fn harness(app: VectorcraftApp) -> Harness<'static, VectorcraftApp> {
let mut h = Harness::builder().with_size(vec2(260.0, 320.0)).build_ui_state(|ui, app: &mut VectorcraftApp| show(app, ui), app);
h.run_steps(2);
h
}
/// The grid the panel drew last, with its key.
fn drawn(h: &Harness<'static, VectorcraftApp>) -> Option<(GamutKey, GamutGrid)> {
super::pstate::<Option<(GamutKey, GamutGrid)>>(&h.ctx, GAMUT)
}
/// At hue 240° the field's top-right cell is nearly pure blue, which the CMYK space cannot print,
/// and its bottom-left cell is nearly black, which it can. Each cell is the color a pick at its
/// center stores, tested as the out-of-gamut warning tests it.
#[test]
fn the_hue_grid_marks_blue_and_leaves_black() {
let cms = Cms::default();
let grid = gamut_grid(&cms, Channel::Hue, 240.0 / 360.0);
let last = GAMUT_CELLS - 1;
assert!(marked(&grid, last, 0), "{grid:04x?}");
assert!(!marked(&grid, 0, last), "{grid:04x?}");
for row in 0..GAMUT_CELLS {
for col in 0..GAMUT_CELLS {
let n = GAMUT_CELLS as f32;
let hsb = box_pick(Channel::Hue, 240.0 / 360.0, (col as f32 + 0.5) / n, (row as f32 + 0.5) / n, [0.0; 3]);
let [r, g, b] = cms.srgb_to_rgb(hsb_to_rgb(hsb));
assert_eq!(marked(&grid, col, row), cms.out_of_gamut(&Color::rgb(r, g, b)), "cell {col}, {row}");
}
}
}
/// In the Blue box at full blue, the field's bottom-left cell (no red, no green) is nearly pure
/// blue.
#[test]
fn an_rgb_box_marks_its_own_cells() {
let grid = gamut_grid(&Cms::default(), Channel::Blue, 1.0);
assert!(marked(&grid, 0, GAMUT_CELLS - 1), "{grid:04x?}");
}
/// With uncalibrated CMYK as the CMYK space every color counts as printable, as the out-of-gamut
/// warning has it, so no cell is marked.
#[test]
fn uncalibrated_cmyk_marks_nothing() {
let cms = Cms::new(&ColorSettings { cmyk: cms::DEVICE_CMYK.into(), ..ColorSettings::default() }).unwrap();
assert_eq!(gamut_grid(&cms, Channel::Hue, 240.0 / 360.0), [0; GAMUT_CELLS]);
}
/// The cache computes a grid once per key: the same channel, value, color settings and profile
/// generation reuse it, and a change of any of them computes it again.
#[test]
fn the_cache_computes_once_per_key() {
let mut slot = None;
let mut runs = 0;
let settings = ColorSettings::default();
let mut get = |slot: &mut Option<(GamutKey, GamutGrid)>, key: GamutKey| {
cached_grid(slot, key, || {
runs += 1;
[runs; GAMUT_CELLS]
})
};
let key = (Channel::Hue, 0.5f32.to_bits(), settings.clone(), 0);
assert_eq!(get(&mut slot, key.clone()), [1; GAMUT_CELLS]);
assert_eq!(get(&mut slot, key.clone()), [1; GAMUT_CELLS], "the same key is not computed again");
assert_eq!(get(&mut slot, (Channel::Hue, 0.25f32.to_bits(), settings.clone(), 0)), [2; GAMUT_CELLS]);
assert_eq!(get(&mut slot, (Channel::Red, 0.25f32.to_bits(), settings.clone(), 0)), [3; GAMUT_CELLS]);
let device = ColorSettings { cmyk: cms::DEVICE_CMYK.into(), ..settings };
assert_eq!(get(&mut slot, (Channel::Red, 0.25f32.to_bits(), device.clone(), 0)), [4; GAMUT_CELLS]);
assert_eq!(get(&mut slot, (Channel::Red, 0.25f32.to_bits(), device, 1)), [5; GAMUT_CELLS], "a profile loaded again");
}
/// A profile loaded again under the same name can change which colors are printable while the
/// color settings stay the same, so the panel tests the colors again after a profile is
/// registered.
#[test]
fn the_grid_is_computed_again_after_a_profile_is_loaded() {
let mut h = harness(app("#3366cc", "box", true));
let Some((before, _)) = drawn(&h) else { panic!("the box drew no grid") };
/// Unregisters the profile when dropped, also after a failed assertion.
struct Unregister(&'static str);
impl Drop for Unregister {
fn drop(&mut self) {
cms::unregister_icc(self.0);
}
}
let name = "Color Wheel Gamut Reload CMYK";
let bytes = cms::icc_bytes(cms::GENERIC_CMYK).unwrap();
cms::register_icc(&bytes, Some(name.into())).unwrap();
let _unregister = Unregister(name);
h.run_steps(2);
let Some((after, _)) = drawn(&h) else { panic!("the box drew no grid") };
assert_eq!((after.0, after.1, &after.2), (before.0, before.1, &before.2));
assert!(after.3 > before.3, "the key follows the loaded profiles: {} then {}", before.3, after.3);
}
/// The wheel's square is the hue box at the ring's hue: both draw the same grid, under one key, so
/// a switch between them does not test the colors again.
#[test]
fn the_wheel_and_the_hue_box_shade_the_same_cells() {
let mut h = harness(app("#3366cc", "wheel", true));
let cms = cms::active();
let Some((key, grid)) = drawn(&h) else { panic!("the wheel drew no grid") };
let z = f32::from_bits(key.1);
assert_eq!((key.0, &key.2), (Channel::Hue, cms.settings()));
assert!((z * 360.0 - 220.0).abs() < 0.5, "the ring's hue: {}", z * 360.0);
assert_eq!(grid, gamut_grid(&cms, Channel::Hue, z));
h.state_mut().run("ui.colorWheel", json!({"view": "box"})).unwrap();
h.run_steps(2);
// Other tests in this process may register profiles between the frames, which changes the
// key's profile generation; the channel, value, settings and grid stay the same.
let Some((boxed, boxed_grid)) = drawn(&h) else { panic!("the box drew no grid") };
assert_eq!((boxed.0, boxed.1, &boxed.2, boxed_grid), (key.0, key.1, &key.2, grid));
}
/// With Show Out-of-Gamut Colors off, the panel tests no colors.
#[test]
fn with_the_setting_off_no_grid_is_computed() {
let h = harness(app("#3366cc", "box", false));
assert_eq!(drawn(&h), None);
}
/// `ui.colorWheel {gamut}` sets the setting and keeps the others; a key set to null keeps its value
/// while the other keys apply; a value that is not true or false is an error that changes nothing,
/// translated where messages are.
#[test]
fn ui_color_wheel_sets_gamut() {
let mut app = VectorcraftApp::new(Session::new(), Default::default());
let with = |v: serde_json::Value| {
let mut v = v;
let rest = json!({"sliders": "none", "harmony": false, "harmonyRule": "complementary", "vision": false});
v.as_object_mut().unwrap().extend(rest.as_object().unwrap().clone());
v
};
app.run("ui.colorWheel", json!({"view": "box"})).unwrap();
assert_eq!(app.run("ui.colorWheel", json!({"gamut": true})).unwrap(), with(json!({"view": "box", "channel": "hue", "gamut": true})));
let e = app.run("ui.colorWheel", json!({"view": "wheel", "gamut": "yes"})).unwrap_err();
assert_eq!(e, "`gamut` must be true or false");
assert_eq!(app.ui.color_wheel, Settings { view: View::Box, gamut: true, ..Default::default() }, "an error changes nothing");
assert_eq!(app.run("ui.colorWheel", json!({"gamut": null})).unwrap()["gamut"], json!(true), "null keeps the value");
app.run("ui.colorWheel", json!({"channel": "red"})).unwrap();
let got = app.run("ui.colorWheel", json!({"view": "wheel", "channel": null, "gamut": null})).unwrap();
assert_eq!(got, with(json!({"view": "wheel", "channel": "red", "gamut": true})), "null keeps a value while the other keys apply");
let got = app.run("ui.colorWheel", json!({"view": null, "gamut": false})).unwrap();
assert_eq!(got, with(json!({"view": "wheel", "channel": "red", "gamut": false})), "a null view keeps the view while gamut applies");
for code in ["de", "fr", "ja", "zh-hans"] {
let lang = crate::i18n::Lang::from_code(code).expect("registered");
let shown = crate::i18n::message(lang, &e);
assert_ne!(shown, e, "{code}");
assert!(shown.contains("`gamut`"), "{code}: {shown}");
}
}
/// The setting survives a JSON round trip of the preferences, and a saved value that is not true
/// or false reads as off without losing the other settings.
#[test]
fn the_gamut_setting_is_kept_and_read_leniently() {
let ui = crate::UiState { color_wheel: Settings { view: View::Box, gamut: true, ..Default::default() }, ..Default::default() };
let saved = serde_json::to_value(&ui).unwrap();
assert_eq!(saved["color_wheel"]["gamut"], json!(true));
let back: crate::UiState = serde_json::from_value(saved.clone()).unwrap();
assert_eq!(back.color_wheel, ui.color_wheel);
let mut odd = saved;
odd["color_wheel"] = json!({"view": "box", "channel": "red", "gamut": "yes"});
let back: crate::UiState = serde_json::from_value(odd).unwrap();
assert_eq!(back.color_wheel, Settings { view: View::Box, channel: Channel::Red, gamut: false, ..Default::default() });
}
/// The panel menu's Show Out-of-Gamut Colors is checked while the setting is on, and switches it.
#[test]
fn the_panel_menu_switches_the_shading() {
let app = app("#ff0000", "wheel", false);
let mut fonts = false;
let mut h = Harness::builder().with_size(vec2(260.0, 360.0)).build_ui_state(
move |ui, app: &mut VectorcraftApp| {
// The fonts, which draw the check mark, take effect from the next frame.
if !fonts {
crate::theme::install_fonts(ui.ctx());
fonts = true;
return;
}
assert!(super::panel_menu_items(app, ui, super::color_wheel::ID));
},
app,
);
h.run_steps(3);
h.get_by_label(" Show Out-of-Gamut Colors").click();
h.run_steps(2);
assert!(h.state().ui.color_wheel.gamut);
assert!(h.query_by_label("✓ Show Out-of-Gamut Colors").is_some());
h.get_by_label("✓ Show Out-of-Gamut Colors").click();
h.run_steps(2);
assert!(!h.state().ui.color_wheel.gamut);
}
/// The edge runs between the marked cells and the others, inside the grid only, and bits past the
/// grid's width are not cells.
#[test]
fn the_edge_runs_between_marked_and_unmarked_cells() {
assert_eq!(crate::widgets::shade_edges(&[0b01, 0b00]), vec![[(1, 0), (1, 1)], [(0, 1), (1, 1)]]);
assert_eq!(crate::widgets::shade_edges(&[0b11, 0b11]), Vec::<[(usize, usize); 2]>::new(), "all marked");
assert_eq!(crate::widgets::shade_edges(&[0b100]), Vec::<[(usize, usize); 2]>::new(), "bit 2 is past a 1 × 1 grid");
assert_eq!(crate::widgets::shade_edges(&[]), Vec::<[(usize, usize); 2]>::new());
}
/// The gray covers each marked cell and no other, and each edge is drawn dark, then light on top.
#[test]
fn the_gray_covers_the_marked_cells_only() {
use egui::{Pos2, Rect, Shape};
let ctx = egui::Context::default();
let rect = Rect::from_min_size(Pos2::new(10.0, 20.0), vec2(16.0, 16.0));
let mut out = ctx.run_ui(egui::RawInput::default(), |ui| crate::widgets::shade_cells(ui.painter(), rect, &[0b01, 0b10]));
out.textures_delta.clear();
let grays: Vec<Rect> = out
.shapes
.iter()
.filter_map(|c| match &c.shape {
Shape::Rect(r) if r.fill == crate::widgets::SHADE => Some(r.rect),
_ => None,
})
.collect();
let cell = |col: f32, row: f32| Rect::from_min_size(Pos2::new(10.0 + col * 8.0, 20.0 + row * 8.0), vec2(8.0, 8.0));
assert_eq!(grays, vec![cell(0.0, 0.0), cell(1.0, 1.0)]);
let lines: Vec<(f32, egui::Color32)> = out
.shapes
.iter()
.filter_map(|c| match &c.shape {
Shape::LineSegment { stroke, .. } => Some((stroke.width, stroke.color)),
_ => None,
})
.collect();
let dark = vec![(2.0, egui::Color32::BLACK); 4];
let light = vec![(1.0, egui::Color32::WHITE); 4];
assert_eq!(lines, [dark, light].concat(), "four edges, dark under light");
}
@@ -225,7 +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, "sliders": "none"});
let settings = |view: &str, vision: bool| json!({"view": view, "channel": "hue", "gamut": false, "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);
@@ -236,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, sliders, harmony, harmonyRule, vision"
"unknown parameter `visoin`; the command takes: view, channel, sliders, gamut, harmony, harmonyRule, vision"
);
assert!(app.ui.color_wheel.vision);
assert_eq!(app.run("ui.colorWheel", json!({"vision": null})).unwrap()["vision"], true);
+3 -2
View File
@@ -829,8 +829,9 @@ 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, the slider rows 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, the
/// out-of-gamut shading 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
+5 -3
View File
@@ -38,11 +38,13 @@ use chips::gradient_chip_colors;
pub use chips::{ProxyClicks, chip_button, chip_button_named, fill_stroke_proxy, gradient_chip, paint_chip, proxy_chip, swatch_tile};
pub use color::{
FieldAxis, Live, MarkerResponse, RingResponse, SliderValue, WheelAxes, WheelResponse, channel_slider, channel_slider_named,
channel_slider_stepped, channel_slider_valued, color_field, color_mesh, color_slider, color_slider_named, color_slider_stepped,
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,
channel_slider_stepped, channel_slider_valued, color_field, color_field_shaded, color_mesh, color_slider, color_slider_named,
color_slider_stepped, 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, color_rail_bar, focus_by_pointer, hex_text, pointer_phase};
#[cfg(test)]
pub(crate) use color::{SHADE, shade_cells, shade_edges};
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,
+66 -1
View File
@@ -402,11 +402,26 @@ fn focus_outline(ui: &Ui, resp: &Response, rect: Rect) {
pub fn color_field(
ui: &mut Ui,
id: impl std::hash::Hash,
(name, axes): (&str, [FieldAxis<'_>; 2]),
labels: (&str, [FieldAxis<'_>; 2]),
size: Vec2,
pos: (f32, f32),
marked: bool,
color_at: &dyn Fn(f32, f32) -> Color32,
) -> (Option<(f32, f32)>, Live) {
color_field_shaded(ui, id, labels, size, pos, marked, (color_at, &[]))
}
/// A [`color_field`] with the cells `shade` marks grayed out under its marker, each run of them
/// edged with a dark and a light line. `shade` holds a row of an n × n grid over the field for each
/// of its n rows (16 at most) from the top, and bit `i` of a row marks its cell `i` from the left.
pub fn color_field_shaded(
ui: &mut Ui,
id: impl std::hash::Hash,
(name, axes): (&str, [FieldAxis<'_>; 2]),
size: Vec2,
pos: (f32, f32),
marked: bool,
(color_at, shade): (&dyn Fn(f32, f32) -> Color32, &[u16]),
) -> (Option<(f32, f32)>, Live) {
use egui::accesskit::{Action, ActionData};
let t = Tokens::get(ui.ctx());
@@ -415,6 +430,7 @@ pub fn color_field(
focus_on_press(&resp);
let painter = ui.painter_at(rect.expand(6.0));
painter.add(color_mesh(rect, (32, 32), color_at));
shade_cells(&painter, rect, shade);
painter.rect_stroke(rect, 0.0, Stroke::new(1.0, t.border), StrokeKind::Outside);
focus_outline(ui, &resp, rect);
let (x, y) = pos;
@@ -465,6 +481,55 @@ pub fn color_field(
(None, Live::Idle)
}
/// The gray over a shaded cell of a [`color_field_shaded`].
pub(crate) const SHADE: Color32 = Color32::from_rgba_premultiplied(96, 96, 96, 192);
/// Whether cell `col` of row `row` of `shade` is marked; a cell outside the grid is not.
fn shaded(shade: &[u16], col: usize, row: usize) -> bool {
col < shade.len().min(16) && shade.get(row).is_some_and(|bits| (bits >> col) & 1 == 1)
}
/// The lines between the marked and the unmarked cells of `shade` (see [`color_field_shaded`]),
/// each from one grid point to the next, as (column, row) from the top-left corner.
pub(crate) fn shade_edges(shade: &[u16]) -> Vec<[(usize, usize); 2]> {
let n = shade.len().min(16);
let mut edges = Vec::new();
for row in 0..n {
for col in 0..n {
let here = shaded(shade, col, row);
if col + 1 < n && here != shaded(shade, col + 1, row) {
edges.push([(col + 1, row), (col + 1, row + 1)]);
}
if row + 1 < n && here != shaded(shade, col, row + 1) {
edges.push([(col, row + 1), (col + 1, row + 1)]);
}
}
}
edges
}
/// Gray out the cells `shade` marks over `rect`, and draw the lines between them and the others
/// dark under light.
pub(crate) fn shade_cells(painter: &egui::Painter, rect: Rect, shade: &[u16]) {
let n = shade.len().min(16);
if n == 0 {
return;
}
let cell = rect.size() / n as f32;
let at = |(col, row): (usize, usize)| rect.min + vec2(col as f32 * cell.x, row as f32 * cell.y);
for row in 0..n {
for col in (0..n).filter(|&col| shaded(shade, col, row)) {
painter.rect_filled(Rect::from_min_size(at((col, row)), cell), 0.0, SHADE);
}
}
let edges = shade_edges(shade);
for stroke in [Stroke::new(2.0, Color32::BLACK), Stroke::new(1.0, Color32::WHITE)] {
for [a, b] in &edges {
painter.line_segment([at(*a), at(*b)], stroke);
}
}
}
/// A smoothly shaded colour area: a `cols` × `rows` grid over `rect` with `color_at(x, y)` (0..1
/// each, y down) at its vertices.
pub fn color_mesh(rect: Rect, (cols, rows): (u32, u32), color_at: &dyn Fn(f32, f32) -> Color32) -> egui::Shape {
+6 -6
View File
@@ -272,12 +272,12 @@ My Themes tab lists the saved themes; every action runs a command (`colorTheme.s
Color Wheel panel (`window.panel {panel: "colorWheel"}`): a hue ring around a saturation and brightness square. A
pick runs the commands the Color panel's sliders run: `paint.setFill` or `paint.setStroke` with `keepModel`,
`paint.editGradient` for a gradient's selected stop, and `paint.freeform.setPoint` for a freeform gradient's selected
point (the first stop or point when none is selected). `ui.colorWheel {view?, channel?, harmony?, harmonyRule?, vision?}`
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
point (the first stop or point when none is selected). `ui.colorWheel {view?, channel?, sliders?, gamut?, harmony?,
harmonyRule?, vision?}` shows the wheel or the box (a color field with a channel strip at its right), picks the box's
channel, shows OKLCH Sliders, HSL Sliders or neither, grays out the colors the CMYK space cannot print, 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` takes (`"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`/
+7 -2
View File
@@ -684,11 +684,16 @@ field does, and `false` shows them from 0 to 255 again. `ui.colorRgbPercent` (To
palette and Keyboard Shortcuts) switches between the two and answers true when the fields show in percent.
`ui.colorWheel {"view": "box", "channel": "red"}` shows the Color Wheel panel's box (a color field with the channel's
strip at its right) in place of the wheel, as the panel menu's Box View and Box Channel do, and `"view": "wheel"`
shows the wheel again. `{"harmony": true, "harmonyRule": "triad"}` puts a marker on the wheel's ring for each other
shows the wheel again. `"gamut": true` grays out the parts of the wheel's square and the box's field whose colors
the CMYK space cannot print, as the panel menu's Show Out-of-Gamut Colors does, and `false` shows them again. The
test is the out-of-gamut warning's, which `color.gamutCheck` answers for one color. The shading is approximate: the
panel tests the color at the center of each cell of a 16 by 16 grid over the square or the field and grays out the
whole cell or none of it, so a grayed cell can hold printable colors and a clear cell can hold colors that cannot
print. `{"harmony": true, "harmonyRule": "triad"}` puts a marker on the wheel's ring for each other
color of a Color Guide harmony rule, as Show Harmony and Harmony Rule do; the wheel takes the 15 rules whose colors
each have a hue of their own (not `monochromatic`, `shades`, `complementary2`, `triad2`, `triad3` or
`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}`,
the list return an error and change nothing. The command returns `{view, channel, sliders, gamut, 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
+1 -1
View File
@@ -1960,7 +1960,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
- **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.
- **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. Show Out-of-Gamut Colors grays out the parts of the square and the box's field whose colors the CMYK space cannot print, by the out-of-gamut warning's test on a 16 by 16 grid (`ui.colorWheel {gamut}`). 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}`).
**Color panel spectrum mode tooltip (part of #7235):** hovering the spectrum names the displayed mode (Grayscale, RGB, HSB, CMYK, Web Safe RGB or Lab), including after Shift-clicking to switch modes and with Show Options or Hide Options. Hovering changes no paint or undo history. Spectrum rendering and vertical resizing remain open. Evidence: `spectrum_tooltip_names_its_displayed_mode` and `spectrum_tooltip_follows_shift_cycle_without_painting` in `crates/ui-egui/tests/color_working_components.rs`. Scores and estimates unchanged.