MCPcopy Create free account
hub / github.com/Thanas-R/Virdis / getNextAutoColor

Function getNextAutoColor

src/components/NewFieldDialog.tsx:24–41  ·  view source on GitHub ↗
(existingColors: string[])

Source from the content-addressed store, hash-verified

22
23// Auto-cycle: first 6 follow DEFAULT_COLOR_ORDER, then pick unused, then random
24function getNextAutoColor(existingColors: string[]): string {
25 const used = new Set(existingColors.map(c => c.toUpperCase()));
26 const count = existingColors.length;
27
28 // First 6 fields: use the ordered defaults
29 if (count < DEFAULT_COLOR_ORDER.length) {
30 const color = DEFAULT_COLOR_ORDER[count];
31 if (!used.has(color.toUpperCase())) return color;
32 }
33
34 // After that, pick first unused from full palette
35 for (const color of PRESET_COLORS) {
36 if (!used.has(color.toUpperCase())) return color;
37 }
38
39 // All used: random from palette
40 return PRESET_COLORS[Math.floor(Math.random() * PRESET_COLORS.length)];
41}
42
43const URBAN_LAND_USES = [
44 "Residential", "Commercial", "Park / Garden", "Industrial",

Callers 1

NewFieldDialogFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected