Skip to content

Commit

Permalink
fix a bug + doc
Browse files Browse the repository at this point in the history
  • Loading branch information
faiface committed Feb 24, 2017
1 parent 7e09988 commit 589becb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
10 changes: 9 additions & 1 deletion batch.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package pixel

import (
"fmt"
"image/color"
"math"

Expand Down Expand Up @@ -75,6 +76,7 @@ func (b *Batch) MakeTriangles(t Triangles) TargetTriangles {
func (b *Batch) MakePicture(p Picture) TargetPicture {
return &batchPicture{
Picture: p,
b: b,
}
}

Expand Down Expand Up @@ -113,6 +115,8 @@ func (bt *batchTriangles) Draw() {

type batchPicture struct {
Picture

b *Batch
}

func (bp *batchPicture) Slice(r Rect) Picture {
Expand All @@ -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)
}
9 changes: 8 additions & 1 deletion interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 589becb

Please sign in to comment.