mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2025-12-13 09:08:34 +00:00
Improved color-blending
This commit is contained in:
parent
fa91b61387
commit
6f05de450e
@ -1,5 +1,6 @@
|
|||||||
// ReSharper disable MemberCanBePrivate.Global
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
||||||
namespace CUE.NET.Helper
|
namespace CUE.NET.Helper
|
||||||
@ -43,7 +44,13 @@ namespace CUE.NET.Helper
|
|||||||
|
|
||||||
public static Color CreateColorFromFloat(float a, float r, float g, float b)
|
public static Color CreateColorFromFloat(float a, float r, float g, float b)
|
||||||
{
|
{
|
||||||
return Color.FromArgb((int)(a * 255), (int)(r * 255), (int)(g * 255), (int)(b * 255));
|
return Color.FromArgb(GetIntColorFromFloat(a), GetIntColorFromFloat(r), GetIntColorFromFloat(g), GetIntColorFromFloat(b));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte GetIntColorFromFloat(float f)
|
||||||
|
{
|
||||||
|
float calcF = (float)Math.Max(0.0, Math.Min(1.0, f));
|
||||||
|
return (byte)(calcF == 1.0 ? 255 : calcF * 256.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user