From b1bcbbeeea60cba7f0b419d1ebe0ea8f8c132d60 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 26 Apr 2022 23:23:31 +0900 Subject: [PATCH] ebiten: add comments at DrawTriangles --- examples/vector/main.go | 5 ++++- image.go | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/vector/main.go b/examples/vector/main.go index 2b6e06cc3..0fd09eb4a 100644 --- a/examples/vector/main.go +++ b/examples/vector/main.go @@ -30,7 +30,10 @@ import ( ) var ( - emptyImage = ebiten.NewImage(3, 3) + emptyImage = ebiten.NewImage(3, 3) + + // emptySubImage is an internal sub image of emptyImage. + // Use emptySubImage at DrawTriangles instead of emptyImage in order to avoid bleeding edges. emptySubImage = emptyImage.SubImage(image.Rect(1, 1, 2, 2)).(*ebiten.Image) ) diff --git a/image.go b/image.go index 7bdad7126..60581e00e 100644 --- a/image.go +++ b/image.go @@ -276,6 +276,11 @@ const MaxIndicesNum = graphics.IndicesNum // DrawTriangles draws triangles with the specified vertices and their indices. // +// img is used as a source image. img cannot be nil. +// If you want to draw triangles with a solid color, use a small white image +// and adjust the color elements in the vertices. For an actual implementation, +// see the example 'vector'. +// // Vertex contains color values, which are interpreted as straight-alpha colors. // // If len(indices) is not multiple of 3, DrawTriangles panics.