Add example
This commit is contained in:
parent
f81faecc92
commit
70a8567646
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
TEST.png
|
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.")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user