forked from joejulian/gio
f32: replace Affine2D{} with AffineId() for identity transformations
Reduces ambiguity by introducing AffineId() for representing identity transformation matrices. References: https://todo.sr.ht/~eliasnaur/gio/655 Signed-off-by: Walter Werner SCHNEIDER <contact@schnwalter.eu>
This commit is contained in:
committed by
Elias Naur
parent
3e601e73c4
commit
d76b4272aa
@@ -30,6 +30,15 @@ func NewAffine2D(sx, hx, ox, hy, sy, oy float32) Affine2D {
|
||||
}
|
||||
}
|
||||
|
||||
// AffineId returns an identity transformation matrix that represents no transformation
|
||||
// when applied.
|
||||
func AffineId() Affine2D {
|
||||
return NewAffine2D(
|
||||
1, 0, 0,
|
||||
0, 1, 0,
|
||||
)
|
||||
}
|
||||
|
||||
// Offset the transformation.
|
||||
func (a Affine2D) Offset(offset Point) Affine2D {
|
||||
return Affine2D{
|
||||
|
||||
@@ -51,6 +51,9 @@ func TestString(t *testing.T) {
|
||||
}, {
|
||||
in: NewAffine2D(29.142342, 31.4123412, 37.53152, 43.51324213, 47.123412, 53.14312342),
|
||||
exp: "[[29.1423 31.4123 37.5315] [43.5132 47.1234 53.1431]]",
|
||||
}, {
|
||||
in: AffineId(),
|
||||
exp: "[[1 0 0] [0 1 0]]",
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
|
||||
Reference in New Issue
Block a user