To draw rectangles, you need a Graphics object and a Pen object. Pen blackPen = new Pen(Color.FromArgb(255, 0, 0, 0), 5) Į.Graphics.DrawRectangle(blackPen, 10, 10, 100, 50) ĭim blackPen As New Pen(Color.FromArgb(255, 0, 0, 0), 5)Į.Graphics.DrawRectangle(blackPen, 10, 10, 100, 50)Ī rectangle is defined by its Width, Height, and upper-left corner represented by the Location property. The example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The enlarged view of the upper-left corner of the rectangle shows that the thick black lines are centered on those dotted lines. The dotted lines show where the rectangle would have been drawn if the pen width had been one pixel. The following illustration shows the resulting rectangle. For more details on pen alignment, see How to: Set Pen Width and Alignment. Because the pen width is 5, the sides of the rectangle are drawn 5 pixels wide, such that 1 pixel is drawn on the boundary itself, 2 pixels are drawn on the inside, and 2 pixels are drawn on the outside. When the rectangle is drawn, the pen is centered on the rectangle's boundary. The second argument passed to the Pen constructor indicates that the pen width is 5 pixels. The rectangle has a width of 100 and a height of 50. The following example draws a rectangle with its upper-left corner at (10, 10). Implements IEquatable(Of Rectangle) Public Structure Rectangle Inheritance Type Rectangle = struct Public Structure Rectangle Type Rectangle = struct type Rectangle = struct Public struct Rectangle : IEquatable public struct Rectangle public struct Rectangle : IEquatable public value class Rectangle : IEquatable public value class Rectangle Stores a set of four integers that represent the location and size of a rectangle.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |