mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
ebiten: clean up tests
This commit is contained in:
parent
d3b3617f66
commit
15ae074c43
@ -3591,18 +3591,13 @@ func TestImageBlendOperation(t *testing.T) {
|
|||||||
}
|
}
|
||||||
src.WritePixels(srcPix)
|
src.WritePixels(srcPix)
|
||||||
|
|
||||||
colorOperations := []ebiten.BlendOperation{
|
operations := []ebiten.BlendOperation{
|
||||||
ebiten.BlendOperationAdd,
|
ebiten.BlendOperationAdd,
|
||||||
ebiten.BlendOperationSubtract,
|
ebiten.BlendOperationSubtract,
|
||||||
ebiten.BlendOperationReverseSubtract,
|
ebiten.BlendOperationReverseSubtract,
|
||||||
}
|
}
|
||||||
alphaOperations := []ebiten.BlendOperation{
|
for _, rgbOp := range operations {
|
||||||
ebiten.BlendOperationAdd,
|
for _, alphaOp := range operations {
|
||||||
ebiten.BlendOperationSubtract,
|
|
||||||
ebiten.BlendOperationReverseSubtract,
|
|
||||||
}
|
|
||||||
for _, cop := range colorOperations {
|
|
||||||
for _, aop := range alphaOperations {
|
|
||||||
// Reset the destination state.
|
// Reset the destination state.
|
||||||
dst.WritePixels(dstPix)
|
dst.WritePixels(dstPix)
|
||||||
op := &ebiten.DrawImageOptions{}
|
op := &ebiten.DrawImageOptions{}
|
||||||
@ -3611,8 +3606,8 @@ func TestImageBlendOperation(t *testing.T) {
|
|||||||
BlendFactorSourceAlpha: ebiten.BlendFactorOne,
|
BlendFactorSourceAlpha: ebiten.BlendFactorOne,
|
||||||
BlendFactorDestinationRGB: ebiten.BlendFactorOne,
|
BlendFactorDestinationRGB: ebiten.BlendFactorOne,
|
||||||
BlendFactorDestinationAlpha: ebiten.BlendFactorOne,
|
BlendFactorDestinationAlpha: ebiten.BlendFactorOne,
|
||||||
BlendOperationRGB: cop,
|
BlendOperationRGB: rgbOp,
|
||||||
BlendOperationAlpha: aop,
|
BlendOperationAlpha: alphaOp,
|
||||||
}
|
}
|
||||||
dst.DrawImage(src, op)
|
dst.DrawImage(src, op)
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
@ -3622,7 +3617,7 @@ func TestImageBlendOperation(t *testing.T) {
|
|||||||
dr, dg, db, da := dstColor(i)
|
dr, dg, db, da := dstColor(i)
|
||||||
|
|
||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
switch cop {
|
switch rgbOp {
|
||||||
case ebiten.BlendOperationAdd:
|
case ebiten.BlendOperationAdd:
|
||||||
want.R = clamp(int(sr) + int(dr))
|
want.R = clamp(int(sr) + int(dr))
|
||||||
want.G = clamp(int(sg) + int(dg))
|
want.G = clamp(int(sg) + int(dg))
|
||||||
@ -3636,7 +3631,7 @@ func TestImageBlendOperation(t *testing.T) {
|
|||||||
want.G = clamp(int(dg) - int(sg))
|
want.G = clamp(int(dg) - int(sg))
|
||||||
want.B = clamp(int(db) - int(sb))
|
want.B = clamp(int(db) - int(sb))
|
||||||
}
|
}
|
||||||
switch aop {
|
switch alphaOp {
|
||||||
case ebiten.BlendOperationAdd:
|
case ebiten.BlendOperationAdd:
|
||||||
want.A = clamp(int(sa) + int(da))
|
want.A = clamp(int(sa) + int(da))
|
||||||
case ebiten.BlendOperationSubtract:
|
case ebiten.BlendOperationSubtract:
|
||||||
@ -3646,7 +3641,7 @@ func TestImageBlendOperation(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !sameColors(got, want, 1) {
|
if !sameColors(got, want, 1) {
|
||||||
t.Errorf("dst.At(%d, 0): operations: %d, %d: got: %v, want: %v", i, cop, aop, got, want)
|
t.Errorf("dst.At(%d, 0): operations: %d, %d: got: %v, want: %v", i, rgbOp, alphaOp, got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user