This commit is contained in:
2026-06-21 01:18:50 +03:00
parent afd438930e
commit 3b32bfa85f
20 changed files with 70 additions and 73 deletions
+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 -1
View File
@@ -68,7 +68,7 @@ func main() {
},
),
)
err = png.Encode(os.Stdout, showColors{palette})
check(err)
}