8
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs;
14
TfrmPen = class(TForm)
15
procedure FormPaint(Sender: TObject);
17
{ private declarations }
19
{ public declarations }
31
procedure TfrmPen.FormPaint(Sender: TObject);
34
MyLine: array[0..2] of TPoint;
36
MyBitmap := TBitmap.Create;
38
{ Set a size for the image }
39
MyBitmap.Height := Height;// 150
40
MyBitmap.Width := Width;// 400
41
{ After memory has been reserved by setting the size
42
of the image, we can start drawing }
44
MyBitmap.Canvas.Brush.Color := clWhite;
45
MyBitmap.Canvas.Pen.Color := clWhite;
46
MyBitmap.Canvas.Rectangle(0, 0, Width, Height);
48
MyBitmap.Canvas.TextOut(100, 5,
49
'Brush: bsClear Pen: Black');
53
MyBitmap.Canvas.TextOut(25, 30, 'Pen styles:');
55
MyBitmap.Canvas.TextOut(25, 60, 'psSolid');
56
MyBitmap.Canvas.TextOut(25, 90, 'psDash');
57
MyBitmap.Canvas.TextOut(25, 120, 'psDot');
58
MyBitmap.Canvas.TextOut(25, 150, 'psDashDot');
59
MyBitmap.Canvas.TextOut(25, 180, 'psDashDotDot');
60
MyBitmap.Canvas.TextOut(25, 210, 'psClear');
61
MyBitmap.Canvas.TextOut(25, 240, 'psInsideframe');
62
MyBitmap.Canvas.TextOut(25, 270, 'psPattern');
64
MyBitmap.Canvas.Brush.Style := bsClear;
65
MyBitmap.Canvas.Pen.Color := clBlack;
67
MyBitmap.Canvas.Pen.Style := psSolid;
68
MyBitmap.Canvas.Rectangle(Bounds(125, 60, 50, 25));
69
MyBitmap.Canvas.Pen.Style := psDash;
70
MyBitmap.Canvas.Rectangle(Bounds(125, 90, 50, 25));
71
MyBitmap.Canvas.Pen.Style := psDot;
72
MyBitmap.Canvas.Rectangle(Bounds(125, 120, 50, 25));
73
MyBitmap.Canvas.Pen.Style := psDashDot;
74
MyBitmap.Canvas.Rectangle(Bounds(125, 150, 50, 25));
75
MyBitmap.Canvas.Pen.Style := psDashDotDot;
76
MyBitmap.Canvas.Rectangle(Bounds(125, 180, 50, 25));
77
MyBitmap.Canvas.Pen.Style := psClear;
78
MyBitmap.Canvas.Rectangle(Bounds(125, 210, 50, 25));
79
MyBitmap.Canvas.Pen.Style := psInsideframe;
80
MyBitmap.Canvas.Rectangle(Bounds(125, 240, 50, 25));
81
MyBitmap.Canvas.Pen.Style := psPattern;
82
MyBitmap.Canvas.Rectangle(Bounds(125, 270, 50, 25));
86
MyBitmap.Canvas.TextOut(200, 30, 'Pen Widths:');
88
MyBitmap.Canvas.Pen.Style := psSolid;
90
MyBitmap.Canvas.TextOut(200, 55, 'Width = 0');
91
MyBitmap.Canvas.Pen.Width := 0;
92
MyBitmap.Canvas.MoveTo(200, 75);
93
MyBitmap.Canvas.LineTo(280, 75);
94
MyBitmap.Canvas.MoveTo(200, 75);
95
MyBitmap.Canvas.LineTo(280, 85);
96
MyBitmap.Canvas.MoveTo(200, 75);
97
MyBitmap.Canvas.LineTo(280, 95);
98
MyBitmap.Canvas.MoveTo(200, 75);
99
MyBitmap.Canvas.LineTo(280, 105);
100
MyBitmap.Canvas.MoveTo(200, 75);
101
MyBitmap.Canvas.LineTo(280, 115);
102
MyBitmap.Canvas.MoveTo(200, 75);
103
MyBitmap.Canvas.LineTo(280, 125);
105
MyBitmap.Canvas.TextOut(300, 55, 'Width = 1');
106
MyBitmap.Canvas.Pen.Width := 1;
107
MyBitmap.Canvas.MoveTo(300, 75);
108
MyBitmap.Canvas.LineTo(380, 75);
109
MyBitmap.Canvas.MoveTo(300, 75);
110
MyBitmap.Canvas.LineTo(380, 85);
111
MyBitmap.Canvas.MoveTo(300, 75);
112
MyBitmap.Canvas.LineTo(380, 95);
113
MyBitmap.Canvas.MoveTo(300, 75);
114
MyBitmap.Canvas.LineTo(380, 105);
115
MyBitmap.Canvas.MoveTo(300, 75);
116
MyBitmap.Canvas.LineTo(380, 115);
117
MyBitmap.Canvas.MoveTo(300, 75);
118
MyBitmap.Canvas.LineTo(380, 125);
120
MyBitmap.Canvas.TextOut(400, 55, 'Width = 2');
121
MyBitmap.Canvas.Pen.Width := 2;
122
MyBitmap.Canvas.MoveTo(400, 75);
123
MyBitmap.Canvas.LineTo(480, 75);
124
MyBitmap.Canvas.MoveTo(400, 75);
125
MyBitmap.Canvas.LineTo(480, 85);
126
MyBitmap.Canvas.MoveTo(400, 75);
127
MyBitmap.Canvas.LineTo(480, 95);
128
MyBitmap.Canvas.MoveTo(400, 75);
129
MyBitmap.Canvas.LineTo(480, 105);
130
MyBitmap.Canvas.MoveTo(400, 75);
131
MyBitmap.Canvas.LineTo(480, 115);
132
MyBitmap.Canvas.MoveTo(400, 75);
133
MyBitmap.Canvas.LineTo(480, 125);
137
MyBitmap.Canvas.TextOut(200, 150, 'Pen End Caps:');
139
MyBitmap.Canvas.Pen.Width := 10;
141
MyBitmap.Canvas.TextOut(200, 175, 'pecRound');
142
MyBitmap.Canvas.Pen.EndCap := pecRound;
143
MyBitmap.Canvas.MoveTo(200, 200);
144
MyBitmap.Canvas.LineTo(280, 200);
146
MyBitmap.Canvas.TextOut(300, 175, 'pecSquare');
147
MyBitmap.Canvas.Pen.EndCap := pecSquare;
148
MyBitmap.Canvas.MoveTo(300, 200);
149
MyBitmap.Canvas.LineTo(380, 200);
151
MyBitmap.Canvas.TextOut(400, 175, 'pecFlat');
152
MyBitmap.Canvas.Pen.EndCap := pecFlat;
153
MyBitmap.Canvas.MoveTo(400, 200);
154
MyBitmap.Canvas.LineTo(480, 200);
158
MyBitmap.Canvas.TextOut(200, 225, 'Joint Style:');
160
MyBitmap.Canvas.Pen.Width := 10;
161
MyBitmap.Canvas.Pen.EndCap := pecRound;
163
MyBitmap.Canvas.TextOut(200, 250, 'pjsRound');
164
MyBitmap.Canvas.Pen.JoinStyle := pjsRound;
165
MyLine[0] := Point(200, 275);
166
MyLine[1] := Point(250, 275);
167
MyLine[2] := Point(250, 325);
168
MyBitmap.Canvas.Polyline(MyLine);
170
MyBitmap.Canvas.TextOut(300, 250, 'pjsBevel');
171
MyBitmap.Canvas.Pen.JoinStyle := pjsBevel;
172
MyLine[0] := Point(300, 275);
173
MyLine[1] := Point(350, 275);
174
MyLine[2] := Point(350, 325);
175
MyBitmap.Canvas.Polyline(MyLine);
177
MyBitmap.Canvas.TextOut(400, 250, 'pjsMiter');
178
MyBitmap.Canvas.Pen.JoinStyle := pjsMiter;
179
MyLine[0] := Point(400, 275);
180
MyLine[1] := Point(450, 275);
181
MyLine[2] := Point(450, 325);
182
MyBitmap.Canvas.Polyline(MyLine);
184
{ Draw the bitmap to the form }
185
Canvas.Draw(0, 0, MyBitmap);