merging all related stuff here
This commit is contained in:
11
go.mod
11
go.mod
@@ -1,13 +1,8 @@
|
||||
module git.niplace.ru/XoxJlopeZi4BB/imageutils
|
||||
module git.nkpl.cc/twocookedfaggots/imageutils
|
||||
|
||||
go 1.24.0
|
||||
go 1.25.5
|
||||
|
||||
require (
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
|
||||
golang.org/x/image v0.33.0
|
||||
)
|
||||
|
||||
require (
|
||||
9fans.net/go v0.0.7 // indirect
|
||||
github.com/potassium5703/texture v0.0.0-20240820054037-fce43fc4b0f0 // indirect
|
||||
golang.org/x/image v0.36.0
|
||||
)
|
||||
|
||||
40
go.sum
40
go.sum
@@ -1,40 +1,4 @@
|
||||
9fans.net/go v0.0.7 h1:H5CsYJTf99C8EYAQr+uSoEJnLP/iZU8RmDuhyk30iSM=
|
||||
9fans.net/go v0.0.7/go.mod h1:Rxvbbc1e+1TyGMjAvLthGTyO97t+6JMQ6ly+Lcs9Uf0=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
||||
github.com/potassium5703/texture v0.0.0-20240820054037-fce43fc4b0f0 h1:sowjIIVme5ovcdB0kjP3w+4xbVNrlOPdx7Up4LIGJz8=
|
||||
github.com/potassium5703/texture v0.0.0-20240820054037-fce43fc4b0f0/go.mod h1:KwM7hMpZhr3XySWuK/SZ7s1BXVQe8p1IyZftYg9KtWY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4=
|
||||
golang.org/x/exp v0.0.0-20210405174845-4513512abef3/go.mod h1:I6l2HNBLBZEcrOoCpyKLdY2lHoRZ8lI4x60KMCQDft4=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.33.0 h1:LXRZRnv1+zGd5XBUVRFmYEphyyKJjQjCRiOuAP3sZfQ=
|
||||
golang.org/x/image v0.33.0/go.mod h1:DD3OsTYT9chzuzTQt+zMcOlBHgfoKQb1gry8p76Y1sc=
|
||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||
golang.org/x/mobile v0.0.0-20201217150744-e6ae53a27f4f/go.mod h1:skQtrUTUwhdJvXM/2KKJzY8pDgNr9I/FOMqDVRPBUS4=
|
||||
golang.org/x/mobile v0.0.0-20210220033013-bdb1ca9a1e08/go.mod h1:skQtrUTUwhdJvXM/2KKJzY8pDgNr9I/FOMqDVRPBUS4=
|
||||
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210415045647-66c3f260301c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/image v0.36.0 h1:Iknbfm1afbgtwPTmHnS2gTM/6PPZfH+z2EFuOkSbqwc=
|
||||
golang.org/x/image v0.36.0/go.mod h1:YsWD2TyyGKiIX1kZlu9QfKIsQ4nAAK9bdgdrIsE7xy4=
|
||||
|
||||
48
http/blank/blank.go
Normal file
48
http/blank/blank.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package blank
|
||||
|
||||
import (
|
||||
"image"
|
||||
"image/color"
|
||||
"image/draw"
|
||||
|
||||
"git.nkpl.cc/twocookedfaggots/imageutils"
|
||||
)
|
||||
|
||||
type blank struct {
|
||||
image.Image
|
||||
color.Color
|
||||
imageutils.Side
|
||||
}
|
||||
|
||||
func (b blank) ColorModel() color.Model { return b.Image.ColorModel() }
|
||||
|
||||
func (b blank) Bounds() image.Rectangle {
|
||||
rect := image.Rectangle{}
|
||||
switch b.Side {
|
||||
case imageutils.Left:
|
||||
fallthrough
|
||||
case imageutils.Right:
|
||||
rect = image.Rectangle{
|
||||
image.ZP,
|
||||
image.Point{
|
||||
1, b.Image.Bounds().Dy(),
|
||||
},
|
||||
}
|
||||
case imageutils.Up:
|
||||
fallthrough
|
||||
case imageutils.Down:
|
||||
rect = image.Rectangle{
|
||||
image.ZP,
|
||||
image.Point{
|
||||
b.Image.Bounds().Dx(), 1,
|
||||
},
|
||||
}
|
||||
}
|
||||
return rect
|
||||
}
|
||||
|
||||
func (b blank) At(x, y int) color.Color { return b.Color }
|
||||
|
||||
func Blank(img image.Image, clr color.Color, side imageutils.Side) image.Image {
|
||||
return imageutils.Concat(img, blank{img, clr, side}, side)
|
||||
}
|
||||
@@ -10,12 +10,15 @@ type imageTransform struct {
|
||||
TransformFunc func(image.Image) image.Image
|
||||
}
|
||||
|
||||
type BlankFill struct {
|
||||
}
|
||||
|
||||
func (t imageTransform) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
func indexHTML(w http.ResponseWriter, r *http.Request) {
|
||||
f, err := os.Open("index.html")
|
||||
f, err := os.Open("")
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
log.Fatalln("error opening file:", err)
|
||||
|
||||
33
http/test.go
Normal file
33
http/test.go
Normal file
@@ -0,0 +1,33 @@
|
||||
//go:build ignore
|
||||
package main
|
||||
|
||||
import "git.nkpl.cc/twocookedfaggots/imageutils/http/blank"
|
||||
|
||||
func BlankFillWhiteUp(img image.Image) image.Image {
|
||||
for i := 0; i < img.Bounds().Dx(); i++ {
|
||||
img = blank.Blank(img, color.White, Up)
|
||||
}
|
||||
return img
|
||||
}
|
||||
|
||||
func ProcessImageStdio(f func(image.Image) image.Image) error {
|
||||
img, err := png.Decode(os.Stdin)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
img = f(img)
|
||||
err := img.Encode(os.Stdout, img)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
err := ProcessImageStdio(
|
||||
BlankFillWhiteUp,
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"os"
|
||||
"slices"
|
||||
|
||||
imgutil "git.niplace.ru/XoxJlopeZi4BB/imageutils/pkg"
|
||||
imgutil "git.nkpl.cc/twocookedfaggots/imageutils/pkg"
|
||||
)
|
||||
|
||||
func check(err error) {
|
||||
|
||||
Binary file not shown.
@@ -8,7 +8,7 @@ import (
|
||||
"math"
|
||||
"os"
|
||||
|
||||
imgutil "git.niplace.ru/XoxJlopeZi4BB/imageutils/pkg"
|
||||
imgutil "git.nkpl.cc/twocookedfaggots/imageutils/pkg"
|
||||
)
|
||||
|
||||
func nearestHighSqrt(n int) int {
|
||||
|
||||
1
pkg/texture
Submodule
1
pkg/texture
Submodule
Submodule pkg/texture added at fce43fc4b0
@@ -8,7 +8,7 @@ import (
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/potassium5703/texture"
|
||||
"git.nkpl.cc/twocookedfaggots/imageutils/pkg/texture"
|
||||
)
|
||||
|
||||
func Render(img image.Image, rect image.Rectangle) image.Image {
|
||||
@@ -33,6 +33,21 @@ func BenchmarkScale(b *testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
type SinglePixel struct{}
|
||||
|
||||
func (s SinglePixel) At(x, y int) color.Color {
|
||||
return color.White
|
||||
}
|
||||
|
||||
func (s SinglePixel) ColorModel() color.Model {
|
||||
return color.RGBAModel
|
||||
}
|
||||
|
||||
func (s SinglePixel) Bounds() image.Rectangle {
|
||||
return image.Rect(0, 0, 1, 1)
|
||||
}
|
||||
|
||||
func BenchmarkSinglePixel(b *testing.B) {
|
||||
instance := SinglePixel{}
|
||||
err := png.Encode(io.Discard,
|
||||
|
||||
20
util/util.go
20
util/util.go
@@ -1,20 +0,0 @@
|
||||
package imageutils
|
||||
|
||||
import (
|
||||
"image"
|
||||
"image/color"
|
||||
)
|
||||
|
||||
type SinglePixel struct{}
|
||||
|
||||
func (s SinglePixel) At(x, y int) color.Color {
|
||||
return color.White
|
||||
}
|
||||
|
||||
func (s SinglePixel) ColorModel() color.Model {
|
||||
return color.RGBAModel
|
||||
}
|
||||
|
||||
func (s SinglePixel) Bounds() image.Rectangle {
|
||||
return image.Rect(0, 0, 1, 1)
|
||||
}
|
||||
Reference in New Issue
Block a user