Fixed polygon filling

This commit is contained in:
2023-07-01 03:44:36 -04:00
parent 85b71a91a3
commit 5ca69d90e6
2 changed files with 33 additions and 16 deletions

View File

@@ -6,14 +6,25 @@ import "image/png"
import "git.tebibyte.media/tomo/ggfx"
func main () {
img := image.NewRGBA(image.Rect(0, 0, 800, 600))
img := image.NewRGBA(image.Rect(0, 0, 300, 300))
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))
black := []uint8 { 0, 0, 0, 255 }
red := []uint8 { 255, 0, 0, 255 }
canvas.FillPolygon (
black,
image.Pt(10, 10),
image.Pt(70, 50),
image.Pt(20, 70))
canvas.StrokePolygon (
red, 1,
image.Pt(10, 10),
image.Pt(70, 50),
image.Pt(20, 70))
file, err := os.Create("TEST.png")
if err != nil { panic(err.Error()) }