LEDController/internal/patterns/plaincolour.go

42 lines
1.1 KiB
Go
Raw Permalink Normal View History

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
var lastPlasmaValue byte = 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])
}
func PlasmaColourPanel(w int, h int, speed uint16) [][]RGBcolor {
if lastIteration > 0 {
lastIteration -= 40
}
if lastIteration <= 0 {
lastPlasmaValue++
var newColour RGBcolor
newColour[0],newColour[1],newColour[2] = plasmaRGBFromVal(lastPlasmaValue)
lastColour = newColour
lastIteration = speed
}
return FillPanel(w, h, lastColour[0], lastColour[1], lastColour[2])
}