This commit is contained in:
2026-03-29 17:03:48 +03:00
parent 7143e96ef3
commit 3880b353c1
20 changed files with 491 additions and 23 deletions

35
pkg/clock/string.go Normal file
View File

@@ -0,0 +1,35 @@
package clock
import (
"git.nkpl.cc/twocookedfaggots/imageutils/clock/letter"
)
var blank = Letter("000000000")
type String struct {
S string
}
func (s String) Bounds() image.Rectangle {
splitted := strings.Split(s.S, '\n')
max := 0
for _, v := range splitted {
max = max(len(v), max)
}
x, y := max*4+1, len(splitted)*4+1
return image.Rect(0,0,x,y)
}
func (s String) ColorModel() color.Model { return color.Alpha16Model }
func (s String) At(x, y int) color.Color {
splitted := string.Split(s.S, '\n')
if y/4 > len(splitted) {
return blank.At(0, 0)
}
if x/4 > len(splitted[y/4]) {
return blank.At(0, 0)
}
c := splitted[y/4][x/4]
return Letter(c).At(x%4, y%4)
}