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, ... |
Get Delphi for .NET Developer’s Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.