Color Wheel: recolor.colors keeps its swatch rule, and a wide row shows every color that fits

- `recolor.colors`, `recolor.reduce` and the recolor groups name the swatch of a color's first
  linked use again. Only `color.used` takes its swatch and tint from the first linked use that is
  not a gradient stop mixing a spot ink with process inks.
- A row wider than 128 chips asks `color.used` for as many colors as it holds.
- The new catalog rows sit with the other Color Wheel rows.
- Tests cover a click on a selected freeform point, the tint a click gives a selected gradient
  stop, a row wider than 128 chips, and `recolor.colors` with a mixed stop painted before a plain
  use linked to another swatch.
This commit is contained in:
dotCooCoo committed 2026-11-14 11:00:27 -08:00
1 parent b83cec1545
commit 276d493e46
32 files changed
+226 -144

No files matched your search

+23 -20
View File
@@ -954,15 +954,14 @@ fn pick_theme(s: &mut Session, p: &Value) -> Result<Value> {
Ok(json!({"colors": colors.iter().map(key_str).collect::<Vec<_>>(), "objects": theme.objects}))
}
/// A color the art uses: how often, and the global swatch it is linked to with the tint (0..1) of
/// the swatch its paint stores, when the paint gives one.
/// A color the art uses: how often, and the global swatch of its first linked use in paint order.
struct Used {
color: Color,
count: usize,
swatch: Option<String>,
tint: Option<f32>,
/// The link comes from a gradient stop that mixes the swatch's ink with process inks.
mixed: bool,
/// The global swatch of the first linked use that is not a gradient stop mixing the swatch's
/// ink with process inks, with the tint (0..1) its paint stores when the paint gives one.
plain: Option<(String, Option<f32>)>,
}
/// The unique colours of the objects `ids` and the objects inside them, most used first (ties by
@@ -983,19 +982,20 @@ fn used_colors(d: &Document, ids: &[NodeId], only: Option<&BTreeSet<NodeId>>) ->
let mut count_tint = |c: &Color, link: Option<&str>, tint: Option<f32>, mixed: bool| {
let k = ColorKey::of(c);
let i = *index.entry(k).or_insert_with(|| {
used.push((k, Used { color: *c, count: 0, swatch: None, tint: None, mixed: false }));
used.push((k, Used { color: *c, count: 0, swatch: None, plain: None }));
used.len() - 1
});
let u = &mut used[i].1;
u.count += 1;
// The first linked use in paint order gives the swatch and tint; a plain linked use
// replaces one from a stop that mixes the swatch's ink with process inks.
if u.swatch.is_none() || (u.mixed && !mixed) {
let linked = link.filter(|l| d.swatch(l).is_some_and(|w| w.global && w.paint.color().is_some()));
if let Some(l) = linked {
if u.swatch.is_some() && (u.plain.is_some() || mixed) {
return;
}
if let Some(l) = link.filter(|l| d.swatch(l).is_some_and(|w| w.global && w.paint.color().is_some())) {
if u.swatch.is_none() {
u.swatch = Some(l.to_string());
u.tint = tint;
u.mixed = mixed;
}
if u.plain.is_none() && !mixed {
u.plain = Some((l.to_string(), tint));
}
}
};
@@ -1089,20 +1089,23 @@ fn all_art(st: &crate::DocState) -> (Vec<NodeId>, Option<BTreeSet<NodeId>>) {
}
/// The `colors` list of `recolor.colors` and `color.used` for the objects `ids` (see
/// [`used_colors`]). With `with_color`, each has its color in its own model and the tint of its
/// swatch, and a gradient stop's color that mixes the swatch's ink with process inks has no swatch.
/// [`used_colors`]). Each names the swatch of its first linked use. With `with_color`, each has its
/// color in its own model, and the swatch and tint come from its first linked use that is not a
/// gradient stop mixing the swatch's ink with process inks (none when every linked use is one).
fn colors_json(used: &[Used], with_color: bool) -> Vec<Value> {
used.iter()
.map(|u| {
let mut v = json!({"key": key_str(&u.color), "hex": u.color.to_hex(), "count": u.count});
if with_color {
v["color"] = json!(u.color);
}
if let Some(w) = u.swatch.as_ref().filter(|_| !(with_color && u.mixed)) {
v["swatch"] = json!(w);
if let Some(t) = u.tint.filter(|_| with_color) {
v["tint"] = json!((f64::from(t) * 100_000.0).round() / 1000.0);
if let Some((w, tint)) = &u.plain {
v["swatch"] = json!(w);
if let Some(t) = tint {
v["tint"] = json!((f64::from(*t) * 100_000.0).round() / 1000.0);
}
}
} else if let Some(w) = &u.swatch {
v["swatch"] = json!(w);
}
v
})
+26
View File
@@ -249,6 +249,32 @@ fn used_colors_take_the_swatch_of_a_plain_use_painted_after_a_mixed_stop_of_the_
assert_eq!((c["swatch"].as_str(), c["tint"].as_f64()), (Some("Ink"), Some(50.0)), "{r}");
}
#[test]
fn recolor_colors_keeps_the_swatch_of_the_first_linked_use_when_a_mixed_stop_comes_first() {
use vectorcraft_color::{Gradient, GradientKind, GradientPaint, GradientStop, Paint};
let mut s = session();
run(&mut s, "swatch.new", json!({"name": "Ink", "color": {"c": 0, "m": 100, "y": 60, "k": 0}, "spot": true}));
run(&mut s, "swatch.new", json!({"name": "Other", "color": {"c": 0, "m": 100, "y": 60, "k": 0}, "spot": true}));
let shape = rect(&mut s, json!("#000000"));
let plain = rect(&mut s, json!("#000000"));
run(&mut s, "paint.setFill", json!({"ids": [plain.0], "swatch": "Other", "tint": 50}));
let ink = fill(&s, plain);
// The stop below the plain fill has the same color, linked to another swatch, with process
// plates that add nothing.
let stop = GradientStop { swatch: Some("Ink".into()), tint: 0.5, plates: Some([0.0; 4]), ..GradientStop::new(0.0, ink) };
let mut end = stop.clone();
end.offset = 1.0;
let g = Gradient::new(GradientKind::Linear, vec![stop, end]);
let st = s.doc_mut().unwrap();
std::sync::Arc::make_mut(&mut st.doc).node_mut(shape).unwrap().appearance.set_fill(Paint::Gradient(Box::new(GradientPaint::new(g))));
run(&mut s, "select.set", json!({"ids": []}));
let three = |r: &Value| r["colors"].as_array().unwrap().iter().find(|c| c["count"] == 3).cloned().unwrap();
let used = run(&mut s, "color.used", json!({}));
assert_eq!(three(&used)["swatch"], "Other", "{used}");
let listed = run(&mut s, "recolor.colors", json!({}));
assert_eq!(three(&listed)["swatch"], "Ink", "recolor.colors names the first linked use: {listed}");
}
#[test]
fn colors_with_nothing_selected_leave_out_hidden_and_locked_objects_in_groups() {
let mut s = session();
+4 -4
View File
@@ -124,10 +124,6 @@
Add to Selection Добавяне към селекцията
Add to Swatches Добавяне към образци
Add Used Colors Добавяне на използваните цветове
Show Document Colors Показване на цветовете на документа
Document Colors Цветове на документа
Selection Colors Цветове на селекцията
@plural Used {n} time|Used {n} times Използван {n} път|Използван {n} пъти
Additional Plug-ins Folder Допълнителна папка за плъгини
Additional Fonts Folder Допълнителна папка за шрифтове
Adjust Adjoining Width Points Регулиране на прилежащите точки за ширина
@@ -566,6 +562,10 @@ font-technology Variable Променливи
Box Channel Канал на квадрата
Color box Цветови квадрат
Color Wheel Options Опции на цветното колело
Show Document Colors Показване на цветовете на документа
Document Colors Цветове на документа
Selection Colors Цветове на селекцията
@plural Used {n} time|Used {n} times Използван {n} път|Използван {n} пъти
Color Type: Цветен тип:
Color: Цвят:
Colorize Оцветяване
Can't render this file because it contains an unexpected character in line 2 and column 73.
+4 -4
View File
@@ -740,6 +740,10 @@
Box Channel Kanal kvadrata
Color box Kvadrat boje
Color Wheel Options Opcije kotača boja
Show Document Colors Prikaži boje dokumenta
Document Colors Boje dokumenta
Selection Colors Boje odabira
@plural Used {n} time|Used {n} times Korišteno {n} put|Korišteno {n} puta|Korišteno {n} puta
CSS Properties CSS svojstva
Document Info Informacije o dokumentu
Flattener Preview Pregled spljoštavanja
@@ -3996,10 +4000,6 @@ theme Appearance Izgled
Add to Graphic Styles Dodaj u grafičke stilove
Graphic Style Library Biblioteka grafičkih stilova
Add Used Colors Dodaj korištene boje
Show Document Colors Prikaži boje dokumenta
Document Colors Boje dokumenta
Selection Colors Boje odabira
@plural Used {n} time|Used {n} times Korišteno {n} put|Korišteno {n} puta|Korišteno {n} puta
Delete Swatch Izbriši uzorak boje
Duplicate Swatch Dupliciraj uzorak boje
Merge Swatches Spoji uzorke boja
Can't render this file because it contains an unexpected character in line 2 and column 73.
+4 -4
View File
@@ -220,10 +220,6 @@
Add to Symbols Afegeix als símbols
Add to the Current Shortcuts Afegeix a les dreceres actuals
Add Used Colors Afegeix els colors utilitzats
Show Document Colors Mostra els colors del document
Document Colors Colors del document
Selection Colors Colors de la selecció
@plural Used {n} time|Used {n} times Utilitzat {n} vegada|Utilitzat {n} vegades
Additional Fonts Folder Carpeta addicional de tipus de lletra
Additional Plug-ins Folder Carpeta addicional de complements
Adjust Adjoining Width Points Ajusta els punts d’amplada contigus
@@ -828,6 +824,10 @@ antiAlias Sharp Nítid
Box Channel Canal del quadre
Color box Quadre de color
Color Wheel Options Opcions de la roda de colors
Show Document Colors Mostra els colors del document
Document Colors Colors del document
Selection Colors Colors de la selecció
@plural Used {n} time|Used {n} times Utilitzat {n} vegada|Utilitzat {n} vegades
Color Type: Tipus de color:
Color wheel Roda de color
Color: Color:
Can't render this file because it contains an unexpected character in line 2 and column 73.
+4 -4
View File
@@ -753,6 +753,10 @@
Box Channel Kanál čtverce
Color box Barevný čtverec
Color Wheel Options Možnosti barevného kola
Show Document Colors Zobrazit barvy dokumentu
Document Colors Barvy dokumentu
Selection Colors Barvy výběru
@plural Used {n} time|Used {n} times Použito {n}krát|Použito {n}krát|Použito {n}krát
CSS Properties Vlastnosti CSS
Document Info Informace o dokumentu
Flattener Preview Náhled sloučení
@@ -4052,10 +4056,6 @@ theme Appearance Motiv
Add to Graphic Styles Přidat do grafických stylů
Graphic Style Library Knihovna grafických stylů
Add Used Colors Přidat použité barvy
Show Document Colors Zobrazit barvy dokumentu
Document Colors Barvy dokumentu
Selection Colors Barvy výběru
@plural Used {n} time|Used {n} times Použito {n}krát|Použito {n}krát|Použito {n}krát
Delete Swatch Odstranit položku vzorníku
Duplicate Swatch Duplikovat položku vzorníku
Merge Swatches Sloučit položky vzorníku
Can't render this file because it is too large.
+4 -4
View File
@@ -698,6 +698,10 @@
Box Channel Kvadratets kanal
Color box Farvekvadrat
Color Wheel Options Indstillinger for farvehjul
Show Document Colors Vis dokumentfarver
Document Colors Dokumentfarver
Selection Colors Markeringens farver
@plural Used {n} time|Used {n} times Brugt {n} gang|Brugt {n} gange
CSS Properties CSS-egenskaber
Document Info Dokumentoplysninger
Flattener Preview Udjævningsforhåndsvisning
@@ -3769,10 +3773,6 @@ theme Appearance Udseende
Add to Graphic Styles Føj til grafikstile
Graphic Style Library Grafikstilbibliotek
Add Used Colors Tilføj anvendte farver
Show Document Colors Vis dokumentfarver
Document Colors Dokumentfarver
Selection Colors Markeringens farver
@plural Used {n} time|Used {n} times Brugt {n} gang|Brugt {n} gange
Delete Swatch Slet farveprøve
Duplicate Swatch Duplikér farveprøve
Merge Swatches Flet farveprøver
Can't render this file because it contains an unexpected character in line 2 and column 73.
+4 -4
View File
@@ -113,10 +113,6 @@
Add to Selection Zur Auswahl hinzufügen
Add to Swatches Zu Farbfeldern hinzufügen
Add Used Colors Verwendete Farben hinzufügen
Show Document Colors Dokumentfarben einblenden
Document Colors Dokumentfarben
Selection Colors Farben der Auswahl
@plural Used {n} time|Used {n} times {n}-mal verwendet|{n}-mal verwendet
Additional Plug-ins Folder Zusätzlicher Plug-in-Ordner
Additional Fonts Folder Zusätzlicher Schriftenordner
Adjust Adjoining Width Points Angrenzende Breitenpunkte anpassen
@@ -559,6 +555,10 @@ font-technology Variable Variabel
Box Channel Kanal des Quadrats
Color box Farbquadrat
Color Wheel Options Optionen für den Farbkreis
Show Document Colors Dokumentfarben einblenden
Document Colors Dokumentfarben
Selection Colors Farben der Auswahl
@plural Used {n} time|Used {n} times {n}-mal verwendet|{n}-mal verwendet
Color Type: Farbart:
Color: Farbe:
Colorize Einfärben
Can't render this file because it is too large.
+4 -4
View File
@@ -118,10 +118,6 @@
Add to Selection Προσθήκη στην επιλογή
Add to Swatches Προσθήκη στα δείγματα χρωμάτων
Add Used Colors Προσθήκη των χρησιμοποιημένων χρωμάτων
Show Document Colors Εμφάνιση χρωμάτων εγγράφου
Document Colors Χρώματα εγγράφου
Selection Colors Χρώματα επιλογής
@plural Used {n} time|Used {n} times Χρησιμοποιείται {n} φορά|Χρησιμοποιείται {n} φορές
Additional Plug-ins Folder Πρόσθετος φάκελος επεκτάσεων
Additional Fonts Folder Πρόσθετος φάκελος γραμματοσειρών
Adjust Adjoining Width Points Ρύθμιση γειτονικών σημείων πλάτους
@@ -541,6 +537,10 @@ font-technology Variable Μεταβλητές
Box Channel Κανάλι τετραγώνου
Color box Τετράγωνο χρώματος
Color Wheel Options Επιλογές χρωματικού τροχού
Show Document Colors Εμφάνιση χρωμάτων εγγράφου
Document Colors Χρώματα εγγράφου
Selection Colors Χρώματα επιλογής
@plural Used {n} time|Used {n} times Χρησιμοποιείται {n} φορά|Χρησιμοποιείται {n} φορές
Color Type: Τύπος χρώματος:
Color: Χρώμα:
Colorize Χρωματισμός
Can't render this file because it is too large.
+4 -4
View File
@@ -138,10 +138,6 @@
Add to Selection Agregar a la selección
Add to Swatches Agregar a muestras
Add Used Colors Agregar colores usados
Show Document Colors Mostrar colores del documento
Document Colors Colores del documento
Selection Colors Colores de la selección
@plural Used {n} time|Used {n} times Usado {n} vez|Usado {n} veces
Additional Plug-ins Folder Carpeta de plugins adicionales
Additional Fonts Folder Carpeta de fuentes adicionales
Adjust Adjoining Width Points Ajustar puntos de anchura contiguos
@@ -581,6 +577,10 @@ font-technology Variable Variables
Box Channel Canal del cuadro
Color box Cuadro de color
Color Wheel Options Opciones de la rueda de color
Show Document Colors Mostrar colores del documento
Document Colors Colores del documento
Selection Colors Colores de la selección
@plural Used {n} time|Used {n} times Usado {n} vez|Usado {n} veces
Color Type: Tipo de color:
Color: Color:
Colorize Colorear
Can't render this file because it contains an unexpected character in line 2 and column 73.
+4 -4
View File
@@ -744,6 +744,10 @@
Box Channel Ruudun kanava
Color box Väriruutu
Color Wheel Options Väriympyrän asetukset
Show Document Colors Näytä asiakirjan värit
Document Colors Asiakirjan värit
Selection Colors Valinnan värit
@plural Used {n} time|Used {n} times Käytetty {n} kerran|Käytetty {n} kertaa
CSS Properties CSS-ominaisuudet
Document Info Asiakirjan tiedot
Flattener Preview Litistyksen esikatselu
@@ -3976,10 +3980,6 @@ theme Appearance Ulkoasu
Add to Graphic Styles Lisää grafiikkatyyleihin
Graphic Style Library Grafiikkatyylikirjasto
Add Used Colors Lisää käytetyt värit
Show Document Colors Näytä asiakirjan värit
Document Colors Asiakirjan värit
Selection Colors Valinnan värit
@plural Used {n} time|Used {n} times Käytetty {n} kerran|Käytetty {n} kertaa
Delete Swatch Poista värimalli
Duplicate Swatch Monista värimalli
Merge Swatches Yhdistä värimallit
Can't render this file because it contains an unexpected character in line 2 and column 73.
+4 -4
View File
@@ -139,10 +139,6 @@
Add to Selection Ajouter à la sélection
Add to Swatches Ajouter au nuancier
Add Used Colors Ajouter les couleurs utilisées
Show Document Colors Afficher les couleurs du document
Document Colors Couleurs du document
Selection Colors Couleurs de la sélection
@plural Used {n} time|Used {n} times Utilisée {n} fois|Utilisée {n} fois
Additional Plug-ins Folder Dossier de modules externes supplémentaires
Additional Fonts Folder Dossier de polices supplémentaires
Adjust Adjoining Width Points Ajuster les points de largeur adjacents
@@ -582,6 +578,10 @@ font-technology Variable Variables
Box Channel Couche du carré
Color box Carré de couleur
Color Wheel Options Options de la roue chromatique
Show Document Colors Afficher les couleurs du document
Document Colors Couleurs du document
Selection Colors Couleurs de la sélection
@plural Used {n} time|Used {n} times Utilisée {n} fois|Utilisée {n} fois
Color Type: Type de couleur :
Color: Couleur :
Colorize Coloriser
Can't render this file because it is too large.
+4 -4
View File
@@ -148,10 +148,6 @@
Add Selected Artwork as One Asset પસંદ કરેલી આર્ટવર્ક એક સંપત્તિ તરીકે ઉમેરો
Add Spine Point સ્પાઇન બિંદુ ઉમેરો
Add Used Colors વપરાયેલા રંગ ઉમેરો
Show Document Colors દસ્તાવેજના રંગો બતાવો
Document Colors દસ્તાવેજના રંગો
Selection Colors પસંદગીના રંગો
@plural Used {n} time|Used {n} times {n} વાર વપરાયો|{n} વાર વપરાયો
Add as Effect ઇફેક્ટ તરીકે ઉમેરો
Add space to fit ફિટ કરવા જગ્યા ઉમેરો
Add to Brushes બ્રશમાં ઉમેરો
@@ -4233,6 +4229,10 @@
Box Channel બૉક્સ ચેનલ
Color box રંગ બૉક્સ
Color Wheel Options રંગ વ્હીલ વિકલ્પો
Show Document Colors દસ્તાવેજના રંગો બતાવો
Document Colors દસ્તાવેજના રંગો
Selection Colors પસંદગીના રંગો
@plural Used {n} time|Used {n} times {n} વાર વપરાયો|{n} વાર વપરાયો
{name} (spot) {name} (સ્પૉટ)
{pages} in all, {count} per copy કુલ {pages}, પ્રતિ નકલ {count}
{page} of {count} {count} માંથી {page}
Can't render this file because it contains an unexpected character in line 72 and column 5.
+4 -4
View File
@@ -254,10 +254,6 @@
Add to Symbols सिंबल्स में जोड़ें
Add to the Current Shortcuts वर्तमान शॉर्टकट में जोड़ें
Add Used Colors उपयोग किए रंग जोड़ें
Show Document Colors डॉक्यूमेंट के रंग दिखाएँ
Document Colors डॉक्यूमेंट के रंग
Selection Colors चयन के रंग
@plural Used {n} time|Used {n} times {n} बार उपयोग किया गया|{n} बार उपयोग किया गया
Additional Fonts Folder अतिरिक्त फ़ॉन्ट फ़ोल्डर
Additional Plug-ins Folder अतिरिक्त प्लग-इन फ़ोल्डर
Adjust Adjoining Width Points सटे हुए चौड़ाई पॉइंट समायोजित करें
@@ -952,6 +948,10 @@ antiAlias Sharp शार्प
Box Channel बॉक्स चैनल
Color box कलर बॉक्स
Color Wheel Options कलर व्हील ऑप्शन्स
Show Document Colors डॉक्यूमेंट के रंग दिखाएँ
Document Colors डॉक्यूमेंट के रंग
Selection Colors चयन के रंग
@plural Used {n} time|Used {n} times {n} बार उपयोग किया गया|{n} बार उपयोग किया गया
Color Type: रंग का प्रकार:
Color wheel कलर व्हील
Color: रंग:
Can't render this file because it is too large.
+4 -4
View File
@@ -208,10 +208,6 @@
Add to Selection Hozzáadás a kijelöléshez
Add to Swatches Hozzáadás a színmintákhoz
Add Used Colors Használt színek hozzáadása
Show Document Colors Dokumentumszínek megjelenítése
Document Colors Dokumentumszínek
Selection Colors A kijelölés színei
@plural Used {n} time|Used {n} times {n} alkalommal használva
Additional Fonts Folder További betűtípusok mappája
Additional Plug-ins Folder További bővítmények mappája
Adjust Adjoining Width Points Szomszédos szélességi pontok igazítása
@@ -757,6 +753,10 @@ font-technology Variable Változó
Box Channel Négyzet csatornája
Color box Színnégyzet
Color Wheel Options Színkör beállításai
Show Document Colors Dokumentumszínek megjelenítése
Document Colors Dokumentumszínek
Selection Colors A kijelölés színei
@plural Used {n} time|Used {n} times {n} alkalommal használva
Color Type: Színtípus:
Color: Szín:
Colorization Színezés
Can't render this file because it contains an unexpected character in line 2 and column 73.
+4 -4
View File
@@ -698,6 +698,10 @@
Box Channel Saluran kotak
Color box Kotak warna
Color Wheel Options Opsi roda warna
Show Document Colors Tampilkan warna dokumen
Document Colors Warna dokumen
Selection Colors Warna pilihan
@plural Used {n} time|Used {n} times Dipakai {n} kali
CSS Properties Properti CSS
Document Info Info dokumen
Flattener Preview Pratinjau perata
@@ -3769,10 +3773,6 @@ theme Appearance Tampilan
Add to Graphic Styles Tambahkan ke gaya grafis
Graphic Style Library Pustaka gaya grafis
Add Used Colors Tambahkan warna yang digunakan
Show Document Colors Tampilkan warna dokumen
Document Colors Warna dokumen
Selection Colors Warna pilihan
@plural Used {n} time|Used {n} times Dipakai {n} kali
Delete Swatch Hapus sampel
Duplicate Swatch Duplikatkan sampel
Merge Swatches Gabungkan sampel
Can't render this file because it contains an unexpected character in line 2442 and column 5.
+4 -4
View File
@@ -138,10 +138,6 @@
Add to Selection Aggiungi alla selezione
Add to Swatches Aggiungi ai campioni
Add Used Colors Aggiungi colori usati
Show Document Colors Mostra colori del documento
Document Colors Colori del documento
Selection Colors Colori della selezione
@plural Used {n} time|Used {n} times Usato {n} volta|Usato {n} volte
Additional Plug-ins Folder Cartella plug-in aggiuntivi
Additional Fonts Folder Cartella font aggiuntivi
Adjust Adjoining Width Points Regola punti di larghezza adiacenti
@@ -581,6 +577,10 @@ font-technology Variable Variabili
Box Channel Canale del riquadro
Color box Riquadro colore
Color Wheel Options Opzioni ruota dei colori
Show Document Colors Mostra colori del documento
Document Colors Colori del documento
Selection Colors Colori della selezione
@plural Used {n} time|Used {n} times Usato {n} volta|Usato {n} volte
Color Type: Tipo di colore:
Color: Colore:
Colorize Colora
Can't render this file because it is too large.
+4 -4
View File
@@ -768,6 +768,10 @@ digits Malayalam マラヤーラム数字
Box Channel ボックスのチャンネル
Color box カラーボックス
Color Wheel Options カラーホイールオプション
Show Document Colors ドキュメントのカラーを表示
Document Colors ドキュメントのカラー
Selection Colors 選択範囲のカラー
@plural Used {n} time|Used {n} times {n} 回使用
CSS Properties CSS プロパティ
Document Info ドキュメント情報
Flattener Preview 分割・統合プレビュー
@@ -1046,10 +1050,6 @@ digits Malayalam マラヤーラム数字
Add Selected Artwork as One Asset 選択したアートワークを 1 つのアセットとして追加
Add Spine Point スパインポイントを追加
Add Used Colors 使用中のカラーを追加
Show Document Colors ドキュメントのカラーを表示
Document Colors ドキュメントのカラー
Selection Colors 選択範囲のカラー
@plural Used {n} time|Used {n} times {n} 回使用
Add to Graphic Styles グラフィックスタイルに追加
Add to Profiles プロファイルに追加
Add to Profiles… プロファイルに追加…
Can't render this file because it contains an unexpected character in line 2 and column 73.
+4 -4
View File
@@ -664,6 +664,10 @@
Box Channel კვადრატის არხი
Color box ფერის კვადრატი
Color Wheel Options ფერთა წრის პარამეტრები
Show Document Colors დოკუმენტის ფერების ჩვენება
Document Colors დოკუმენტის ფერები
Selection Colors მონიშნულის ფერები
@plural Used {n} time|Used {n} times გამოყენებულია {n}-ჯერ
CSS Properties CSS თვისებები
Document Info დოკუმენტის ინფორმაცია
Flattener Preview გაბრტყელების წინასწარი ნახვა
@@ -3608,10 +3612,6 @@ theme Appearance იერსახე
Add to Graphic Styles გრაფიკულ სტილებში დამატება
Graphic Style Library გრაფიკული სტილების ბიბლიოთეკა
Add Used Colors გამოყენებული ფერების დამატება
Show Document Colors დოკუმენტის ფერების ჩვენება
Document Colors დოკუმენტის ფერები
Selection Colors მონიშნულის ფერები
@plural Used {n} time|Used {n} times გამოყენებულია {n}-ჯერ
Delete Swatch ფერის ნიმუშის წაშლა
Duplicate Swatch ფერის ნიმუშის დუბლირება
Merge Swatches ფერის ნიმუშების შერწყმა
Can't render this file because it is too large.
+4 -4
View File
@@ -761,6 +761,10 @@ digits Malayalam 말라얄람어
Box Channel 상자 채널
Color box 색상 상자
Color Wheel Options 색상환 옵션
Show Document Colors 문서 색상 표시
Document Colors 문서 색상
Selection Colors 선택 영역 색상
@plural Used {n} time|Used {n} times {n}회 사용
CSS Properties CSS 속성
Document Info 문서 정보
Flattener Preview 병합 미리 보기
@@ -1036,10 +1040,6 @@ digits Malayalam 말라얄람어
Add Selected Artwork as One Asset 선택한 아트워크를 하나의 에셋으로 추가
Add Spine Point 스파인 포인트 추가
Add Used Colors 사용한 색상 추가
Show Document Colors 문서 색상 표시
Document Colors 문서 색상
Selection Colors 선택 영역 색상
@plural Used {n} time|Used {n} times {n}회 사용
Add to Graphic Styles 그래픽 스타일에 추가
Add to Profiles 프로필에 추가
Add to Profiles… 프로필에 추가…
Can't render this file because it is too large.
+4 -4
View File
@@ -1216,6 +1216,10 @@
Box Channel Kanaal van het vak
Color box Kleurvak
Color Wheel Options Opties voor kleurenwiel
Show Document Colors Documentkleuren tonen
Document Colors Documentkleuren
Selection Colors Kleuren van de selectie
@plural Used {n} time|Used {n} times {n} keer gebruikt|{n} keer gebruikt
CSS Properties CSS-eigenschappen
Document Info Documentinfo
Flattener Preview Afvlakvoorbeeld
@@ -4287,10 +4291,6 @@ theme Appearance Vormgeving
Add to Graphic Styles Aan grafische stijlen toevoegen
Graphic Style Library Bibliotheek met grafische stijlen
Add Used Colors Gebruikte kleuren toevoegen
Show Document Colors Documentkleuren tonen
Document Colors Documentkleuren
Selection Colors Kleuren van de selectie
@plural Used {n} time|Used {n} times {n} keer gebruikt|{n} keer gebruikt
Delete Swatch Kleurstaal verwijderen
Duplicate Swatch Kleurstaal dupliceren
Merge Swatches Kleurstalen samenvoegen
Can't render this file because it contains an unexpected character in line 2 and column 73.
+4 -4
View File
@@ -702,6 +702,10 @@
Box Channel Kanał kwadratu
Color box Kwadrat koloru
Color Wheel Options Opcje koła kolorów
Show Document Colors Pokaż kolory dokumentu
Document Colors Kolory dokumentu
Selection Colors Kolory zaznaczenia
@plural Used {n} time|Used {n} times Użyty {n} raz|Użyty {n} razy|Użyty {n} razy
CSS Properties Właściwości CSS
Document Info Informacje o dokumencie
Flattener Preview Podgląd spłaszczania
@@ -3911,10 +3915,6 @@ theme Appearance Wygląd
Add to Graphic Styles Dodaj do stylów graficznych
Graphic Style Library Biblioteka stylów graficznych
Add Used Colors Dodaj użyte kolory
Show Document Colors Pokaż kolory dokumentu
Document Colors Kolory dokumentu
Selection Colors Kolory zaznaczenia
@plural Used {n} time|Used {n} times Użyty {n} raz|Użyty {n} razy|Użyty {n} razy
Delete Swatch Usuń próbkę
Duplicate Swatch Powiel próbkę
Merge Swatches Scal próbki
Can't render this file because it is too large.
+4 -4
View File
@@ -140,10 +140,6 @@
Add Selected Artwork as One Asset Adicionar Arte Selecionada como Um Ativo
Add Spine Point Adicionar Ponto de Coluna
Add Used Colors Adicionar Cores Usadas
Show Document Colors Mostrar Cores do Documento
Document Colors Cores do Documento
Selection Colors Cores da Seleção
@plural Used {n} time|Used {n} times Usada {n} vez|Usada {n} vezes
Add to Graphic Styles Adicionar aos Estilos Gráficos
Add to Profiles Adicionar aos Perfis
Add to Profiles… Adicionar aos Perfis…
@@ -526,6 +522,10 @@ antiAlias Sharp Nítido
Box Channel Canal da Caixa
Color box Caixa de cor
Color Wheel Options Opções da Roda de Cores
Show Document Colors Mostrar Cores do Documento
Document Colors Cores do Documento
Selection Colors Cores da Seleção
@plural Used {n} time|Used {n} times Usada {n} vez|Usada {n} vezes
Color Type: Tipo de Cor:
Color blindness – Deuteranopia-type Daltonismo – tipo deuteranopia
Color blindness – Protanopia-type Daltonismo – tipo protanopia
Can't render this file because it is too large.
+4 -4
View File
@@ -136,10 +136,6 @@
Add to Selection Добавить к выделению
Add to Swatches Добавить в образцы
Add Used Colors Добавить использованные цвета
Show Document Colors Показать цвета документа
Document Colors Цвета документа
Selection Colors Цвета выделения
@plural Used {n} time|Used {n} times Используется {n} раз|Используется {n} раза|Используется {n} раз
Additional Plug-ins Folder Папка дополнительных модулей
Additional Fonts Folder Папка дополнительных шрифтов
Adjust Adjoining Width Points Настроить смежные точки ширины
@@ -579,6 +575,10 @@ font-technology Variable Вариативные
Box Channel Канал квадрата
Color box Цветовой квадрат
Color Wheel Options Параметры цветового круга
Show Document Colors Показать цвета документа
Document Colors Цвета документа
Selection Colors Цвета выделения
@plural Used {n} time|Used {n} times Используется {n} раз|Используется {n} раза|Используется {n} раз
Color Type: Тип цвета:
Color: Цвет:
Colorize Тонировать
Can't render this file because it is too large.
+4 -4
View File
@@ -126,10 +126,6 @@
Add to Selection Lägg till i markering
Add to Swatches Lägg till i färgrutor
Add Used Colors Lägg till använda färger
Show Document Colors Visa dokumentfärger
Document Colors Dokumentfärger
Selection Colors Markeringens färger
@plural Used {n} time|Used {n} times Används {n} gång|Används {n} gånger
Additional Plug-ins Folder Mapp för ytterligare plugins
Additional Fonts Folder Mapp för ytterligare typsnitt
Adjust Adjoining Width Points Justera angränsande breddpunkter
@@ -568,6 +564,10 @@ font-technology Variable Variabla
Box Channel Rutans kanal
Color box Färgruta
Color Wheel Options Alternativ för färghjulet
Show Document Colors Visa dokumentfärger
Document Colors Dokumentfärger
Selection Colors Markeringens färger
@plural Used {n} time|Used {n} times Används {n} gång|Används {n} gånger
Color Type: Färgtyp:
Color: Färg:
Colorize Färglägg
Can't render this file because it is too large.
+4 -4
View File
@@ -123,10 +123,6 @@
Add to Selection Seçime Ekle
Add to Swatches Renk Örneklerine Ekle
Add Used Colors Kullanılan Renkleri Ekle
Show Document Colors Belge Renklerini Göster
Document Colors Belge Renkleri
Selection Colors Seçim Renkleri
@plural Used {n} time|Used {n} times {n} kez kullanıldı
Additional Plug-ins Folder Ek Eklentiler Klasörü
Additional Fonts Folder Ek Yazı Tipleri Klasörü
Adjust Adjoining Width Points Bitişik Genişlik Noktalarını Ayarlayın
@@ -562,6 +558,10 @@ font-technology Variable Değişken
Box Channel Kutu Kanalı
Color box Renk kutusu
Color Wheel Options Renk Tekerleği Seçenekleri
Show Document Colors Belge Renklerini Göster
Document Colors Belge Renkleri
Selection Colors Seçim Renkleri
@plural Used {n} time|Used {n} times {n} kez kullanıldı
Color Type: Renk Türü:
Color: Renk:
Colorize Renklendir
Can't render this file because it contains an unexpected character in line 5 and column 25.
+4 -4
View File
@@ -132,10 +132,6 @@
Add to Selection Додати до виділення
Add to Swatches Додати до зразків
Add Used Colors Додати використані кольори
Show Document Colors Показати кольори документа
Document Colors Кольори документа
Selection Colors Кольори виділення
@plural Used {n} time|Used {n} times Використано {n} раз|Використано {n} рази|Використано {n} разів
Additional Plug-ins Folder Папка додаткових модулів
Additional Fonts Folder Папка додаткових шрифтів
Adjust Adjoining Width Points Налаштувати суміжні точки ширини
@@ -575,6 +571,10 @@ font-technology Variable Варіативні
Box Channel Канал квадрата
Color box Колірний квадрат
Color Wheel Options Параметри колірного кола
Show Document Colors Показати кольори документа
Document Colors Кольори документа
Selection Colors Кольори виділення
@plural Used {n} time|Used {n} times Використано {n} раз|Використано {n} рази|Використано {n} разів
Color Type: Тип кольору:
Color: Колір:
Colorize Тонувати
Can't render this file because it is too large.
+4 -4
View File
@@ -154,10 +154,6 @@
Add to Selection Thêm vào vùng chọn
Add to Swatches Thêm vào mẫu màu
Add Used Colors Thêm các màu đã dùng
Show Document Colors Hiện màu của tài liệu
Document Colors Màu của tài liệu
Selection Colors Màu của vùng chọn
@plural Used {n} time|Used {n} times Dùng {n} lần
Additional Fonts Folder Thư mục phông bổ sung
Additional Plug-ins Folder Thư mục plug-in bổ sung
Adjust Adjoining Width Points Điều chỉnh các điểm chiều rộng kề nhau
@@ -668,6 +664,10 @@ font-technology Variable Biến thiên
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
Show Document Colors Hiện màu của tài liệu
Document Colors Màu của tài liệu
Selection Colors Màu của vùng chọn
@plural Used {n} time|Used {n} times Dùng {n} lần
Color Type: Loại màu:
Color: Màu:
Colorization Tô màu
Can't render this file because it contains an unexpected character in line 204 and column 5.
+4 -4
View File
@@ -88,10 +88,6 @@
Add to Selection 添加到选区
Add to Swatches 添加到色板
Add Used Colors 添加已用颜色
Show Document Colors 显示文档颜色
Document Colors 文档颜色
Selection Colors 所选对象的颜色
@plural Used {n} time|Used {n} times 使用 {n} 次
Additional Plug-ins Folder 附加增效工具文件夹
Additional Fonts Folder 附加字体文件夹
Adjust Adjoining Width Points 调整相邻宽度点
@@ -527,6 +523,10 @@ antiAlias Sharp 锐利
Box Channel 方块色版
Color box 颜色方块
Color Wheel Options 色轮选项
Show Document Colors 显示文档颜色
Document Colors 文档颜色
Selection Colors 所选对象的颜色
@plural Used {n} time|Used {n} times 使用 {n} 次
Color Type: 颜色类型:
Color: 颜色:
Colorize 上色
Can't render this file because it is too large.
+4 -4
View File
@@ -97,10 +97,6 @@
Add to Selection 加入選取範圍
Add to Swatches 新增至色票
Add Used Colors 新增使用中的顏色
Show Document Colors 顯示文件顏色
Document Colors 文件顏色
Selection Colors 所選物件的顏色
@plural Used {n} time|Used {n} times 使用 {n} 次
Additional Plug-ins Folder 額外的增效模組資料夾
Additional Fonts Folder 額外的字體資料夾
Adjust Adjoining Width Points 調整相鄰寬度點
@@ -544,6 +540,10 @@ font-technology Variable 可變
Box Channel 方塊色版
Color box 顏色方塊
Color Wheel Options 色輪選項
Show Document Colors 顯示文件顏色
Document Colors 文件顏色
Selection Colors 所選物件的顏色
@plural Used {n} time|Used {n} times 使用 {n} 次
Color Type: 顏色類型:
Color: 顏色:
Colorize 上色
Can't render this file because it is too large.
+16 -9
View File
@@ -162,7 +162,8 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
/// Panel state: the Show Document Colors row's colors, with the [`UsedKey`] they were read for.
const USED: &str = "color-wheel-used";
/// The most chips the row asks `color.used` for.
/// The fewest chips the row asks `color.used` for; a row wider than this many chips asks for as
/// many as it holds.
const MAX_CHIPS: usize = 128;
/// Above this many color uses, an edit makes the row read the colors again at most once every
/// [`LARGE_EVERY`] seconds; a change of document or selection still reads them at once.
@@ -184,6 +185,8 @@ struct UsedCache {
uses: u64,
/// Whether the colors are the selection's.
selected: bool,
/// The most colors asked for.
limit: usize,
colors: Vec<Used>,
}
@@ -210,15 +213,19 @@ impl Used {
/// The colors the row shows and whether they are the selection's, read with `color.used` once per
/// document revision and selection and kept as they are while an interaction is in progress (a
/// preview raises the revision on every frame of a drag). In art with more than [`LARGE_USES`]
/// color uses, an edit reads them again only after [`LARGE_EVERY`] seconds.
fn used_colors(app: &mut VectorcraftApp, ui: &Ui) -> Arc<UsedCache> {
/// color uses, an edit reads them again only after [`LARGE_EVERY`] seconds. A row that holds more
/// than the colors last asked for reads them again.
fn used_colors(app: &mut VectorcraftApp, ui: &Ui, per_row: usize) -> Arc<UsedCache> {
let limit = per_row.max(MAX_CHIPS);
let key: UsedKey = app.session.active().map(|d| {
let mut h = std::collections::hash_map::DefaultHasher::new();
d.selection.objects.hash(&mut h);
(d.uid, d.revision, d.selection.objects.len(), h.finish())
});
let now = ui.input(|i| i.time);
if let Some(cache) = pstate::<Option<Arc<UsedCache>>>(ui.ctx(), USED) {
if let Some(cache) = pstate::<Option<Arc<UsedCache>>>(ui.ctx(), USED)
&& (cache.limit >= per_row || cache.colors.len() < cache.limit)
{
if cache.key == key || app.session.in_interaction() {
return cache;
}
@@ -229,7 +236,7 @@ fn used_colors(app: &mut VectorcraftApp, ui: &Ui) -> Arc<UsedCache> {
return cache;
}
}
let r = key.as_ref().and_then(|_| app.session.execute("color.used", &json!({ "limit": MAX_CHIPS })).ok());
let r = key.as_ref().and_then(|_| app.session.execute("color.used", &json!({ "limit": limit })).ok());
let colors: Vec<Used> = r
.as_ref()
.and_then(|r| r["colors"].as_array())
@@ -246,7 +253,7 @@ fn used_colors(app: &mut VectorcraftApp, ui: &Ui) -> Arc<UsedCache> {
.unwrap_or_default();
let selected = r.as_ref().is_some_and(|r| r["selection"] == true);
let uses = r.as_ref().and_then(|r| r["uses"].as_u64()).unwrap_or(0);
let cache = Arc::new(UsedCache { key, at: now, uses, selected, colors });
let cache = Arc::new(UsedCache { key, at: now, uses, selected, limit, colors });
set_pstate(ui.ctx(), USED, Some(Arc::clone(&cache)));
cache
}
@@ -254,13 +261,13 @@ fn used_colors(app: &mut VectorcraftApp, ui: &Ui) -> Arc<UsedCache> {
/// The Show Document Colors row: a heading (Selection Colors or Document Colors) and the colors,
/// most used first, as many as fit in one row. Returns the color clicked.
fn document_colors_row(app: &mut VectorcraftApp, ui: &mut Ui) -> Option<Used> {
let cache = used_colors(app, ui);
widgets::subheader(ui, if cache.selected { tl!("Selection Colors") } else { tl!("Document Colors") });
let t = Tokens::get(ui.ctx());
let width = ui.available_width();
// Chips are 16 px on a 19 px pitch, inset 3 px, with 2 px kept clear of the right edge, as
// in the Recent Colors row.
let per_row = (((width - 21.0) / 19.0).floor().max(0.0) as usize + 1).max(1);
let cache = used_colors(app, ui, per_row);
widgets::subheader(ui, if cache.selected { tl!("Selection Colors") } else { tl!("Document Colors") });
let t = Tokens::get(ui.ctx());
let (r, _) = ui.allocate_exact_size(vec2(width, 22.0), Sense::hover());
ui.painter().rect_stroke(r, 0.0, egui::Stroke::new(1.0, t.input_border), egui::StrokeKind::Inside);
let mut chosen = None;
@@ -1,6 +1,6 @@
//! The Color Wheel panel's Show Document Colors row drawn headless: its colors and their order,
//! the heading that follows the selection, the colors that fit in one row, a click and an Alt+click
//! on a color, swatch links, gradient stops, the colors kept during a drag, the panel menu,
//! on a color, swatch links, gradient stops and freeform points, the colors kept during a drag, the panel menu,
//! `ui.colorWheel {documentColors}` and the saved setting.
use egui::{Event, Modifiers, PointerButton, Pos2, vec2};
@@ -110,6 +110,21 @@ fn the_row_shows_only_the_colors_that_fit() {
assert!(shown.iter().all(|r| (r.top() - red.top()).abs() < 0.5 && r.right() <= 260.0), "one row inside the panel: {shown:?}");
}
/// A row wide enough for more than 128 chips shows as many colors as fit.
#[test]
fn a_wide_row_shows_more_than_128_colors() {
let (mut app, _, _) = app();
let hex = |i: usize| format!("#{:02x}{:02x}80", i % 256, i / 256 + 1);
for i in 0..160 {
rect(&mut app, 170.0, json!({"color": hex(i)}));
}
app.run("select.none", json!({})).unwrap();
let mut h = Harness::builder().with_size(vec2(3400.0, 360.0)).build_ui_state(|ui, app: &mut VectorcraftApp| show(app, ui), app);
h.run_steps(2);
let shown = (0..160).filter(|i| has(&h, &label(&hex(*i), 1))).count();
assert!(shown > 128, "{shown} of the 160 colors show");
}
/// A click on a color fills the selection with it, as one undo step.
#[test]
fn a_click_on_a_color_sets_the_fill() {
@@ -170,13 +185,13 @@ fn a_click_keeps_a_swatch_link_and_its_tint() {
assert!((tint - 0.4).abs() < 1e-3, "tint {tint}");
}
/// A click recolors the selected gradient stop, linking it to a color's swatch.
/// A click recolors the selected gradient stop, linking it to a color's swatch at its tint.
#[test]
fn a_click_recolors_the_selected_gradient_stop() {
let mut app = VectorcraftApp::new(Session::new(), Default::default());
app.run("file.new", json!({"width": 300, "height": 200})).unwrap();
app.run("swatch.new", json!({"name": "Ink", "color": {"c": 0, "m": 100, "y": 60, "k": 0}, "spot": true})).unwrap();
let stops = json!([{"offset": 0, "color": "#000000", "swatch": "Ink"}, {"offset": 1, "color": "#0000ff"}]);
let stops = json!([{"offset": 0, "color": "#000000", "swatch": "Ink", "tint": 40}, {"offset": 1, "color": "#0000ff"}]);
rect(&mut app, 10.0, json!({"gradient": {"stops": stops, "start": [10, 25], "end": [40, 25]}}));
app.select_tool("gradient");
app.run("gradient.selectStop", json!({"index": 1})).unwrap();
@@ -196,6 +211,37 @@ fn a_click_recolors_the_selected_gradient_stop() {
let Paint::Gradient(g) = crate::panels::current_paints(h.state()).0 else { panic!("still a gradient") };
let stop = &g.gradient.stops[1];
assert_eq!((stop.color.to_hex(), stop.swatch.as_deref()), (hex, Some("Ink")));
assert!((stop.tint - 0.4).abs() < 1e-3, "tint {}", stop.tint);
}
/// A click on a color linked to a swatch gives a selected freeform point the color alone and keeps
/// the freeform fill.
#[test]
fn a_click_gives_a_freeform_point_the_color_alone() {
let mut app = VectorcraftApp::new(Session::new(), Default::default());
app.run("file.new", json!({"width": 300, "height": 200})).unwrap();
app.run("swatch.new", json!({"name": "Ink", "color": {"c": 0, "m": 100, "y": 60, "k": 0}, "spot": true})).unwrap();
app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 100, "height": 100})).unwrap();
app.run("paint.editGradient", json!({"kind": "freeform"})).unwrap();
app.run("paint.setStroke", json!({"swatch": "Ink", "tint": 40, "focus": false})).unwrap();
app.select_tool("gradient");
app.run("paint.freeform.selectPoint", json!({"index": 1})).unwrap();
app.run("ui.colorWheel", json!({"documentColors": true})).unwrap();
let hex = app.session.execute("color.used", &json!({})).unwrap()["colors"]
.as_array()
.unwrap()
.iter()
.find(|c| c["swatch"] == "Ink")
.expect("the stroke's color is listed")["hex"]
.as_str()
.unwrap()
.to_string();
let mut h = harness(app);
let at = h.get_by_label(&label(&hex, 1)).rect().center();
click(&mut h, at, Modifiers::NONE);
let Paint::Gradient(g) = crate::panels::current_paints(h.state()).0 else { panic!("still a gradient") };
let points = g.freeform.expect("still freeform").points;
assert_eq!(points[1].color.to_hex(), hex);
}
/// While a drag on the wheel recolors the selection, the row keeps the colors from before the