Add example

This commit is contained in:
Sasha Koshka 2023-07-01 03:16:34 -04:00
parent f81faecc92
commit 70a8567646
2 changed files with 27 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
TEST.png

26
examples/glaggle/main.go Normal file
View File

@ -0,0 +1,26 @@
package main
import "os"
import "image"
import "image/png"
import "git.tebibyte.media/tomo/ggfx"
func main () {
img := image.NewRGBA(image.Rect(0, 0, 800, 600))
canvas := ggfx.Image[uint8] {
Pix: img.Pix,
Stride: img.Stride,
Bounds: img.Rect,
Width: 4,
}
canvas.FillRectangle([]uint8 { 255, 0, 0, 255 }, image.Rect(7, 4, 34, 78))
file, err := os.Create("TEST.png")
if err != nil { panic(err.Error()) }
defer file.Close()
err = png.Encode(file, img)
if err != nil { panic(err.Error()) }
println("Open TEST.png to see the result.")
}