Compare commits

...

2 Commits

Author SHA1 Message Date
twocookedfaggots 729a636b9b Update .gitignore 2026-06-21 02:38:30 +03:00
twocookedfaggots 3b32bfa85f go fmt 2026-06-21 02:37:34 +03:00
21 changed files with 73 additions and 73 deletions
+3
View File
@@ -2,3 +2,6 @@ child_porn
imageutils.test
cpu.out
profile.out
*.png
*.jpg
*.jpeg
+4 -4
View File
@@ -29,14 +29,14 @@ func Circles(b image.Rectangle, radius int) chan iu.Circle {
var exchange = color.ModelFunc(
func(c color.Color) color.Color {
if color.Alpha16Model.Convert(c) == color.Transparent{
if color.Alpha16Model.Convert(c) == color.Transparent {
return color.Opaque
}
return color.Transparent
},
)
type Exchange struct { image.Image }
type Exchange struct{ image.Image }
func (e Exchange) ColorModel() color.Model { return color.Alpha16Model }
func (e Exchange) Bounds() image.Rectangle { return e.Image.Bounds() }
@@ -47,7 +47,7 @@ func (e Exchange) At(x, y int) color.Color {
var blackAndWhite = color.ModelFunc(
func(c color.Color) color.Color {
if color.Alpha16Model.Convert(c) == color.Transparent{
if color.Alpha16Model.Convert(c) == color.Transparent {
return color.Black
}
return color.White
@@ -55,7 +55,7 @@ var blackAndWhite = color.ModelFunc(
)
// Black and white's alpha image.
type BlackAndWhite struct { image.Image }
type BlackAndWhite struct{ image.Image }
func (b BlackAndWhite) ColorModel() color.Model { return color.GrayModel }
func (b BlackAndWhite) Bounds() image.Rectangle { return b.Image.Bounds() }
+3 -3
View File
@@ -15,9 +15,9 @@ func main() {
circles := Circles(canvas.Bounds(), 2160/6)
palette := []color.Color{
color.RGBA{R:255, A:255},
color.RGBA{G:255, A:255},
color.RGBA{B:255, A:255},
color.RGBA{R: 255, A: 255},
color.RGBA{G: 255, A: 255},
color.RGBA{B: 255, A: 255},
}
c := palette[rand.Int()%2]
+4 -4
View File
@@ -10,10 +10,10 @@ func main() {
draw.Draw(canvas, c.Bounds(), xor{c, canvas}, c.Bounds().Min, draw.Src)
/*
draw.DrawMask(
canvas, canvas.Bounds(), &image.Uniform{color.White},
image.Point{}, xor{c, canvas}, image.Point{}, draw.Src,
)
draw.DrawMask(
canvas, canvas.Bounds(), &image.Uniform{color.White},
image.Point{}, xor{c, canvas}, image.Point{}, draw.Src,
)
*/
}
/*
-2
View File
@@ -1,3 +1 @@
package main
+1
View File
@@ -1,4 +1,5 @@
//go:build upsampling
package main
import (
View File
+5 -6
View File
@@ -1,23 +1,22 @@
packagemain
package main
import (
"flag"
"image"
"git.nkpl.cc/twocookedfaggots/imageutils/pkg/downscale"
"git.nkpl.cc/twocookedfaggots/imageutils/downscale"
"git.nkpl.cc/twocookedfaggots/imageutils/util"
)
var x = flag.Int("x", 256, "dx value of new bounds")
var y = flag.Int("y", 256, "dy value of new bounds")
var x = flag.Int("x", 1024, "dx value of new bounds")
var y = flag.Int("y", 1024, "dy value of new bounds")
func main() {
flag.Parse()
if err := util.ProcessStdio(func(img image.Image) image.Image {
return downscale.GridDownscale{
Image: img,
Rectangle: image.Rect(0,0,x,y),
Image: img,
NewBounds: image.Rect(0, 0, *x, *y),
}
}); err != nil {
panic(err)
+21 -23
View File
@@ -10,29 +10,27 @@ var (
func main() {
flag.Parse()
f, err := truetype.Parse(gomono.TTF)
if err != nil {
panic(err)
}
face := truetype.NewFace(f, &truetype.Options{
Size: float64(img.Bounds().Dx() / size),
DPI: 72,
Hinting: font.HintingNone,
})
if err != nil {
panic(err)
}
face := truetype.NewFace(f, &truetype.Options{
Size: float64(img.Bounds().Dx() / size),
DPI: 72,
Hinting: font.HintingNone,
})
d := &font.Drawer{
Dst: dst,
Src: image.NewUniform(color.Black),
Face: face,
Dot: fixed.Point26_6{fixed.Int26_6(img.Bounds().Dx() /
x,
),
fixed.Int26_6(img.Bounds().Dy() /
y,
),
},
}
d.DrawString(time.Now().Format(time.Kitchen))
d := &font.Drawer{
Dst: dst,
Src: image.NewUniform(color.Black),
Face: face,
Dot: fixed.Point26_6{fixed.Int26_6(img.Bounds().Dx() /
x,
),
fixed.Int26_6(img.Bounds().Dy() /
y,
),
},
}
d.DrawString(time.Now().Format(time.Kitchen))
}
+1 -1
View File
@@ -1,8 +1,8 @@
package main
import (
"net/http"
"log"
"net/http"
)
type imageTransform struct {
+3 -3
View File
@@ -5,13 +5,13 @@
package main
import (
"git.nkpl.cc/twocookedfaggots/imageutils"
"git.nkpl.cc/twocookedfaggots/imageutils/http/blank"
"image"
"image/color"
"image/png"
"image/jpeg"
"image/png"
"os"
"git.nkpl.cc/twocookedfaggots/imageutils"
"git.nkpl.cc/twocookedfaggots/imageutils/http/blank"
)
func BlankFillWhite(img image.Image) image.Image {
+1 -1
View File
@@ -12,7 +12,7 @@ func (i Into) At(x, y int) color.Color {
r := image.Rect(x1, y1,
x1+i.Src.Bounds().Dx(), y1+i.Src.Bounds().Dy())
if (image.Point{x, y}).In(r) {
return i.Src.At(x-x1,y-y2)
return i.Src.At(x-x1, y-y2)
}
return i.Dst.At(x, y)
}
+1 -1
View File
@@ -27,7 +27,7 @@ func (g grid) At(x, y int) color.Color {
if n == 0 {
return color.Black
}
step := int((side*side-1) / n)
step := int((side*side - 1) / n)
if (y*side+x)%step == 0 {
return color.White
}
Binary file not shown.
+11 -9
View File
@@ -18,7 +18,7 @@ func (sub sub) At(x, y int) color.Color {
type GridDownscale struct {
image.Image
newBounds image.Rectangle
NewBounds image.Rectangle
}
func blend(c1, c2 color.Color) color.RGBA {
@@ -39,24 +39,25 @@ func blend(c1, c2 color.Color) color.RGBA {
}
func avgColor(img image.Image) (c color.Color) {
dx, dy := img.Bounds().Dx(), img.Bounds().Dy()
for y := 0; y < dy; y++ {
for x := 0; x < dx; x++ {
b := img.Bounds()
c = img.At(b.Min.X, b.Min.Y)
for y := b.Min.Y; y < b.Max.Y; y++ {
for x := b.Min.X + 1; x < b.Max.X; x++ {
c = blend(c, img.At(x, y))
}
}
return
}
func (grid grid) ColorModel() color.Model { return grid.Image.ColorModel }
func (grid grid) Bounds() image.Rectangle { return grid.NewBounds }
func (grid grid) At(x, y int) color.Color {
func (grid GridDownscale) ColorModel() color.Model { return grid.Image.ColorModel() }
func (grid GridDownscale) Bounds() image.Rectangle { return grid.NewBounds }
func (grid GridDownscale) At(x, y int) color.Color {
b := grid.Image.Bounds()
dx, dy := b.Dx(), b.Dy()
cellBounds := image.Rect(
0, 0,
dx/grid.newBounds.Dx(),
dy/grid.newBounds.Dy(),
dx/grid.NewBounds.Dx(),
dy/grid.NewBounds.Dy(),
)
r := grid.Image.Bounds().Intersect(
@@ -68,6 +69,7 @@ func (grid grid) At(x, y int) color.Color {
},
),
)
println(r.Min.X, r.Min.Y)
return avgColor(sub{grid.Image, r})
}
+5 -5
View File
@@ -12,11 +12,11 @@ var err error
func Wallpaper(img image.Image) error {
/*
cmd := exec.Command(
"swaybg",
"--image", "/dev/stdin",
"--mode", "fill",
)
cmd := exec.Command(
"swaybg",
"--image", "/dev/stdin",
"--mode", "fill",
)
*/
cmd := exec.Command("imv", "/dev/stdin")
+4 -4
View File
@@ -57,10 +57,10 @@ func main() {
slices.Collect(maps.Keys(p)), imgutil.ColorToHex,
)
/*
h := make([]hex, 0, len(s))
for i := range s {
h = append(h, hex(s[i]))
}
h := make([]hex, 0, len(s))
for i := range s {
h = append(h, hex(s[i]))
}
*/
err = w.Write(s)
check(err)
-1
View File
@@ -33,7 +33,6 @@ func BenchmarkScale(b *testing.B) {
}
}
type SinglePixel struct{}
func (s SinglePixel) At(x, y int) color.Color {