43 lines
725 B
Go
43 lines
725 B
Go
package main
|
|
|
|
import (
|
|
"image"
|
|
"image/color"
|
|
"image/png"
|
|
"os"
|
|
)
|
|
|
|
const SIZE_X = 128
|
|
const SIZE_Y = 128
|
|
const CELL_SIZE = 16
|
|
const CELL_SCALE = 8
|
|
|
|
func main() {
|
|
|
|
img := image.NewRGBA(image.Rect(0, 0, SIZE_X*CELL_SCALE, SIZE_Y*CELL_SCALE))
|
|
|
|
white := color.RGBA{R: 255, G: 255, B: 255, A: 255}
|
|
black := color.RGBA{R: 0, G: 0, B: 0, A: 255}
|
|
|
|
for y := 0; y < SIZE_Y*CELL_SCALE; y++ {
|
|
for x := 0; x < SIZE_X*CELL_SCALE; x++ {
|
|
stripeIndex := (x / CELL_SIZE) % 2
|
|
if stripeIndex == 0 {
|
|
img.SetRGBA(x, y, white)
|
|
} else {
|
|
img.SetRGBA(x, y, black)
|
|
}
|
|
}
|
|
}
|
|
|
|
f, err := os.Create("stripes.png")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer f.Close()
|
|
|
|
if err := png.Encode(f, img); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|