Files
ui/src/features/annotations/classColors.ts
T
Armen Rohalov 63cc18e788 Enhance annotations: save/download, fallback classes, photo mode icons
Add local annotation save fallback, PNG+txt download with drawn boxes,
shared classColors helper, photo mode icon toggles, and react-dropzone
/ react-icons dependencies.
2026-04-17 23:33:00 +03:00

25 lines
812 B
TypeScript

const CLASS_COLORS = [
'#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#FF00FF', '#00FFFF',
'#800000', '#008000', '#000080', '#808000', '#800080', '#008080',
]
export const FALLBACK_CLASS_NAMES = [
'Car', 'Person', 'Truck', 'Bicycle', 'Motorcycle', 'Bus',
'Animal', 'Tree', 'Building', 'Sign', 'Boat', 'Plane',
]
export function getClassColor(classNum: number): string {
const base = classNum % 20
return CLASS_COLORS[base % CLASS_COLORS.length]
}
export function getPhotoModeSuffix(classNum: number): string {
const mode = Math.floor(classNum / 20)
return mode === 1 ? ' (winter)' : mode === 2 ? ' (night)' : ''
}
export function getClassNameFallback(classNum: number): string {
const base = classNum % 20
return FALLBACK_CLASS_NAMES[base % FALLBACK_CLASS_NAMES.length] ?? `#${classNum}`
}