|
You can change intensity of three basic colors and see what you
get by mixing them.

Download this example
This procedure shows intensity of each color and resultant color
you get by mixing them.
procedure
TForm1.ChangeColor(Sender: TObject);
Var
CRed, CGreen, CBlue : TColor;
begin
{ Display mixture
of colors }
Shape1.Brush.Color:=StrToInt64Def('$'+
IntToHex(ColorToRGB(Blue),2)+
IntToHex(ColorToRGB(Green),2)+
IntToHex(ColorToRGB(Red),2),0);
{ Convert integer
to color value }
CRed:=StrToInt64Def('$0000'+IntToHex(ColorToRGB(Red),2),0);
CGreen:=StrToInt64Def('$00'+IntToHex(ColorToRGB(Green),2)+'00',0);
CBlue:=StrToInt64Def('$'+IntToHex(ColorToRGB(Blue),2)+'0000',0);
{ display circles
for each color }
Image1.Canvas.Brush.Color:=CRed;
Image1.Canvas.Pen.Color:=CRed;
Image1.Canvas.Ellipse(X-25, Y-40, X+25,
Y+10);
Image1.Canvas.Brush.Color:=CGreen;
Image1.Canvas.Pen.Color:=CGreen;
Image1.Canvas.Ellipse(X-40, Y-15, X+10,
Y+35);
Image1.Canvas.Brush.Color:=CBlue;
Image1.Canvas.Pen.Color:=CBlue;
Image1.Canvas.Ellipse(X-10, Y-15, X+40,
Y+35);
end;
When
changing track bar position, use following method to change color
intensity.
procedure
TForm1.RedTrackBarChange(Sender: TObject);
begin
Red:=RedTrackBar.Position;
ChangeColor(Self);
end;
procedure
TForm1.GreenTrackBarChange(Sender: TObject);
begin
Green:=GreenTrackBar.Position;
ChangeColor(Self);
end;
procedure
TForm1.BlueTrackBarChange(Sender: TObject);
begin
Blue:=BlueTrackBar.Position;
ChangeColor(Self);
end;
This
one draws three circles with basic colors at startup.
procedure
TForm1.FormCreate(Sender: TObject);
begin
Red:=255;
Green:=255;
Blue:=255;
X:=Image1.Width Div 2;
Y:=Image1.Height Div 2;
Image1.Canvas.Brush.Color:=clRed;
Image1.Canvas.Pen.Color:=clRed;
Image1.Canvas.Ellipse(X-25, Y-40, X+25,
Y+10);
Image1.Canvas.Brush.Color:=cllime;
Image1.Canvas.Pen.Color:=cllime;
Image1.Canvas.Ellipse(X-40, Y-15, X+10,
Y+35);
Image1.Canvas.Brush.Color:=clBlue;
Image1.Canvas.Pen.Color:=clBlue;
Image1.Canvas.Ellipse(X-10, Y-15, X+40,
Y+35);
end;
DOWNLOAD this example
Click
here
to download this complete example for Delphi 6. (File size 4KB)

|