LEDController-old/internal/patterns/plaincolour.go

27 lines
660 B
Go
Executable File

package patterns
import "math/rand"
import "time"
func RedPanel(w int, h int) [][]RGBcolor {
return FillPanel(w, h, 255, 0, 0)
}
var lastColour RGBcolor
var lastIteration uint16 = 0
func RandomColourPanel(w int, h int, speed uint16) [][]RGBcolor {
if lastIteration > 0 {
lastIteration -= 40
}
if lastIteration <= 0 {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
var newColour RGBcolor
newColour[0] = byte(r.Intn(255))
newColour[1] = byte(r.Intn(255))
newColour[2] = byte(r.Intn(255))
lastColour = newColour
lastIteration = speed
}
return FillPanel(w, h, lastColour[0], lastColour[1], lastColour[2])
}