source: trunk/UGraphics.pas

Last change on this file was 1, checked in by chronos, 3 years ago
  • Added: "Clovece nezlob se" game with adjustable board for different player count.
File size: 4.5 KB
Line 
1unit UGraphics;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, Types;
9
10type
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
84const
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
99implementation
100
101{ TFont }
102
103procedure TFont.Assign(Source: TFont);
104begin
105 Size := Source.Size;
106end;
107
108{ TBrush }
109
110procedure TBrush.Assign(Source: TBrush);
111begin
112 Style := Source.Style;
113 Color := Source.Color;
114 Opacity := Source.Opacity;
115end;
116
117{ TPen }
118
119procedure TPen.Assign(Source: TPen);
120begin
121 Color := Source.Color;
122 Style := Source.Style;
123 Width := Source.Width;
124 Position := Source.Position;
125end;
126
127constructor TPen.Create;
128begin
129 Width := 1;
130end;
131
132{ TCanvas }
133
134function TCanvas.GetSize: TSize;
135begin
136end;
137
138procedure TCanvas.SetSize(AValue: TSize);
139begin
140end;
141
142procedure TCanvas.TextOut(const Pos: TPoint; Text: string);
143begin
144end;
145
146procedure TCanvas.TextOut(X, Y: Integer; Text: string);
147begin
148 TextOut(Point(X, Y), Text);
149end;
150
151procedure TCanvas.Rectangle(const ARect: TRect);
152begin
153end;
154
155procedure TCanvas.Rectangle(X1, Y1, X2, Y2: Integer);
156begin
157 Rectangle(Rect(X1, Y1, X2, Y2));
158end;
159
160procedure TCanvas.RoundRect(X1, Y1, X2, Y2: Integer; RX, RY: Integer);
161begin
162 RoundRect(Rect(X1, Y1, X2, Y2), RX, RY);
163end;
164
165procedure TCanvas.RoundRect(const Rect: TRect; RX, RY: Integer);
166begin
167end;
168
169procedure TCanvas.MoveTo(X, Y: Integer);
170begin
171 MoveTo(Point(X, Y));
172end;
173
174procedure TCanvas.MoveTo(const P: TPoint);
175begin
176 Pen.Position := P;
177end;
178
179procedure TCanvas.LineTo(X, Y: Integer);
180begin
181 LineTo(Point(X, Y));
182end;
183
184procedure TCanvas.LineTo(const P: TPoint);
185begin
186 Line(Pen.Position, P);
187 Pen.Position := P;
188end;
189
190procedure TCanvas.Polygon(const Points: array of TPoint);
191begin
192end;
193
194procedure TCanvas.StretchDraw(const DestRect: TRect; SrcGraphic: TGraphic);
195begin
196end;
197
198function TCanvas.TextExtent(const Text: string): TSize;
199begin
200 Result := TSize.Create(0, 0);
201end;
202
203procedure TCanvas.Pie(EllipseX1, EllipseY1, EllipseX2, EllipseY2, StartX,
204 StartY, EndX, EndY: Integer);
205begin
206end;
207
208procedure TCanvas.Line(const P1, P2: TPoint);
209begin
210end;
211
212procedure TCanvas.Line(X1, Y1, X2, Y2: Integer);
213begin
214 Line(Point(X1, Y1), Point(X2, Y2));
215end;
216
217procedure TCanvas.Ellipse(X1, Y1, X2, Y2: Integer);
218begin
219 Ellipse(Rect(X1, Y1, X2, Y2));
220end;
221
222procedure TCanvas.Ellipse(const Bounds: TRect);
223begin
224end;
225
226constructor TCanvas.Create;
227begin
228 Brush := TBrush.Create;
229 Pen := TPen.Create;
230end;
231
232destructor TCanvas.Destroy;
233begin
234 Pen.Free;
235 Brush.Free;
236 inherited;
237end;
238
239end.
240
Note: See TracBrowser for help on using the repository browser.