mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-10 02:45:41 +00:00
Add Color.Deconstruct
This commit is contained in:
parent
c0395feba3
commit
3a5b017a72
@ -4,6 +4,7 @@
|
|||||||
### Added
|
### Added
|
||||||
- X10D: Added `MathUtility.InverseLerp(float, float, float)` and `MathUtility.InverseLerp(double, double, double)`
|
- X10D: Added `MathUtility.InverseLerp(float, float, float)` and `MathUtility.InverseLerp(double, double, double)`
|
||||||
- X10D: Added `Circle`, `CircleF`, `Cuboid`, `Ellipse`, `EllipseF`, `Line3D`, `Line`, `LineF`, `Polygon`, `PolygonF`, `Polyhedron`, and `Sphere`, to complement System.Drawing structs such as `Point` and `Rectangle`
|
- X10D: Added `Circle`, `CircleF`, `Cuboid`, `Ellipse`, `EllipseF`, `Line3D`, `Line`, `LineF`, `Polygon`, `PolygonF`, `Polyhedron`, and `Sphere`, to complement System.Drawing structs such as `Point` and `Rectangle`
|
||||||
|
- X10D: Added `Color.Deconstruct()` - with optional alpha parameter
|
||||||
- X10D: Added `Color.GetClosestConsoleColor()`
|
- X10D: Added `Color.GetClosestConsoleColor()`
|
||||||
- X10D: Added `DateTime.GetIso8601WeekOfYear()` and `DateTimeOffset.GetIso8601WeekOfYear()`
|
- X10D: Added `DateTime.GetIso8601WeekOfYear()` and `DateTimeOffset.GetIso8601WeekOfYear()`
|
||||||
- X10D: Added `DirectoryInfo.Clear([bool])`
|
- X10D: Added `DirectoryInfo.Clear([bool])`
|
||||||
@ -34,8 +35,10 @@
|
|||||||
- X10D.Unity: Added `DebugEx`, which mimics `UnityEngine.Debug` while offering more useful primitive drawing methods
|
- X10D.Unity: Added `DebugEx`, which mimics `UnityEngine.Debug` while offering more useful primitive drawing methods
|
||||||
- X10D.Unity: Added `System.Drawing.Color.ToUnityColor()`
|
- X10D.Unity: Added `System.Drawing.Color.ToUnityColor()`
|
||||||
- X10D.Unity: Added `System.Drawing.Color.ToUnityColor32()`
|
- X10D.Unity: Added `System.Drawing.Color.ToUnityColor32()`
|
||||||
|
- X10D.Unity: Added `Color.Deconstruct()` - with optional alpha parameter
|
||||||
- X10D.Unity: Added `Color.GetClosestConsoleColor()`
|
- X10D.Unity: Added `Color.GetClosestConsoleColor()`
|
||||||
- X10D.Unity: Added `Color.ToSystemDrawingColor()`
|
- X10D.Unity: Added `Color.ToSystemDrawingColor()`
|
||||||
|
- X10D.Unity: Added `Color32.Deconstruct()` - with optional alpha parameter
|
||||||
- X10D.Unity: Added `Color32.GetClosestConsoleColor()`
|
- X10D.Unity: Added `Color32.GetClosestConsoleColor()`
|
||||||
- X10D.Unity: Added `Color32.ToSystemDrawingColor()`
|
- X10D.Unity: Added `Color32.ToSystemDrawingColor()`
|
||||||
- X10D.Unity: Added `Point.ToUnityVector2()`
|
- X10D.Unity: Added `Point.ToUnityVector2()`
|
||||||
|
@ -10,6 +10,60 @@ namespace X10D.Unity.Drawing;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class Color32Extensions
|
public static class Color32Extensions
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Deconstructs the current color into its RGB components.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="color">The source color.</param>
|
||||||
|
/// <param name="a">
|
||||||
|
/// When this method returns, contains the <see cref="Color32.a" /> component of <paramref name="color" />.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="r">
|
||||||
|
/// When this method returns, contains the <see cref="Color32.r" /> component of <paramref name="color" />.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="g">
|
||||||
|
/// When this method returns, contains the <see cref="Color32.g" /> component of <paramref name="color" />.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="b">
|
||||||
|
/// When this method returns, contains the <see cref="Color32.b" /> component of <paramref name="color" />.
|
||||||
|
/// </param>
|
||||||
|
[Pure]
|
||||||
|
#if NETSTANDARD2_1
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
#else
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
|
#endif
|
||||||
|
public static void Deconstruct(this Color32 color, out byte a, out byte r, out byte g, out byte b)
|
||||||
|
{
|
||||||
|
a = color.a;
|
||||||
|
(r, g, b) = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deconstructs the current color into its RGB components.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="color">The source color.</param>
|
||||||
|
/// <param name="r">
|
||||||
|
/// When this method returns, contains the <see cref="Color32.r" /> component of <paramref name="color" />.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="g">
|
||||||
|
/// When this method returns, contains the <see cref="Color32.g" /> component of <paramref name="color" />.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="b">
|
||||||
|
/// When this method returns, contains the <see cref="Color32.b" /> component of <paramref name="color" />.
|
||||||
|
/// </param>
|
||||||
|
[Pure]
|
||||||
|
#if NETSTANDARD2_1
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
#else
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
|
#endif
|
||||||
|
public static void Deconstruct(this Color32 color, out byte r, out byte g, out byte b)
|
||||||
|
{
|
||||||
|
r = color.r;
|
||||||
|
g = color.g;
|
||||||
|
b = color.b;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a <see cref="ConsoleColor" /> which most closely resembles the current color.
|
/// Returns a <see cref="ConsoleColor" /> which most closely resembles the current color.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -10,6 +10,60 @@ namespace X10D.Unity.Drawing;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class ColorExtensions
|
public static class ColorExtensions
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Deconstructs the current color into its ARGB components.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="color">The source color.</param>
|
||||||
|
/// <param name="a">
|
||||||
|
/// When this method returns, contains the <see cref="Color.a" /> component of <paramref name="color" />.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="r">
|
||||||
|
/// When this method returns, contains the <see cref="Color.r" /> component of <paramref name="color" />.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="g">
|
||||||
|
/// When this method returns, contains the <see cref="Color.g" /> component of <paramref name="color" />.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="b">
|
||||||
|
/// When this method returns, contains the <see cref="Color.b" /> component of <paramref name="color" />.
|
||||||
|
/// </param>
|
||||||
|
[Pure]
|
||||||
|
#if NETSTANDARD2_1
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
#else
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
|
#endif
|
||||||
|
public static void Deconstruct(this Color color, out float a, out float r, out float g, out float b)
|
||||||
|
{
|
||||||
|
a = color.a;
|
||||||
|
(r, g, b) = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deconstructs the current color into its RGB components.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="color">The source color.</param>
|
||||||
|
/// <param name="r">
|
||||||
|
/// When this method returns, contains the <see cref="Color.r" /> component of <paramref name="color" />.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="g">
|
||||||
|
/// When this method returns, contains the <see cref="Color.g" /> component of <paramref name="color" />.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="b">
|
||||||
|
/// When this method returns, contains the <see cref="Color.b" /> component of <paramref name="color" />.
|
||||||
|
/// </param>
|
||||||
|
[Pure]
|
||||||
|
#if NETSTANDARD2_1
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
#else
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
|
#endif
|
||||||
|
public static void Deconstruct(this Color color, out float r, out float g, out float b)
|
||||||
|
{
|
||||||
|
r = color.r;
|
||||||
|
g = color.g;
|
||||||
|
b = color.b;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a <see cref="ConsoleColor" /> which most closely resembles the current color.
|
/// Returns a <see cref="ConsoleColor" /> which most closely resembles the current color.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -9,6 +9,60 @@ namespace X10D.Drawing;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class ColorExtensions
|
public static class ColorExtensions
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Deconstructs the current color into its ARGB components.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="color">The source color.</param>
|
||||||
|
/// <param name="a">
|
||||||
|
/// When this method returns, contains the <see cref="Color.A" /> component of <paramref name="color" />.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="r">
|
||||||
|
/// When this method returns, contains the <see cref="Color.R" /> component of <paramref name="color" />.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="g">
|
||||||
|
/// When this method returns, contains the <see cref="Color.G" /> component of <paramref name="color" />.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="b">
|
||||||
|
/// When this method returns, contains the <see cref="Color.B" /> component of <paramref name="color" />.
|
||||||
|
/// </param>
|
||||||
|
[Pure]
|
||||||
|
#if NETSTANDARD2_1
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
#else
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
|
#endif
|
||||||
|
public static void Deconstruct(this Color color, out byte a, out byte r, out byte g, out byte b)
|
||||||
|
{
|
||||||
|
a = color.A;
|
||||||
|
(r, g, b) = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deconstructs the current color into its RGB components.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="color">The source color.</param>
|
||||||
|
/// <param name="r">
|
||||||
|
/// When this method returns, contains the <see cref="Color.R" /> component of <paramref name="color" />.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="g">
|
||||||
|
/// When this method returns, contains the <see cref="Color.G" /> component of <paramref name="color" />.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="b">
|
||||||
|
/// When this method returns, contains the <see cref="Color.B" /> component of <paramref name="color" />.
|
||||||
|
/// </param>
|
||||||
|
[Pure]
|
||||||
|
#if NETSTANDARD2_1
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
#else
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
|
#endif
|
||||||
|
public static void Deconstruct(this Color color, out byte r, out byte g, out byte b)
|
||||||
|
{
|
||||||
|
r = color.R;
|
||||||
|
g = color.G;
|
||||||
|
b = color.B;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a <see cref="ConsoleColor" /> which most closely resembles the current color.
|
/// Returns a <see cref="ConsoleColor" /> which most closely resembles the current color.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user