diff --git a/assets/color_books/README.md b/assets/color_books/README.md
new file mode 100644
index 000000000..d20dbd5f6
--- /dev/null
+++ b/assets/color_books/README.md
@@ -0,0 +1,13 @@
+# Built-in colour books
+
+AutoCAD `.acb` colour books built into the Select Color panel. Each file
+carries its source and licence in its header comment.
+
+| File | Book | Licence |
+|---|---|---|
+| `ral-classic.acb` | RAL CLASSIC, 216 approximate sRGB values | CC BY-SA 4.0, adapted from Wikipedia, "List of RAL colours" |
+| `css-colors.acb` | CSS COLORS, the 148 CSS named colours | Values from the W3C CSS Color Module Level 4 |
+
+RAL is a registered trademark of RAL gGmbH. The RAL values are approximate
+screen representations, not colour-binding references, and are not
+affiliated with, endorsed by or licensed by RAL gGmbH.
diff --git a/assets/color_books/css-colors.acb b/assets/color_books/css-colors.acb
new file mode 100644
index 000000000..0868c4b83
--- /dev/null
+++ b/assets/color_books/css-colors.acb
@@ -0,0 +1,202 @@
+
+
+
+ CSS COLORS
+ 1
+ 0
+
+ mistyrose255228225
+ red25500
+ salmon250128114
+ lightcoral240128128
+ indianred2059292
+ rosybrown188143143
+ firebrick1783434
+
+
+ brown1654242
+ darkred13900
+ maroon12800
+ coral25512780
+ lightsalmon255160122
+ orangered255690
+ tomato2559971
+
+
+ darksalmon233150122
+ sienna1608245
+ bisque255228196
+ blanchedalmond255235205
+ darkorange2551400
+ navajowhite255222173
+ papayawhip255239213
+
+
+ peachpuff255218185
+ antiquewhite250235215
+ sandybrown24416496
+ burlywood222184135
+ chocolate21010530
+ tan210180140
+ peru20513363
+
+
+ saddlebrown1396919
+ cornsilk255248220
+ gold2552150
+ moccasin255228181
+ orange2551650
+ wheat245222179
+ goldenrod21816532
+
+
+ darkgoldenrod18413411
+ lemonchiffon255250205
+ lightyellow255255224
+ yellow2552550
+ lightgoldenrodyellow250250210
+ beige245245220
+ khaki240230140
+
+
+ palegoldenrod238232170
+ darkkhaki189183107
+ olive1281280
+ yellowgreen15420550
+ olivedrab10714235
+ darkolivegreen8510747
+ chartreuse1272550
+
+
+ greenyellow17325547
+ lawngreen1242520
+ lime02550
+ palegreen152251152
+ lightgreen144238144
+ limegreen5020550
+ darkseagreen143188143
+
+
+ forestgreen3413934
+ green01280
+ darkgreen01000
+ springgreen0255127
+ mediumspringgreen0250154
+ mediumseagreen60179113
+ seagreen4613987
+
+
+ aquamarine127255212
+ mediumaquamarine102205170
+ aqua0255255
+ cyan0255255
+ lightcyan224255255
+ paleturquoise175238238
+ powderblue176224230
+
+
+ turquoise64224208
+ darkturquoise0206209
+ mediumturquoise72209204
+ lightseagreen32178170
+ cadetblue95158160
+ darkcyan0139139
+ teal0128128
+
+
+ darkslategray477979
+ darkslategrey477979
+ deepskyblue0191255
+ skyblue135206235
+ lightblue173216230
+ dodgerblue30144255
+ lightskyblue135206250
+
+
+ lightsteelblue176196222
+ steelblue70130180
+ lightslategray119136153
+ lightslategrey119136153
+ slategray112128144
+ slategrey112128144
+ cornflowerblue100149237
+
+
+ royalblue65105225
+ blue00255
+ mediumblue00205
+ darkblue00139
+ navy00128
+ midnightblue2525112
+ mediumslateblue123104238
+
+
+ mediumpurple147112219
+ slateblue10690205
+ darkslateblue7261139
+ blueviolet13843226
+ rebeccapurple10251153
+ indigo750130
+ darkviolet1480211
+
+
+ mediumorchid18685211
+ darkorchid15350204
+ fuchsia2550255
+ magenta2550255
+ violet238130238
+ plum221160221
+ orchid218112214
+
+
+ thistle216191216
+ darkmagenta1390139
+ purple1280128
+ mediumvioletred19921133
+ deeppink25520147
+ hotpink255105180
+ lightpink255182193
+
+
+ pink255192203
+ crimson2202060
+ palevioletred219112147
+ aliceblue240248255
+ azure240255255
+ floralwhite255250240
+ ghostwhite248248255
+
+
+ honeydew240255240
+ ivory255255240
+ lavenderblush255240245
+ mintcream245255250
+ seashell255245238
+ snow255250250
+ white255255255
+
+
+ oldlace253245230
+ lavender230230250
+ linen250240230
+ whitesmoke245245245
+ gainsboro220220220
+ lightgray211211211
+ lightgrey211211211
+
+
+ silver192192192
+ darkgray169169169
+ darkgrey169169169
+ gray128128128
+ grey128128128
+ dimgray105105105
+ dimgrey105105105
+
+
+ black000
+
+
diff --git a/assets/color_books/ral-classic.acb b/assets/color_books/ral-classic.acb
new file mode 100644
index 000000000..cd2462f3d
--- /dev/null
+++ b/assets/color_books/ral-classic.acb
@@ -0,0 +1,301 @@
+
+
+
+ RAL CLASSIC
+ 1
+ 0
+
+ RAL 1000205186136
+ RAL 1001208176132
+ RAL 1002210170109
+ RAL 10032491680
+ RAL 10042281580
+ RAL 10052031420
+ RAL 10062261440
+
+
+ RAL 10072321400
+ RAL 101117512879
+ RAL 101222117539
+ RAL 1013227217198
+ RAL 1014221196154
+ RAL 1015230210181
+ RAL 101624122156
+
+
+ RAL 101724616980
+ RAL 101825020248
+ RAL 1019164143122
+ RAL 1020160143101
+ RAL 10212461820
+ RAL 10232471810
+ RAL 102418614376
+
+
+ RAL 10262552550
+ RAL 102716712714
+ RAL 10282551550
+ RAL 10322261630
+ RAL 103324915428
+ RAL 103423515682
+ RAL 1035144131112
+
+
+ RAL 103612810063
+ RAL 10372401460
+
+
+ RAL 20002211217
+ RAL 20011907832
+ RAL 20021985739
+ RAL 200325013243
+ RAL 20042319118
+ RAL 2005255350
+ RAL 200725516433
+
+
+ RAL 200824311744
+ RAL 2009225851
+ RAL 201021210147
+ RAL 201123612437
+ RAL 201221910680
+ RAL 20131496939
+ RAL 2017250682
+
+
+ RAL 30001713736
+ RAL 30011603340
+ RAL 30021613543
+ RAL 30031412944
+ RAL 30041123141
+ RAL 3005943240
+ RAL 3007643437
+
+
+ RAL 30091125549
+ RAL 30111264144
+ RAL 3012203141115
+ RAL 30131565046
+ RAL 3014212116121
+ RAL 3015225166173
+ RAL 30161726452
+
+
+ RAL 30172118495
+ RAL 30182096582
+ RAL 30201931828
+ RAL 302221310986
+ RAL 302424700
+ RAL 302625500
+ RAL 30271803265
+
+
+ RAL 30282313718
+ RAL 30311725059
+ RAL 30321132133
+ RAL 30331787667
+
+
+ RAL 400113890131
+ RAL 40021476180
+ RAL 400320991143
+ RAL 40041052257
+ RAL 400513199157
+ RAL 400615337114
+ RAL 4007743259
+
+
+ RAL 400814470132
+ RAL 4009163137149
+ RAL 401019854120
+ RAL 4011135115161
+ RAL 4012107104128
+
+
+ RAL 50005676112
+ RAL 50013171100
+ RAL 50024344124
+ RAL 5003425586
+ RAL 5004293142
+ RAL 50052172137
+ RAL 500765103141
+
+
+ RAL 5008496072
+ RAL 50094689120
+ RAL 50101968124
+ RAL 5011354463
+ RAL 501252129184
+ RAL 5013354583
+ RAL 5014108124152
+
+
+ RAL 501540116178
+ RAL 50171481141
+ RAL 501833136143
+ RAL 50192687132
+ RAL 5020116581
+ RAL 50217115122
+ RAL 5022474290
+
+
+ RAL 502377102142
+ RAL 5024106147176
+ RAL 502541100120
+ RAL 5026164484
+
+
+ RAL 60005011898
+ RAL 60014011362
+ RAL 6002399853
+ RAL 6003758762
+ RAL 6004146667
+ RAL 6005156754
+ RAL 6006646759
+
+
+ RAL 6007405236
+ RAL 6008535646
+ RAL 6009385747
+ RAL 60106211759
+ RAL 601110413091
+ RAL 6012496461
+ RAL 601312112490
+
+
+ RAL 6014686755
+ RAL 6015616458
+ RAL 6016210682
+ RAL 60177013465
+ RAL 60187216463
+ RAL 6019183217177
+ RAL 6020537151
+
+
+ RAL 6021134164124
+ RAL 6022626050
+ RAL 6024013584
+ RAL 60258311760
+ RAL 602609382
+ RAL 6027129192187
+ RAL 6028458570
+
+
+ RAL 6029011467
+ RAL 60321513388
+ RAL 603371138132
+ RAL 6034127176178
+ RAL 6035278444
+ RAL 603609376
+ RAL 60373723118
+
+
+ RAL 603802470
+ RAL 603917919662
+
+
+ RAL 7000126139146
+ RAL 7001143153159
+ RAL 7002129127104
+ RAL 7003122123109
+ RAL 7004158160161
+ RAL 7005107113111
+ RAL 700611711197
+
+
+ RAL 700811610267
+ RAL 7009919889
+ RAL 7010879387
+ RAL 7011859397
+ RAL 7012899799
+ RAL 7013858572
+ RAL 7015818692
+
+
+ RAL 7016556367
+ RAL 7021465052
+ RAL 7022757770
+ RAL 7023129132121
+ RAL 7024717480
+ RAL 7026556871
+ RAL 7030147147136
+
+
+ RAL 703193105112
+ RAL 7032185185168
+ RAL 7033129137121
+ RAL 7034147145118
+ RAL 7035203208204
+ RAL 7036154150151
+ RAL 7037124127126
+
+
+ RAL 7038180184176
+ RAL 703910710595
+ RAL 7040157163166
+ RAL 7042143150149
+ RAL 7043788481
+ RAL 7044189189178
+ RAL 7045145150154
+
+
+ RAL 7046130137142
+ RAL 7047207208207
+ RAL 7048136129117
+
+
+ RAL 800013611366
+ RAL 800115610748
+ RAL 80021238165
+ RAL 80031288447
+ RAL 80041437853
+ RAL 80071117447
+ RAL 80081117940
+
+
+ RAL 8011905841
+ RAL 80121035649
+ RAL 8014735745
+ RAL 8015995852
+ RAL 8016764738
+ RAL 8017685045
+ RAL 8019635858
+
+
+ RAL 8022333132
+ RAL 80231669447
+ RAL 80241218560
+ RAL 80251179273
+ RAL 8028785943
+ RAL 80291196039
+
+
+ RAL 9001239235220
+ RAL 9002221222212
+ RAL 9003255255255
+ RAL 9004464850
+ RAL 9005192122
+ RAL 9006165168166
+ RAL 9007143143140
+
+
+ RAL 9010247249239
+ RAL 9011282828
+ RAL 9012255253230
+ RAL 9016247251245
+ RAL 9017424547
+ RAL 9018207211205
+ RAL 9022133133131
+
+
+ RAL 9023126129130
+
+
diff --git a/src/app/update/mod.rs b/src/app/update/mod.rs
index 8830f12a4..1211eff5b 100644
--- a/src/app/update/mod.rs
+++ b/src/app/update/mod.rs
@@ -11731,21 +11731,29 @@ impl OpenCADStudio {
(newest, true, name_of(newest_handle))
}
- /// Read the colour books remembered in the settings, once per session.
+ /// Read the built-in colour books and the ones remembered in the
+ /// settings, once per session. A loaded book replaces a built-in one of
+ /// the same name.
fn read_color_books(&mut self) {
if std::mem::replace(&mut self.color_books_read, true) {
return;
}
+ use crate::ui::color_select::book;
+ #[cfg_attr(target_arch = "wasm32", allow(unused_mut))]
+ let mut books: Vec<_> = book::builtin().collect();
#[cfg(not(target_arch = "wasm32"))]
+ for loaded in self
+ .color_book_paths
+ .iter()
+ .filter_map(|path| std::fs::read_to_string(path).ok())
+ .filter_map(|text| book::parse(&text).ok())
{
- let books: Vec<_> = self
- .color_book_paths
- .iter()
- .filter_map(|path| std::fs::read_to_string(path).ok())
- .filter_map(|text| crate::ui::color_select::book::parse(&text).ok())
- .collect();
- self.color_books = std::sync::Arc::new(books);
+ match books.iter_mut().find(|b| b.name == loaded.name) {
+ Some(same) => *same = loaded,
+ None => books.push(loaded),
+ }
}
+ self.color_books = std::sync::Arc::new(books);
}
/// Colour the selected objects (or set the current colour when nothing
diff --git a/src/ui/color_select/book.rs b/src/ui/color_select/book.rs
index f06cf8e3e..59bbdba88 100644
--- a/src/ui/color_select/book.rs
+++ b/src/ui/color_select/book.rs
@@ -57,6 +57,17 @@ impl ColorBook {
}
}
+/// The colour books that ship with the program; their licences are in the
+/// files' header comments.
+pub fn builtin() -> impl Iterator- {
+ [
+ include_str!("../../../assets/color_books/ral-classic.acb"),
+ include_str!("../../../assets/color_books/css-colors.acb"),
+ ]
+ .into_iter()
+ .filter_map(|text| parse(text).ok())
+}
+
/// Read an `.acb` file's text.
pub fn parse(text: &str) -> Result {
let doc = roxmltree::Document::parse(text.trim_start_matches('\u{feff}'))