Browse Source

Use existing method. (There's precedence)

pull/775/head
James Jackson-South 8 years ago
parent
commit
5d034d5fc0
  1. 14
      src/ImageSharp/Common/Helpers/ImageMaths.cs
  2. 4
      src/ImageSharp/Processing/AffineTransformBuilder.cs
  3. 5
      src/ImageSharp/Processing/ProjectiveTransformBuilder.cs

14
src/ImageSharp/Common/Helpers/ImageMaths.cs

@ -125,19 +125,7 @@ namespace SixLabors.ImageSharp
/// <paramref name="m"/> should be power of 2.
/// </summary>
[MethodImpl(InliningOptions.ShortMethod)]
public static int ModuloP2(int x, int m)
{
return x & (m - 1);
}
/// <summary>
/// Converts degrees to radians
/// </summary>
[MethodImpl(InliningOptions.ShortMethod)]
public static float DegreesToRadians(float degrees)
{
return degrees * ((float)Math.PI / 180f);
}
public static int ModuloP2(int x, int m) => x & (m - 1);
/// <summary>
/// Returns the absolute value of a 32-bit signed integer. Uses bit shifting to speed up the operation.

4
src/ImageSharp/Processing/AffineTransformBuilder.cs

@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="degrees">The amount of rotation, in degrees.</param>
/// <returns>The <see cref="AffineTransformBuilder"/>.</returns>
public AffineTransformBuilder PrependRotationDegrees(float degrees)
=> this.PrependRotationRadians(ImageMaths.DegreesToRadians(degrees));
=> this.PrependRotationRadians(MathFExtensions.DegreeToRadian(degrees));
/// <summary>
/// Appends a rotation matrix using the given rotation angle in degrees
@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="degrees">The amount of rotation, in degrees.</param>
/// <returns>The <see cref="AffineTransformBuilder"/>.</returns>
public AffineTransformBuilder AppendRotationDegrees(float degrees)
=> this.AppendRotationRadians(ImageMaths.DegreesToRadians(degrees));
=> this.AppendRotationRadians(MathFExtensions.DegreeToRadian(degrees));
/// <summary>
/// Prepends a scale matrix from the given uniform scale.

5
src/ImageSharp/Processing/ProjectiveTransformBuilder.cs

@ -1,7 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using System.Collections.Generic;
using System.Numerics;
using SixLabors.ImageSharp.Processing.Processors.Transforms;
@ -115,7 +114,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="degrees">The amount of rotation, in degrees.</param>
/// <returns>The <see cref="AffineTransformBuilder"/>.</returns>
public ProjectiveTransformBuilder PrependCenteredRotationDegrees(float degrees)
=> this.PrependRotationRadians(ImageMaths.DegreesToRadians(degrees));
=> this.PrependRotationRadians(MathFExtensions.DegreeToRadian(degrees));
/// <summary>
/// Appends a centered rotation matrix using the given rotation in degrees.
@ -123,7 +122,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="degrees">The amount of rotation, in degrees.</param>
/// <returns>The <see cref="AffineTransformBuilder"/>.</returns>
public ProjectiveTransformBuilder AppendRotationDegrees(float degrees)
=> this.AppendRotationRadians(ImageMaths.DegreesToRadians(degrees));
=> this.AppendRotationRadians(MathFExtensions.DegreeToRadian(degrees));
/// <summary>
/// Prepends a scale matrix from the given uniform scale.

Loading…
Cancel
Save