ToggleSwitch/ToggleSwitch/GraphicsExtensionMethods.cs
2021-01-30 20:40:26 +08:00

17 lines
470 B
C#

using System.Drawing;
namespace JCS
{
public static class GraphicsExtensionMethods
{
public static Color ToGrayScale(this Color originalColor)
{
if (originalColor.Equals(Color.Transparent))
return originalColor;
int grayScale = (int)((originalColor.R * .299) + (originalColor.G * .587) + (originalColor.B * .114));
return Color.FromArgb(grayScale, grayScale, grayScale);
}
}
}