Skip to content

Commit

Permalink
Improve Toitdocs for Transform (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Corry authored Dec 8, 2023
1 parent be8500c commit 90197d9
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/common.toit
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ class Transform:
y2_ = y2
ty_ = ty

/**
Applies the other transform to this transform.
Returns a transform that does both transformations in one transform.
*/
apply other/Transform -> Transform:
a0 := x1_
a1 := y1_
Expand All @@ -310,6 +314,11 @@ class Transform:
--tx = a0 * o4 + a2 * o5 + tx_
--ty = a1 * o4 + a3 * o5 + ty_

/**
Inverts this transform, returning a new transform that represents the
inverse transformation.
Since we don't support scaling, there always exists an inverse transform.
*/
invert -> Transform:
a0 := x1_
a1 := y1_
Expand All @@ -325,6 +334,9 @@ class Transform:
--tx = -a3 * tx_ + a2 * ty_
--ty = a1 * tx_ - a0 * ty_

/**
Returns true if the transforms represent the same transformation.
*/
operator == other/Transform -> bool:
if x1_ != other.x1_: return false
if y1_ != other.y1_: return false
Expand Down Expand Up @@ -376,7 +388,7 @@ class Transform:

/**
Returns a new transform which represents this transform rotated left
around the origin in the space of this transform
around the origin in the space of this transform.
*/
rotate_left -> Transform:
return Transform.with_
Expand All @@ -389,7 +401,7 @@ class Transform:

/**
Returns a new transform which represents this transform rotated right
around the origin in the space of this transform
around the origin in the space of this transform.
*/
rotate_right -> Transform:
return Transform.with_
Expand Down

0 comments on commit 90197d9

Please sign in to comment.