Skip to content

Instantly share code, notes, and snippets.

@aoisensi
Created August 7, 2016 00:30
Show Gist options
  • Save aoisensi/b69468ffb21d29fbf447022e2e35c58d to your computer and use it in GitHub Desktop.
Save aoisensi/b69468ffb21d29fbf447022e2e35c58d to your computer and use it in GitHub Desktop.
package main
import (
"os"
"log"
"image/png"
"image"
"image/color"
)
func main() {
s := 256
img := image.NewGray(image.Rect(0, 0, s*2, s*2))
for x:=0; x<s; x++ {
for y:=0; y<s; y++ {
var c color.Gray
if x < y {
c.Y = uint8(x)
} else {
c.Y = uint8(y)
}
xn := s+(s-x-1)
yn := s+(s-y-1)
img.SetGray(x, y, c)
img.SetGray(xn, y, c)
img.SetGray(x, yn, c)
img.SetGray(xn, yn, c)
}
}
f, err := os.Create("forcuse.png")
if err != nil {
log.Fatal(err)
}
err = png.Encode(f, img)
if err != nil {
log.Fatal(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment