Skip to content

Commit d564169

Browse files
authored
fix: fix issue #7 (#8)
1 parent 5c035d7 commit d564169

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

bindings/javascript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "A DWG/DXF JavaScript parser based on libredwg",
44
"license": "GPL-2.0-only",
55
"private": false,
6-
"version": "0.6.7",
6+
"version": "0.6.9",
77
"author": "MLight Lee <mlight.lee@outlook.com>",
88
"type": "module",
99
"repository": {

bindings/javascript/src/converter/converter.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -655,12 +655,15 @@ export class LibreDwgConverter {
655655
const method = color.method
656656
let colorIndex = 256
657657
let rgbColor = 0xffffff
658-
// It looks like that libredwg always returns 256 for property 'index' in Dwg_Color
659-
if (method === 0xc3 || ((color.rgb >>> 24) & 0xff) === 0xc3) {
660-
colorIndex = color.rgb & 0x000000ff
661-
} else if (method == 0xc2 || ((color.rgb >>> 24) & 0xff) === 0xc2) {
662-
rgbColor = color.rgb & 0x00ffffff
663-
}
658+
// NOTE: Some older DWG formats use method=0x0 and provide the ACI index via color.index.
659+
if (method === 0xc3 || ((color.rgb >>> 24) & 0xff) === 0xc3) {
660+
colorIndex = color.rgb & 0x000000ff
661+
} else if (method == 0xc2 || ((color.rgb >>> 24) & 0xff) === 0xc2) {
662+
rgbColor = color.rgb & 0x00ffffff
663+
} else if (color.index >= 1 && color.index <= 255) {
664+
// Older DWG format: ACI index is directly available in color.index.
665+
colorIndex = color.index
666+
}
664667

665668
return {
666669
...commonAttrs,

bindings/javascript/src/svg/svgConverter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ export class SvgConverter {
692692
color.color = entity.color
693693
}
694694

695-
// If it is white color, convert it to black because the background of svg is white
695+
// ACI 7 is one background-dependent color
696696
if (color.colorIndex == 7) {
697697
color.colorIndex = 256
698698
}

0 commit comments

Comments
 (0)