mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/affine: Add String
This commit is contained in:
parent
18757cff16
commit
e84506dfc3
@ -15,8 +15,6 @@
|
||||
package ebiten
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"image/color"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/affine"
|
||||
@ -41,12 +39,7 @@ type ColorM struct {
|
||||
|
||||
// String returns a string representation of ColorM.
|
||||
func (c *ColorM) String() string {
|
||||
b, t := c.impl.UnsafeElements()
|
||||
return fmt.Sprintf("[[%f, %f, %f, %f, %f], [%f, %f, %f, %f, %f], [%f, %f, %f, %f, %f], [%f, %f, %f, %f, %f]]",
|
||||
b[0], b[4], b[8], b[12], t[0],
|
||||
b[1], b[5], b[9], b[13], t[1],
|
||||
b[2], b[6], b[10], b[14], t[2],
|
||||
b[3], b[7], b[11], b[15], t[3])
|
||||
return c.impl.String()
|
||||
}
|
||||
|
||||
// Reset resets the ColorM as identity.
|
||||
|
@ -15,6 +15,7 @@
|
||||
package affine
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image/color"
|
||||
"math"
|
||||
"sync"
|
||||
@ -50,6 +51,15 @@ type ColorM struct {
|
||||
translate []float32
|
||||
}
|
||||
|
||||
func (c *ColorM) String() string {
|
||||
b, t := c.UnsafeElements()
|
||||
return fmt.Sprintf("[[%f, %f, %f, %f, %f], [%f, %f, %f, %f, %f], [%f, %f, %f, %f, %f], [%f, %f, %f, %f, %f]]",
|
||||
b[0], b[4], b[8], b[12], t[0],
|
||||
b[1], b[5], b[9], b[13], t[1],
|
||||
b[2], b[6], b[10], b[14], t[2],
|
||||
b[3], b[7], b[11], b[15], t[3])
|
||||
}
|
||||
|
||||
func clamp(x float32) float32 {
|
||||
if x > 1 {
|
||||
return 1
|
||||
|
Loading…
Reference in New Issue
Block a user