Skip to content

Instantly share code, notes, and snippets.

@floodcode
Created November 19, 2018 04:17
Show Gist options
  • Save floodcode/21f735d35efe38827ff956d81a19a23e to your computer and use it in GitHub Desktop.
Save floodcode/21f735d35efe38827ff956d81a19a23e to your computer and use it in GitHub Desktop.
Simple bitwise fractal
package main
import (
"image"
"image/color"
"image/png"
"os"
)
const width = 512
const height = 512
func main() {
img := makeImage()
file, _ := os.Create("fract.png")
png.Encode(file, img)
}
func makeImage() *image.RGBA {
img := image.NewRGBA(image.Rectangle{
image.Point{0, 0},
image.Point{width, height},
})
for x := 0; x < width; x++ {
for y := 0; y < height; y++ {
pix := gen(uint8(x), uint8(y))
img.SetRGBA(x, y, color.RGBA{0, pix, 0, 0xff})
}
}
return img
}
func gen(x uint8, y uint8) uint8 {
return x ^ y
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment