Color: constructor overloads that accept ints
Without these overloads it is possible that integers (expected to be 0-255) are interpreted as floats and clamped between 0 and 1.0 #308, #253
This commit is contained in:
Родитель
f205201cac
Коммит
53a870df1b
|
@ -42,6 +42,22 @@ namespace Microsoft.Maui.Graphics
|
|||
Alpha = alpha.Clamp(0, 1);
|
||||
}
|
||||
|
||||
public Color(int red, int green, int blue)
|
||||
{
|
||||
Red = (red / 255f).Clamp(0, 255);
|
||||
Green = (green / 255f).Clamp(0, 255);
|
||||
Blue = (blue / 255f).Clamp(0, 255);
|
||||
Alpha = 1.0f;
|
||||
}
|
||||
|
||||
public Color(int red, int green, int blue, int alpha)
|
||||
{
|
||||
Red = (red / 255f).Clamp(0, 255);
|
||||
Green = (green / 255f).Clamp(0, 255);
|
||||
Blue = (blue / 255f).Clamp(0, 255);
|
||||
Alpha = (alpha / 255f).Clamp(0, 255);
|
||||
}
|
||||
|
||||
public Color(Vector4 color)
|
||||
{
|
||||
Red = color.X.Clamp(0, 1);
|
||||
|
|
Загрузка…
Ссылка в новой задаче