-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtransformations.pas
More file actions
67 lines (54 loc) · 1.35 KB
/
transformations.pas
File metadata and controls
67 lines (54 loc) · 1.35 KB
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
program AggEx;
uses
SysUtils,
AggExample,
agg_2D,
agg_basics;
type
TAggExample1 = class(TAggExample)
protected
procedure Draw(agg: Agg2D_ptr); override;
end;
const
SURFACE_WIDTH = 480;
SURFACE_HEIGHT = 480;
procedure TAggExample1.Draw(agg: Agg2D_ptr);
var
x, y, nx, ny: double;
af: Transformations_;
begin
agg^.clearAll(0, 0, 0, 0);
//agg^.clearAll(255, 255, 255);
agg^.noLine;
// Red Arrow
agg^.fillColor(255, 0, 0, 128);
agg^.Triangle(100, 20, 40, 100, 160, 100);
agg^.rectangle(70, 100, 130, 170);
// Coordinates will be reflected along line
// defined as from 0:0 to 90:85
x := 90;
y := 85;
nx := x / Sqrt(x * x + y * y);
ny := y / Sqrt(x * x + y * y);
af.affineMatrix[0] := 2.0 * nx * nx - 1.0;
af.affineMatrix[1] := 2.0 * nx * ny;
af.affineMatrix[2] := 2.0 * nx * ny;
af.affineMatrix[3] := 2.0 * ny * ny - 1.0;
af.affineMatrix[4] := 0.0;
af.affineMatrix[5] := 0.0;
// Add Reflection Transformation by utilizing
// custom matrix set-up function
agg^.Transformations(@af);
// Blue Arrow (same as Red)
agg^.fillColor(0, 0, 255, 128);
agg^.Triangle(100, 20, 40, 100, 160, 100);
agg^.rectangle(70, 100, 130, 170);
end;
var
p: TAggExample1;
begin
p := TAggExample1.Create(SURFACE_WIDTH, SURFACE_HEIGHT, ChangeFileExt({$I %FILE%}, '.png'));
p.DrawImage;
p.SaveToPng;
p.Free;
end.