Add example
This commit is contained in:
26
examples/glaggle/main.go
Normal file
26
examples/glaggle/main.go
Normal 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.")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user