This commit is contained in:
2026-03-29 17:03:48 +03:00
parent 7143e96ef3
commit 3880b353c1
20 changed files with 491 additions and 23 deletions

View File

@@ -13,6 +13,8 @@ import (
"golang.org/x/image/font"
"golang.org/x/image/font/gofont/gomono"
"golang.org/x/image/math/fixed"
"git.nkpl.cc/twocookedfaggots/imageutils/pkg/mesh/wallpaper"
// "github.com/droyo/styx"
// "io/fs"
)
@@ -42,22 +44,22 @@ func render(img image.Image) draw.Image {
}
func main() {
// x := flag.Int("x", 2, "use to grid by x axis")
// y := flag.Int("y", 2, "use to grid by y axis")
// x := flag.Int("x", 2, "use to grid by x axis")
// y := flag.Int("y", 2, "use to grid by y axis")
flag.Parse() // now flags is ready to use
img, err := png.Decode(os.Stdin)
if err != nil {
panic(err)
}
// Mesh{ // our image modifyer
// Image: img,
// X: *x,
// Y: *y,
// },
// Mesh{ // our image modifyer
// Image: img,
// X: *x,
// Y: *y,
// },
dst := render(
img,
img,
)
f, err := truetype.Parse(gomono.TTF)
@@ -75,16 +77,16 @@ func main() {
Src: image.NewUniform(color.Black),
Face: face,
Dot: fixed.Point26_6{fixed.Int26_6(img.Bounds().Dx() /
9*64,
9 * 64,
),
fixed.Int26_6(img.Bounds().Dy() /
5*64,
5 * 64,
),
},
}
d.DrawString(time.Now().Format(time.Kitchen))
err = png.Encode(os.Stdout, dst)
err = wallpaper.Wallpaper(dst)
if err != nil {
panic(err)
}

23
pkg/mesh/test_cmd.go Normal file
View File

@@ -0,0 +1,23 @@
package main
import (
"os"
"os/exec"
)
func main() {
f, err := os.Open("/home/potassium/documents/wallpaper/8.png")
if err != nil {
panic(err)
}
cmd := exec.Command(
"swaybg",
"--image", "/dev/stdin",
)
cmd.Stderr = os.Stderr
cmd.Stdin = f
err = cmd.Run()
if err != nil {
panic(err)
}
}

View File

@@ -0,0 +1,37 @@
package wallpaper
import (
"bytes"
"image"
"image/png"
"os"
"os/exec"
)
var err error
func Wallpaper(img image.Image) error {
/*
cmd := exec.Command(
"swaybg",
"--image", "/dev/stdin",
"--mode", "fill",
)
*/
cmd := exec.Command("imv", "/dev/stdin")
var buf = new(bytes.Buffer)
err := png.Encode(buf, img)
if err != nil {
panic(err)
}
cmd.Stderr = os.Stdout
cmd.Stdin = buf
err = cmd.Run()
if err != nil {
return err
}
return nil
}