forked from 1b-agent/opencadstudio-upstream
Colour names: show a palette colour by its index (#1748)
Unnamed ACI colours printed their RGB, which read the same as a true colour of that value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7b4c13c6ca
commit
2c062daa03
1 file changed
+3
-6
@@ -82,16 +82,13 @@ pub fn aci_string_to_color(s: &str) -> AcadColor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Display name for a colour: the standard name for ACI 1-9 / ByLayer /
|
/// Display name for a colour: the standard name for ACI 1-9 / ByLayer /
|
||||||
/// ByBlock, otherwise the "R,G,B" values (0-255) so unnamed palette colours
|
/// ByBlock, the index for any other palette colour and "R,G,B" for a true
|
||||||
/// read meaningfully.
|
/// colour, so the two kinds read apart (#1748).
|
||||||
pub fn color_display_name(c: AcadColor) -> String {
|
pub fn color_display_name(c: AcadColor) -> String {
|
||||||
let (_, label) = acad_color_display(c);
|
let (_, label) = acad_color_display(c);
|
||||||
if label == "Index" || label == "Custom" {
|
if label == "Index" || label == "Custom" {
|
||||||
match c {
|
match c {
|
||||||
AcadColor::Index(i) => {
|
AcadColor::Index(i) => i.to_string(),
|
||||||
let (r, g, b) = codec::types::aci_table::aci_to_rgb(i).unwrap_or((128, 128, 128));
|
|
||||||
format!("{r},{g},{b}")
|
|
||||||
}
|
|
||||||
AcadColor::Rgb { r, g, b } => format!("{r},{g},{b}"),
|
AcadColor::Rgb { r, g, b } => format!("{r},{g},{b}"),
|
||||||
_ => label.to_string(),
|
_ => label.to_string(),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user