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

View File

@@ -9,6 +9,7 @@ const side = 16
type grid struct {
color.Gray
Factor float64
}
func (_ grid) ColorModel() color.Model {
@@ -20,7 +21,7 @@ func (_ grid) Bounds() image.Rectangle {
}
func (g grid) At(x, y int) color.Color {
n := uint8(g.Gray.Y * 10)
n := uint8(float64(g.Gray.Y) * g.Factor)
if n == 0 {
return color.Black
@@ -52,12 +53,13 @@ func (g uniformGrid) At(x, y int) color.Color {
type Dithering struct {
image.Image
Factor float64
}
func (d Dithering) ColorModel() color.Model { return color.GrayModel }
func (d Dithering) Bounds() image.Rectangle { return d.Image.Bounds() }
func (d Dithering) At(x, y int) color.Color {
c := color.GrayModel.Convert(d.Image.At(x, y))
return uniformGrid{grid{c.(color.Gray)}}.
return uniformGrid{grid{c.(color.Gray), d.Factor}}.
At(x, y)
}