GDI+ Shapes: Arcs |
|
Description |
An arc is a portion or segment of an ellipse, meaning an arc is a non-complete ellipse. While a pie is a closed shape, an arc is not: it uses only a portion of the line that defines an ellipse. Because an arc must confirm to the shape of an ellipse, it is defined as it fits in a rectangle and can be illustrated as follows: |
To support arcs, the Graphics class is equipped with the DrawArc() method that is provided in four versions whose syntaxes are: Public Sub DrawArc ( _ pen As Pen, _ rect As Rectangle, _ startAngle As Single, _ sweepAngle As Single _ ) Public Sub DrawArc ( _ pen As Pen, _ rect As RectangleF, _ startAngle As Single, _ sweepAngle As Single _ ) Public Sub DrawArc ( _ pen As Pen, _ x As Integer, _ y As Integer, _ width As Integer, _ height As Integer, _ startAngle As Integer, _ sweepAngle As Integer _ ) Public Sub DrawArc ( _ pen As Pen, _ x As Single, _ y As Single, _ width As Single, _ height As Single, _ startAngle As Single, _ sweepAngle As Single _ ) The ellipse that would contain the arc must be drawn in a Rectangle or a RectangleF rect. You can also define that ellipse by the coordinates of its inscribed rectangle x, y, and its dimensions width, height. Besides the borders of the rectangle in which the arc would fit, an arc must specify its starting angle, startAngle, measured clockwise from the x-axis its starting point. An arc must also determine its sweep angle measured clockwise from the startAngle parameter to the end of the arc. These two value follow the same definitions we reviewed for the Graphics.Pie() method. Here is an example: Imports System.Drawing Imports System.Windows.Forms Module Exercise Public Class Starter Inherits Form Dim components As System.ComponentModel.Container Public Sub New() InitializeComponent() End Sub Public Sub InitializeComponent() End Sub Private Sub FormPaint(ByVal sender As Object, _ ByVal e As PaintEventArgs) _ Handles MyBase.Paint Dim penCurrent As Pen = New Pen(Color.Red) e.Graphics.DrawArc(penCurrent, 20, 20, 200, 150, 225, 200) End Sub End Class Function Main() As Integer Dim frmStart As Starter = New Starter Application.Run(frmStart) Return 0 End Function End Module
|
|
||
Home | Copyright © 2008-2016, FunctionX, Inc. | Home |
|