Skip to content

Commit ad70002

Browse files
committed
change color reading and execution id setting
1 parent b375fc2 commit ad70002

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

apps/port/xml2geo.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
parser = new DOMParser();
22

33
function generateRandomId(length = 6) {
4-
return Math.random().toString(36).substr(2, length);
4+
return Array.from({length}, () => Math.floor(Math.random() * 36).toString(36)).join('');
55
}
66

77
var template = {
@@ -107,7 +107,13 @@ function xml2geo() {
107107
let annotationLineColor = annotation.getAttribute('LineColor') || '0';
108108
let annotationId = annotation.getAttribute('Id');
109109

110-
let hexColor = `#${parseInt(annotationLineColor).toString(16).padStart(6, '0')}`;
110+
// Aperio LineColor is a Windows COLORREF (0x00BBGGRR), so channels must be
111+
// unpacked individually and reassembled as RRGGBB rather than hex-stringified directly.
112+
let rawColor = parseInt(annotationLineColor) || 0;
113+
let r = rawColor & 0xFF;
114+
let g = (rawColor >> 8) & 0xFF;
115+
let b = (rawColor >> 16) & 0xFF;
116+
let hexColor = `#${[r, g, b].map((c) => c.toString(16).padStart(2, '0')).join('')}`;
111117

112118
let colorKey = apolloColors ? classifyColor(hexColor) : hexColor;
113119

0 commit comments

Comments
 (0)