fix a bug + doc
This commit is contained in:
parent
7e09988467
commit
589becbcdb
10
batch.go
10
batch.go
|
@ -1,6 +1,7 @@
|
|||
package pixel
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image/color"
|
||||
"math"
|
||||
|
||||
|
@ -75,6 +76,7 @@ func (b *Batch) MakeTriangles(t Triangles) TargetTriangles {
|
|||
func (b *Batch) MakePicture(p Picture) TargetPicture {
|
||||
return &batchPicture{
|
||||
Picture: p,
|
||||
b: b,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,6 +115,8 @@ func (bt *batchTriangles) Draw() {
|
|||
|
||||
type batchPicture struct {
|
||||
Picture
|
||||
|
||||
b *Batch
|
||||
}
|
||||
|
||||
func (bp *batchPicture) Slice(r Rect) Picture {
|
||||
|
@ -122,5 +126,9 @@ func (bp *batchPicture) Slice(r Rect) Picture {
|
|||
}
|
||||
|
||||
func (bp *batchPicture) Draw(t TargetTriangles) {
|
||||
t.(*batchTriangles).draw(bp)
|
||||
bt := t.(*batchTriangles)
|
||||
if bp.b != bt.b {
|
||||
panic(fmt.Sprintf("%T.Draw: TargetTriangles generated by different Batch", bp))
|
||||
}
|
||||
bt.draw(bp)
|
||||
}
|
||||
|
|
|
@ -19,7 +19,11 @@ type Target interface {
|
|||
// present) when making new TargetTriangles. This varies from Target to Target.
|
||||
MakeTriangles(Triangles) TargetTriangles
|
||||
|
||||
//TODO: doc
|
||||
// MakePicture generates a specialized copy of the provided Picture.
|
||||
//
|
||||
// When calling Draw method on the returned TargetPicture, the TargetPicture will be drawn
|
||||
// onto the Target that generated it together with the TargetTriangles supplied to the Draw
|
||||
// method.
|
||||
MakePicture(Picture) TargetPicture
|
||||
}
|
||||
|
||||
|
@ -116,6 +120,9 @@ type Picture interface {
|
|||
type TargetPicture interface {
|
||||
Picture
|
||||
|
||||
// Draw draws the supplied TargetTriangles (which must be generated by the same Target as
|
||||
// this TargetPicture) with this TargetPicture. The TargetTriangles should utilize the data
|
||||
// from this TargetPicture in some way.
|
||||
Draw(TargetTriangles)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue