unit main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, ToolWin, StdCtrls, ExtCtrls;
type
TRGBstructure =
record
case integer
of
0: (r,g,b: byte);
1: (red,green,blue,alpha: byte);
//Die RGB Werte
2: (color: Longint);
//Die Mischfarbe
end;
type
TRGBClass =
class //Eine Klasse zur Bearbeitung der Farbwerte
private
rgbStruc: TRGBStructure;
function getColor: Longint;
procedure setColor(value: Longint);
function getred: byte;
procedure setred(value: byte);
function getgreen: byte;
procedure setgreen(value: byte);
function getblue: byte;
procedure setblue(value: byte);
public
constructor create(filename:
string);
destructor destroy;
override;
procedure LoadFromFile(filename:
string);
procedure SaveToFile(filename:
string);
property Color: Longint
read getColor
write setColor;
property red: byte
read getred
write setred;
property green: byte
read getgreen
write setgreen;
property blue: byte
read getblue
write setblue;
end;
type
TForm1 =
class(TForm)
RedValue: TTrackBar;
GreenVal: TTrackBar;
BlueVal: TTrackBar;
ColorMonitor: TShape;
stxtRed: TStaticText;
stGreen: TStaticText;
stBlue: TStaticText;
Button1: TButton;
Button2: TButton;
Button3: TButton;
strMin: TStaticText;
strMax: TStaticText;
stgMin: TStaticText;
stgMax: TStaticText;
stbMin: TStaticText;
stbMax: TStaticText;
CoolBar1: TCoolBar;
ToolBar1: TToolBar;
procedure RedValueChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure GreenValChange(Sender: TObject);
procedure BlueValChange(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
Palette: TRGBClass;
implementation
{$R *.DFM}
function TRGBClass.getColor: Longint;
begin
Result := rgbStruc.Color;
end;
procedure TRGBClass.setColor(value: Longint);
begin
if rgbStruc.Color <> value
then value := rgbStruc.Color;
end;
function TRGBClass.getred: byte;
begin
Result := rgbStruc.red
end;
procedure TRGBClass.setred(value: byte);
begin
if value <> rgbStruc.red
then rgbStruc.red := value
end;
function TRGBClass.getgreen: byte;
begin
Result := rgbStruc.green
end;
procedure TRGBClass.setgreen(value: byte);
begin
if value <> rgbStruc.green
then rgbStruc.green := value
end;
function TRGBClass.getblue: byte;
begin
Result := rgbStruc.blue;
end;
procedure TRGBClass.setblue(value: byte);
begin
if value <> rgbStruc.blue
then rgbStruc.blue := value
end;
constructor TRGBClass.create(filename:
string);
begin
inherited Create;
end;
destructor TRGBClass.destroy;
begin
inherited Destroy;
end;
procedure TRGBClass.LoadFromFile(filename:
string);
begin
//noch nicht implementiert
end;
procedure TRGBClass.SaveToFile(filename:
string);
begin
//noch nicht implementiert
end;
procedure TForm1.RedValueChange(Sender: TObject);
begin
Palette.red := RedValue.Position;
//Farbwert einstellen
Brush.Color := Palette.Color;
//Gesamtfarbe übergeben
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Palette := TRGBClass.Create('
');
ColorMonitor.Brush.Style := bsSolid;
ColorMonitor.Brush.Color := Palette.Color;
end;
procedure TForm1.GreenValChange(Sender: TObject);
begin
Palette.green := GreenVal.Position;
ColorMonitor.Brush.Color := Palette.Color;
end;
procedure TForm1.BlueValChange(Sender: TObject);
begin
Palette.blue := BlueVal.Position;
ColorMonitor.Brush.Color := Palette.Color;
end;
end.