1 | unit UGraphics;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, Types;
|
---|
9 |
|
---|
10 | type
|
---|
11 | TColor = Cardinal;
|
---|
12 |
|
---|
13 | TBrushStyle = (bsSolid, bsClear);
|
---|
14 |
|
---|
15 | { TBrush }
|
---|
16 |
|
---|
17 | TBrush = class
|
---|
18 | Style: TBrushStyle;
|
---|
19 | Color: TColor;
|
---|
20 | Opacity: Byte;
|
---|
21 | procedure Assign(Source: TBrush);
|
---|
22 | end;
|
---|
23 |
|
---|
24 | TPenStyle = (psSolid, psClear);
|
---|
25 |
|
---|
26 | { TPen }
|
---|
27 |
|
---|
28 | TPen = class
|
---|
29 | Position: TPoint;
|
---|
30 | Style: TPenStyle;
|
---|
31 | Color: TColor;
|
---|
32 | Width: Integer;
|
---|
33 | procedure Assign(Source: TPen);
|
---|
34 | constructor Create;
|
---|
35 | end;
|
---|
36 |
|
---|
37 | { TFont }
|
---|
38 |
|
---|
39 | TFont = class
|
---|
40 | Size: Integer;
|
---|
41 | procedure Assign(Source: TFont);
|
---|
42 | end;
|
---|
43 |
|
---|
44 | TGraphic = class
|
---|
45 |
|
---|
46 | end;
|
---|
47 |
|
---|
48 | { TCanvas }
|
---|
49 |
|
---|
50 | TCanvas = class
|
---|
51 | protected
|
---|
52 | function GetSize: TSize; virtual;
|
---|
53 | procedure SetSize(AValue: TSize); virtual;
|
---|
54 | public
|
---|
55 | Pen: TPen;
|
---|
56 | Brush: TBrush;
|
---|
57 | Font: TFont;
|
---|
58 | procedure TextOut(const Pos: TPoint; Text: string); overload; virtual;
|
---|
59 | procedure TextOut(X, Y: Integer; Text: string); overload;
|
---|
60 | procedure Line(const P1, P2: TPoint); overload; virtual;
|
---|
61 | procedure Line(X1, Y1, X2, Y2: Integer); overload;
|
---|
62 | procedure Ellipse(X1, Y1, X2, Y2: Integer); overload;
|
---|
63 | procedure Ellipse(const Bounds: TRect); overload; virtual;
|
---|
64 | procedure Rectangle(const ARect: TRect); overload; virtual;
|
---|
65 | procedure Rectangle(X1, Y1, X2, Y2: Integer); overload;
|
---|
66 | procedure RoundRect(X1, Y1, X2, Y2: Integer; RX, RY: Integer); overload;
|
---|
67 | procedure RoundRect(const Rect: TRect; RX, RY: Integer); overload; virtual;
|
---|
68 | procedure MoveTo(X, Y: Integer); overload;
|
---|
69 | procedure MoveTo(const P: TPoint); overload;
|
---|
70 | procedure LineTo(X, Y: Integer); overload;
|
---|
71 | procedure LineTo(const P: TPoint); overload;
|
---|
72 | procedure Polygon(const Points: array of TPoint); virtual;
|
---|
73 | procedure StretchDraw(const DestRect: TRect; SrcGraphic: TGraphic); virtual;
|
---|
74 | function TextExtent(const Text: string): TSize; virtual;
|
---|
75 | procedure Pie(EllipseX1, EllipseY1, EllipseX2, EllipseY2,
|
---|
76 | StartX, StartY, EndX, EndY: Integer); virtual;
|
---|
77 | constructor Create;
|
---|
78 | destructor Destroy; override;
|
---|
79 | property Size: TSize read GetSize write SetSize;
|
---|
80 | end;
|
---|
81 |
|
---|
82 |
|
---|
83 |
|
---|
84 | const
|
---|
85 | clBlack = $000000;
|
---|
86 | clWhite = $ffffff;
|
---|
87 | clGray = $808080;
|
---|
88 | clRed = $0000ff;
|
---|
89 | clGreen = $00ff00;
|
---|
90 | clBlue = $ff0000;
|
---|
91 | clYellow = $00ffff;
|
---|
92 | clFuchsia = $ff00ff;
|
---|
93 | clAqua = $ffff00;
|
---|
94 | clBrown = $003090;
|
---|
95 | clOrange = $0080ff;
|
---|
96 | clLightBlue = $ff5050;
|
---|
97 |
|
---|
98 |
|
---|
99 | implementation
|
---|
100 |
|
---|
101 | { TFont }
|
---|
102 |
|
---|
103 | procedure TFont.Assign(Source: TFont);
|
---|
104 | begin
|
---|
105 | Size := Source.Size;
|
---|
106 | end;
|
---|
107 |
|
---|
108 | { TBrush }
|
---|
109 |
|
---|
110 | procedure TBrush.Assign(Source: TBrush);
|
---|
111 | begin
|
---|
112 | Style := Source.Style;
|
---|
113 | Color := Source.Color;
|
---|
114 | Opacity := Source.Opacity;
|
---|
115 | end;
|
---|
116 |
|
---|
117 | { TPen }
|
---|
118 |
|
---|
119 | procedure TPen.Assign(Source: TPen);
|
---|
120 | begin
|
---|
121 | Color := Source.Color;
|
---|
122 | Style := Source.Style;
|
---|
123 | Width := Source.Width;
|
---|
124 | Position := Source.Position;
|
---|
125 | end;
|
---|
126 |
|
---|
127 | constructor TPen.Create;
|
---|
128 | begin
|
---|
129 | Width := 1;
|
---|
130 | end;
|
---|
131 |
|
---|
132 | { TCanvas }
|
---|
133 |
|
---|
134 | function TCanvas.GetSize: TSize;
|
---|
135 | begin
|
---|
136 | end;
|
---|
137 |
|
---|
138 | procedure TCanvas.SetSize(AValue: TSize);
|
---|
139 | begin
|
---|
140 | end;
|
---|
141 |
|
---|
142 | procedure TCanvas.TextOut(const Pos: TPoint; Text: string);
|
---|
143 | begin
|
---|
144 | end;
|
---|
145 |
|
---|
146 | procedure TCanvas.TextOut(X, Y: Integer; Text: string);
|
---|
147 | begin
|
---|
148 | TextOut(Point(X, Y), Text);
|
---|
149 | end;
|
---|
150 |
|
---|
151 | procedure TCanvas.Rectangle(const ARect: TRect);
|
---|
152 | begin
|
---|
153 | end;
|
---|
154 |
|
---|
155 | procedure TCanvas.Rectangle(X1, Y1, X2, Y2: Integer);
|
---|
156 | begin
|
---|
157 | Rectangle(Rect(X1, Y1, X2, Y2));
|
---|
158 | end;
|
---|
159 |
|
---|
160 | procedure TCanvas.RoundRect(X1, Y1, X2, Y2: Integer; RX, RY: Integer);
|
---|
161 | begin
|
---|
162 | RoundRect(Rect(X1, Y1, X2, Y2), RX, RY);
|
---|
163 | end;
|
---|
164 |
|
---|
165 | procedure TCanvas.RoundRect(const Rect: TRect; RX, RY: Integer);
|
---|
166 | begin
|
---|
167 | end;
|
---|
168 |
|
---|
169 | procedure TCanvas.MoveTo(X, Y: Integer);
|
---|
170 | begin
|
---|
171 | MoveTo(Point(X, Y));
|
---|
172 | end;
|
---|
173 |
|
---|
174 | procedure TCanvas.MoveTo(const P: TPoint);
|
---|
175 | begin
|
---|
176 | Pen.Position := P;
|
---|
177 | end;
|
---|
178 |
|
---|
179 | procedure TCanvas.LineTo(X, Y: Integer);
|
---|
180 | begin
|
---|
181 | LineTo(Point(X, Y));
|
---|
182 | end;
|
---|
183 |
|
---|
184 | procedure TCanvas.LineTo(const P: TPoint);
|
---|
185 | begin
|
---|
186 | Line(Pen.Position, P);
|
---|
187 | Pen.Position := P;
|
---|
188 | end;
|
---|
189 |
|
---|
190 | procedure TCanvas.Polygon(const Points: array of TPoint);
|
---|
191 | begin
|
---|
192 | end;
|
---|
193 |
|
---|
194 | procedure TCanvas.StretchDraw(const DestRect: TRect; SrcGraphic: TGraphic);
|
---|
195 | begin
|
---|
196 | end;
|
---|
197 |
|
---|
198 | function TCanvas.TextExtent(const Text: string): TSize;
|
---|
199 | begin
|
---|
200 | Result := TSize.Create(0, 0);
|
---|
201 | end;
|
---|
202 |
|
---|
203 | procedure TCanvas.Pie(EllipseX1, EllipseY1, EllipseX2, EllipseY2, StartX,
|
---|
204 | StartY, EndX, EndY: Integer);
|
---|
205 | begin
|
---|
206 | end;
|
---|
207 |
|
---|
208 | procedure TCanvas.Line(const P1, P2: TPoint);
|
---|
209 | begin
|
---|
210 | end;
|
---|
211 |
|
---|
212 | procedure TCanvas.Line(X1, Y1, X2, Y2: Integer);
|
---|
213 | begin
|
---|
214 | Line(Point(X1, Y1), Point(X2, Y2));
|
---|
215 | end;
|
---|
216 |
|
---|
217 | procedure TCanvas.Ellipse(X1, Y1, X2, Y2: Integer);
|
---|
218 | begin
|
---|
219 | Ellipse(Rect(X1, Y1, X2, Y2));
|
---|
220 | end;
|
---|
221 |
|
---|
222 | procedure TCanvas.Ellipse(const Bounds: TRect);
|
---|
223 | begin
|
---|
224 | end;
|
---|
225 |
|
---|
226 | constructor TCanvas.Create;
|
---|
227 | begin
|
---|
228 | Brush := TBrush.Create;
|
---|
229 | Pen := TPen.Create;
|
---|
230 | end;
|
---|
231 |
|
---|
232 | destructor TCanvas.Destroy;
|
---|
233 | begin
|
---|
234 | Pen.Free;
|
---|
235 | Brush.Free;
|
---|
236 | inherited;
|
---|
237 | end;
|
---|
238 |
|
---|
239 | end.
|
---|
240 |
|
---|