This repository has been archived on 2024-06-03. You can view files and clone it, but cannot push or open issues or pull requests.
2023-07-05 07:25:50 +00:00
|
|
|
package x
|
|
|
|
|
2023-08-25 06:51:07 +00:00
|
|
|
import "image/color"
|
|
|
|
|
2023-07-05 07:25:50 +00:00
|
|
|
func indexOf[T comparable] (haystack []T, needle T) int {
|
|
|
|
for index, test := range haystack {
|
|
|
|
if test == needle {
|
|
|
|
return index
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
func remove[T any] (slice []T, index int) []T {
|
|
|
|
return append(slice[:index], slice[index + 1:]...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func insert[T any] (slice []T, index int, element T) []T {
|
|
|
|
slice = append(slice[:index + 1], slice[index:]...)
|
|
|
|
slice[index] = element
|
|
|
|
return slice
|
|
|
|
}
|
2023-08-25 06:51:07 +00:00
|
|
|
|
|
|
|
func transparent (c color.Color) bool {
|
|
|
|
_, _, _, a := c.RGBA()
|
|
|
|
return a != 0xFFFF
|
|
|
|
}
|