procedure TMainForm.RGBChange(Sender: TObject);
begin
UpdateColor(Sender, RGBChange, SetRGBValues(edtR.AsInteger, edtG.AsInteger, edtB.AsInteger));
end;
procedure TMainForm.HSLChange(Sender: TObject);
var
R, G, B: Byte;
begin
HSLRangeToRGB(edtH.AsInteger, edtS.AsInteger, edtL.AsInteger, R, G, B);
UpdateColor(Sender, HSLChange, SetRGBValues(R, G, B));
end;
procedure TMainForm.CMYKChange(Sender: TObject);
var
R, G, B: Byte;
begin
CMYKToRGB(edtC.AsInteger, edtM.AsInteger, edtY.AsInteger, edtK.AsInteger, R, G, B);
UpdateColor(Sender, CMYKChange, SetRGBValues(R, G, B));
end;
procedure TMainForm.ColorPaletteCellClick(Button: TMouseButton;
Shift: TShiftState; Index: Integer; AColor: TColor; var DontCheck: Boolean);
var
C: TColor;
begin
if AColor = clNone then
C := clBlack
else
C := AColor
;
UpdateColor(nil, nil, C);
end;
procedure TMainForm.FavouritePaletteCellClick(Button: TMouseButton;
Shift: TShiftState; Index: Integer; AColor: TColor; var DontCheck: Boolean);
var
C: TColor;
begin
if AColor = clNone then
C := clBlack
else
C := AColor
;
UpdateColor(nil, nil, C);
end;
procedure TMainForm.FormClick(Sender: TObject);
begin
edtR.OnChange := nil;
edtR.AsInteger := 0;
edtR.OnChange := RGBChange;
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
Randomize;
UpdateColor(nil, nil, RandomColor);
end;
procedure TMainForm.HSLPickerChange(Sender: TObject);
begin
UpdateColor(HSLPicker, HSLPickerChange, HSLPicker.SelectedColor);
end;
procedure TMainForm.HSVPickerChange(Sender: TObject);
begin
LightnessPicker.Saturation := HSVPicker.Saturation;
LightnessPicker.Hue := HSVPicker.Hue;
UpdateColor(HSVPicker, HSVPickerChange, HSVPicker.SelectedColor);
end;
procedure TMainForm.HuePickerChange(Sender: TObject);
begin
SLPicker.Hue := HuePicker.Hue;
end;
procedure TMainForm.LightnessPickerChange(Sender: TObject);
begin
HSVPicker.Value := LightnessPicker.Value;
end;
procedure TMainForm.PageControlChange(Sender: TObject);
begin
UpdateColor(nil, nil, ColorPreview.Color);
end;
procedure TMainForm.SLPickerChange(Sender: TObject);
begin
UpdateColor(SLPicker, SLPickerChange, SLPicker.SelectedColor);
end;
procedure TMainForm.DisableAutoChange(Sender: TObject; Event: TNotifyEvent);
begin
HSLPicker.OnChange := nil;
SLPicker.OnChange := nil;
HuePicker.OnChange := nil;
HSVPicker.OnChange := nil;
LightnessPicker.OnChange := nil;
edtR.OnChange := nil;
edtG.OnChange := nil;
edtB.OnChange := nil;
edtH.OnChange := nil;
edtS.OnChange := nil;
edtL.OnChange := nil;
edtM.OnChange := nil;
edtM.OnChange := nil;
edtY.OnChange := nil;
edtK.OnChange := nil;
edtCIEL.OnChange := nil;
edtCIEa.OnChange := nil;
edtCIEb.OnChange := nil;
end;
procedure TMainForm.EnableAutoChange;
begin
HSLPicker.OnChange := HSLPickerChange;
SLPicker.OnChange := SLPickerChange;
HuePicker.OnChange := HuePickerChange;
HSVPicker.OnChange := HSVPickerChange;
LightnessPicker.OnChange := LightnessPickerChange;
edtR.OnChange := RGBChange;
edtG.OnChange := RGBChange;
edtB.OnChange := RGBChange;
edtH.OnChange := HSLChange;
edtS.OnChange := HSLChange;
edtL.OnChange := HSLChange;
edtM.OnChange := CMYKChange;
edtM.OnChange := CMYKChange;
edtY.OnChange := CMYKChange;
edtK.OnChange := CMYKChange;
edtCIEL.OnChange := nil;
edtCIEa.OnChange := nil;
edtCIEb.OnChange := nil;
end;
procedure TMainForm.UpdateColor(Sender: TObject; Event: TNotifyEvent; const AColor: TColor);
var
R, G, B: Byte;
H, S, L: Int32;
C, M, Y, K: Byte;
CIEL, CIEa, CIEb: Double;
begin
DisableAutoChange(Sender, Event);
try
ColorPreview.Color := AColor;
GetRGBValues(ColorPreview.Color, R, G, B);
edtR.AsInteger := R;
edtG.AsInteger := G;
edtB.AsInteger := B;
RGBToHSLRange(R, G, B, H, S, L);
edtH.AsInteger := H;
edtS.AsInteger := S;
edtL.AsInteger := L;
edtH.GuageBeginColor := HSLRangeHueToColor(H);
edtH.GuageEndColor := edtH.GuageBeginColor;
edtS.GuageBeginColor := clWhite;
edtS.GuageEndColor := edtH.GuageBeginColor;
edtL.GuageBeginColor := clBlack;
edtL.GuageEndColor := edtH.GuageBeginColor;
RGBToCMYK(R, G, B, C, M, Y, K);
edtC.AsInteger := C;
edtM.AsInteger := M;
edtY.AsInteger := Y;
edtK.AsInteger := K;
RGBToLab(ColorPreview.Color, CIEL, CIEa, CIEb);
edtCIEL.Value := CIEL;
edtCIEa.Value := CIEa;
edtCIEb.Value := CIEb;
HSLPicker.SelectedColor := AColor;
SLPicker.SelectedColor := AColor;
HuePicker.Hue := SLPicker.Hue;
HSVPicker.SelectedColor := AColor;
LightnessPicker.Saturation := HSVPicker.Saturation;
LightnessPicker.Hue := HSVPicker.Hue;
LightnessPicker.Value := HSVPicker.Value;
finally
EnableAutoChange;
end;
end;
initialization
MaxHue := 360;
MaxSat := 100;
MaxLum := 100;
end.