Class

GraphicsPath


Description

A graphics path is a mathematical description of a series of shapes or lines.

Properties

Name

Type

Read-Only

Shared

CurrentPoint

Point

IsEmpty

Boolean

IsRectangle

Boolean

Methods

Name

Parameters

Returns

Shared

AddArc

x As Double, y As Double, radius As Double, startAngle As Double, endAngle As Double, counterclockwise As Boolean

AddCurveToPoint

cp1x As Double, cp1y As Double, cp2X As Double, cp2Y As Double, x As Double, y As Double

AddLineToPoint

x As Double, y As Double

AddQuadraticCurveToPoint

cpX As Double, cpY As Double, x As Double, y As Double

AddRectangle

x As Double, y As Double, width As Double, height As Double

AddRoundRectangle

x As Double, y As Double, width As Double, height As Double, cornerWidth As Double, cornerHeight As Double

Bounds

Rect

Contains

x As Double, y As Double

Boolean

pt As Point

Boolean

MoveToPoint

x As Double, y As Double

Property descriptions


GraphicsPath.CurrentPoint

CurrentPoint As Point

The point at which the next drawing will take place.

This property is read-only.

Drawing methods like AddLineToPoint will change the CurrentPoint. MoveToPoint also changes the CurrentPoint.


GraphicsPath.IsEmpty

IsEmpty As Boolean

Checks if the path is empty. An empty path contains no elements.

This property is read-only.


GraphicsPath.IsRectangle

IsRectangle As Boolean

Checks if the path is a rectangle.

This property is read-only.

Method descriptions


GraphicsPath.AddArc

AddArc(x As Double, y As Double, radius As Double, startAngle As Double, endAngle As Double, counterclockwise As Boolean)

Adds an arc to the path.

The ending point of the Arc becomes the start point for the next element added to the path. In particular, if you add two arcs in a row, there will be a line that connects the ending point of the first arc to the starting point of the second arc. If you do not want this behavior, set the new starting point manually using MoveToPoint.

Draw an arc that is 1/4 of a circle:

Const Pi = 3.14159
Var arc As New GraphicsPath
arc.AddArc(50, 50, 20, 0, Pi / 2, False)
g.DrawPath(arc)

GraphicsPath.AddCurveToPoint

AddCurveToPoint(cp1x As Double, cp1y As Double, cp2X As Double, cp2Y As Double, x As Double, y As Double)

Adds a cubic Bézier curve to the point in the path.

Draw a cloud:

Var curve As New GraphicsPath
curve.MoveToPoint(20, 20)
curve.AddCurveToPoint(20, 100, 200, 100, 200, 20)
g.DrawPath(curve)

' Draw a fluffy white cloud
Var cloud As New GraphicsPath
cloud.MoveToPoint(170, 80)
cloud.AddCurveToPoint(130, 100, 130, 150, 230, 150)
cloud.AddCurveToPoint(250, 180, 320, 180, 340, 150)
cloud.AddCurveToPoint(420, 150, 420, 120, 390, 100)
cloud.AddCurveToPoint(430, 40, 370, 30, 340, 50)
cloud.AddCurveToPoint(320, 5, 250, 20, 250, 50)
cloud.AddCurveToPoint(200, 5, 150, 20, 170, 80)

g.DrawingColor = &c0000FF
g.PenSize = 5
g.DrawPath(cloud)

GraphicsPath.AddLineToPoint

AddLineToPoint(x As Double, y As Double)

Draws a line from the CurrentPoint to the specified point.

Draw a triangle:

Var p As New GraphicsPath
p.MoveToPoint(10, 5) ' Start location
p.AddLineToPoint(40, 40)
p.AddLineToPoint(5, 60)

g.DrawingColor = &c0000FF
g.DrawPath(p, True)

' Use FillPath to draw a filled triangle

GraphicsPath.AddQuadraticCurveToPoint

AddQuadraticCurveToPoint(cpX As Double, cpY As Double, x As Double, y As Double)

Adds a quadratic Bézier curve to the point in the path.

Draw a curve:

Var qCurve As New GraphicsPath
qCurve.MoveToPoint(38, 150)
qCurve.AddQuadraticCurveToPoint(138, 0, 238, 150)

g.PenSize = 10
g.DrawPath(qCurve)

GraphicsPath.AddRectangle

AddRectangle(x As Double, y As Double, width As Double, height As Double)

Adds a rectangle to the path.

A simple rectangle:

Var rect As New GraphicsPath
rect.AddRectangle(10, 10, 100, 150)
g.DrawPath(rect)

GraphicsPath.AddRoundRectangle

AddRoundRectangle(x As Double, y As Double, width As Double, height As Double, cornerWidth As Double, cornerHeight As Double)

Adds a rounded rectangle to the path.

A simple rounded rectangle:

Var rect As New GraphicsPath
rect.AddRoundRectangle(10, 10, 100, 150, 10, 10)
g.DrawPath(rect)

GraphicsPath.Bounds

Bounds As Rect

Returns the boundary of the GraphicsPath.

Important

This is not currently supported for Android.


GraphicsPath.Contains

Contains(x As Double, y As Double) As Boolean

Returns True if the coordinates passed are within bounds of the GraphicsPath.

Important

This is not currently supported for Android.

Contains(pt As Point) As Boolean

Returns True if the point passed is within bounds of the GraphicsPath.

Important

This is not currently supported for Android.


GraphicsPath.MoveToPoint

MoveToPoint(x As Double, y As Double)

Moves to the point without drawing anything.

Var p As New GraphicsPath
p.MoveToPoint(50, 50)

Compatibility

All project types on all supported operating systems.

See also

Object parent class; Canvas control; Window, DesktopContainer classes, Graphics.DrawPath, Graphics.FillPath methods