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
|
unit pentest;
{$mode objfpc}{$H+}
interface
uses
Classes, Forms, Graphics;
type
{ TfrmPen }
TfrmPen = class(TForm)
procedure FormPaint(Sender: TObject);
private
public
end;
var
frmPen: TfrmPen;
implementation
{$R *.lfm}
{ TfrmPen }
procedure TfrmPen.FormPaint(Sender: TObject);
var
MyBitmap: TBitmap;
MyLine: array[0..2] of TPoint;
begin
MyBitmap := TBitmap.Create;
try
{ Set a size for the image }
MyBitmap.Height := Height;// 150
MyBitmap.Width := Width;// 400
{ After memory has been reserved by setting the size
of the image, we can start drawing }
// Background
MyBitmap.Canvas.Brush.Color := clWhite;
MyBitmap.Canvas.Pen.Color := clWhite;
MyBitmap.Canvas.Rectangle(0, 0, Width, Height);
// Explaning text
MyBitmap.Canvas.TextOut(100, 5,
'Brush: bsClear Pen: Black');
// Pen styles
MyBitmap.Canvas.TextOut(25, 30, 'Pen styles:');
MyBitmap.Canvas.TextOut(25, 60, 'psSolid');
MyBitmap.Canvas.TextOut(25, 90, 'psDash');
MyBitmap.Canvas.TextOut(25, 120, 'psDot');
MyBitmap.Canvas.TextOut(25, 150, 'psDashDot');
MyBitmap.Canvas.TextOut(25, 180, 'psDashDotDot');
MyBitmap.Canvas.TextOut(25, 210, 'psClear');
MyBitmap.Canvas.TextOut(25, 240, 'psInsideframe');
MyBitmap.Canvas.TextOut(25, 270, 'psPattern');
MyBitmap.Canvas.Brush.Style := bsClear;
MyBitmap.Canvas.Pen.Color := clBlack;
MyBitmap.Canvas.Pen.Style := psSolid;
MyBitmap.Canvas.Rectangle(Bounds(125, 60, 50, 25));
MyBitmap.Canvas.Pen.Style := psDash;
MyBitmap.Canvas.Rectangle(Bounds(125, 90, 50, 25));
MyBitmap.Canvas.Pen.Style := psDot;
MyBitmap.Canvas.Rectangle(Bounds(125, 120, 50, 25));
MyBitmap.Canvas.Pen.Style := psDashDot;
MyBitmap.Canvas.Rectangle(Bounds(125, 150, 50, 25));
MyBitmap.Canvas.Pen.Style := psDashDotDot;
MyBitmap.Canvas.Rectangle(Bounds(125, 180, 50, 25));
MyBitmap.Canvas.Pen.Style := psClear;
MyBitmap.Canvas.Rectangle(Bounds(125, 210, 50, 25));
MyBitmap.Canvas.Pen.Style := psInsideframe;
MyBitmap.Canvas.Rectangle(Bounds(125, 240, 50, 25));
MyBitmap.Canvas.Pen.Style := psPattern;
MyBitmap.Canvas.Rectangle(Bounds(125, 270, 50, 25));
// Line widths
MyBitmap.Canvas.TextOut(200, 30, 'Pen Widths:');
MyBitmap.Canvas.Pen.Style := psSolid;
MyBitmap.Canvas.TextOut(200, 55, 'Width = 0');
MyBitmap.Canvas.Pen.Width := 0;
MyBitmap.Canvas.MoveTo(200, 75);
MyBitmap.Canvas.LineTo(280, 75);
MyBitmap.Canvas.MoveTo(200, 75);
MyBitmap.Canvas.LineTo(280, 85);
MyBitmap.Canvas.MoveTo(200, 75);
MyBitmap.Canvas.LineTo(280, 95);
MyBitmap.Canvas.MoveTo(200, 75);
MyBitmap.Canvas.LineTo(280, 105);
MyBitmap.Canvas.MoveTo(200, 75);
MyBitmap.Canvas.LineTo(280, 115);
MyBitmap.Canvas.MoveTo(200, 75);
MyBitmap.Canvas.LineTo(280, 125);
MyBitmap.Canvas.TextOut(300, 55, 'Width = 1');
MyBitmap.Canvas.Pen.Width := 1;
MyBitmap.Canvas.MoveTo(300, 75);
MyBitmap.Canvas.LineTo(380, 75);
MyBitmap.Canvas.MoveTo(300, 75);
MyBitmap.Canvas.LineTo(380, 85);
MyBitmap.Canvas.MoveTo(300, 75);
MyBitmap.Canvas.LineTo(380, 95);
MyBitmap.Canvas.MoveTo(300, 75);
MyBitmap.Canvas.LineTo(380, 105);
MyBitmap.Canvas.MoveTo(300, 75);
MyBitmap.Canvas.LineTo(380, 115);
MyBitmap.Canvas.MoveTo(300, 75);
MyBitmap.Canvas.LineTo(380, 125);
MyBitmap.Canvas.TextOut(400, 55, 'Width = 2');
MyBitmap.Canvas.Pen.Width := 2;
MyBitmap.Canvas.MoveTo(400, 75);
MyBitmap.Canvas.LineTo(480, 75);
MyBitmap.Canvas.MoveTo(400, 75);
MyBitmap.Canvas.LineTo(480, 85);
MyBitmap.Canvas.MoveTo(400, 75);
MyBitmap.Canvas.LineTo(480, 95);
MyBitmap.Canvas.MoveTo(400, 75);
MyBitmap.Canvas.LineTo(480, 105);
MyBitmap.Canvas.MoveTo(400, 75);
MyBitmap.Canvas.LineTo(480, 115);
MyBitmap.Canvas.MoveTo(400, 75);
MyBitmap.Canvas.LineTo(480, 125);
// End Caps
MyBitmap.Canvas.TextOut(200, 150, 'Pen End Caps:');
MyBitmap.Canvas.Pen.Width := 10;
MyBitmap.Canvas.TextOut(200, 175, 'pecRound');
MyBitmap.Canvas.Pen.EndCap := pecRound;
MyBitmap.Canvas.MoveTo(200, 200);
MyBitmap.Canvas.LineTo(280, 200);
MyBitmap.Canvas.TextOut(300, 175, 'pecSquare');
MyBitmap.Canvas.Pen.EndCap := pecSquare;
MyBitmap.Canvas.MoveTo(300, 200);
MyBitmap.Canvas.LineTo(380, 200);
MyBitmap.Canvas.TextOut(400, 175, 'pecFlat');
MyBitmap.Canvas.Pen.EndCap := pecFlat;
MyBitmap.Canvas.MoveTo(400, 200);
MyBitmap.Canvas.LineTo(480, 200);
// Join Style
MyBitmap.Canvas.TextOut(200, 225, 'Joint Style:');
MyBitmap.Canvas.Pen.Width := 10;
MyBitmap.Canvas.Pen.EndCap := pecRound;
MyBitmap.Canvas.TextOut(200, 250, 'pjsRound');
MyBitmap.Canvas.Pen.JoinStyle := pjsRound;
MyLine[0] := Point(200, 275);
MyLine[1] := Point(250, 275);
MyLine[2] := Point(250, 325);
MyBitmap.Canvas.Polyline(MyLine);
MyBitmap.Canvas.TextOut(300, 250, 'pjsBevel');
MyBitmap.Canvas.Pen.JoinStyle := pjsBevel;
MyLine[0] := Point(300, 275);
MyLine[1] := Point(350, 275);
MyLine[2] := Point(350, 325);
MyBitmap.Canvas.Polyline(MyLine);
MyBitmap.Canvas.TextOut(400, 250, 'pjsMiter');
MyBitmap.Canvas.Pen.JoinStyle := pjsMiter;
MyLine[0] := Point(400, 275);
MyLine[1] := Point(450, 275);
MyLine[2] := Point(450, 325);
MyBitmap.Canvas.Polyline(MyLine);
{ Draw the bitmap to the form }
Canvas.Draw(0, 0, MyBitmap);
finally
MyBitmap.Free;
end;
end;
end.
|