Checkpoint

This commit is contained in:
maze authored and maze committed 2026-10-29 17:29:41 +01:00
1 parent b8a493b93d
commit 85a9ec684c
54 files changed
+6855 -526

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
package screensaver
import (
"image"
"math/rand"
"go.maze.io/harmon/hardware"
"go.maze.io/harmon/internal/pixel"
)
type Stars struct {
display hardware.Display
points []image.Point
}
func NewStars(display hardware.Display, n int) *Stars {
s := &Stars{
display: display,
}
for i := 0; i < n; i++ {
s.points = append(s.points, s.randomPoint(display.Size()))
}
return s
}
func (s *Stars) randomPoint(p image.Point) image.Point {
return image.Point{X: rand.Intn(p.X), Y: rand.Intn(p.Y)}
}
func (s *Stars) Refresh() error {
s.display.Clear()
for _, p := range s.points {
s.display.Set(p.X, p.Y, pixel.On)
}
copy(s.points[1:], s.points)
s.points[0] = s.randomPoint(s.display.Size())
return s.display.Refresh()
}