diff --git a/colorm.go b/colorm.go index f6effe0c6..d4bcbfcc4 100644 --- a/colorm.go +++ b/colorm.go @@ -46,7 +46,7 @@ func (c *ColorM) affineColorM() affine.ColorM { // String returns a string representation of ColorM. func (c *ColorM) String() string { - return affine.ColorMString(c.affineColorM()) + return c.affineColorM().String() } // Reset resets the ColorM as identity. diff --git a/internal/affine/colorm.go b/internal/affine/colorm.go index 01f888477..0851dd1ff 100644 --- a/internal/affine/colorm.go +++ b/internal/affine/colorm.go @@ -42,6 +42,8 @@ var ( // Before applying a matrix, a color is un-multiplied, and after applying the matrix, // the color is multiplied again. type ColorM interface { + String() string + IsIdentity() bool ScaleOnly() bool At(i, j int) float32 @@ -71,7 +73,7 @@ type ColorM interface { scaleElements() (r, g, b, a float32) } -func ColorMString(c ColorM) string { +func colorMString(c ColorM) string { var b [16]float32 var t [4]float32 c.Elements(&b, &t) @@ -93,6 +95,18 @@ type colorMImplBodyTranslate struct { translate [4]float32 } +func (c ColorMIdentity) String() string { + return "Identity[]" +} + +func (c colorMImplScale) String() string { + return fmt.Sprintf("Scale[%f, %f, %f, %f]", c.scale[0], c.scale[1], c.scale[2], c.scale[3]) +} + +func (c *colorMImplBodyTranslate) String() string { + return colorMString(c) +} + func clamp(x float32) float32 { if x > 1 { return 1 diff --git a/internal/graphicscommand/command.go b/internal/graphicscommand/command.go index f55afac1f..6d422bfa0 100644 --- a/internal/graphicscommand/command.go +++ b/internal/graphicscommand/command.go @@ -381,7 +381,7 @@ func (c *drawTrianglesCommand) String() string { r := fmt.Sprintf("(x:%d, y:%d, width:%d, height:%d)", int(c.dstRegion.X), int(c.dstRegion.Y), int(c.dstRegion.Width), int(c.dstRegion.Height)) - return fmt.Sprintf("draw-triangles: dst: %s <- src: [%s], dst region: %s, num of indices: %d, colorm: %v, mode: %s, filter: %s, address: %s, even-odd: %t", dst, strings.Join(srcstrs[:], ", "), r, c.nindices, c.color, mode, filter, address, c.evenOdd) + return fmt.Sprintf("draw-triangles: dst: %s <- src: [%s], dst region: %s, num of indices: %d, colorm: %s, mode: %s, filter: %s, address: %s, even-odd: %t", dst, strings.Join(srcstrs[:], ", "), r, c.nindices, c.color, mode, filter, address, c.evenOdd) } // Exec executes the drawTrianglesCommand.