Reverting back to origin
This commit is contained in:
parent
50ef216e79
commit
95148365d0
|
@ -95,12 +95,6 @@ Here's the list of the main features in Pixel. Although Pixel is still under hea
|
||||||
arbitrarily crazy stuff (e.g. graphical effects)
|
arbitrarily crazy stuff (e.g. graphical effects)
|
||||||
- Small codebase, ~5K lines of code, including the backend [glhf](https://github.com/faiface/glhf)
|
- Small codebase, ~5K lines of code, including the backend [glhf](https://github.com/faiface/glhf)
|
||||||
package
|
package
|
||||||
|
|
||||||
## Related repositories
|
|
||||||
|
|
||||||
Here are some packages which use Pixel:
|
|
||||||
- [TilePix](https://github.com/bcvery1/tilepix) Makes handling TMX files built with [Tiled](https://www.mapeditor.org/)
|
|
||||||
trivially easy to work with using Pixel.
|
|
||||||
|
|
||||||
## Missing features
|
## Missing features
|
||||||
|
|
||||||
|
|
361
color_test.go
361
color_test.go
|
@ -3,7 +3,6 @@ package pixel_test
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"image/color"
|
"image/color"
|
||||||
"reflect"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/faiface/pixel"
|
"github.com/faiface/pixel"
|
||||||
|
@ -23,363 +22,3 @@ func BenchmarkColorToRGBA(b *testing.B) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRGB(t *testing.T) {
|
|
||||||
type args struct {
|
|
||||||
r float64
|
|
||||||
g float64
|
|
||||||
b float64
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
args args
|
|
||||||
want pixel.RGBA
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "RBG: create black",
|
|
||||||
args: args{r: 0, g: 0, b: 0},
|
|
||||||
want: pixel.RGBA{R: 0, G: 0, B: 0, A: 1},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "RBG: create white",
|
|
||||||
args: args{r: 1, g: 1, b: 1},
|
|
||||||
want: pixel.RGBA{R: 1, G: 1, B: 1, A: 1},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "RBG: create nonsense",
|
|
||||||
args: args{r: 500, g: 500, b: 500},
|
|
||||||
want: pixel.RGBA{R: 500, G: 500, B: 500, A: 1},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
if got := pixel.RGB(tt.args.r, tt.args.g, tt.args.b); !reflect.DeepEqual(got, tt.want) {
|
|
||||||
t.Errorf("RGB() = %v, want %v", got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAlpha(t *testing.T) {
|
|
||||||
type args struct {
|
|
||||||
a float64
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
args args
|
|
||||||
want pixel.RGBA
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "Alpha: transparent",
|
|
||||||
args: args{a: 0},
|
|
||||||
want: pixel.RGBA{R: 0, G: 0, B: 0, A: 0},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Alpha: obaque",
|
|
||||||
args: args{a: 1},
|
|
||||||
want: pixel.RGBA{R: 1, G: 1, B: 1, A: 1},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Alpha: nonsense",
|
|
||||||
args: args{a: 1024},
|
|
||||||
want: pixel.RGBA{R: 1024, G: 1024, B: 1024, A: 1024},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
if got := pixel.Alpha(tt.args.a); !reflect.DeepEqual(got, tt.want) {
|
|
||||||
t.Errorf("Alpha() = %v, want %v", got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRGBA_Add(t *testing.T) {
|
|
||||||
type fields struct {
|
|
||||||
R float64
|
|
||||||
G float64
|
|
||||||
B float64
|
|
||||||
A float64
|
|
||||||
}
|
|
||||||
type args struct {
|
|
||||||
d pixel.RGBA
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
fields fields
|
|
||||||
args args
|
|
||||||
want pixel.RGBA
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "RGBA.Add: add to black",
|
|
||||||
fields: fields{R: 0, G: 0, B: 0, A: 1},
|
|
||||||
args: args{d: pixel.RGBA{R: 50, G: 50, B: 50, A: 0}},
|
|
||||||
want: pixel.RGBA{R: 50, G: 50, B: 50, A: 1},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "RGBA.Add: add to white",
|
|
||||||
fields: fields{R: 1, G: 1, B: 1, A: 1},
|
|
||||||
args: args{d: pixel.RGBA{R: 1, G: 1, B: 1, A: 1}},
|
|
||||||
want: pixel.RGBA{R: 2, G: 2, B: 2, A: 2},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
c := pixel.RGBA{
|
|
||||||
R: tt.fields.R,
|
|
||||||
G: tt.fields.G,
|
|
||||||
B: tt.fields.B,
|
|
||||||
A: tt.fields.A,
|
|
||||||
}
|
|
||||||
if got := c.Add(tt.args.d); !reflect.DeepEqual(got, tt.want) {
|
|
||||||
t.Errorf("RGBA.Add() = %v, want %v", got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRGBA_Sub(t *testing.T) {
|
|
||||||
type fields struct {
|
|
||||||
R float64
|
|
||||||
G float64
|
|
||||||
B float64
|
|
||||||
A float64
|
|
||||||
}
|
|
||||||
type args struct {
|
|
||||||
d pixel.RGBA
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
fields fields
|
|
||||||
args args
|
|
||||||
want pixel.RGBA
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "RGBA.Sub: sub from white",
|
|
||||||
fields: fields{R: 1, G: 1, B: 1, A: 1},
|
|
||||||
args: args{d: pixel.RGBA{R: .5, G: .5, B: .5, A: 0}},
|
|
||||||
want: pixel.RGBA{R: .5, G: .5, B: .5, A: 1},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "RGBA.Sub: sub from black",
|
|
||||||
fields: fields{R: 0, G: 0, B: 0, A: 0},
|
|
||||||
args: args{d: pixel.RGBA{R: 1, G: 1, B: 1, A: 1}},
|
|
||||||
want: pixel.RGBA{R: -1, G: -1, B: -1, A: -1},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
c := pixel.RGBA{
|
|
||||||
R: tt.fields.R,
|
|
||||||
G: tt.fields.G,
|
|
||||||
B: tt.fields.B,
|
|
||||||
A: tt.fields.A,
|
|
||||||
}
|
|
||||||
if got := c.Sub(tt.args.d); !reflect.DeepEqual(got, tt.want) {
|
|
||||||
t.Errorf("RGBA.Sub() = %v, want %v", got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRGBA_Mul(t *testing.T) {
|
|
||||||
type fields struct {
|
|
||||||
R float64
|
|
||||||
G float64
|
|
||||||
B float64
|
|
||||||
A float64
|
|
||||||
}
|
|
||||||
type args struct {
|
|
||||||
d pixel.RGBA
|
|
||||||
}
|
|
||||||
|
|
||||||
greaterThanOne := args{d: pixel.RGBA{R: 2, G: 3, B: 4, A: 5}}
|
|
||||||
lessThanOne := args{d: pixel.RGBA{R: .2, G: .3, B: .4, A: .5}}
|
|
||||||
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
fields fields
|
|
||||||
args args
|
|
||||||
want pixel.RGBA
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "RGBA.Mul: multiply black by >1",
|
|
||||||
fields: fields{R: 0, G: 0, B: 0, A: 0},
|
|
||||||
args: greaterThanOne,
|
|
||||||
want: pixel.RGBA{R: 0, G: 0, B: 0, A: 0},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "RGBA.Mul: multiply white by >1",
|
|
||||||
fields: fields{R: 1, G: 1, B: 1, A: 1},
|
|
||||||
args: greaterThanOne,
|
|
||||||
want: pixel.RGBA{R: 2, G: 3, B: 4, A: 5},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "RGBA.Mul: multiply black by <1",
|
|
||||||
fields: fields{R: 0, G: 0, B: 0, A: 0},
|
|
||||||
args: lessThanOne,
|
|
||||||
want: pixel.RGBA{R: 0, G: 0, B: 0, A: 0},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "RGBA.Mul: multiply white by <1",
|
|
||||||
fields: fields{R: 1, G: 1, B: 1, A: 1},
|
|
||||||
args: lessThanOne,
|
|
||||||
want: pixel.RGBA{R: .2, G: .3, B: .4, A: .5},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
c := pixel.RGBA{
|
|
||||||
R: tt.fields.R,
|
|
||||||
G: tt.fields.G,
|
|
||||||
B: tt.fields.B,
|
|
||||||
A: tt.fields.A,
|
|
||||||
}
|
|
||||||
if got := c.Mul(tt.args.d); !reflect.DeepEqual(got, tt.want) {
|
|
||||||
t.Errorf("RGBA.Mul() = %v, want %v", got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRGBA_Scaled(t *testing.T) {
|
|
||||||
type fields struct {
|
|
||||||
R float64
|
|
||||||
G float64
|
|
||||||
B float64
|
|
||||||
A float64
|
|
||||||
}
|
|
||||||
type args struct {
|
|
||||||
scale float64
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
fields fields
|
|
||||||
args args
|
|
||||||
want pixel.RGBA
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "RBGA.Scaled: black <1",
|
|
||||||
fields: fields{R: 0, G: 0, B: 0, A: 0},
|
|
||||||
args: args{scale: 0.5},
|
|
||||||
want: pixel.RGBA{R: 0, G: 0, B: 0, A: 0},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "RBGA.Scaled: black <1",
|
|
||||||
fields: fields{R: 1, G: 1, B: 1, A: 1},
|
|
||||||
args: args{scale: 0.5},
|
|
||||||
want: pixel.RGBA{R: .5, G: .5, B: .5, A: .5},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "RBGA.Scaled: black >1",
|
|
||||||
fields: fields{R: 0, G: 0, B: 0, A: 0},
|
|
||||||
args: args{scale: 2},
|
|
||||||
want: pixel.RGBA{R: 0, G: 0, B: 0, A: 0},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "RBGA.Scaled: black >1",
|
|
||||||
fields: fields{R: 1, G: 1, B: 1, A: 1},
|
|
||||||
args: args{scale: 2},
|
|
||||||
want: pixel.RGBA{R: 2, G: 2, B: 2, A: 2},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
c := pixel.RGBA{
|
|
||||||
R: tt.fields.R,
|
|
||||||
G: tt.fields.G,
|
|
||||||
B: tt.fields.B,
|
|
||||||
A: tt.fields.A,
|
|
||||||
}
|
|
||||||
if got := c.Scaled(tt.args.scale); !reflect.DeepEqual(got, tt.want) {
|
|
||||||
t.Errorf("RGBA.Scaled() = %v, want %v", got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRGBA_RGBA(t *testing.T) {
|
|
||||||
type fields struct {
|
|
||||||
R float64
|
|
||||||
G float64
|
|
||||||
B float64
|
|
||||||
A float64
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
fields fields
|
|
||||||
wantR uint32
|
|
||||||
wantG uint32
|
|
||||||
wantB uint32
|
|
||||||
wantA uint32
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "RGBA.RGBA: black",
|
|
||||||
fields: fields{R: 0, G: 0, B: 0, A: 0},
|
|
||||||
wantR: 0,
|
|
||||||
wantG: 0,
|
|
||||||
wantB: 0,
|
|
||||||
wantA: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "RGBA.RGBA: white",
|
|
||||||
fields: fields{R: 1, G: 1, B: 1, A: 1},
|
|
||||||
wantR: 65535,
|
|
||||||
wantG: 65535,
|
|
||||||
wantB: 65535,
|
|
||||||
wantA: 65535,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
c := pixel.RGBA{
|
|
||||||
R: tt.fields.R,
|
|
||||||
G: tt.fields.G,
|
|
||||||
B: tt.fields.B,
|
|
||||||
A: tt.fields.A,
|
|
||||||
}
|
|
||||||
gotR, gotG, gotB, gotA := c.RGBA()
|
|
||||||
if gotR != tt.wantR {
|
|
||||||
t.Errorf("RGBA.RGBA() gotR = %v, want %v", gotR, tt.wantR)
|
|
||||||
}
|
|
||||||
if gotG != tt.wantG {
|
|
||||||
t.Errorf("RGBA.RGBA() gotG = %v, want %v", gotG, tt.wantG)
|
|
||||||
}
|
|
||||||
if gotB != tt.wantB {
|
|
||||||
t.Errorf("RGBA.RGBA() gotB = %v, want %v", gotB, tt.wantB)
|
|
||||||
}
|
|
||||||
if gotA != tt.wantA {
|
|
||||||
t.Errorf("RGBA.RGBA() gotA = %v, want %v", gotA, tt.wantA)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestToRGBA(t *testing.T) {
|
|
||||||
type args struct {
|
|
||||||
c color.Color
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
args args
|
|
||||||
want pixel.RGBA
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "ToRGBA: black",
|
|
||||||
args: args{c: color.Black},
|
|
||||||
want: pixel.RGBA{R: 0, G: 0, B: 0, A: 1},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "ToRGBA: white",
|
|
||||||
args: args{c: color.White},
|
|
||||||
want: pixel.RGBA{R: 1, G: 1, B: 1, A: 1},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
if got := pixel.ToRGBA(tt.args.c); !reflect.DeepEqual(got, tt.want) {
|
|
||||||
t.Errorf("ToRGBA() = %v, want %v", got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
118
drawer_test.go
118
drawer_test.go
|
@ -16,121 +16,3 @@ func BenchmarkSpriteDrawBatch(b *testing.B) {
|
||||||
sprite.Draw(batch, pixel.IM)
|
sprite.Draw(batch, pixel.IM)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDrawer_Dirty(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
d *pixel.Drawer
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "Drawer.Dirty",
|
|
||||||
d: &pixel.Drawer{},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
tt.d.Dirty()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type targetMock struct {
|
|
||||||
makeTrianglesCount int
|
|
||||||
makePictureCount int
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *targetMock) MakePicture(_ pixel.Picture) pixel.TargetPicture {
|
|
||||||
t.makePictureCount++
|
|
||||||
return targetPictureMock{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *targetMock) MakeTriangles(_ pixel.Triangles) pixel.TargetTriangles {
|
|
||||||
t.makeTrianglesCount++
|
|
||||||
return targetTrianglesMock{}
|
|
||||||
}
|
|
||||||
|
|
||||||
type targetTrianglesMock struct{}
|
|
||||||
|
|
||||||
func (targetTrianglesMock) Len() int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (targetTrianglesMock) SetLen(_ int) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (targetTrianglesMock) Slice(_, _ int) pixel.Triangles {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (targetTrianglesMock) Update(_ pixel.Triangles) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (targetTrianglesMock) Copy() pixel.Triangles {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (targetTrianglesMock) Draw() {
|
|
||||||
}
|
|
||||||
|
|
||||||
type targetPictureMock struct{}
|
|
||||||
|
|
||||||
func (targetPictureMock) Bounds() pixel.Rect {
|
|
||||||
return pixel.R(0, 0, 0, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (targetPictureMock) Draw(_ pixel.TargetTriangles) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDrawer_Draw(t *testing.T) {
|
|
||||||
type args struct {
|
|
||||||
t pixel.Target
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
d *pixel.Drawer
|
|
||||||
args args
|
|
||||||
wantPictureCount int
|
|
||||||
wantTriangleCount int
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "Drawer.Draw: nil triangles",
|
|
||||||
d: &pixel.Drawer{},
|
|
||||||
args: args{t: &targetMock{}},
|
|
||||||
wantPictureCount: 0,
|
|
||||||
wantTriangleCount: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Drawer.Draw: non-nil triangles",
|
|
||||||
d: &pixel.Drawer{Triangles: pixel.MakeTrianglesData(1)},
|
|
||||||
args: args{t: &targetMock{}},
|
|
||||||
wantPictureCount: 0,
|
|
||||||
wantTriangleCount: 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Drawer.Draw: non-nil picture",
|
|
||||||
d: &pixel.Drawer{
|
|
||||||
Triangles: pixel.MakeTrianglesData(1),
|
|
||||||
Picture: pixel.MakePictureData(pixel.R(0, 0, 0, 0)),
|
|
||||||
},
|
|
||||||
args: args{t: &targetMock{}},
|
|
||||||
wantPictureCount: 1,
|
|
||||||
wantTriangleCount: 1,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
tt.d.Draw(tt.args.t)
|
|
||||||
|
|
||||||
target := tt.args.t.(*targetMock)
|
|
||||||
|
|
||||||
if tt.wantPictureCount != target.makePictureCount {
|
|
||||||
t.Fatalf("MakePicture not called. Expected %d, got: %d", tt.wantPictureCount, target.makePictureCount)
|
|
||||||
}
|
|
||||||
if tt.wantTriangleCount != target.makeTrianglesCount {
|
|
||||||
t.Fatalf("MakeTriangles not called. Expected %d, got: %d", tt.wantTriangleCount, target.makeTrianglesCount)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
168
matrix_test.go
168
matrix_test.go
|
@ -2,7 +2,6 @@ package pixel_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"reflect"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/faiface/pixel"
|
"github.com/faiface/pixel"
|
||||||
|
@ -62,170 +61,3 @@ func BenchmarkMatrix(b *testing.B) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMatrix_String(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
m pixel.Matrix
|
|
||||||
want string
|
|
||||||
}{
|
|
||||||
// TODO: Add test cases.
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
if got := tt.m.String(); got != tt.want {
|
|
||||||
t.Errorf("Matrix.String() = %v, want %v", got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatrix_Moved(t *testing.T) {
|
|
||||||
type args struct {
|
|
||||||
delta pixel.Vec
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
m pixel.Matrix
|
|
||||||
args args
|
|
||||||
want pixel.Matrix
|
|
||||||
}{
|
|
||||||
// TODO: Add test cases.
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
if got := tt.m.Moved(tt.args.delta); !reflect.DeepEqual(got, tt.want) {
|
|
||||||
t.Errorf("Matrix.Moved() = %v, want %v", got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatrix_ScaledXY(t *testing.T) {
|
|
||||||
type args struct {
|
|
||||||
around pixel.Vec
|
|
||||||
scale pixel.Vec
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
m pixel.Matrix
|
|
||||||
args args
|
|
||||||
want pixel.Matrix
|
|
||||||
}{
|
|
||||||
// TODO: Add test cases.
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
if got := tt.m.ScaledXY(tt.args.around, tt.args.scale); !reflect.DeepEqual(got, tt.want) {
|
|
||||||
t.Errorf("Matrix.ScaledXY() = %v, want %v", got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatrix_Scaled(t *testing.T) {
|
|
||||||
type args struct {
|
|
||||||
around pixel.Vec
|
|
||||||
scale float64
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
m pixel.Matrix
|
|
||||||
args args
|
|
||||||
want pixel.Matrix
|
|
||||||
}{
|
|
||||||
// TODO: Add test cases.
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
if got := tt.m.Scaled(tt.args.around, tt.args.scale); !reflect.DeepEqual(got, tt.want) {
|
|
||||||
t.Errorf("Matrix.Scaled() = %v, want %v", got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatrix_Rotated(t *testing.T) {
|
|
||||||
type args struct {
|
|
||||||
around pixel.Vec
|
|
||||||
angle float64
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
m pixel.Matrix
|
|
||||||
args args
|
|
||||||
want pixel.Matrix
|
|
||||||
}{
|
|
||||||
// TODO: Add test cases.
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
if got := tt.m.Rotated(tt.args.around, tt.args.angle); !reflect.DeepEqual(got, tt.want) {
|
|
||||||
t.Errorf("Matrix.Rotated() = %v, want %v", got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatrix_Chained(t *testing.T) {
|
|
||||||
type args struct {
|
|
||||||
next pixel.Matrix
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
m pixel.Matrix
|
|
||||||
args args
|
|
||||||
want pixel.Matrix
|
|
||||||
}{
|
|
||||||
// TODO: Add test cases.
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
if got := tt.m.Chained(tt.args.next); !reflect.DeepEqual(got, tt.want) {
|
|
||||||
t.Errorf("Matrix.Chained() = %v, want %v", got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatrix_Project(t *testing.T) {
|
|
||||||
type args struct {
|
|
||||||
u pixel.Vec
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
m pixel.Matrix
|
|
||||||
args args
|
|
||||||
want pixel.Vec
|
|
||||||
}{
|
|
||||||
// TODO: Add test cases.
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
if got := tt.m.Project(tt.args.u); !reflect.DeepEqual(got, tt.want) {
|
|
||||||
t.Errorf("Matrix.Project() = %v, want %v", got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatrix_Unproject(t *testing.T) {
|
|
||||||
type args struct {
|
|
||||||
u pixel.Vec
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
m pixel.Matrix
|
|
||||||
args args
|
|
||||||
want pixel.Vec
|
|
||||||
}{
|
|
||||||
// TODO: Add test cases.
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
if got := tt.m.Unproject(tt.args.u); !reflect.DeepEqual(got, tt.want) {
|
|
||||||
t.Errorf("Matrix.Unproject() = %v, want %v", got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue