annotation-styles.ts
2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
* Shared annotation styling utilities for visualization.
* Provides consistent styling for position validation annotations.
*/
/** Annotation colors */
export const ANNOTATION_COLORS = {
RED: '#ef4444', // Tailwind red-500 - for current/render positions
GREEN: '#22c55e', // Tailwind green-500 - for target/expected positions
} as const;
/** Annotation box position data */
export interface AnnotationBoxData {
index: number;
x: number;
y: number;
width: number;
height: number;
label?: string;
distance?: number;
}
/**
* Creates the CSS for an annotation container that overlays the page.
*/
export function createContainerStyle(): string {
return `
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 999999;
`;
}
/**
* Creates the CSS for an annotation box at the specified position.
*/
export function createBoxStyle(x: number, y: number, width: number, height: number, color: string): string {
return `
position: absolute;
left: ${x}px;
top: ${y}px;
width: ${width}px;
height: ${height}px;
border: 4px solid ${color};
box-sizing: border-box;
pointer-events: none;
`;
}
/**
* Creates the CSS for a numbered circle label.
* Clamps to at least 5px from edges to prevent cutoff (mirrors Python implementation).
*/
export function createCircleLabelStyle(x: number, y: number, color: string): string {
const labelX = Math.max(5, x - 22);
const labelY = Math.max(5, y - 22);
return `
position: absolute;
left: ${labelX}px;
top: ${labelY}px;
background: ${color};
color: white;
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
font: bold 18px Arial, sans-serif;
border-radius: 50%;
pointer-events: none;
border: 2px solid white;
box-shadow: 0 2px 4px rgba(0,0,0,0.3);
`;
}
/**
* Creates the CSS for a text label positioned below the box.
*/
export function createTextLabelStyle(x: number, y: number, height: number, color: string): string {
return `
position: absolute;
left: ${x}px;
top: ${y + height + 4}px;
background: ${color};
color: white;
padding: 4px 8px;
font: 12px Arial, sans-serif;
border-radius: 4px;
pointer-events: none;
white-space: nowrap;
box-shadow: 0 2px 4px rgba(0,0,0,0.3);
`;
}