SkiaSharp
SkiaSharp copied to clipboard
[FEATURE] Get SKColor from color name
Description
As a SkiaSharp user, I want to be able to get SKColor
instance from the input string which is a color name.
It can be, for example, a new .FromName()
method:
var inputClrName = "blue";
var color = SKColor.FromName(inputClrName);
Additional context
Initial discussion: https://github.com/mono/SkiaSharp/discussions/2250
Is this function part of Skia? If not then it shouldn't be added. You can use any string to Color? function (there is one in System.Drawing.Color) and then convert to SKColor.
System.Drawing.Color causes major problems in linux due to its utilization of libdgiplus and its not available for every linux distro. so may be an alternative is var color = SKColor.FromName(inputClrName); if available
Hi guys, any news on it?
here is a sample:
private static SKColor GetColor(string colorName) { var skColor = typeof(SKColors).GetField(colorName); if (skColor != null) { return (SKColor)skColor.GetValue(null)!; } return SKColors.Black; }