|
|
|
@ -1,25 +1,23 @@ |
|
|
|
// <copyright file="Matrix.cs" company="Six Labors">
|
|
|
|
// <copyright file="Matrix3x2Extensions.cs" company="Six Labors">
|
|
|
|
// Copyright (c) Six Labors and contributors.
|
|
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
// </copyright>
|
|
|
|
|
|
|
|
namespace SixLabors.Primitives |
|
|
|
{ |
|
|
|
using System; |
|
|
|
using System.Numerics; |
|
|
|
using System.Runtime.CompilerServices; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// A Matrix object for applying matrix transforms to primitives.
|
|
|
|
/// Extension methods for the <see cref="Matrix3x2"/> struct.
|
|
|
|
/// </summary>
|
|
|
|
public static class Matrix3x2Extentions |
|
|
|
public static class Matrix3x2Extensions |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Creates a translation matrix from the given vector.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="position">The translation position.</param>
|
|
|
|
/// <returns>A translation matrix.</returns>
|
|
|
|
public static Matrix3x2 CreateTranslation(PointF position) => System.Numerics.Matrix3x2.CreateTranslation(position); |
|
|
|
public static Matrix3x2 CreateTranslation(PointF position) => Matrix3x2.CreateTranslation(position); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a scale matrix that is offset by a given center point.
|
|
|
|
@ -28,14 +26,14 @@ namespace SixLabors.Primitives |
|
|
|
/// <param name="yScale">Value to scale by on the Y-axis.</param>
|
|
|
|
/// <param name="centerPoint">The center point.</param>
|
|
|
|
/// <returns>A scaling matrix.</returns>
|
|
|
|
public static Matrix3x2 CreateScale(float xScale, float yScale, PointF centerPoint) => System.Numerics.Matrix3x2.CreateScale(xScale, yScale, centerPoint); |
|
|
|
public static Matrix3x2 CreateScale(float xScale, float yScale, PointF centerPoint) => Matrix3x2.CreateScale(xScale, yScale, centerPoint); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a scale matrix from the given vector scale.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="scales">The scale to use.</param>
|
|
|
|
/// <returns>A scaling matrix.</returns>
|
|
|
|
public static Matrix3x2 CreateScale(SizeF scales) => System.Numerics.Matrix3x2.CreateScale(scales); |
|
|
|
public static Matrix3x2 CreateScale(SizeF scales) => Matrix3x2.CreateScale(scales); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a scale matrix from the given vector scale with an offset from the given center point.
|
|
|
|
@ -43,7 +41,7 @@ namespace SixLabors.Primitives |
|
|
|
/// <param name="scales">The scale to use.</param>
|
|
|
|
/// <param name="centerPoint">The center offset.</param>
|
|
|
|
/// <returns>A scaling matrix.</returns>
|
|
|
|
public static Matrix3x2 CreateScale(SizeF scales, PointF centerPoint) => System.Numerics.Matrix3x2.CreateScale(scales, centerPoint); |
|
|
|
public static Matrix3x2 CreateScale(SizeF scales, PointF centerPoint) => Matrix3x2.CreateScale(scales, centerPoint); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a scale matrix that scales uniformly with the given scale with an offset from the given center.
|
|
|
|
@ -51,7 +49,7 @@ namespace SixLabors.Primitives |
|
|
|
/// <param name="scale">The uniform scale to use.</param>
|
|
|
|
/// <param name="centerPoint">The center offset.</param>
|
|
|
|
/// <returns>A scaling matrix.</returns>
|
|
|
|
public static Matrix3x2 CreateScale(float scale, PointF centerPoint) => System.Numerics.Matrix3x2.CreateScale(scale, centerPoint); |
|
|
|
public static Matrix3x2 CreateScale(float scale, PointF centerPoint) => Matrix3x2.CreateScale(scale, centerPoint); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a skew matrix from the given angles in radians.
|
|
|
|
@ -59,7 +57,7 @@ namespace SixLabors.Primitives |
|
|
|
/// <param name="degreesX">The X angle, in degrees.</param>
|
|
|
|
/// <param name="degreesY">The Y angle, in degrees.</param>
|
|
|
|
/// <returns>A skew matrix.</returns>
|
|
|
|
public static Matrix3x2 CreateSkewDegrees(float degreesX, float degreesY) => System.Numerics.Matrix3x2.CreateSkew(MathF.ToRadians(degreesX), MathF.ToRadians(degreesY)); |
|
|
|
public static Matrix3x2 CreateSkewDegrees(float degreesX, float degreesY) => Matrix3x2.CreateSkew(MathF.ToRadians(degreesX), MathF.ToRadians(degreesY)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a skew matrix from the given angles in radians and a center point.
|
|
|
|
@ -68,7 +66,7 @@ namespace SixLabors.Primitives |
|
|
|
/// <param name="radiansY">The Y angle, in radians.</param>
|
|
|
|
/// <param name="centerPoint">The center point.</param>
|
|
|
|
/// <returns>A skew matrix.</returns>
|
|
|
|
public static Matrix3x2 CreateSkew(float radiansX, float radiansY, PointF centerPoint) => System.Numerics.Matrix3x2.CreateSkew(radiansX, radiansY, centerPoint); |
|
|
|
public static Matrix3x2 CreateSkew(float radiansX, float radiansY, PointF centerPoint) => Matrix3x2.CreateSkew(radiansX, radiansY, centerPoint); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a skew matrix from the given angles in radians and a center point.
|
|
|
|
@ -77,14 +75,14 @@ namespace SixLabors.Primitives |
|
|
|
/// <param name="degreesY">The Y angle, in degrees.</param>
|
|
|
|
/// <param name="centerPoint">The center point.</param>
|
|
|
|
/// <returns>A skew matrix.</returns>
|
|
|
|
public static Matrix3x2 CreateSkewDegrees(float degreesX, float degreesY, PointF centerPoint) => System.Numerics.Matrix3x2.CreateSkew(MathF.ToRadians(degreesX), MathF.ToRadians(degreesY), centerPoint); |
|
|
|
public static Matrix3x2 CreateSkewDegrees(float degreesX, float degreesY, PointF centerPoint) => Matrix3x2.CreateSkew(MathF.ToRadians(degreesX), MathF.ToRadians(degreesY), centerPoint); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a rotation matrix using the given rotation in radians.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="degrees">The amount of rotation, in degrees.</param>
|
|
|
|
/// <returns>A rotation matrix.</returns>
|
|
|
|
public static Matrix3x2 CreateRotationDegrees(float degrees) => System.Numerics.Matrix3x2.CreateRotation(MathF.ToRadians(degrees)); |
|
|
|
public static Matrix3x2 CreateRotationDegrees(float degrees) => Matrix3x2.CreateRotation(MathF.ToRadians(degrees)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a rotation matrix using the given rotation in radians and a center point.
|
|
|
|
@ -92,7 +90,7 @@ namespace SixLabors.Primitives |
|
|
|
/// <param name="radians">The amount of rotation, in radians.</param>
|
|
|
|
/// <param name="centerPoint">The center point.</param>
|
|
|
|
/// <returns>A rotation matrix.</returns>
|
|
|
|
public static Matrix3x2 CreateRotation(float radians, PointF centerPoint) => System.Numerics.Matrix3x2.CreateRotation(radians, centerPoint); |
|
|
|
public static Matrix3x2 CreateRotation(float radians, PointF centerPoint) => Matrix3x2.CreateRotation(radians, centerPoint); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a rotation matrix using the given rotation in radians and a center point.
|
|
|
|
@ -100,6 +98,6 @@ namespace SixLabors.Primitives |
|
|
|
/// <param name="degrees">The amount of rotation, in degrees.</param>
|
|
|
|
/// <param name="centerPoint">The center point.</param>
|
|
|
|
/// <returns>A rotation matrix.</returns>
|
|
|
|
public static Matrix3x2 CreateRotationDegrees(float degrees, PointF centerPoint) => System.Numerics.Matrix3x2.CreateRotation(MathF.ToRadians(degrees), centerPoint); |
|
|
|
public static Matrix3x2 CreateRotationDegrees(float degrees, PointF centerPoint) => Matrix3x2.CreateRotation(MathF.ToRadians(degrees), centerPoint); |
|
|
|
} |
|
|
|
} |