Just a quick tips for those of you needing to blend two colors. Usage is very easy.
// Usage NewColor:= Blend(Color1, Color2, blending level 0 to 100); function Blend(Color1, Color2: TColor; A: Byte): TColor; var c1, c2: LongInt; r, g, b, v1, v2: byte; begin A:= Round(2.55 * A); c1 := ColorToRGB(Color1); c2 := ColorToRGB(Color2); v1:= Byte(c1); v2:= Byte(c2); r:= A * (v1 - v2) shr 8 + v2; v1:= Byte(c1 shr 8); v2:= Byte(c2 shr 8); g:= A * (v1 - v2) shr 8 + v2; v1:= Byte(c1 shr 16); v2:= Byte(c2 shr 16); b:= A * (v1 - v2) shr 8 + v2; Result := (b shl 16) + (g shl 8) + r; end; |