Skip to content

Commit

Permalink
Use regex to determine known channel matches
Browse files Browse the repository at this point in the history
  • Loading branch information
annehaley committed Jun 27, 2023
1 parent 99c38f6 commit 5274457
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,20 @@ export default {
autoRange: undefined
}
})
Object.entries(CHANNEL_COLORS).forEach(([channelName, color]) => {
if(this.layers.includes(channelName)){
this.compositeLayerInfo[channelName].palette = color
usedColors.push(color)
}
})
// Assign colors
this.layers.forEach((layerName) => {
if (!this.compositeLayerInfo[layerName].palette) {
let chosenColor;
// Search for case-insensitive regex match among known channel-colors
Object.entries(CHANNEL_COLORS).forEach(([channelName, color]) => {
if (layerName.toUpperCase().match(
new RegExp("^" + channelName + ".*$")
)) {
chosenColor = color
}
})
const unusedColors = OTHER_COLORS.filter(
(color) => !usedColors.includes(color)
)
Expand Down

0 comments on commit 5274457

Please sign in to comment.