Skip to content

Commit aed8b53

Browse files
authored
Merge pull request #16 from synercoder/develop
Size.Rotate property & Value.AsRaw extension
2 parents fa29a3c + b9e7ba3 commit aed8b53

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace Synercoding.Primitives.Extensions
2+
{
3+
/// <summary>
4+
/// Extension methods for <see cref="Value"/>
5+
/// </summary>
6+
public static class ValueExtensions
7+
{
8+
/// <summary>
9+
/// Get a double representing a value in a given unit
10+
/// </summary>
11+
/// <param name="value">The value to get the raw number for</param>
12+
/// <param name="unit">The unit of the returned raw value</param>
13+
/// <returns>A double representing the value</returns>
14+
/// <remarks>
15+
/// Shorthand for <c>value.ConvertTo(unit).Raw</c>
16+
/// </remarks>
17+
public static double AsRaw(this Value value, Unit unit)
18+
=> value.ConvertTo(unit).Raw;
19+
}
20+
}

src/Synercoding.Primitives/PackageDetails.props

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
<Product>Synercoding.Primitives</Product>
1111
<Title>Synercoding.Primitives</Title>
1212
<Description>Primitives with types attached (think mm, cm, in, px) that can be used for 2D graphics.</Description>
13-
<PackageReleaseNotes>- Added Value.Zero</PackageReleaseNotes>
13+
<PackageReleaseNotes>
14+
- Added extension method for Value .AsRaw(Unit)
15+
- Added Rotated property to size
16+
</PackageReleaseNotes>
1417
</PropertyGroup>
1518

1619
</Project>

src/Synercoding.Primitives/Size.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ public static Size Empty
5858
/// </summary>
5959
public Value Height { get; }
6060

61+
/// <summary>
62+
/// The rotated version of this <see cref="Size"/>; Same as calling var newSize = new Size(oldSize.Height, oldSize.Width);
63+
/// </summary>
64+
public Size Rotated
65+
=> new Size(Height, Width);
66+
6167
/// <summary>
6268
/// Get the <see cref="Primitives.Orientation"/> of the size
6369
/// </summary>

0 commit comments

Comments
 (0)