new simple downscaling ideas

This commit is contained in:
2026-06-20 11:31:44 +03:00
parent 67ff655767
commit b75a8814a2
20 changed files with 395 additions and 65 deletions
+19
View File
@@ -0,0 +1,19 @@
package main
var Opaque, Transparent = color.Alpha{0xff}, color.Alpha{0}
type xor struct{ dst, src image.Image }
func (t xor) ColorModel() color.Model { return t.dst.ColorModel() }
func (t xor) Bounds() image.Rectangle { return t.src.Bounds() }
func (t xor) At(x, y int) color.Color {
dstColor := t.ColorModel().Convert(t.dst.At(x, y))
srcColor := t.ColorModel().Convert(t.src.At(x, y))
// xor operation (a || b) && !(a && b)
if ((dstColor == color.Opaque) || (srcColor == color.Opaque)) &&
!((dstColor == color.Opaque) && (srcColor == color.Opaque)) {
return color.Opaque
}
return color.Transparent
}