|
|
|
|
@ -704,7 +704,13 @@ impl<'a> ObjectsBuilder<'a> {
|
|
|
|
|
//how best to pass in the flag for dynamic text or not....should the flag also default to true?
|
|
|
|
|
let mut text: Text = (
|
|
|
|
|
text,
|
|
|
|
|
HexColor::from_u32(self.ent.common.color_24_bit as u32),
|
|
|
|
|
{
|
|
|
|
|
if let Some(aci_index) = self.ent.common.color.index() {
|
|
|
|
|
aci_to_hex_color(aci_index)
|
|
|
|
|
} else {
|
|
|
|
|
HexColor::from_u32(self.ent.common.color_24_bit as u32)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
.into();
|
|
|
|
|
|
|
|
|
|
@ -716,7 +722,15 @@ impl<'a> ObjectsBuilder<'a> {
|
|
|
|
|
Objects::Text(text)
|
|
|
|
|
} else {
|
|
|
|
|
let mut dtext = DTextBuilder::from_text(text)
|
|
|
|
|
.color(HexColor::from_u32(self.ent.common.color_24_bit as u32))
|
|
|
|
|
.color({
|
|
|
|
|
// 优先使用 ACI 颜色索引
|
|
|
|
|
if let Some(aci_index) = self.ent.common.color.index() {
|
|
|
|
|
aci_to_hex_color(aci_index)
|
|
|
|
|
} else {
|
|
|
|
|
// 回退到24位颜色
|
|
|
|
|
HexColor::from_u32(self.ent.common.color_24_bit as u32)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
dtext.scale(self.scale_fact.x, self.scale_fact.y);
|
|
|
|
|
@ -971,7 +985,16 @@ impl<'a> ObjectsBuilder<'a> {
|
|
|
|
|
EntityType::AttributeDefinition(attrib) => Ok({
|
|
|
|
|
//need to look up the proper way to get the color for the Attrib
|
|
|
|
|
let mut dtext = DTextBuilder::from_attrib(attrib)
|
|
|
|
|
.color(HexColor::from_u32(self.ent.common.color_24_bit as u32))
|
|
|
|
|
.color({
|
|
|
|
|
println!("color index:{:?}", self.ent.common.color.index());
|
|
|
|
|
// 优先使用 ACI 颜色索引
|
|
|
|
|
if let Some(aci_index) = self.ent.common.color.index() {
|
|
|
|
|
aci_to_hex_color(aci_index)
|
|
|
|
|
} else {
|
|
|
|
|
// 回退到24位颜色
|
|
|
|
|
HexColor::from_u32(self.ent.common.color_24_bit as u32)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
dtext.scale(self.scale_fact.x, self.scale_fact.y);
|
|
|
|
|
@ -1662,3 +1685,26 @@ enum TextEntity<'a> {
|
|
|
|
|
Attrib(&'a AttributeDefinition),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// AutoCAD Color Index (ACI) 到 RGB 转换函数
|
|
|
|
|
fn aci_to_rgb(aci: u8) -> (u8, u8, u8) {
|
|
|
|
|
match aci {
|
|
|
|
|
1 => (255, 0, 0), // 红色
|
|
|
|
|
2 => (255, 255, 0), // 黄色
|
|
|
|
|
3 => (0, 255, 0), // 绿色
|
|
|
|
|
4 => (0, 255, 255), // 青色
|
|
|
|
|
5 => (0, 0, 255), // 蓝色
|
|
|
|
|
6 => (255, 0, 255), // 洋红色
|
|
|
|
|
7 => (255, 255, 255), // 白色
|
|
|
|
|
8 => (128, 128, 128), // 深灰色
|
|
|
|
|
9 => (192, 192, 192), // 浅灰色
|
|
|
|
|
94 => (0, 129, 0), // 深绿色
|
|
|
|
|
// 更多标准颜色可以根据需要添加
|
|
|
|
|
_ => (0, 0, 0), // 默认黑色
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ACI 转换为 HexColor
|
|
|
|
|
fn aci_to_hex_color(aci: u8) -> HexColor {
|
|
|
|
|
let (r, g, b) = aci_to_rgb(aci);
|
|
|
|
|
HexColor::rgb(r, g, b)
|
|
|
|
|
}
|