1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
| ///////////////////////////////////////////////////////////////////////////
// //
// Copyright (c) 2015 by Charta Software B.V. //
// All rights reserved //
// //
// Version: 1.7.0.83525 //
// Web site: https://pascal.chartasoftware.com/ //
// //
// This code and information are provided "as is" without warranty of //
// any kind. Dissemination of this information or reproduction of //
// this material is strictly forbidden unless prior written permission //
// is obtained from Charta Software B.V.. //
// //
///////////////////////////////////////////////////////////////////////////
unit Drawing.Canvas;
interface
uses
Color.Rgb,
Drawing.Canvas.ClippingWindow,
Drawing.Fill,
Drawing.Resource,
Drawing.Stroke,
FloatingPoint._64,
FloatingPoint._64.Interval,
Font,
Geometry._2d,
Geometry._2d.Dimension,
Geometry._2d.FloatingPoint64.Ellipse,
Geometry._2d.FloatingPoint64.Point,
Geometry._2d.FloatingPoint64.Rectangle,
Geometry._2d.FloatingPoint64.Rectangle.Rounded,
Geometry._2d.Integer32.Point,
Geometry._2d.Integer32.Rectangle,
Geometry._2d.Integer32.Size,
Geometry._2d.Transformation.Affine.Compound,
Image.Raster,
Integer._32,
Integer._32.Interval,
Text;
type
TCanvasLayer = class(TObject)
private
FBounds: T2dFloatingPoint64Rectangle;
public
constructor Create(const Bounds: T2dFloatingPoint64Rectangle); virtual;
property Bounds: T2dFloatingPoint64Rectangle read FBounds;
end;
TCanvas = class(TObject)
protected
FFont: TSizedFont;
FStroke: TStroke;
FFill: TFill;
procedure SetFont(const Value: TSizedFont);
procedure SetStroke(const Value: TStroke);
procedure SetFill(const Value: TFill);
function GetTransformation(): T2dCompoundAffineTransformation; virtual; abstract;
function GetClippingWindow(): TClippingWindow; virtual; abstract;
procedure FontChanged(); virtual;
procedure StrokeChanged(); virtual;
procedure FillChanged(); virtual;
public
destructor Destroy(); override;
procedure FillRectangle(const Rectangle: TInteger32Rectangle); overload; virtual; abstract;
procedure FillRectangle(const Rectangle: T2dFloatingPoint64Rectangle); overload; virtual; abstract;
procedure DrawRectangle(const Rectangle: TInteger32Rectangle); overload; virtual; abstract;
procedure DrawRectangle(const Rectangle: T2dFloatingPoint64Rectangle); overload; virtual; abstract;
procedure DrawRoundedRectangle(const Rectangle: T2dFloatingPoint64RoundedRectangle); virtual; abstract;
procedure FillRoundedRectangle(const Rectangle: T2dFloatingPoint64RoundedRectangle); virtual; abstract;
procedure DrawImage(const Position: T2dFloatingPoint64Point; Image: TRasterImage); virtual; abstract;
procedure StrokeGeometry(Geometry: T2dGeometry); virtual; abstract;
procedure FillGeometry(Geometry: T2dGeometry); virtual; abstract;
procedure DrawLine(const Point1: TInteger32Point; const Point2: TInteger32Point); overload; virtual; abstract;
procedure DrawLine(const Point1: T2dFloatingPoint64Point; const Point2: T2dFloatingPoint64Point); overload; virtual; abstract;
procedure HorizontalLine(const HorizontalRange: TInteger32Interval; Y: TInteger32); overload; virtual;
procedure VerticalLine(X: TInteger32; const VerticalRange: TInteger32Interval); overload; virtual;
procedure HorizontalLine(const HorizontalRange: TFloatingPoint64Interval; Y: TFloatingPoint64); overload; virtual;
procedure VerticalLine(X: TFloatingPoint64; const VerticalRange: TFloatingPoint64Interval); overload; virtual;
procedure FillEllipse(const Ellipse: T2dFloatingPoint64Ellipse); virtual; abstract;
procedure TextOut(const TopLeft: T2dFloatingPoint64Point; const Text: TText); virtual; deprecated 'Please use FillText';
procedure FillText(const BaseLineLeft: T2dFloatingPoint64Point; const Text: TText); virtual; abstract;
procedure FillTextLayout(const TopLeft: T2dFloatingPoint64Point; Layout: TTextLayout); virtual; abstract;
procedure OverlayRectangle(const Rectangle: TInteger32Rectangle; Factor: TFloatingPoint64); virtual; abstract;
procedure OverlayGradient(const Rectangle: TInteger32Rectangle; const Color: TRgbColor; const Factors: TFloatingPoint64Interval; Dimension: T2dDimension); virtual; abstract;
function PushLayer(const Bounds: T2dFloatingPoint64Rectangle; Opacity: TFloatingPoint64): TCanvas; virtual; abstract;
procedure PopLayer(); virtual; abstract;
function Create3dCanvas(const Size: TInteger32Size; RotationX: TFloatingPoint64; RotationY: TFloatingPoint64): TCanvas; virtual; abstract;
procedure Destroy3dCanvas(Canvas: TCanvas); virtual; abstract;
property Transformation: T2dCompoundAffineTransformation read GetTransformation;
property ClippingWindow: TClippingWindow read GetClippingWindow;
property Font: TSizedFont read FFont write SetFont;
property Stroke: TStroke read FStroke write SetStroke;
property Fill: TFill read FFill write SetFill;
end;
implementation
uses
Exception.NotImplemented;
{ TCanvas }
destructor TCanvas.Destroy();
begin
Stroke.ReleaseReference();
Fill.ReleaseReference();
inherited Destroy();
end;
procedure TCanvas.FillChanged();
begin
end;
procedure TCanvas.FontChanged();
begin
end;
procedure TCanvas.HorizontalLine(const HorizontalRange: TFloatingPoint64Interval; Y: TFloatingPoint64);
begin
DrawLine(T2dFloatingPoint64Point.New(HorizontalRange.Low, Y), T2dFloatingPoint64Point.New(HorizontalRange.High + 1, Y));
end;
procedure TCanvas.HorizontalLine(const HorizontalRange: TInteger32Interval; Y: TInteger32);
begin
DrawLine(TInteger32Point.New(HorizontalRange.Low, Y), TInteger32Point.New(HorizontalRange.High + 1, Y));
end;
procedure TCanvas.SetFill(const Value: TFill);
begin
if Value <> Fill then
begin
Value.AddReference();
Fill.ReleaseReference();
FFill := Value;
FillChanged();
end;
end;
procedure TCanvas.SetFont(const Value: TSizedFont);
begin
if Value <> Font then
begin
FFont := Value;
FontChanged();
end;
end;
procedure TCanvas.SetStroke(const Value: TStroke);
begin
if Value <> Stroke then
begin
Value.AddReference();
Stroke.ReleaseReference();
FStroke := Value;
StrokeChanged();
end;
end;
procedure TCanvas.StrokeChanged();
begin
end;
procedure TCanvas.TextOut(const TopLeft: T2dFloatingPoint64Point; const Text: TText);
begin
raise ENotImplemented.Create(ClassType, 'TextOut');
end;
procedure TCanvas.VerticalLine(X: TFloatingPoint64; const VerticalRange: TFloatingPoint64Interval);
begin
DrawLine(T2dFloatingPoint64Point.New(X, VerticalRange.Low), T2dFloatingPoint64Point.New(X, VerticalRange.High + 1));
end;
procedure TCanvas.VerticalLine(X: TInteger32; const VerticalRange: TInteger32Interval);
begin
DrawLine(TInteger32Point.New(X, VerticalRange.Low), TInteger32Point.New(X, VerticalRange.High + 1));
end;
{ TCanvasLayer }
constructor TCanvasLayer.Create(const Bounds: T2dFloatingPoint64Rectangle);
begin
inherited Create();
FBounds := Bounds;
end;
end.
|