From 3b32bfa85f3587ef8892bd183c991890eae19ebe Mon Sep 17 00:00:00 2001 From: potassium Date: Sun, 21 Jun 2026 01:18:50 +0300 Subject: [PATCH] go fmt --- cmd/playground/circles/circles.go | 8 ++--- cmd/playground/circles/colored.go | 8 ++--- cmd/playground/circles/main.go | 8 ++--- cmd/playground/circles/xor.go | 2 +- cmd/playground/circles/xor_colored.go | 2 -- cmd/playground/main.go | 2 +- cmd/scale/downscale.go | 1 + cmd/scale/downscaled.png | 0 cmd/scale/griddownscale.go | 11 +++---- cmd/textonimage/main.go | 44 ++++++++++++-------------- http/http.go | 6 ++-- http/test.go | 6 ++-- pkg/center/main.go | 2 +- pkg/dithering/grid.go | 2 +- pkg/downscale/.grid.go.swp | Bin 0 -> 12288 bytes pkg/downscale/grid.go | 20 ++++++------ pkg/mesh/wallpaper/swaybg.go | 10 +++--- pkg/mkpalette/palette.go | 8 ++--- pkg/showpalette/show.go | 2 +- scale_test.go | 1 - 20 files changed, 70 insertions(+), 73 deletions(-) create mode 100644 cmd/scale/downscaled.png create mode 100644 pkg/downscale/.grid.go.swp diff --git a/cmd/playground/circles/circles.go b/cmd/playground/circles/circles.go index dc79df9..cbdbf87 100644 --- a/cmd/playground/circles/circles.go +++ b/cmd/playground/circles/circles.go @@ -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() } diff --git a/cmd/playground/circles/colored.go b/cmd/playground/circles/colored.go index 427cb7b..068857a 100644 --- a/cmd/playground/circles/colored.go +++ b/cmd/playground/circles/colored.go @@ -15,10 +15,10 @@ 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] - + } diff --git a/cmd/playground/circles/main.go b/cmd/playground/circles/main.go index 653d77e..1d70c58 100644 --- a/cmd/playground/circles/main.go +++ b/cmd/playground/circles/main.go @@ -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, + ) */ } /* diff --git a/cmd/playground/circles/xor.go b/cmd/playground/circles/xor.go index 6dd9ca2..3054399 100644 --- a/cmd/playground/circles/xor.go +++ b/cmd/playground/circles/xor.go @@ -11,7 +11,7 @@ func (t xor) At(x, y int) color.Color { srcColor := t.ColorModel().Convert(t.src.At(x, y)) // xor operation (a || b) && !(a && b) - if ((dstColor == color.Opaque) || (srcColor == color.Opaque)) && + if ((dstColor == color.Opaque) || (srcColor == color.Opaque)) && !((dstColor == color.Opaque) && (srcColor == color.Opaque)) { return color.Opaque } diff --git a/cmd/playground/circles/xor_colored.go b/cmd/playground/circles/xor_colored.go index 1110061..06ab7d0 100644 --- a/cmd/playground/circles/xor_colored.go +++ b/cmd/playground/circles/xor_colored.go @@ -1,3 +1 @@ package main - - diff --git a/cmd/playground/main.go b/cmd/playground/main.go index e1b7f4c..0d3ed4a 100644 --- a/cmd/playground/main.go +++ b/cmd/playground/main.go @@ -5,5 +5,5 @@ import ( ) func main() { - + } diff --git a/cmd/scale/downscale.go b/cmd/scale/downscale.go index 7df49df..4406643 100644 --- a/cmd/scale/downscale.go +++ b/cmd/scale/downscale.go @@ -1,4 +1,5 @@ //go:build upsampling + package main import ( diff --git a/cmd/scale/downscaled.png b/cmd/scale/downscaled.png new file mode 100644 index 0000000..e69de29 diff --git a/cmd/scale/griddownscale.go b/cmd/scale/griddownscale.go index 27835dc..e502440 100644 --- a/cmd/scale/griddownscale.go +++ b/cmd/scale/griddownscale.go @@ -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) diff --git a/cmd/textonimage/main.go b/cmd/textonimage/main.go index 6031678..700d8e5 100644 --- a/cmd/textonimage/main.go +++ b/cmd/textonimage/main.go @@ -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)) } diff --git a/http/http.go b/http/http.go index c84af96..3b67352 100644 --- a/http/http.go +++ b/http/http.go @@ -1,8 +1,8 @@ package main import ( - "net/http" "log" + "net/http" ) type imageTransform struct { @@ -29,14 +29,14 @@ func indexHTML(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) log.Println("copy error:", err) return - } + } } func main() { http.HandleFunc("/", indexHTML) http.Handle("POST /upload", imageTransform) - err := http.ListenAndServe(":8080", nil) + err := http.ListenAndServe(":8080", nil) if err != nil { log.Panicln(err) } diff --git a/http/test.go b/http/test.go index 5a5af85..4581657 100644 --- a/http/test.go +++ b/http/test.go @@ -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 { diff --git a/pkg/center/main.go b/pkg/center/main.go index 1cfe847..be3de78 100644 --- a/pkg/center/main.go +++ b/pkg/center/main.go @@ -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) } diff --git a/pkg/dithering/grid.go b/pkg/dithering/grid.go index ca04034..3ff03d0 100644 --- a/pkg/dithering/grid.go +++ b/pkg/dithering/grid.go @@ -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 } diff --git a/pkg/downscale/.grid.go.swp b/pkg/downscale/.grid.go.swp new file mode 100644 index 0000000000000000000000000000000000000000..f8ba58e184b396c95c82fa30be56a62afc97a153 GIT binary patch literal 12288 zcmYc?2=nw+u+%eTU|?VnU|={j!7R&7cn6#20|thI{F21t;>^-qkQ^SIl$u(Ql%HRK zM+sP}4sM`+aZ$24A9i>J?U^E0qLtr!nMnhmU1V%$(Gz3ONU^E0qLtr!nMnhmU z1cqP;B&IMh{N-R^aO8r_|HJzK@Aw%Q-tsdrJmF_xxXsVNaE70O;S@gu!%2PyhVA?e z46FDV7-sS_FihuXV3@|wz~IBrz`)JV!0?cdf#Db*1H%zM28P3Y3=GTp7#L>pF)-Bg zF)-BfF)-BdF)#%1F)$eOF))bnF))boF)%RmF))1OWnj3^%fN7!mx197F9X94UIvCG zybKHzco`UKco`Tnco`T{c^Mdzc^Mdzco`TBc^Mewco`TNco`UO@h~uKFsu?&rk@PyI zq-Zd3a_Z|V+ z(sNQ3suiHo39?EL?rnuyJcfa-^UY65&C!6l0L()(44fPwZUakeXe!h)Fu)TK17|G* zCm3@kE7&R|<)r4NXe8?>Wag&pLH(!+N-1giMG6(5U`m3dByB@$g$e~5g(N-S#0tF# zYlRAJZG~zEPLMii7=uz=q_sjNTos4|Q3bLJY6H|f9gs0-T_oU}8xKF?X0)IzlW6 zCRPL&gT@jhzJuJI9IF`^I1@p^l4z)Jq@b;kXryn%07*|t5RoLXNIFPOIz%KLECS9A zMG%o9kO%{3k&%u*w5g(O2Ag+xQJq#;Za zoJ^rnXQ-o)Y=jyd2