change TrianglesPicture to retun intensity instead of ok

This commit is contained in:
faiface 2017-03-05 12:17:07 +01:00
parent 28f0f01173
commit 3aa7e6e8bf
2 changed files with 13 additions and 13 deletions

24
data.go
View File

@ -11,10 +11,10 @@ import (
// TrianglesData specifies a list of Triangles vertices with three common properties: Position, // TrianglesData specifies a list of Triangles vertices with three common properties: Position,
// Color and Texture. // Color and Texture.
type TrianglesData []struct { type TrianglesData []struct {
Position Vec Position Vec
Color NRGBA Color NRGBA
Picture Vec Picture Vec
HasPicture bool Intensity float64
} }
// MakeTrianglesData creates TrianglesData of length len initialized with default property values. // MakeTrianglesData creates TrianglesData of length len initialized with default property values.
@ -41,11 +41,11 @@ func (td *TrianglesData) SetLen(len int) {
needAppend := len - td.Len() needAppend := len - td.Len()
for i := 0; i < needAppend; i++ { for i := 0; i < needAppend; i++ {
*td = append(*td, struct { *td = append(*td, struct {
Position Vec Position Vec
Color NRGBA Color NRGBA
Picture Vec Picture Vec
HasPicture bool Intensity float64
}{V(0, 0), NRGBA{1, 1, 1, 1}, V(0, 0), false}) }{V(0, 0), NRGBA{1, 1, 1, 1}, V(0, 0), 0})
} }
} }
if len < td.Len() { if len < td.Len() {
@ -79,7 +79,7 @@ func (td *TrianglesData) updateData(t Triangles) {
} }
if t, ok := t.(TrianglesPicture); ok { if t, ok := t.(TrianglesPicture); ok {
for i := range *td { for i := range *td {
(*td)[i].Picture, (*td)[i].HasPicture = t.Picture(i) (*td)[i].Picture, (*td)[i].Intensity = t.Picture(i)
} }
} }
} }
@ -113,8 +113,8 @@ func (td *TrianglesData) Color(i int) NRGBA {
} }
// Picture returns the picture property of i-th vertex. // Picture returns the picture property of i-th vertex.
func (td *TrianglesData) Picture(i int) (pic Vec, ok bool) { func (td *TrianglesData) Picture(i int) (pic Vec, intensity float64) {
return (*td)[i].Picture, (*td)[i].HasPicture return (*td)[i].Picture, (*td)[i].Intensity
} }
// PictureData specifies an in-memory rectangular area of NRGBA pixels and implements Picture and // PictureData specifies an in-memory rectangular area of NRGBA pixels and implements Picture and

View File

@ -97,7 +97,7 @@ type TrianglesColor interface {
// Note that this represents picture coordinates, not an actual picture. // Note that this represents picture coordinates, not an actual picture.
type TrianglesPicture interface { type TrianglesPicture interface {
Triangles Triangles
Picture(i int) (pic Vec, ok bool) Picture(i int) (pic Vec, intensity float64)
} }
// Picture represents a rectangular area of raster data, such as a color. It has Bounds which // Picture represents a rectangular area of raster data, such as a color. It has Bounds which