@@ -12,7 +12,6 @@ namespace SixLabors.ImageSharp.Processing;
12
12
public class AffineTransformBuilder
13
13
{
14
14
private readonly List < Func < Size , Matrix3x2 > > transformMatrixFactories = new ( ) ;
15
- private readonly List < Func < Size , Matrix3x2 > > boundsMatrixFactories = new ( ) ;
16
15
17
16
/// <summary>
18
17
/// Prepends a rotation matrix using the given rotation angle in degrees
@@ -31,8 +30,7 @@ public AffineTransformBuilder PrependRotationDegrees(float degrees)
31
30
/// <returns>The <see cref="AffineTransformBuilder"/>.</returns>
32
31
public AffineTransformBuilder PrependRotationRadians ( float radians )
33
32
=> this . Prepend (
34
- size => TransformUtils . CreateRotationTransformMatrixRadians ( radians , size ) ,
35
- size => TransformUtils . CreateRotationBoundsMatrixRadians ( radians , size ) ) ;
33
+ size => TransformUtils . CreateRotationTransformMatrixRadians ( radians , size ) ) ;
36
34
37
35
/// <summary>
38
36
/// Prepends a rotation matrix using the given rotation in degrees at the given origin.
@@ -68,9 +66,7 @@ public AffineTransformBuilder AppendRotationDegrees(float degrees)
68
66
/// <param name="radians">The amount of rotation, in radians.</param>
69
67
/// <returns>The <see cref="AffineTransformBuilder"/>.</returns>
70
68
public AffineTransformBuilder AppendRotationRadians ( float radians )
71
- => this . Append (
72
- size => TransformUtils . CreateRotationTransformMatrixRadians ( radians , size ) ,
73
- size => TransformUtils . CreateRotationBoundsMatrixRadians ( radians , size ) ) ;
69
+ => this . Append ( size => TransformUtils . CreateRotationTransformMatrixRadians ( radians , size ) ) ;
74
70
75
71
/// <summary>
76
72
/// Appends a rotation matrix using the given rotation in degrees at the given origin.
@@ -145,9 +141,7 @@ public AffineTransformBuilder AppendScale(Vector2 scales)
145
141
/// <param name="degreesY">The Y angle, in degrees.</param>
146
142
/// <returns>The <see cref="AffineTransformBuilder"/>.</returns>
147
143
public AffineTransformBuilder PrependSkewDegrees ( float degreesX , float degreesY )
148
- => this . Prepend (
149
- size => TransformUtils . CreateSkewTransformMatrixDegrees ( degreesX , degreesY , size ) ,
150
- size => TransformUtils . CreateSkewBoundsMatrixDegrees ( degreesX , degreesY , size ) ) ;
144
+ => this . Prepend ( size => TransformUtils . CreateSkewTransformMatrixDegrees ( degreesX , degreesY , size ) ) ;
151
145
152
146
/// <summary>
153
147
/// Prepends a centered skew matrix from the give angles in radians.
@@ -156,9 +150,7 @@ public AffineTransformBuilder PrependSkewDegrees(float degreesX, float degreesY)
156
150
/// <param name="radiansY">The Y angle, in radians.</param>
157
151
/// <returns>The <see cref="AffineTransformBuilder"/>.</returns>
158
152
public AffineTransformBuilder PrependSkewRadians ( float radiansX , float radiansY )
159
- => this . Prepend (
160
- size => TransformUtils . CreateSkewTransformMatrixRadians ( radiansX , radiansY , size ) ,
161
- size => TransformUtils . CreateSkewBoundsMatrixRadians ( radiansX , radiansY , size ) ) ;
153
+ => this . Prepend ( size => TransformUtils . CreateSkewTransformMatrixRadians ( radiansX , radiansY , size ) ) ;
162
154
163
155
/// <summary>
164
156
/// Prepends a skew matrix using the given angles in degrees at the given origin.
@@ -187,9 +179,7 @@ public AffineTransformBuilder PrependSkewRadians(float radiansX, float radiansY,
187
179
/// <param name="degreesY">The Y angle, in degrees.</param>
188
180
/// <returns>The <see cref="AffineTransformBuilder"/>.</returns>
189
181
public AffineTransformBuilder AppendSkewDegrees ( float degreesX , float degreesY )
190
- => this . Append (
191
- size => TransformUtils . CreateSkewTransformMatrixDegrees ( degreesX , degreesY , size ) ,
192
- size => TransformUtils . CreateSkewBoundsMatrixDegrees ( degreesX , degreesY , size ) ) ;
182
+ => this . Append ( size => TransformUtils . CreateSkewTransformMatrixDegrees ( degreesX , degreesY , size ) ) ;
193
183
194
184
/// <summary>
195
185
/// Appends a centered skew matrix from the give angles in radians.
@@ -198,9 +188,7 @@ public AffineTransformBuilder AppendSkewDegrees(float degreesX, float degreesY)
198
188
/// <param name="radiansY">The Y angle, in radians.</param>
199
189
/// <returns>The <see cref="AffineTransformBuilder"/>.</returns>
200
190
public AffineTransformBuilder AppendSkewRadians ( float radiansX , float radiansY )
201
- => this . Append (
202
- size => TransformUtils . CreateSkewTransformMatrixRadians ( radiansX , radiansY , size ) ,
203
- size => TransformUtils . CreateSkewBoundsMatrixRadians ( radiansX , radiansY , size ) ) ;
191
+ => this . Append ( size => TransformUtils . CreateSkewTransformMatrixRadians ( radiansX , radiansY , size ) ) ;
204
192
205
193
/// <summary>
206
194
/// Appends a skew matrix using the given angles in degrees at the given origin.
@@ -267,7 +255,7 @@ public AffineTransformBuilder AppendTranslation(Vector2 position)
267
255
public AffineTransformBuilder PrependMatrix ( Matrix3x2 matrix )
268
256
{
269
257
CheckDegenerate ( matrix ) ;
270
- return this . Prepend ( _ => matrix , _ => matrix ) ;
258
+ return this . Prepend ( _ => matrix ) ;
271
259
}
272
260
273
261
/// <summary>
@@ -283,7 +271,7 @@ public AffineTransformBuilder PrependMatrix(Matrix3x2 matrix)
283
271
public AffineTransformBuilder AppendMatrix ( Matrix3x2 matrix )
284
272
{
285
273
CheckDegenerate ( matrix ) ;
286
- return this . Append ( _ => matrix , _ => matrix ) ;
274
+ return this . Append ( _ => matrix ) ;
287
275
}
288
276
289
277
/// <summary>
@@ -340,13 +328,13 @@ public Size GetTransformedSize(Rectangle sourceRectangle)
340
328
// Translate the origin matrix to cater for source rectangle offsets.
341
329
Matrix3x2 matrix = Matrix3x2 . CreateTranslation ( - sourceRectangle . Location ) ;
342
330
343
- foreach ( Func < Size , Matrix3x2 > factory in this . boundsMatrixFactories )
331
+ foreach ( Func < Size , Matrix3x2 > factory in this . transformMatrixFactories )
344
332
{
345
333
matrix *= factory ( size ) ;
346
334
CheckDegenerate ( matrix ) ;
347
335
}
348
336
349
- return TransformUtils . GetTransformedSize ( size , matrix ) ;
337
+ return TransformUtils . GetTransformedSize ( matrix , size ) ;
350
338
}
351
339
352
340
private static void CheckDegenerate ( Matrix3x2 matrix )
@@ -357,17 +345,15 @@ private static void CheckDegenerate(Matrix3x2 matrix)
357
345
}
358
346
}
359
347
360
- private AffineTransformBuilder Prepend ( Func < Size , Matrix3x2 > transformFactory , Func < Size , Matrix3x2 > boundsFactory )
348
+ private AffineTransformBuilder Prepend ( Func < Size , Matrix3x2 > transformFactory )
361
349
{
362
350
this . transformMatrixFactories . Insert ( 0 , transformFactory ) ;
363
- this . boundsMatrixFactories . Insert ( 0 , boundsFactory ) ;
364
351
return this ;
365
352
}
366
353
367
- private AffineTransformBuilder Append ( Func < Size , Matrix3x2 > transformFactory , Func < Size , Matrix3x2 > boundsFactory )
354
+ private AffineTransformBuilder Append ( Func < Size , Matrix3x2 > transformFactory )
368
355
{
369
356
this . transformMatrixFactories . Add ( transformFactory ) ;
370
- this . boundsMatrixFactories . Add ( boundsFactory ) ;
371
357
return this ;
372
358
}
373
359
}
0 commit comments