summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon C. Irizarry <brandon.irizarry@gmail.com>2026-03-05 21:29:01 -0500
committerBrandon C. Irizarry <brandon.irizarry@gmail.com>2026-03-05 21:29:01 -0500
commit6118dce2db22e8461d9e21c70c330674f5fe6ca0 (patch)
tree9da2e13e395c54b662188ad333895c42ce36a316
parent95c756e854b1e9fa5aaa44893a1c7370ac1edcfb (diff)
feat: make the lissajous design flash in a few random colors
-rw-r--r--main.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/main.go b/main.go
index 7bdf3f3..b73f5fb 100644
--- a/main.go
+++ b/main.go
@@ -13,6 +13,8 @@ import (
var palette = []color.Color{
color.Black,
color.RGBA{0x00, 0xff, 0x00, 0xff},
+ color.RGBA{0xff, 0x00, 0x00, 0xff},
+ color.RGBA{0x00, 0x00, 0xff, 0xff},
}
const (
@@ -52,10 +54,12 @@ func newImage(size, cycles int, phase, res, freq float64) *image.Paletted {
rect := image.Rect(0, 0, 2*size+1, 2*size+1)
img := image.NewPaletted(rect, palette)
+ randIndex := 1 + uint8(rand.IntN(len(palette)-1))
+
for t := 0.0; t < float64(cycles)*2*math.Pi; t += res {
x := math.Sin(t)
y := math.Sin(t*freq + phase)
- img.SetColorIndex(size+int(x*float64(size)+0.5), size+int(y*float64(size)+0.5), foregroundIndex)
+ img.SetColorIndex(size+int(x*float64(size)+0.5), size+int(y*float64(size)+0.5), randIndex)
}
return img