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 imageutils.test
cpu.out cpu.out
profile.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( var exchange = color.ModelFunc(
func(c color.Color) color.Color { 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.Opaque
} }
return color.Transparent 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) ColorModel() color.Model { return color.Alpha16Model }
func (e Exchange) Bounds() image.Rectangle { return e.Image.Bounds() } 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( var blackAndWhite = color.ModelFunc(
func(c color.Color) color.Color { 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.Black
} }
return color.White return color.White
@@ -55,7 +55,7 @@ var blackAndWhite = color.ModelFunc(
) )
// Black and white's alpha image. // 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) ColorModel() color.Model { return color.GrayModel }
func (b BlackAndWhite) Bounds() image.Rectangle { return b.Image.Bounds() } 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) circles := Circles(canvas.Bounds(), 2160/6)
palette := []color.Color{ palette := []color.Color{
color.RGBA{R:255, A:255}, color.RGBA{R: 255, A: 255},
color.RGBA{G:255, A:255}, color.RGBA{G: 255, A: 255},
color.RGBA{B:255, A:255}, color.RGBA{B: 255, A: 255},
} }
c := palette[rand.Int()%2] c := palette[rand.Int()%2]
-2
View File
@@ -1,3 +1 @@
package main package main
+1
View File
@@ -1,4 +1,5 @@
//go:build upsampling //go:build upsampling
package main package main
import ( import (
View File
+4 -5
View File
@@ -1,23 +1,22 @@
packagemain package main
import ( import (
"flag" "flag"
"image" "image"
"git.nkpl.cc/twocookedfaggots/imageutils/pkg/downscale" "git.nkpl.cc/twocookedfaggots/imageutils/pkg/downscale"
"git.nkpl.cc/twocookedfaggots/imageutils/downscale"
"git.nkpl.cc/twocookedfaggots/imageutils/util" "git.nkpl.cc/twocookedfaggots/imageutils/util"
) )
var x = flag.Int("x", 256, "dx value of new bounds") var x = flag.Int("x", 1024, "dx value of new bounds")
var y = flag.Int("y", 256, "dy value of new bounds") var y = flag.Int("y", 1024, "dy value of new bounds")
func main() { func main() {
flag.Parse() flag.Parse()
if err := util.ProcessStdio(func(img image.Image) image.Image { if err := util.ProcessStdio(func(img image.Image) image.Image {
return downscale.GridDownscale{ return downscale.GridDownscale{
Image: img, Image: img,
Rectangle: image.Rect(0,0,x,y), NewBounds: image.Rect(0, 0, *x, *y),
} }
}); err != nil { }); err != nil {
panic(err) panic(err)
-2
View File
@@ -10,8 +10,6 @@ var (
func main() { func main() {
flag.Parse() flag.Parse()
f, err := truetype.Parse(gomono.TTF) f, err := truetype.Parse(gomono.TTF)
if err != nil { if err != nil {
panic(err) panic(err)
+1 -1
View File
@@ -1,8 +1,8 @@
package main package main
import ( import (
"net/http"
"log" "log"
"net/http"
) )
type imageTransform struct { type imageTransform struct {
+3 -3
View File
@@ -5,13 +5,13 @@
package main package main
import ( import (
"git.nkpl.cc/twocookedfaggots/imageutils"
"git.nkpl.cc/twocookedfaggots/imageutils/http/blank"
"image" "image"
"image/color" "image/color"
"image/png"
"image/jpeg" "image/jpeg"
"image/png"
"os" "os"
"git.nkpl.cc/twocookedfaggots/imageutils"
"git.nkpl.cc/twocookedfaggots/imageutils/http/blank"
) )
func BlankFillWhite(img image.Image) image.Image { 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, r := image.Rect(x1, y1,
x1+i.Src.Bounds().Dx(), y1+i.Src.Bounds().Dy()) x1+i.Src.Bounds().Dx(), y1+i.Src.Bounds().Dy())
if (image.Point{x, y}).In(r) { 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) 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 { if n == 0 {
return color.Black return color.Black
} }
step := int((side*side-1) / n) step := int((side*side - 1) / n)
if (y*side+x)%step == 0 { if (y*side+x)%step == 0 {
return color.White 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 { type GridDownscale struct {
image.Image image.Image
newBounds image.Rectangle NewBounds image.Rectangle
} }
func blend(c1, c2 color.Color) color.RGBA { 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) { func avgColor(img image.Image) (c color.Color) {
dx, dy := img.Bounds().Dx(), img.Bounds().Dy() b := img.Bounds()
for y := 0; y < dy; y++ { c = img.At(b.Min.X, b.Min.Y)
for x := 0; x < dx; x++ { 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)) c = blend(c, img.At(x, y))
} }
} }
return return
} }
func (grid grid) ColorModel() color.Model { return grid.Image.ColorModel } func (grid GridDownscale) ColorModel() color.Model { return grid.Image.ColorModel() }
func (grid grid) Bounds() image.Rectangle { return grid.NewBounds } func (grid GridDownscale) Bounds() image.Rectangle { return grid.NewBounds }
func (grid grid) At(x, y int) color.Color { func (grid GridDownscale) At(x, y int) color.Color {
b := grid.Image.Bounds() b := grid.Image.Bounds()
dx, dy := b.Dx(), b.Dy() dx, dy := b.Dx(), b.Dy()
cellBounds := image.Rect( cellBounds := image.Rect(
0, 0, 0, 0,
dx/grid.newBounds.Dx(), dx/grid.NewBounds.Dx(),
dy/grid.newBounds.Dy(), dy/grid.NewBounds.Dy(),
) )
r := grid.Image.Bounds().Intersect( 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}) return avgColor(sub{grid.Image, r})
} }
-1
View File
@@ -33,7 +33,6 @@ func BenchmarkScale(b *testing.B) {
} }
} }
type SinglePixel struct{} type SinglePixel struct{}
func (s SinglePixel) At(x, y int) color.Color { func (s SinglePixel) At(x, y int) color.Color {