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