Skip to content

Commit

Permalink
fix: ignoring colorNumber when layer is not found (#140)
Browse files Browse the repository at this point in the history
Solves #139
  • Loading branch information
apriljunge authored Aug 30, 2024
1 parent 9895f4f commit a930aa1
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/toPolylines.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,20 @@ export default (parsed) => {
const entities = denormalise(parsed)
const polylines = entities.map((entity) => {
const layerTable = parsed.tables.layers[entity.layer]
let rgb
if (layerTable) {
const colorNumber =
'colorNumber' in entity ? entity.colorNumber : layerTable.colorNumber
rgb = colors[colorNumber]
if (rgb === undefined) {
logger.warn('Color index', colorNumber, 'invalid, defaulting to black')
rgb = [0, 0, 0]
}
} else {
logger.warn('no layer table for layer:' + entity.layer)
rgb = [0, 0, 0]
let colorNumber = 0
if ('colorNumber' in entity) {
colorNumber = entity.colorNumber
} else if (layerTable) {
colorNumber = layerTable.colorNumber
}

if (colors[colorNumber] === undefined) {
logger.warn('Color index', colorNumber, 'invalid, defaulting to black')
colorNumber = 0
}

return {
rgb,
rgb: colors[colorNumber],
vertices: applyTransforms(entityToPolyline(entity), entity.transforms),
}
})
Expand Down

0 comments on commit a930aa1

Please sign in to comment.