public static Blend ( |
||
ca | ||
cb | ||
cbAlpha | byte | |
Результат |
public static ColorBgra Blend(ColorBgra ca, ColorBgra cb, byte cbAlpha)
{
uint caA = (uint)Utility.FastScaleByteByByte((byte)(255 - cbAlpha), ca.A);
uint cbA = (uint)Utility.FastScaleByteByByte(cbAlpha, cb.A);
uint cbAT = caA + cbA;
uint r;
uint g;
uint b;
if (cbAT == 0)
{
r = 0;
g = 0;
b = 0;
}
else
{
r = ((ca.R * caA) + (cb.R * cbA)) / cbAT;
g = ((ca.G * caA) + (cb.G * cbA)) / cbAT;
b = ((ca.B * caA) + (cb.B * cbA)) / cbAT;
}
return ColorBgra.FromBgra((byte)b, (byte)g, (byte)r, (byte)cbAT);
}
ColorBgra::Blend ( |
public virtual void BeforeRender() { if (!this.lerpCacheIsValid) { byte startAlpha; byte endAlpha; if (this.alphaOnly) { ComputeAlphaOnlyValuesFromColors(this.startColor, this.endColor, out startAlpha, out endAlpha); } else { startAlpha = this.startColor.A; endAlpha = this.endColor.A; } this.lerpAlphas = new byte[256]; this.lerpColors = new ColorBgra[256]; for (int i = 0; i < 256; ++i) { byte a = (byte)i; this.lerpColors[a] = ColorBgra.Blend(this.startColor, this.endColor, a); this.lerpAlphas[a] = (byte)(startAlpha + ((endAlpha - startAlpha) * a) / 255); } this.lerpCacheIsValid = true; } }