SaveColorPattern adds or replaces a named color pattern in memory and persists the file.
(name string, colors []int)
| 21 | |
| 22 | // SaveColorPattern adds or replaces a named color pattern in memory and persists the file. |
| 23 | func SaveColorPattern(name string, colors []int) error { |
| 24 | if name == "" { |
| 25 | return fmt.Errorf("color pattern name cannot be empty") |
| 26 | } |
| 27 | if len(colors) == 0 { |
| 28 | return fmt.Errorf("color pattern must have at least one color value") |
| 29 | } |
| 30 | cp := make([]int, len(colors)) |
| 31 | copy(cp, colors) |
| 32 | numericPatterns[name] = cp |
| 33 | colorsCompiled = false |
| 34 | CompileColorPatterns() |
| 35 | return saveColorPatternsFile() |
| 36 | } |
| 37 | |
| 38 | // DeleteColorPattern removes a named color pattern from memory and persists the file. |
| 39 | func DeleteColorPattern(name string) error { |
no test coverage detected