50 lines
1.2 KiB
Go
Executable File
50 lines
1.2 KiB
Go
Executable File
package patterns
|
|
|
|
import "math"
|
|
|
|
var sineoffset int = 0
|
|
var lastSineSpeed uint16 = 0
|
|
|
|
func Sinewave(w int, h int, bgColor RGBcolor, fgColor RGBcolor, speed uint16) [][]RGBcolor {
|
|
if speed != lastSineSpeed {
|
|
lastSineSpeed = speed
|
|
sineoffset = 0
|
|
}
|
|
sineoffset += int(speed/40)
|
|
background := FillPanelRGB(w,h,bgColor)
|
|
for x := 0; x < w; x++ {
|
|
y := int(math.Round((math.Sin(float64(x+sineoffset))+1) / 2 * float64(h-1)))
|
|
background[x][y] = fgColor
|
|
}
|
|
return background
|
|
}
|
|
|
|
var lastSinePos int = 0
|
|
|
|
func SineChase(w int, h int, bgColor RGBcolor, fgColor RGBcolor, speed uint16) [][]RGBcolor {
|
|
if speed != lastSineSpeed {
|
|
lastSineSpeed = speed
|
|
lastSinePos = 0
|
|
}
|
|
background := FillPanelRGB(w,h,bgColor)
|
|
y := int(math.Round((math.Sin(float64(lastSinePos))+1) / 2 * float64(h-1)))
|
|
background[lastSinePos][y] = fgColor
|
|
lastSinePos += 1
|
|
if lastSinePos >= w {
|
|
lastSinePos = 0
|
|
}
|
|
return background
|
|
}
|
|
|
|
func ZigZag(w int, h int) [][]RGBcolor {
|
|
var bgColor = [3]byte{0,0,0}
|
|
var fgColor = [3]byte{255,0,0}
|
|
//var a = [5]int{2, 4, 6, 8, 10}
|
|
background := FillPanelRGB(w,h,bgColor)
|
|
for x := 0; x < w; x++ {
|
|
y := x % (h-1)
|
|
background[x][y] = fgColor
|
|
}
|
|
return background
|
|
}
|