-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move all Color structs to ImageSharp; Make modal close cancel check async;
- Loading branch information
1 parent
73fbbd6
commit 973efd8
Showing
9 changed files
with
31 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
using System.Drawing; | ||
using System.Numerics; | ||
using System.Numerics; | ||
using SixLabors.ImageSharp; | ||
using SixLabors.ImageSharp.PixelFormats; | ||
|
||
namespace ImGui.Forms.Extensions | ||
{ | ||
public static class ColorExtensions | ||
{ | ||
public static uint ToUInt32(this Color c) | ||
{ | ||
return (uint)((c.A << 24) | (c.B << 16) | (c.G << 8) | c.R); | ||
var pixel = c.ToPixel<Rgba32>(); | ||
return (uint)((pixel.A << 24) | (pixel.B << 16) | (pixel.G << 8) | pixel.R); | ||
} | ||
|
||
public static Color ToColor(this uint value) | ||
{ | ||
return Color.FromArgb((byte)(value >> 24), (byte)value, (byte)(value >> 8), (byte)(value >> 16)); | ||
return Color.FromRgba((byte)value, (byte)(value >> 8), (byte)(value >> 16), (byte)(value >> 24)); | ||
} | ||
|
||
public static Vector4 ToVector4(this Color c) | ||
{ | ||
return new Vector4(c.R / 255f, c.G / 255f, c.B / 255f, c.A / 255f); | ||
var pixel = c.ToPixel<Rgba32>(); | ||
return new Vector4(pixel.R / 255f, pixel.G / 255f, pixel.B / 255f, pixel.A / 255f); | ||
} | ||
|
||
public static Color ToColor(this Vector4 value) | ||
{ | ||
return Color.FromArgb((int)(value.W * 255), (int)(value.X * 255), (int)(value.Y * 255), (int)(value.Z * 255)); | ||
return Color.FromRgba((byte)(value.X * 255), (byte)(value.Y * 255), (byte)(value.Z * 255), (byte)(value.W * 255)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters