better error messages %T -> (%T)
This commit is contained in:
parent
7f38aac901
commit
a1e7f9bf04
5
batch.go
5
batch.go
|
@ -73,6 +73,9 @@ func (b *Batch) MakeTriangles(t Triangles) TargetTriangles {
|
|||
|
||||
// MakePicture returns a specialized copy of the provided Picture that draws onto this Batch.
|
||||
func (b *Batch) MakePicture(p Picture) TargetPicture {
|
||||
if p.Original() != b.cont.Picture.Original() {
|
||||
panic(fmt.Errorf("(%T).MakePicture: Picture is not a slice of Batch's Picture", b))
|
||||
}
|
||||
bp := &batchPicture{
|
||||
Picture: p,
|
||||
dst: b,
|
||||
|
@ -134,7 +137,7 @@ func (bp *batchPicture) Original() Picture {
|
|||
func (bp *batchPicture) Draw(t TargetTriangles) {
|
||||
bt := t.(*batchTriangles)
|
||||
if bp.dst != bt.dst {
|
||||
panic(fmt.Errorf("%T.Draw: TargetTriangles generated by different Batch", bp))
|
||||
panic(fmt.Errorf("(%T).Draw: TargetTriangles generated by different Batch", bp))
|
||||
}
|
||||
bt.draw(bp)
|
||||
}
|
||||
|
|
2
data.go
2
data.go
|
@ -89,7 +89,7 @@ func (td *TrianglesData) updateData(t Triangles) {
|
|||
// TrianglesPosition, TrianglesColor and TrianglesTexture are supported.
|
||||
func (td *TrianglesData) Update(t Triangles) {
|
||||
if td.Len() != t.Len() {
|
||||
panic(fmt.Errorf("%T.Update: invalid triangles length", td))
|
||||
panic(fmt.Errorf("(%T).Update: invalid triangles length", td))
|
||||
}
|
||||
td.updateData(t)
|
||||
}
|
||||
|
|
|
@ -402,7 +402,7 @@ func (cp *canvasPicture) Color(at pixel.Vec) pixel.NRGBA {
|
|||
func (cp *canvasPicture) Draw(t pixel.TargetTriangles) {
|
||||
ct := t.(*canvasTriangles)
|
||||
if cp.dst != ct.dst {
|
||||
panic(fmt.Errorf("%T.Draw: TargetTriangles generated by different Canvas", cp))
|
||||
panic(fmt.Errorf("(%T).Draw: TargetTriangles generated by different Canvas", cp))
|
||||
}
|
||||
ct.draw(cp.tex, cp.borders, cp.bounds)
|
||||
}
|
||||
|
@ -438,7 +438,7 @@ func (ccp *canvasCanvasPicture) Color(at pixel.Vec) pixel.NRGBA {
|
|||
func (ccp *canvasCanvasPicture) Draw(t pixel.TargetTriangles) {
|
||||
ct := t.(*canvasTriangles)
|
||||
if ccp.dst != ct.dst {
|
||||
panic(fmt.Errorf("%T.Draw: TargetTriangles generated by different Canvas", ccp))
|
||||
panic(fmt.Errorf("(%T).Draw: TargetTriangles generated by different Canvas", ccp))
|
||||
}
|
||||
ct.draw(ccp.src.orig.f.Texture(), ccp.src.orig.borders, ccp.bounds)
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ func (gt *GLTriangles) submitData() {
|
|||
// The two Triangles (gt and t) must be of the same len.
|
||||
func (gt *GLTriangles) Update(t pixel.Triangles) {
|
||||
if gt.Len() != t.Len() {
|
||||
panic(fmt.Errorf("%T.Update: invalid triangles len", gt))
|
||||
panic(fmt.Errorf("(%T).Update: invalid triangles len", gt))
|
||||
}
|
||||
gt.updateData(t)
|
||||
gt.submitData()
|
||||
|
|
Loading…
Reference in New Issue