This commit is contained in:
2025-12-14 06:04:57 +03:00
parent 2709034fc3
commit 02ece86303
23 changed files with 633 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

BIN
cmd/negate/minus19blue Executable file

Binary file not shown.

39
cmd/negate/minus19blue.go Normal file
View File

@@ -0,0 +1,39 @@
//go:build ignore
package main
import (
"image"
"image/color"
"image/png"
"os"
)
type Reshade struct{ image.Image }
func (rs Reshade) ColorModel() color.Model { return rs.Image.ColorModel() }
func (rs Reshade) Bounds() image.Rectangle { return rs.Image.Bounds() }
func (rs Reshade) At(x, y int) color.Color {
c := rs.Image.At(x, y)
r, g, b, a := c.RGBA()
// minus 19 blue
return color.RGBA{
uint8(r >> 8),
uint8(g >> 8),
uint8(b>>8) - 8*8,
uint8(a >> 8),
}
}
func check(err error) {
if err != nil {
panic(err)
}
}
func main() {
img, err := png.Decode(os.Stdin)
check(err)
err = png.Encode(os.Stdout, Reshade{img})
check(err)
}

70
cmd/negate/mixed.go Normal file
View File

@@ -0,0 +1,70 @@
package main
import (
"image"
"image/color"
"image/png"
"math/rand"
"os"
)
type MixedNegation struct {
src image.Image
counter int
}
func toRGBA(c color.Color) color.RGBA {
r, g, b, a := c.RGBA()
return color.RGBA{
R: uint8(r >> 8),
G: uint8(g >> 8),
B: uint8(b >> 8),
A: uint8(a >> 8),
}
}
func negateRGBA(c color.RGBA) color.RGBA {
c.R = 255 - c.R
c.G = 255 - c.G
c.B = 255 - c.B
return c
}
func Negate(c color.Color) color.Color {
return negateRGBA(toRGBA(c))
}
func randomBool() bool {
return rand.Intn(3) == 0
}
func (mn MixedNegation) ColorModel() color.Model { return mn.src.ColorModel() }
func (mn MixedNegation) Bounds() image.Rectangle { return mn.src.Bounds() }
func (mn *MixedNegation) At(x, y int) color.Color {
if (x%1 != 0) && (y%8 != 0) {
if randomBool() {
return Negate(mn.src.At(x, y))
}
}
return mn.src.At(x, y)
}
func pixelCount(img image.Image) int {
return img.Bounds().Dx() * img.Bounds().Dy()
}
func main() {
img, err := png.Decode(os.Stdin)
if err != nil {
panic(err)
}
n := pixelCount(img)
println(n)
err = png.Encode(os.Stdout, &MixedNegation{src: img, counter: n})
if err != nil {
panic(err)
}
}

BIN
cmd/negate/negate Executable file

Binary file not shown.

44
cmd/negate/negate.go Normal file
View File

@@ -0,0 +1,44 @@
package main
import (
"image"
"image/color"
"image/png"
"os"
)
func NegateRGBA(c color.RGBA) color.RGBA {
c.R = 255 - c.R
c.G = 255 - c.G
c.B = 255 - c.B
return c
}
type Negate struct{ image.Image }
func (n Negate) ColorModel() color.Model { return n.Image.ColorModel() }
func (n Negate) Bounds() image.Rectangle { return n.Image.Bounds() }
func (n Negate) At(x, y int) color.Color {
c := n.Image.At(x, y)
r, g, b, a := c.RGBA()
RGBAColor := color.RGBA{
R: uint8(r >> 8),
G: uint8(g >> 8),
B: uint8(b >> 8),
A: uint8(a >> 8),
}
return NegateRGBA(RGBAColor)
}
func check(err error) {
if err != nil {
panic(err)
}
}
func main() {
img, err := png.Decode(os.Stdin)
check(err)
err = png.Encode(os.Stdout, Negate{img})
check(err)
}

BIN
cmd/negate/negated5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 977 KiB

BIN
cmd/negate/negated8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB