some redesign
This commit is contained in:
43
pkg/dithering/8x8grid.go
Normal file
43
pkg/dithering/8x8grid.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package dithering
|
||||
|
||||
import (
|
||||
"image"
|
||||
"image/color"
|
||||
)
|
||||
|
||||
type grid struct {
|
||||
color.Gray
|
||||
}
|
||||
|
||||
func (_ grid) ColorModel() color.Model {
|
||||
return color.RGBAModel
|
||||
}
|
||||
|
||||
func (_ grid) Bounds() image.Rectangle {
|
||||
return image.Rect(0, 0, 8, 8)
|
||||
}
|
||||
|
||||
func (g grid) At(x, y int) color.Color {
|
||||
step := int(64 / (g.Gray.Y / 4))
|
||||
if (y*8+x)%step == 0 {
|
||||
return color.Black
|
||||
}
|
||||
return color.White
|
||||
}
|
||||
|
||||
type uniformGrid struct {
|
||||
image.Image
|
||||
image.Rectangle
|
||||
}
|
||||
|
||||
func (g uniformGrid) ColorModel() color.Model {
|
||||
return g.Image.ColorModel()
|
||||
}
|
||||
|
||||
func (g uniformGrid) Bounds() image.Rectangle {
|
||||
return g.Rectangle
|
||||
}
|
||||
|
||||
func (g uniformGrid) At(x, y int) color.Color {
|
||||
return color.Color(nil)
|
||||
}
|
||||
Reference in New Issue
Block a user