@duyafeng/pseudocolor-viewer 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PseudoColorViewer.vue +532 -63
- package/package.json +4 -4
- package/positionPresets.js +39 -17
- package/lib/canvasRectangle.js +0 -404
- package/lib/colorMaps.js +0 -113
- package/lib/imageDisplayManager.js +0 -481
- package/lib/imageModule.js +0 -88
- package/lib/index.js +0 -17
- package/lib/medicalColorProcessor.js +0 -161
- package/lib/windowLevelController.js +0 -215
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duyafeng/pseudocolor-viewer",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "红外伪彩看图 Vue 2
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "红外伪彩看图 Vue 2 组件(全屏弹窗+测温工具+温窗调节),跨子应用共享,依赖 @duyafeng/pseudocolor 引擎",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"module": "./index.js",
|
|
7
7
|
"files": [
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
"PseudoColorViewer.vue",
|
|
10
10
|
"Rect.vue",
|
|
11
11
|
"positionPresets.js",
|
|
12
|
-
"lib/",
|
|
13
12
|
"assets/"
|
|
14
13
|
],
|
|
15
14
|
"peerDependencies": {
|
|
16
15
|
"vue": "^2.6.0",
|
|
17
|
-
"element-ui": "^2.15.0"
|
|
16
|
+
"element-ui": "^2.15.0",
|
|
17
|
+
"@duyafeng/pseudocolor": "^0.2.0"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {},
|
|
20
20
|
"sideEffects": false,
|
package/positionPresets.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 部位列表预设
|
|
3
|
-
*
|
|
3
|
+
* 身体部位(男 7 / 女 9)/ 面部部位(4 面)
|
|
4
|
+
*
|
|
5
|
+
* 每个部位对象同时有 bodyFlag 和 flag 字段(值相同),
|
|
6
|
+
* bodyFlag 是组件内部统一读取的 key,flag 是通用字段名。
|
|
7
|
+
* 接口返回的 imageFlag 值直接对等于 bodyFlag。
|
|
4
8
|
*/
|
|
5
9
|
|
|
6
|
-
// 部位定义公共字段生成器
|
|
7
10
|
function buildPosition(bodyFlag, order, btnName) {
|
|
8
11
|
return {
|
|
9
|
-
bodyFlag,
|
|
12
|
+
bodyFlag, // 组件内部 key(统一字段名)
|
|
13
|
+
flag: bodyFlag, // 通用 key(和 bodyFlag 值相同)
|
|
10
14
|
unique_key: bodyFlag,
|
|
11
15
|
order,
|
|
12
16
|
imageName: '',
|
|
@@ -14,43 +18,61 @@ function buildPosition(bodyFlag, order, btnName) {
|
|
|
14
18
|
};
|
|
15
19
|
}
|
|
16
20
|
|
|
17
|
-
//
|
|
18
|
-
export const
|
|
21
|
+
// ── 身体部位 ──
|
|
22
|
+
export const MEN_POSITIONS = [
|
|
19
23
|
buildPosition('05', 'a05', '胸部前位'),
|
|
20
24
|
buildPosition('06', 'a06', '胸部后位'),
|
|
21
25
|
buildPosition('09', 'a09', '整体前位'),
|
|
22
26
|
buildPosition('08', 'a08', '整体后位'),
|
|
23
27
|
buildPosition('01', 'a01', '举手前位'),
|
|
24
28
|
buildPosition('02', 'a02', '抱头位'),
|
|
25
|
-
buildPosition('03', 'a03', '抱头左位'),
|
|
26
|
-
buildPosition('04', 'a04', '抱头右位'),
|
|
27
29
|
buildPosition('07', 'a07', '举手后位'),
|
|
28
30
|
];
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
export const MEN_POSITIONS = [
|
|
32
|
+
export const WOMEN_POSITIONS = [
|
|
32
33
|
buildPosition('05', 'a05', '胸部前位'),
|
|
33
34
|
buildPosition('06', 'a06', '胸部后位'),
|
|
34
35
|
buildPosition('09', 'a09', '整体前位'),
|
|
35
36
|
buildPosition('08', 'a08', '整体后位'),
|
|
36
37
|
buildPosition('01', 'a01', '举手前位'),
|
|
37
38
|
buildPosition('02', 'a02', '抱头位'),
|
|
39
|
+
buildPosition('03', 'a03', '抱头左位'),
|
|
40
|
+
buildPosition('04', 'a04', '抱头右位'),
|
|
38
41
|
buildPosition('07', 'a07', '举手后位'),
|
|
39
42
|
];
|
|
40
43
|
|
|
44
|
+
// ── 面部部位(4 面:正面/背面/左侧面/右侧面) ──
|
|
45
|
+
// 注意:面部接口返回的 imageFlag 值也是 '01','02','03','04'
|
|
46
|
+
export const FACE_POSITIONS = [
|
|
47
|
+
buildPosition('01', 'f01', '正面图像'),
|
|
48
|
+
buildPosition('02', 'f02', '背面图像'),
|
|
49
|
+
buildPosition('03', 'f03', '左侧面图像'),
|
|
50
|
+
buildPosition('04', 'f04', '右侧面图像'),
|
|
51
|
+
];
|
|
52
|
+
|
|
41
53
|
/**
|
|
42
|
-
*
|
|
43
|
-
* @param {number|string}
|
|
44
|
-
*
|
|
54
|
+
* 按场景返回默认部位列表
|
|
55
|
+
* @param {Object|number|string} options
|
|
56
|
+
* - 对象: { scene: 'body'|'face', sex: 1|2|'男'|'女' }
|
|
57
|
+
* - 数字/字符串: 直接作为 sex 传给身体场景
|
|
45
58
|
*/
|
|
46
|
-
export function getDefaultPositions(
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
export function getDefaultPositions(options) {
|
|
60
|
+
if (typeof options === 'object') {
|
|
61
|
+
if (options.scene === 'face') return FACE_POSITIONS;
|
|
62
|
+
const sex = options.sex;
|
|
63
|
+
if (sex == 1 || sex === '男') return MEN_POSITIONS;
|
|
64
|
+
if (sex == 2 || sex === '女') return WOMEN_POSITIONS;
|
|
65
|
+
return WOMEN_POSITIONS;
|
|
66
|
+
}
|
|
67
|
+
// 兼容旧调用: getDefaultPositions(sex)
|
|
68
|
+
if (options == 1 || options === '男') return MEN_POSITIONS;
|
|
69
|
+
if (options == 2 || options === '女') return WOMEN_POSITIONS;
|
|
70
|
+
return WOMEN_POSITIONS;
|
|
50
71
|
}
|
|
51
72
|
|
|
52
73
|
export default {
|
|
53
|
-
WOMEN_POSITIONS,
|
|
54
74
|
MEN_POSITIONS,
|
|
75
|
+
WOMEN_POSITIONS,
|
|
76
|
+
FACE_POSITIONS,
|
|
55
77
|
getDefaultPositions,
|
|
56
78
|
};
|
package/lib/canvasRectangle.js
DELETED
|
@@ -1,404 +0,0 @@
|
|
|
1
|
-
// utils/canvasRectangleUtils.js
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Canvas Rectangle Utility Functions
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Create a DOM-based delete button for a rectangle
|
|
9
|
-
*/
|
|
10
|
-
export function createDOMDeleteButton(rectangle, canvasElement, onDeleteCallback, parentContainer) {
|
|
11
|
-
const existingButton = document.getElementById(`delete-btn-${rectangle.id}`);
|
|
12
|
-
if (existingButton) existingButton.remove();
|
|
13
|
-
|
|
14
|
-
const deleteButton = document.createElement('div');
|
|
15
|
-
deleteButton.id = `delete-btn-${rectangle.id}`;
|
|
16
|
-
deleteButton.className = 'delete-btn';
|
|
17
|
-
deleteButton.innerHTML = '×';
|
|
18
|
-
|
|
19
|
-
Object.assign(deleteButton.style, {
|
|
20
|
-
position: 'absolute',
|
|
21
|
-
width: '14px',
|
|
22
|
-
height: '14px',
|
|
23
|
-
backgroundColor: 'rgba(255, 0, 0, 0.85)',
|
|
24
|
-
color: 'white',
|
|
25
|
-
border: '1px solid white',
|
|
26
|
-
borderRadius: '2px',
|
|
27
|
-
display: 'flex',
|
|
28
|
-
alignItems: 'center',
|
|
29
|
-
justifyContent: 'center',
|
|
30
|
-
cursor: 'pointer',
|
|
31
|
-
fontSize: '11px',
|
|
32
|
-
lineHeight: '1',
|
|
33
|
-
fontWeight: 'bold',
|
|
34
|
-
zIndex: '1',
|
|
35
|
-
userSelect: 'none',
|
|
36
|
-
pointerEvents: 'auto'
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const canvasRect = canvasElement.getBoundingClientRect();
|
|
40
|
-
const scale = {
|
|
41
|
-
x: canvasElement.width / canvasRect.width,
|
|
42
|
-
y: canvasElement.height / canvasRect.height
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const buttonX = rectangle._renderInfo.x + rectangle._renderInfo.width - 4;
|
|
46
|
-
const buttonY = rectangle._renderInfo.y - 4;
|
|
47
|
-
const pageX = canvasRect.left + (buttonX / scale.x);
|
|
48
|
-
const pageY = canvasRect.top + (buttonY / scale.y);
|
|
49
|
-
|
|
50
|
-
Object.assign(deleteButton.style, {
|
|
51
|
-
left: `${pageX}px`,
|
|
52
|
-
top: `${pageY}px`
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
deleteButton.addEventListener('click', (e) => {
|
|
56
|
-
e.stopPropagation();
|
|
57
|
-
if (onDeleteCallback) onDeleteCallback(rectangle);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
if (parentContainer) parentContainer.appendChild(deleteButton);
|
|
61
|
-
return deleteButton;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function updateDOMDeleteButtons(rectangles, canvasRef, parentContainer, onDeleteCallback) {
|
|
65
|
-
const existingButtons = document.querySelectorAll('[id^="delete-btn-"]');
|
|
66
|
-
existingButtons.forEach(button => { button.style.zIndex = '1'; });
|
|
67
|
-
|
|
68
|
-
if (rectangles && rectangles.length > 0 && canvasRef && canvasRef[0]) {
|
|
69
|
-
const canvasElement = canvasRef[0];
|
|
70
|
-
rectangles.forEach(rectangle => {
|
|
71
|
-
if (rectangle._renderInfo) {
|
|
72
|
-
createDOMDeleteButton(rectangle, canvasElement, onDeleteCallback, parentContainer);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function removeAllDOMDeleteButtons() {
|
|
79
|
-
document.querySelectorAll('[id^="delete-btn-"]').forEach(btn => btn.remove());
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Calculate statistics from temperature data
|
|
84
|
-
*/
|
|
85
|
-
export function calculateStats(temperatureValues) {
|
|
86
|
-
if (!temperatureValues || temperatureValues.length === 0) return null;
|
|
87
|
-
const sum = temperatureValues.reduce((acc, t) => acc + t, 0);
|
|
88
|
-
const avg = sum / temperatureValues.length;
|
|
89
|
-
const max = Math.max(...temperatureValues);
|
|
90
|
-
const min = Math.min(...temperatureValues);
|
|
91
|
-
const variance = temperatureValues.reduce((acc, t) => acc + Math.pow(t - avg, 2), 0) / temperatureValues.length;
|
|
92
|
-
return {
|
|
93
|
-
regionAvgTemp: avg.toFixed(2),
|
|
94
|
-
regionMaxTemp: max.toFixed(2),
|
|
95
|
-
regionMinTemp: min.toFixed(2),
|
|
96
|
-
regionVariance: variance.toFixed(4)
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Extract region data. shape: 'rect' | 'circle' | 'point'
|
|
102
|
-
*/
|
|
103
|
-
export function extractRegionData(temperatureData, startX, startY, endX, endY, canvas, shape = 'rect') {
|
|
104
|
-
if (!temperatureData) return [];
|
|
105
|
-
|
|
106
|
-
const IMAGE_WIDTH = canvas.width;
|
|
107
|
-
const IMAGE_HEIGHT = canvas.height;
|
|
108
|
-
const rect = canvas.getBoundingClientRect();
|
|
109
|
-
const pixelScaleX = IMAGE_WIDTH / rect.width;
|
|
110
|
-
const pixelScaleY = IMAGE_HEIGHT / rect.height;
|
|
111
|
-
const tempValues = [];
|
|
112
|
-
|
|
113
|
-
// 把 display 坐标映射到 temperature 数组下标
|
|
114
|
-
const pushPixel = (dx, dy) => {
|
|
115
|
-
const px = Math.floor(dx * pixelScaleX);
|
|
116
|
-
const py = Math.floor(dy * pixelScaleY);
|
|
117
|
-
if (px >= 0 && px < IMAGE_WIDTH && py >= 0 && py < IMAGE_HEIGHT) {
|
|
118
|
-
tempValues.push(temperatureData[py * IMAGE_WIDTH + px]);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
if (shape === 'point') {
|
|
123
|
-
// 取点击点周围 3x3
|
|
124
|
-
for (let dy = -1; dy <= 1; dy++) {
|
|
125
|
-
for (let dx = -1; dx <= 1; dx++) {
|
|
126
|
-
pushPixel(startX + dx, startY + dy);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return tempValues;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (shape === 'circle') {
|
|
133
|
-
const x1 = Math.min(startX, endX), x2 = Math.max(startX, endX);
|
|
134
|
-
const y1 = Math.min(startY, endY), y2 = Math.max(startY, endY);
|
|
135
|
-
const cx = (x1 + x2) / 2, cy = (y1 + y2) / 2;
|
|
136
|
-
const rx = (x2 - x1) / 2, ry = (y2 - y1) / 2;
|
|
137
|
-
if (rx < 2 || ry < 2) return [];
|
|
138
|
-
for (let y = Math.floor(y1); y < Math.ceil(y2); y++) {
|
|
139
|
-
for (let x = Math.floor(x1); x < Math.ceil(x2); x++) {
|
|
140
|
-
const nx = (x - cx) / rx, ny = (y - cy) / ry;
|
|
141
|
-
if (nx * nx + ny * ny <= 1) pushPixel(x, y);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return tempValues;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// rect(默认)
|
|
148
|
-
const x1 = Math.floor(Math.min(startX, endX));
|
|
149
|
-
const y1 = Math.floor(Math.min(startY, endY));
|
|
150
|
-
const x2 = Math.floor(Math.max(startX, endX));
|
|
151
|
-
const y2 = Math.floor(Math.max(startY, endY));
|
|
152
|
-
for (let y = y1; y < y2; y++) {
|
|
153
|
-
for (let x = x1; x < x2; x++) pushPixel(x, y);
|
|
154
|
-
}
|
|
155
|
-
return tempValues;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Draw existing measurements on canvas. Supports rect / circle / point via rect.shape.
|
|
160
|
-
*/
|
|
161
|
-
export function drawExistingRectangles(ctx, canvas, rectangles, style = {}) {
|
|
162
|
-
if (!rectangles || rectangles.length === 0) return [];
|
|
163
|
-
|
|
164
|
-
const strokeColor = style.strokeColor || '#000000';
|
|
165
|
-
const textColor = style.textColor || '#000000';
|
|
166
|
-
const scaleFactor = {
|
|
167
|
-
x: canvas.width / canvas.getBoundingClientRect().width,
|
|
168
|
-
y: canvas.height / canvas.getBoundingClientRect().height,
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
const selectedId = style.selectedId;
|
|
172
|
-
|
|
173
|
-
return rectangles.map(rect => {
|
|
174
|
-
const shape = rect.shape || 'rect';
|
|
175
|
-
const sx = rect.startX * scaleFactor.x;
|
|
176
|
-
const sy = rect.startY * scaleFactor.y;
|
|
177
|
-
const ex = rect.endX * scaleFactor.x;
|
|
178
|
-
const ey = rect.endY * scaleFactor.y;
|
|
179
|
-
const isSelected = selectedId !== undefined && selectedId !== null && rect.id === selectedId;
|
|
180
|
-
|
|
181
|
-
// 与画图工具一致:图形轮廓始终实线,线宽 2
|
|
182
|
-
ctx.setLineDash([]);
|
|
183
|
-
ctx.strokeStyle = strokeColor;
|
|
184
|
-
ctx.fillStyle = textColor;
|
|
185
|
-
ctx.lineWidth = 2;
|
|
186
|
-
ctx.font = 'bold 9px Arial';
|
|
187
|
-
|
|
188
|
-
let renderInfo = {};
|
|
189
|
-
if (shape === 'circle') {
|
|
190
|
-
// 与画图工具一致:start/end 构成外接矩形,圆/椭圆内切其中
|
|
191
|
-
const bx = Math.min(sx, ex), by = Math.min(sy, ey);
|
|
192
|
-
const bw = Math.abs(ex - sx), bh = Math.abs(ey - sy);
|
|
193
|
-
ctx.beginPath();
|
|
194
|
-
ctx.ellipse(bx + bw / 2, by + bh / 2, Math.max(bw / 2, 0.5), Math.max(bh / 2, 0.5), 0, 0, Math.PI * 2);
|
|
195
|
-
ctx.stroke();
|
|
196
|
-
ctx.fillText(rect.orderCount.toString(), bx + 3, by + 9);
|
|
197
|
-
renderInfo = { x: bx, y: by, width: bw, height: bh };
|
|
198
|
-
} else if (shape === 'point') {
|
|
199
|
-
ctx.lineWidth = 1;
|
|
200
|
-
ctx.beginPath();
|
|
201
|
-
ctx.arc(sx, sy, 3, 0, Math.PI * 2);
|
|
202
|
-
ctx.stroke();
|
|
203
|
-
ctx.setLineDash([]);
|
|
204
|
-
ctx.beginPath();
|
|
205
|
-
ctx.moveTo(sx - 5, sy); ctx.lineTo(sx + 5, sy);
|
|
206
|
-
ctx.moveTo(sx, sy - 5); ctx.lineTo(sx, sy + 5);
|
|
207
|
-
ctx.stroke();
|
|
208
|
-
renderInfo = { x: sx - 3, y: sy - 3, width: 6, height: 6 };
|
|
209
|
-
ctx.fillText(rect.orderCount.toString(), sx + 4, sy - 4);
|
|
210
|
-
} else {
|
|
211
|
-
const rx = Math.min(sx, ex), ry = Math.min(sy, ey);
|
|
212
|
-
const rw = Math.abs(ex - sx), rh = Math.abs(ey - sy);
|
|
213
|
-
ctx.beginPath();
|
|
214
|
-
ctx.rect(rx, ry, rw, rh);
|
|
215
|
-
ctx.stroke();
|
|
216
|
-
ctx.fillText(rect.orderCount.toString(), rx + 3, ry + 9);
|
|
217
|
-
renderInfo = { x: rx, y: ry, width: rw, height: rh };
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// 选中态:1:1 仿 Windows 画图 —— 淡蓝虚线外接框 + 8 个白底蓝边小方块
|
|
221
|
-
if (isSelected) {
|
|
222
|
-
const bx = Math.min(sx, ex), by = Math.min(sy, ey);
|
|
223
|
-
const bw = Math.abs(ex - sx), bh = Math.abs(ey - sy);
|
|
224
|
-
const SELECT_BLUE = '#4a90e2';
|
|
225
|
-
// 手柄按屏幕显示像素换算,避免 canvas 缩放后变大(对齐画图工具的 6px 小方块)
|
|
226
|
-
const HANDLE_SIZE = 6 * scaleFactor.x;
|
|
227
|
-
const BORDER_WIDTH = 1 * scaleFactor.x;
|
|
228
|
-
|
|
229
|
-
ctx.setLineDash([4 * scaleFactor.x, 2 * scaleFactor.x]);
|
|
230
|
-
ctx.strokeStyle = SELECT_BLUE;
|
|
231
|
-
ctx.lineWidth = BORDER_WIDTH;
|
|
232
|
-
ctx.beginPath();
|
|
233
|
-
ctx.rect(bx, by, bw, bh);
|
|
234
|
-
ctx.stroke();
|
|
235
|
-
|
|
236
|
-
if (shape !== 'point') {
|
|
237
|
-
const points = [
|
|
238
|
-
[bx, by], [bx + bw / 2, by], [bx + bw, by],
|
|
239
|
-
[bx, by + bh / 2], [bx + bw, by + bh / 2],
|
|
240
|
-
[bx, by + bh], [bx + bw / 2, by + bh], [bx + bw, by + bh]
|
|
241
|
-
];
|
|
242
|
-
ctx.setLineDash([]);
|
|
243
|
-
ctx.strokeStyle = SELECT_BLUE;
|
|
244
|
-
ctx.lineWidth = BORDER_WIDTH;
|
|
245
|
-
for (const pt of points) {
|
|
246
|
-
ctx.fillStyle = '#ffffff';
|
|
247
|
-
ctx.beginPath();
|
|
248
|
-
ctx.rect(pt[0] - HANDLE_SIZE / 2, pt[1] - HANDLE_SIZE / 2, HANDLE_SIZE, HANDLE_SIZE);
|
|
249
|
-
ctx.fill();
|
|
250
|
-
ctx.stroke();
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
// 恢复文字颜色,避免影响后续编号绘制
|
|
254
|
-
ctx.fillStyle = textColor;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
return { ...rect, _renderInfo: renderInfo };
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Draw an in-progress selection (drag preview).
|
|
263
|
-
*/
|
|
264
|
-
export function drawSelectionRectangle(ctx, params) {
|
|
265
|
-
const {
|
|
266
|
-
startX, startY, currentX, currentY,
|
|
267
|
-
scaleFactor, strokeColor = '#000000', shape = 'rect'
|
|
268
|
-
} = params;
|
|
269
|
-
|
|
270
|
-
const sx = startX * scaleFactor.x;
|
|
271
|
-
const sy = startY * scaleFactor.y;
|
|
272
|
-
const cx = currentX * scaleFactor.x;
|
|
273
|
-
const cy = currentY * scaleFactor.y;
|
|
274
|
-
|
|
275
|
-
ctx.strokeStyle = strokeColor;
|
|
276
|
-
ctx.lineWidth = 2;
|
|
277
|
-
ctx.setLineDash([]);
|
|
278
|
-
|
|
279
|
-
if (shape === 'circle') {
|
|
280
|
-
// 与画图工具一致:拖拽出的矩形为外接框,圆/椭圆内切其中
|
|
281
|
-
const bx = Math.min(sx, cx), by = Math.min(sy, cy);
|
|
282
|
-
const bw = Math.abs(cx - sx), bh = Math.abs(cy - sy);
|
|
283
|
-
ctx.beginPath();
|
|
284
|
-
ctx.ellipse(bx + bw / 2, by + bh / 2, Math.max(bw / 2, 0.5), Math.max(bh / 2, 0.5), 0, 0, Math.PI * 2);
|
|
285
|
-
ctx.stroke();
|
|
286
|
-
return { rectX: bx, rectY: by, rectWidth: bw, rectHeight: bh };
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if (shape === 'point') {
|
|
290
|
-
ctx.lineWidth = 1;
|
|
291
|
-
ctx.beginPath();
|
|
292
|
-
ctx.arc(sx, sy, 3, 0, Math.PI * 2);
|
|
293
|
-
ctx.stroke();
|
|
294
|
-
ctx.setLineDash([]);
|
|
295
|
-
ctx.beginPath();
|
|
296
|
-
ctx.moveTo(sx - 5, sy); ctx.lineTo(sx + 5, sy);
|
|
297
|
-
ctx.moveTo(sx, sy - 5); ctx.lineTo(sx, sy + 5);
|
|
298
|
-
ctx.stroke();
|
|
299
|
-
return { x: sx, y: sy };
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
const rx = Math.min(sx, cx), ry = Math.min(sy, cy);
|
|
303
|
-
const rw = Math.abs(cx - sx), rh = Math.abs(cy - sy);
|
|
304
|
-
ctx.beginPath();
|
|
305
|
-
ctx.rect(rx, ry, rw, rh);
|
|
306
|
-
ctx.stroke();
|
|
307
|
-
return { rectX: rx, rectY: ry, rectWidth: rw, rectHeight: rh };
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* Create a new shape record (rect / circle / point).
|
|
312
|
-
*/
|
|
313
|
-
export function createRectangle(rectData, rectCount) {
|
|
314
|
-
const rectId = Date.now() + Math.floor(Math.random() * 1000);
|
|
315
|
-
return {
|
|
316
|
-
id: rectId,
|
|
317
|
-
shape: rectData.shape || 'rect',
|
|
318
|
-
startX: rectData.startX,
|
|
319
|
-
startY: rectData.startY,
|
|
320
|
-
endX: rectData.endX,
|
|
321
|
-
endY: rectData.endY,
|
|
322
|
-
width: rectData.width,
|
|
323
|
-
height: rectData.height,
|
|
324
|
-
regionAvgTemp: rectData.regionAvgTemp,
|
|
325
|
-
regionMaxTemp: rectData.regionMaxTemp,
|
|
326
|
-
regionMinTemp: rectData.regionMinTemp,
|
|
327
|
-
regionVariance: rectData.regionVariance,
|
|
328
|
-
orderCount: rectCount
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* 命中测试:返回 { rect, part: 'handle' | 'body' } 或 null
|
|
334
|
-
* x/y 为画布 display 坐标
|
|
335
|
-
*/
|
|
336
|
-
export function hitTestMeasurement(rectangles, x, y, selectedId) {
|
|
337
|
-
if (!rectangles || rectangles.length === 0) return null;
|
|
338
|
-
|
|
339
|
-
// 从后往前,后画的优先
|
|
340
|
-
for (let i = rectangles.length - 1; i >= 0; i--) {
|
|
341
|
-
const rect = rectangles[i];
|
|
342
|
-
const shape = rect.shape || 'rect';
|
|
343
|
-
|
|
344
|
-
// 已选中的框优先检测 8 个缩放手柄
|
|
345
|
-
if (rect.id === selectedId && shape !== 'point') {
|
|
346
|
-
const x1 = Math.min(rect.startX, rect.endX), x2 = Math.max(rect.startX, rect.endX);
|
|
347
|
-
const y1 = Math.min(rect.startY, rect.endY), y2 = Math.max(rect.startY, rect.endY);
|
|
348
|
-
const mx = (x1 + x2) / 2, my = (y1 + y2) / 2;
|
|
349
|
-
const handles = [
|
|
350
|
-
{ dir: 'nw', px: x1, py: y1 }, { dir: 'n', px: mx, py: y1 }, { dir: 'ne', px: x2, py: y1 },
|
|
351
|
-
{ dir: 'w', px: x1, py: my }, { dir: 'e', px: x2, py: my },
|
|
352
|
-
{ dir: 'sw', px: x1, py: y2 }, { dir: 's', px: mx, py: y2 }, { dir: 'se', px: x2, py: y2 }
|
|
353
|
-
];
|
|
354
|
-
for (const h of handles) {
|
|
355
|
-
if (Math.abs(x - h.px) <= 6 && Math.abs(y - h.py) <= 6) {
|
|
356
|
-
return { rect, part: 'handle', dir: h.dir };
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
if (shape === 'circle') {
|
|
362
|
-
const x1 = Math.min(rect.startX, rect.endX), x2 = Math.max(rect.startX, rect.endX);
|
|
363
|
-
const y1 = Math.min(rect.startY, rect.endY), y2 = Math.max(rect.startY, rect.endY);
|
|
364
|
-
const cx = (x1 + x2) / 2, cy = (y1 + y2) / 2;
|
|
365
|
-
const rx = (x2 - x1) / 2, ry = (y2 - y1) / 2;
|
|
366
|
-
const nx = rx > 0 ? (x - cx) / rx : 0;
|
|
367
|
-
const ny = ry > 0 ? (y - cy) / ry : 0;
|
|
368
|
-
if (nx * nx + ny * ny <= 1) return { rect, part: 'body' };
|
|
369
|
-
} else if (shape === 'point') {
|
|
370
|
-
const d = Math.sqrt(Math.pow(x - rect.startX, 2) + Math.pow(y - rect.startY, 2));
|
|
371
|
-
if (d <= 8) return { rect, part: 'body' };
|
|
372
|
-
} else {
|
|
373
|
-
const x1 = Math.min(rect.startX, rect.endX), x2 = Math.max(rect.startX, rect.endX);
|
|
374
|
-
const y1 = Math.min(rect.startY, rect.endY), y2 = Math.max(rect.startY, rect.endY);
|
|
375
|
-
if (x >= x1 && x <= x2 && y >= y1 && y <= y2) return { rect, part: 'body' };
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
return null;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
export function deleteRectangleById(rectangles, rectId) {
|
|
382
|
-
const index = rectangles.findIndex(item => item.id === rectId);
|
|
383
|
-
if (index !== -1) {
|
|
384
|
-
const deletedRect = rectangles[index];
|
|
385
|
-
const updatedRectangles = [...rectangles];
|
|
386
|
-
updatedRectangles.splice(index, 1);
|
|
387
|
-
const renumbered = updatedRectangles.map((item, idx) => ({ ...item, orderCount: idx + 1 }));
|
|
388
|
-
return { updatedRectangles: renumbered, deletedRect, success: true };
|
|
389
|
-
}
|
|
390
|
-
return { updatedRectangles: rectangles, deletedRect: null, success: false };
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
export default {
|
|
394
|
-
createDOMDeleteButton,
|
|
395
|
-
updateDOMDeleteButtons,
|
|
396
|
-
removeAllDOMDeleteButtons,
|
|
397
|
-
calculateStats,
|
|
398
|
-
extractRegionData,
|
|
399
|
-
drawExistingRectangles,
|
|
400
|
-
drawSelectionRectangle,
|
|
401
|
-
createRectangle,
|
|
402
|
-
deleteRectangleById,
|
|
403
|
-
hitTestMeasurement
|
|
404
|
-
};
|
package/lib/colorMaps.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
// colorMaps.js
|
|
2
|
-
// 7种颜色映射表数据
|
|
3
|
-
export const COLOR_MAPS = [
|
|
4
|
-
{
|
|
5
|
-
name: "铁红热图",
|
|
6
|
-
colors: [
|
|
7
|
-
[2, 2, 7], [5, 7, 10], [13, 16, 19], [20, 24, 23], [18, 22, 22],
|
|
8
|
-
[19, 23, 23], [22, 25, 25], [19, 23, 23], [24, 29, 29], [34, 35, 35],
|
|
9
|
-
[36, 40, 39], [39, 43, 44], [46, 50, 51], [51, 56, 58], [52, 60, 60],
|
|
10
|
-
[56, 63, 62], [60, 66, 65], [61, 69, 69], [63, 72, 72], [69, 77, 79],
|
|
11
|
-
[76, 85, 86], [75, 85, 85], [76, 78, 84], [78, 76, 83], [76, 75, 82],
|
|
12
|
-
[65, 67, 83], [61, 64, 83], [59, 62, 87], [50, 54, 97], [51, 55, 100],
|
|
13
|
-
[47, 50, 103], [36, 39, 107], [33, 35, 102], [29, 31, 107], [25, 26, 114],
|
|
14
|
-
[24, 25, 111], [18, 18, 120], [14, 14, 124], [11, 12, 120], [10, 10, 136],
|
|
15
|
-
[4, 5, 135], [3, 0, 130], [5, 1, 142], [4, 2, 149], [10, 4, 153], [19, 6, 155],
|
|
16
|
-
[25, 10, 161], [26, 17, 165], [22, 17, 168], [25, 20, 171], [24, 21, 173],
|
|
17
|
-
[26, 27, 178], [35, 34, 186], [45, 40, 193], [52, 46, 199], [56, 49, 201],
|
|
18
|
-
[61, 50, 204], [64, 53, 207], [67, 57, 210], [62, 58, 213], [71, 67, 220],
|
|
19
|
-
[65, 65, 220], [61, 62, 218], [65, 65, 223], [70, 66, 225], [72, 68, 226],
|
|
20
|
-
[71, 68, 226], [76, 69, 226], [77, 66, 225], [78, 69, 224], [82, 75, 226],
|
|
21
|
-
[86, 78, 225], [85, 80, 223], [82, 83, 221], [85, 82, 219], [68, 91, 214],
|
|
22
|
-
[54, 105, 212], [56, 101, 212], [46, 107, 205], [41, 111, 202], [45, 112, 204],
|
|
23
|
-
[49, 114, 194], [52, 113, 192], [50, 115, 191], [40, 119, 187], [40, 121, 187],
|
|
24
|
-
[41, 124, 187], [39, 125, 184], [39, 122, 182], [28, 127, 185], [13, 136, 187],
|
|
25
|
-
[12, 138, 184], [10, 140, 181], [6, 144, 177], [4, 146, 175], [1, 149, 172],
|
|
26
|
-
[0, 152, 169], [0, 155, 167], [0, 155, 167], [2, 157, 169], [6, 161, 173],
|
|
27
|
-
[8, 163, 175], [11, 166, 178], [14, 169, 181], [17, 172, 184], [19, 174, 186],
|
|
28
|
-
[24, 178, 190], [25, 179, 191], [25, 179, 191], [31, 185, 197], [33, 187, 200],
|
|
29
|
-
[35, 189, 202], [40, 194, 207], [41, 195, 208], [42, 196, 209], [45, 198, 212],
|
|
30
|
-
[48, 201, 215], [51, 204, 218], [54, 207, 221], [57, 210, 224], [59, 212, 226],
|
|
31
|
-
[63, 216, 230], [65, 218, 232], [68, 221, 235], [71, 224, 238], [73, 226, 240],
|
|
32
|
-
[73, 226, 240], [78, 231, 245], [83, 236, 250], [85, 238, 252], [86, 238, 255],
|
|
33
|
-
[82, 246, 249], [75, 242, 228], [70, 237, 219], [61, 228, 194], [55, 222, 171],
|
|
34
|
-
[53, 220, 163], [51, 218, 155], [43, 210, 132], [34, 201, 109], [30, 198, 99],
|
|
35
|
-
[27, 195, 89], [21, 189, 69], [11, 180, 45], [9, 178, 37], [3, 172, 21], [0, 169, 14],
|
|
36
|
-
[4, 173, 18], [6, 175, 19], [12, 181, 25], [22, 190, 34], [27, 195, 39], [33, 200, 45],
|
|
37
|
-
[39, 206, 51], [44, 211, 56], [47, 214, 59], [54, 221, 66], [62, 229, 74], [64, 231, 76],
|
|
38
|
-
[68, 235, 80], [76, 243, 88], [84, 251, 96], [83, 253, 98], [85, 252, 91], [93, 252, 83],
|
|
39
|
-
[100, 252, 83], [108, 252, 83], [120, 252, 83], [134, 252, 83], [143, 252, 83], [151, 252, 83],
|
|
40
|
-
[161, 252, 83], [179, 252, 83], [187, 252, 83], [197, 252, 83], [213, 252, 83], [222, 252, 83],
|
|
41
|
-
[231, 253, 83], [239, 252, 83], [238, 249, 80], [239, 246, 77], [241, 242, 73], [236, 234, 67],
|
|
42
|
-
[228, 216, 59], [222, 205, 53], [219, 199, 50], [210, 183, 41], [206, 172, 37], [202, 163, 32],
|
|
43
|
-
[198, 156, 27], [185, 144, 39], [170, 133, 40], [163, 123, 27], [163, 108, 22], [163, 102, 20],
|
|
44
|
-
[165, 99, 29], [169, 92, 44], [174, 97, 48], [183, 99, 61], [192, 98, 74], [192, 100, 71], [193, 90, 88],
|
|
45
|
-
[195, 91, 107], [198, 94, 104], [208, 96, 122], [215, 96, 132], [213, 94, 139], [215, 96, 173], [218, 96, 190],
|
|
46
|
-
[224, 99, 204], [239, 103, 231], [239, 104, 234], [239, 96, 229], [238, 82, 224], [231, 75, 214], [226, 69, 208],
|
|
47
|
-
[221, 63, 204], [217, 58, 197], [219, 62, 210], [210, 58, 209], [205, 51, 201], [203, 52, 202], [206, 51, 198],
|
|
48
|
-
[203, 47, 193], [199, 40, 187], [195, 38, 186], [186, 28, 174], [168, 11, 151], [171, 14, 159], [160, 15, 143],
|
|
49
|
-
[162, 24, 142], [176, 38, 157], [169, 41, 140], [163, 41, 132], [174, 46, 129], [198, 56, 109], [210, 64, 104],
|
|
50
|
-
[218, 71, 100], [227, 78, 90], [230, 79, 96], [226, 84, 92], [222, 94, 86], [223, 92, 87], [226, 108, 90],
|
|
51
|
-
[223, 111, 82], [218, 102, 76], [235, 83, 71], [243, 66, 62], [236, 66, 62], [223, 67, 63], [218, 64, 59],
|
|
52
|
-
[213, 68, 62], [209, 70, 63], [209, 70, 63], [209, 70, 63], [255, 255, 255]
|
|
53
|
-
]
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
name: "彩色温度图",
|
|
58
|
-
colors: [
|
|
59
|
-
[0, 0, 0], [4, 4, 4], [8, 8, 8], [12, 12, 12], [16, 16, 16], [20, 20, 20], [24, 24, 24], [28, 28, 28], [32, 32, 32], [36, 36, 36], [40, 40, 40], [44, 44, 44], [48, 48, 48], [52, 52, 52], [56, 56, 56], [60, 60, 60], [64, 64, 64], [68, 68, 68], [72, 72, 72], [76, 76, 76], [84, 84, 84], [84, 84, 84], [76, 76, 88], [72, 72, 92], [68, 68, 96], [64, 64, 100], [60, 60, 104], [56, 56, 108], [52, 52, 112], [48, 48, 116], [44, 44, 120], [40, 40, 124], [36, 36, 128], [32, 32, 132], [28, 28, 136], [24, 24, 140], [20, 20, 144], [16, 16, 148], [12, 12, 152], [8, 8, 156], [4, 4, 160], [0, 0, 168], [0, 0, 168], [4, 4, 172], [8, 8, 176], [12, 12, 180], [16, 16, 184], [20, 20, 188], [24, 24, 192], [28, 48, 196], [32, 32, 200], [36, 36, 204], [40, 40, 208], [44, 44, 212], [48, 48, 216], [52, 52, 220], [56, 56, 224], [60, 60, 228], [64, 64, 232], [68, 68, 236], [72, 72, 240], [76, 76, 244], [80, 80, 248], [84, 84, 252], [84, 84, 252], [80, 84, 252], [76, 88, 248], [72, 92, 244], [72, 92, 244], [68, 96, 240], [64, 100, 236], [64, 100, 236], [60, 104, 232], [56, 108, 228], [56, 108, 228], [52, 112, 224], [48, 116, 220], [48, 116, 220], [44, 120, 216], [40, 124, 212], [40, 124, 212], [36, 128, 208], [32, 132, 204], [32, 132, 204], [28, 136, 200], [24, 140, 196], [24, 140, 196], [20, 144, 192], [16, 148, 188], [16, 148, 188], [12, 152, 184], [8, 156, 180], [8, 156, 180], [4, 160, 176], [0, 164, 172], [0, 168, 168], [0, 168, 168], [0, 168, 168], [4, 172, 172], [8, 176, 176], [8, 176, 176], [12, 180, 180], [16, 184, 184], [16, 184, 184], [20, 188, 188], [24, 192, 192], [24, 192, 192], [28, 196, 196], [32, 200, 200], [32, 200, 200], [36, 204, 204], [40, 208, 208], [40, 208, 208], [44, 212, 212], [48, 216, 216], [48, 216, 216], [52, 220, 220], [56, 224, 224], [56, 224, 224], [60, 228, 228], [64, 232, 232], [64, 232, 232], [68, 236, 236], [72, 240, 240], [72, 240, 240], [76, 244, 244], [80, 248, 248], [84, 252, 252], [84, 252, 252], [80, 248, 236], [76, 244, 220], [68, 236, 204], [64, 232, 188], [56, 224, 168], [52, 220, 152], [48, 216, 136], [40, 208, 120], [36, 204, 104], [28, 196, 84], [24, 192, 68], [20, 188, 52], [12, 180, 36], [8, 176, 20], [0, 168, 0], [0, 168, 0], [4, 172, 4], [8, 176, 8], [16, 184, 16], [20, 188, 20], [28, 196, 28], [32, 200, 32], [36, 204, 36], [44, 212, 44], [48, 216, 48], [56, 224, 56], [60, 228, 60], [64, 232, 64], [72, 240, 72], [76, 244, 76], [84, 252, 84], [84, 252, 84], [92, 252, 84], [104, 252, 84], [116, 252, 84], [128, 252, 84], [140, 252, 84], [148, 252, 84], [160, 252, 84], [172, 252, 84], [184, 252, 84], [196, 252, 84], [204, 252, 84], [216, 252, 84], [228, 252, 84], [240, 252, 84], [252, 252, 84], [252, 252, 84], [248, 244, 80], [244, 232, 76], [236, 220, 68], [232, 208, 64], [224, 196, 56], [220, 188, 52], [216, 176, 48], [208, 164, 40], [204, 152, 36], [196, 140, 28], [192, 132, 24], [188, 120, 20], [180, 108, 12], [176, 96, 8], [168, 84, 0], [168, 84, 0], [172, 84, 16], [176, 84, 32], [184, 84, 48], [188, 84, 64], [196, 84, 84], [200, 84, 100], [204, 84, 116], [212, 84, 132], [216, 84, 148], [224, 84, 168], [228, 84, 184], [232, 84, 200], [240, 84, 216], [244, 84, 232], [252, 84, 252], [252, 84, 252], [248, 80, 248], [244, 76, 244], [236, 68, 236], [232, 64, 232], [224, 56, 224], [220, 52, 220], [216, 48, 216], [208, 40, 208], [204, 36, 204], [196, 28, 196], [192, 24, 192], [188, 20, 188], [180, 12, 180], [176, 8, 176], [168, 0, 168], [168, 0, 168], [172, 4, 164], [176, 8, 160], [184, 16, 152], [188, 20, 148], [196, 28, 140], [200, 32, 136], [204, 36, 132], [212, 44, 124], [216, 48, 120], [224, 56, 112], [228, 60, 108], [232, 64, 104], [240, 72, 96], [244, 76, 92], [252, 84, 84], [252, 84, 84], [252, 76, 76], [252, 72, 72], [252, 64, 64], [252, 60, 60], [252, 56, 56], [252, 48, 48], [252, 44, 44], [252, 36, 36], [252, 32, 32], [252, 28, 28], [252, 20, 20], [252, 16, 16], [252, 8, 8], [252, 4, 4], [252, 252, 252]
|
|
60
|
-
]
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
{
|
|
64
|
-
name: "灰度图",
|
|
65
|
-
colors: Array.from({length: 256}, (_, i) => {
|
|
66
|
-
const v = i;
|
|
67
|
-
return [v, v, v];
|
|
68
|
-
})
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
{
|
|
72
|
-
name: "彩虹图",
|
|
73
|
-
colors: [
|
|
74
|
-
[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 64, 64], [0, 64, 64], [0, 64, 64], [0, 64, 64], [0, 64, 64], [0, 64, 64], [0, 64, 64], [0, 64, 64], [128, 128, 128], [128, 128, 128], [128, 128, 128], [128, 128, 128], [128, 128, 128], [128, 128, 128], [128, 128, 128], [128, 128, 128], [0, 64, 128], [0, 64, 128], [0, 64, 128], [0, 64, 128], [0, 64, 128], [0, 64, 128], [0, 64, 128], [0, 64, 128], [0, 252, 0], [0, 252, 0], [0, 252, 0], [0, 252, 0], [0, 252, 0], [0, 252, 0], [0, 252, 0], [0, 252, 0], [0, 128, 252], [0, 128, 252], [0, 128, 252], [0, 128, 252], [0, 128, 252], [0, 128, 252], [0, 128, 252], [0, 128, 252], [0, 0, 252], [0, 0, 252], [0, 0, 252], [0, 0, 252], [0, 0, 252], [0, 0, 252], [0, 0, 252], [0, 0, 252], [60, 0, 128], [60, 0, 128], [60, 0, 128], [60, 0, 128], [60, 0, 128], [60, 0, 128], [60, 0, 128], [60, 0, 128], [128, 0, 0], [128, 0, 0], [128, 0, 0], [128, 0, 0], [128, 0, 0], [128, 0, 0], [128, 0, 0], [128, 0, 0], [128, 128, 64], [128, 128, 64], [128, 128, 64], [128, 128, 64], [128, 128, 64], [128, 128, 64], [128, 128, 64], [128, 128, 64], [0, 128, 0], [0, 128, 0], [0, 128, 0], [0, 128, 0], [0, 128, 0], [0, 128, 0], [0, 128, 0], [0, 128, 0], [192, 192, 192], [192, 192, 192], [192, 192, 192], [192, 192, 192], [192, 192, 192], [192, 192, 192], [192, 192, 192], [192, 192, 192], [0, 0, 128], [0, 0, 128], [0, 0, 128], [0, 0, 128], [0, 0, 128], [0, 0, 128], [0, 0, 128], [0, 0, 128], [0, 128, 128], [0, 128, 128], [0, 128, 128], [0, 128, 128], [0, 128, 128], [0, 128, 128], [0, 128, 128], [0, 128, 128], [252, 252, 128], [252, 252, 128], [252, 252, 128], [252, 252, 128], [252, 252, 128], [252, 252, 128], [252, 252, 128], [252, 252, 128], [128, 128, 0], [128, 128, 0], [128, 128, 0], [128, 128, 0], [128, 128, 0], [128, 128, 0], [128, 128, 0], [128, 128, 0], [0, 252, 252], [0, 252, 252], [0, 252, 252], [0, 252, 252], [0, 252, 252], [0, 252, 252], [0, 252, 252], [0, 252, 252], [128, 0, 128], [128, 0, 128], [128, 0, 128], [128, 0, 128], [128, 0, 128], [128, 0, 128], [128, 0, 128], [128, 0, 128], [0, 252, 128], [0, 252, 128], [0, 252, 128], [0, 252, 128], [0, 252, 128], [0, 252, 128], [0, 252, 128], [0, 252, 128], [252, 0, 252], [252, 0, 252], [252, 0, 252], [252, 0, 252], [252, 0, 252], [252, 0, 252], [252, 0, 252], [252, 0, 252], [128, 252, 252], [128, 252, 252], [128, 252, 252], [128, 252, 252], [128, 252, 252], [128, 252, 252], [128, 252, 252], [128, 252, 252], [252, 128, 64], [252, 128, 64], [252, 128, 64], [252, 128, 64], [252, 128, 64], [252, 128, 64], [252, 128, 64], [252, 128, 64], [252, 252, 0], [252, 252, 0], [252, 252, 0], [252, 252, 0], [252, 252, 0], [252, 252, 0], [252, 252, 0], [252, 252, 0], [64, 192, 64], [64, 192, 64], [64, 192, 64], [64, 192, 64], [64, 192, 64], [64, 192, 64], [64, 192, 64], [64, 192, 64], [128, 128, 252], [128, 128, 252], [128, 128, 252], [128, 128, 252], [128, 128, 252], [128, 128, 252], [128, 128, 252], [128, 128, 252], [192, 32, 64], [192, 32, 64], [192, 32, 64], [192, 32, 64], [192, 32, 64], [192, 32, 64], [192, 32, 64], [192, 32, 64], [252, 0, 128], [252, 0, 128], [252, 0, 128], [252, 0, 128], [252, 0, 128], [252, 0, 128], [252, 0, 128], [252, 0, 128], [64, 192, 252], [64, 192, 252], [64, 192, 252], [64, 192, 252], [64, 192, 252], [64, 192, 252], [64, 192, 252], [64, 192, 252], [128, 64, 0], [128, 64, 0], [128, 64, 0], [128, 64, 0], [128, 64, 0], [128, 64, 0], [128, 64, 0], [128, 64, 0], [64, 128, 192], [64, 128, 192], [64, 128, 192], [64, 128, 192], [64, 128, 192], [64, 128, 192], [64, 128, 192], [64, 128, 192], [192, 128, 64], [192, 128, 64], [192, 128, 64], [192, 128, 64], [192, 128, 64], [192, 128, 64], [192, 128, 64], [192, 128, 64], [252, 0, 0], [252, 0, 0], [252, 0, 0], [252, 0, 0], [252, 0, 0], [252, 0, 0], [252, 0, 0], [252, 252, 252]
|
|
75
|
-
]
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
{
|
|
79
|
-
name: "光谱图",
|
|
80
|
-
colors: [
|
|
81
|
-
[0, 0, 0], [4, 4, 4], [8, 8, 8], [12, 12, 12], [16, 16, 16], [20, 20, 20], [24, 24, 24], [28, 28, 28], [32, 32, 32], [36, 36, 36], [40, 40, 40], [44, 44, 44], [48, 48, 48], [52, 52, 52], [56, 56, 56], [60, 60, 60], [64, 64, 64], [68, 68, 68], [72, 72, 72], [76, 76, 76], [80, 80, 80], [84, 84, 84], [88, 88, 88], [92, 92, 92], [96, 96, 96], [100, 100, 100], [104, 104, 104], [108, 108, 108], [112, 112, 112], [116, 116, 116], [120, 120, 120], [124, 124, 124], [120, 120, 128], [112, 112, 128], [104, 104, 128], [96, 96, 128], [88, 88, 128], [80, 80, 128], [72, 72, 128], [64, 64, 128], [56, 56, 128], [48, 48, 128], [40, 40, 128], [32, 32, 128], [24, 24, 128], [16, 16, 128], [8, 8, 128], [0, 0, 128], [0, 0, 132], [0, 0, 140], [0, 0, 148], [0, 0, 156], [0, 0, 164], [0, 0, 172], [0, 0, 180], [0, 0, 188], [0, 0, 196], [0, 0, 204], [0, 0, 212], [0, 0, 220], [0, 0, 228], [0, 0, 236], [0, 0, 244], [0, 0, 252], [0, 0, 252], [0, 8, 244], [0, 16, 236], [0, 24, 228], [0, 32, 220], [0, 40, 212], [0, 48, 204], [0, 56, 196], [0, 64, 188], [0, 72, 180], [0, 80, 172], [0, 88, 164], [0, 96, 156], [0, 104, 148], [0, 112, 140], [0, 120, 132], [0, 128, 128], [0, 136, 136], [0, 144, 144], [0, 152, 152], [0, 160, 160], [0, 168, 168], [0, 176, 176], [0, 184, 184], [0, 192, 192], [0, 200, 200], [0, 208, 208], [0, 216, 216], [0, 224, 224], [0, 232, 232], [0, 240, 240], [0, 248, 248], [0, 248, 240], [0, 240, 224], [0, 232, 208], [0, 224, 192], [0, 216, 176], [0, 208, 160], [0, 200, 144], [0, 192, 128], [0, 184, 112], [0, 176, 96], [0, 168, 80], [0, 160, 64], [0, 152, 48], [0, 144, 32], [0, 136, 16], [0, 128, 0], [0, 132, 0], [0, 140, 0], [0, 148, 0], [0, 156, 0], [0, 164, 0], [0, 172, 0], [0, 180, 0], [0, 188, 0], [0, 196, 0], [0, 204, 0], [0, 212, 0], [0, 220, 0], [0, 228, 0], [0, 236, 0], [0, 244, 0], [0, 252, 0], [8, 248, 0], [16, 240, 0], [24, 232, 0], [32, 224, 0], [40, 216, 0], [48, 208, 0], [56, 200, 0], [64, 192, 0], [72, 184, 0], [80, 176, 0], [88, 168, 0], [96, 160, 0], [104, 152, 0], [112, 144, 0], [120, 136, 0], [128, 128, 0], [132, 132, 0], [140, 140, 0], [148, 148, 0], [156, 156, 0], [164, 164, 0], [172, 172, 0], [180, 180, 0], [188, 188, 0], [196, 196, 0], [204, 204, 0], [212, 212, 0], [220, 220, 0], [228, 228, 0], [236, 236, 0], [244, 244, 0], [252, 252, 0], [248, 240, 8], [240, 224, 16], [232, 208, 24], [224, 192, 32], [216, 176, 40], [208, 160, 48], [200, 144, 56], [192, 128, 64], [184, 112, 72], [176, 96, 80], [168, 80, 88], [160, 64, 96], [152, 48, 104], [144, 32, 112], [136, 16, 120], [128, 0, 128], [132, 0, 132], [140, 0, 140], [148, 0, 148], [156, 0, 156], [164, 0, 164], [172, 0, 172], [180, 0, 180], [188, 0, 188], [196, 0, 196], [204, 0, 204], [212, 0, 212], [220, 0, 220], [228, 0, 228], [236, 0, 236], [244, 0, 244], [252, 0, 252], [248, 0, 240], [240, 0, 224], [232, 0, 208], [224, 0, 192], [216, 0, 176], [208, 0, 160], [200, 0, 144], [192, 0, 128], [184, 0, 112], [176, 0, 96], [168, 0, 80], [160, 0, 64], [152, 0, 48], [144, 0, 32], [136, 0, 16], [128, 0, 0], [132, 0, 0], [140, 0, 0], [148, 0, 0], [156, 0, 0], [164, 0, 0], [172, 0, 0], [180, 0, 0], [188, 0, 0], [196, 0, 0], [204, 0, 0], [212, 0, 0], [220, 0, 0], [228, 0, 0], [236, 0, 0], [244, 0, 0], [252, 0, 0], [252, 4, 4], [252, 12, 12], [252, 20, 20], [252, 28, 28], [252, 36, 36], [252, 44, 44], [252, 52, 52], [252, 60, 60], [252, 68, 68], [252, 76, 76], [252, 84, 84], [252, 92, 92], [252, 100, 100], [252, 108, 108], [252, 116, 116], [252, 124, 124], [252, 132, 132], [252, 140, 140], [252, 148, 148], [252, 156, 156], [252, 164, 164], [252, 172, 172], [252, 180, 180], [252, 188, 188], [252, 196, 196], [252, 204, 204], [252, 212, 212], [252, 220, 220], [252, 228, 228], [252, 236, 236], [252, 244, 244], [252, 252, 252]
|
|
82
|
-
]
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
{
|
|
86
|
-
name: "反相灰度图",
|
|
87
|
-
colors: Array.from({length: 256}, (_, i) => {
|
|
88
|
-
const v = 255 - i;
|
|
89
|
-
return [v, v, v];
|
|
90
|
-
})
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
{
|
|
94
|
-
name: "分段彩色图",
|
|
95
|
-
colors: [
|
|
96
|
-
[0, 0, 0], [3, 3, 3], [6, 6, 6], [9, 9, 9], [12, 12, 12], [15, 15, 15], [18, 18, 18], [21, 21, 21], [24, 24, 24], [27, 27, 27], [30, 30, 30], [33, 33, 33], [36, 36, 36], [39, 39, 39], [42, 42, 42], [45, 45, 45], [48, 48, 48], [51, 51, 51], [54, 54, 54], [57, 57, 57], [60, 60, 60], [63, 63, 63], [66, 66, 66], [69, 69, 69], [72, 72, 72], [75, 75, 75], [78, 78, 78], [81, 81, 81], [84, 84, 84], [87, 87, 87], [90, 90, 90], [93, 93, 93], [128, 0, 128], [131, 0, 131], [134, 0, 134], [137, 0, 137], [140, 0, 140], [143, 0, 143], [146, 0, 146], [149, 0, 149], [152, 0, 152], [155, 0, 155], [158, 0, 158], [161, 0, 161], [164, 0, 164], [167, 0, 167], [170, 0, 170], [173, 0, 173], [176, 0, 176], [179, 0, 179], [182, 0, 182], [185, 0, 185], [188, 0, 188], [191, 0, 191], [194, 0, 194], [197, 0, 197], [200, 0, 200], [203, 0, 203], [206, 0, 206], [209, 0, 209], [212, 0, 212], [215, 0, 215], [218, 0, 218], [221, 0, 221], [0, 0, 128], [0, 0, 131], [0, 0, 134], [0, 0, 137], [0, 0, 140], [0, 0, 143], [0, 0, 146], [0, 0, 149], [0, 0, 152], [0, 0, 155], [0, 0, 158], [0, 0, 161], [0, 0, 164], [0, 0, 167], [0, 0, 170], [0, 0, 173], [0, 0, 176], [0, 0, 179], [0, 0, 182], [0, 0, 185], [0, 0, 188], [0, 0, 191], [0, 0, 194], [0, 0, 197], [0, 0, 200], [0, 0, 203], [0, 0, 206], [0, 0, 209], [0, 0, 212], [0, 0, 215], [0, 0, 218], [0, 0, 221], [0, 128, 0], [0, 131, 0], [0, 134, 0], [0, 137, 0], [0, 140, 0], [0, 143, 0], [0, 146, 0], [0, 149, 0], [0, 152, 0], [0, 155, 0], [0, 158, 0], [0, 161, 0], [0, 164, 0], [0, 167, 0], [0, 170, 0], [0, 173, 0], [0, 176, 0], [0, 179, 0], [0, 182, 0], [0, 185, 0], [0, 188, 0], [0, 191, 0], [0, 194, 0], [0, 197, 0], [0, 200, 0], [0, 203, 0], [0, 206, 0], [0, 209, 0], [0, 212, 0], [0, 215, 0], [0, 218, 0], [0, 221, 0], [162, 162, 0], [165, 165, 0], [168, 168, 0], [171, 171, 0], [174, 174, 0], [177, 177, 0], [180, 180, 0], [183, 183, 0], [186, 186, 0], [189, 189, 0], [192, 192, 0], [195, 195, 0], [198, 198, 0], [201, 201, 0], [204, 204, 0], [207, 207, 0], [210, 210, 0], [213, 213, 0], [216, 216, 0], [219, 219, 0], [222, 222, 0], [225, 225, 0], [228, 228, 0], [231, 231, 0], [234, 234, 0], [237, 237, 0], [240, 240, 0], [243, 243, 0], [246, 246, 0], [249, 249, 0], [252, 252, 0], [255, 255, 0], [162, 99, 0], [165, 102, 0], [168, 105, 0], [171, 108, 0], [174, 111, 0], [177, 114, 0], [180, 117, 0], [183, 120, 0], [186, 123, 0], [189, 126, 0], [192, 129, 0], [195, 132, 0], [198, 135, 0], [201, 138, 0], [204, 141, 0], [207, 144, 0], [210, 147, 0], [213, 150, 0], [216, 153, 0], [219, 156, 0], [222, 159, 0], [225, 162, 0], [228, 165, 0], [231, 168, 0], [234, 171, 0], [237, 174, 0], [240, 177, 0], [243, 180, 0], [246, 183, 0], [249, 186, 0], [252, 189, 0], [255, 192, 0], [162, 0, 0], [165, 3, 3], [168, 6, 6], [171, 9, 9], [174, 12, 12], [177, 15, 15], [180, 18, 18], [183, 21, 21], [186, 24, 24], [189, 27, 27], [192, 30, 30], [195, 33, 33], [198, 36, 36], [201, 39, 39], [204, 42, 42], [207, 45, 45], [210, 48, 48], [213, 51, 51], [216, 54, 54], [219, 57, 57], [222, 60, 60], [225, 63, 63], [228, 66, 66], [231, 69, 69], [234, 72, 72], [237, 75, 75], [240, 78, 78], [243, 81, 81], [246, 84, 84], [249, 87, 87], [252, 90, 90], [255, 93, 93], [162, 162, 162], [165, 165, 165], [168, 168, 168], [171, 171, 171], [174, 174, 174], [177, 177, 177], [180, 180, 180], [183, 183, 183], [186, 186, 186], [189, 189, 189], [192, 192, 192], [195, 195, 195], [198, 198, 198], [201, 201, 201], [204, 204, 204], [207, 207, 207], [210, 210, 210], [213, 213, 213], [216, 216, 216], [219, 219, 219], [222, 222, 222], [225, 225, 225], [228, 228, 228], [231, 231, 231], [234, 234, 234], [237, 237, 237], [240, 240, 240], [243, 243, 243], [246, 246, 246], [249, 249, 249], [252, 252, 252], [255, 255, 255]
|
|
97
|
-
]
|
|
98
|
-
}
|
|
99
|
-
];
|
|
100
|
-
|
|
101
|
-
// 确保所有颜色映射都有256个颜色值
|
|
102
|
-
COLOR_MAPS.forEach((map, index) => {
|
|
103
|
-
// 补充颜色值到256个
|
|
104
|
-
while (map.colors.length < 256) {
|
|
105
|
-
// 使用最后一个颜色值填充
|
|
106
|
-
map.colors.push([...map.colors[map.colors.length - 1]]);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// 如果超过256个,则截取前256个
|
|
110
|
-
if (map.colors.length > 256) {
|
|
111
|
-
map.colors = map.colors.slice(0, 256);
|
|
112
|
-
}
|
|
113
|
-
});
|