Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[code]
[navy][i]// for automatic syntax highlighting see faq102-6487
[/i][/navy][navy][i]////////////////////////////////////////////////////////////////////////////////
[/i][/navy][navy][i]// Delphi 7 Unit "JDGraphics.pas"
[/i][/navy][navy][i]// JD's Custom Graphics Library
[/i][/navy][navy][i]// Classes:
[/i][/navy][navy][i]// TJDColor: TPersistent - Custom TColor wrapper with RGB and CMYK properties
[/i][/navy][navy][i]////////////////////////////////////////////////////////////////////////////////
[/i][/navy]
[b]unit[/b] JDGraphics;
[b]interface[/b]
[b]uses[/b]
Classes, Controls, SysUtils, Windows, StdCtrls, ExtCtrls, Graphics, StrUtils,
JPEG, Messages, Variants, Forms, Dialogs, Buttons, ComCtrls, ImgList;
[navy][i]////////////////////////////////////////////////////////////////////////////////
[/i][/navy][navy][i]// TJDColor
[/i][/navy][navy][i]// Custom color wrapper providing RGB and CMYK values
[/i][/navy][navy][i]////////////////////////////////////////////////////////////////////////////////
[/i][/navy]
[b]type[/b]
TJDColor = [b]class[/b];
TColEvent = [b]procedure[/b](Sender: TObject) [b]of[/b] [b]object[/b];
TJDColor = [b]class[/b](TPersistent)
[b]private[/b]
FColor: TColor;
fEvent: TColEvent;
[b]procedure[/b] SetColor(Value: TColor);
[b]function[/b] GetRed: Integer;
[b]function[/b] GetGreen: Integer;
[b]function[/b] GetBlue: Integer;
[b]procedure[/b] SetRed(Value: Integer);
[b]procedure[/b] SetGreen(Value: Integer);
[b]procedure[/b] SetBlue(Value: Integer);
[b]function[/b] GetCyan: Integer;
[b]function[/b] GetMagenta: Integer;
[b]function[/b] GetYellow: Integer;
[b]function[/b] GetBlack: Integer;
[b]procedure[/b] SetCyan(Value: Integer);
[b]procedure[/b] SetMagenta(Value: Integer);
[b]procedure[/b] SetYellow(Value: Integer);
[b]procedure[/b] SetBlack(Value: Integer);
[b]procedure[/b] RaiseEvent;
[b]public[/b]
[b]constructor[/b] Create;
[b]property[/b] Red: Integer [b]read[/b] GetRed [b]write[/b] SetRed;
[b]property[/b] Green: Integer [b]read[/b] GetGreen [b]write[/b] SetGreen;
[b]property[/b] Blue: Integer [b]read[/b] GetBlue [b]write[/b] SetBlue;
[b]property[/b] Cyan: Integer [b]read[/b] GetCyan [b]write[/b] SetCyan;
[b]property[/b] Magenta: Integer [b]read[/b] GetMagenta [b]write[/b] SetMagenta;
[b]property[/b] Yellow: Integer [b]read[/b] GetYellow [b]write[/b] SetYellow;
[b]property[/b] Black: Integer [b]read[/b] GetBlack [b]write[/b] SetBlack;
[b]published[/b]
[b]property[/b] Color: TColor [b]read[/b] FColor [b]write[/b] SetColor;
[b]property[/b] OnEvent: TColEvent [b]read[/b] fEvent [b]write[/b] fEvent;
[b]end[/b];
[b]implementation[/b]
[navy][i]////////////////////////////////////////////////////////////////////////////////
[/i][/navy][navy][i]// TJDColor
[/i][/navy][navy][i]// Stores TColor and provides read/write of RGB and CMYK color values
[/i][/navy][navy][i]////////////////////////////////////////////////////////////////////////////////
[/i][/navy]
[b]constructor[/b] TJDColor.Create;
[b]begin[/b]
Self.Color:= clBlack;
Self.RaiseEvent;
[b]end[/b];
[b]procedure[/b] TJDColor.SetColor(Value: TColor);
[b]begin[/b]
Self.FColor:= Value;
Self.RaiseEvent;
[b]end[/b];
[b]function[/b] TJDColor.GetRed: Integer;
[b]begin[/b]
Result:= GetRValue(FColor);
[b]end[/b];
[b]function[/b] TJDColor.GetGreen: Integer;
[b]begin[/b]
Result:= GetGValue(FColor);
[b]end[/b];
[b]function[/b] TJDColor.GetBlue: Integer;
[b]begin[/b]
Result:= GetBValue(FColor);
[b]end[/b];
[b]procedure[/b] TJDColor.SetRed(Value: Integer);
[b]begin[/b]
Self.FColor:= RGB(Value, GetGreen, GetBlue);
RaiseEvent;
[b]end[/b];
[b]procedure[/b] TJDColor.SetGreen(Value: Integer);
[b]begin[/b]
Self.FColor:= RGB(GetRed, Value, GetBlue);
RaiseEvent;
[b]end[/b];
[b]procedure[/b] TJDColor.SetBlue(Value: Integer);
[b]begin[/b]
Self.FColor:= RGB(GetRed, GetGreen, Value);
RaiseEvent;
[b]end[/b];
[b]function[/b] TJDColor.GetCyan: Integer;
[b]begin[/b]
Result:= GetCValue(FColor);
[b]end[/b];
[b]function[/b] TJDColor.GetMagenta: Integer;
[b]begin[/b]
Result:= GetMValue(FColor);
[b]end[/b];
[b]function[/b] TJDColor.GetYellow: Integer;
[b]begin[/b]
Result:= GetYValue(FColor);
[b]end[/b];
[b]function[/b] TJDColor.GetBlack: Integer;
[b]begin[/b]
Result:= GetBValue(FColor);
[b]end[/b];
[b]procedure[/b] TJDColor.SetCyan(Value: Integer);
[b]begin[/b]
Self.FColor:= CMYK(Value, GetMagenta, GetYellow, GetBlack);
RaiseEvent;
[b]end[/b];
[b]procedure[/b] TJDColor.SetMagenta(Value: Integer);
[b]begin[/b]
Self.FColor:= CMYK(GetCyan, Value, GetYellow, GetBlack);
RaiseEvent;
[b]end[/b];
[b]procedure[/b] TJDColor.SetYellow(Value: Integer);
[b]begin[/b]
Self.FColor:= CMYK(GetCyan, GetMagenta, Value, GetBlack);
RaiseEvent;
[b]end[/b];
[b]procedure[/b] TJDColor.SetBlack(Value: Integer);
[b]begin[/b]
Self.FColor:= CMYK(GetCyan, GetMagenta, GetYellow, Value);
RaiseEvent;
[b]end[/b];
[b]procedure[/b] TJDColor.RaiseEvent; [navy][i]//Postback for components
[/i][/navy][b]begin[/b]
[b]if[/b] assigned(Self.fEvent) [b]then[/b] [b]begin[/b]
Self.fEvent(Self);
[b]end[/b];
[b]end[/b];
[b]end[/b].