O'Reilly logo

Delphi for .NET Developer’s Guide by Xavier Pacheco

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Drawing Shapes

Graphics drawing wouldn’t be graphics drawing if you couldn’t draw shapes. GDI+ supports the Rectangle, Ellipse, Polygon, and Pie shapes and also gives you the ability to draw other shapes that don’t fit these common ones.

Drawing Rectangles

Drawing rectangles is simple. You use the Rectangle class to define the rectangle boundaries, and then you draw it using whatever Pen and Brush you choose. Listing 7.8 shows the code for drawing a rectangle.

Listing 7.8. Drawing a Rectangle
1: procedure DrawRectangle(aBrush: Brush); 2: var 3: MyRect: Rectangle; 4: begin 5: MyPen.Width := 5; 6: MyRect := Rectangle.Create(10, 10, 500, 250); 7: MyGraphics.DrawRectangle(MyPen, MyRect); 8: if Assigned(aBrush) then 9: MyGraphics.FillRectangle(aBrush, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required