mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/graphicscommand: better strings for ColorM
This commit is contained in:
parent
c8f0bf52e4
commit
a9c9e18ff4
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user