Class

FigureShape


Description

Used to draw vector graphic shapes composed of lines and curves. It is similar to a polygon except that a “side” may be curved. A figure consists of a set of CurveShapes, with the end point of one curve automatically joined to the starting point of the next.

Methods

Name

Parameters

Returns

Shared

AddCubic

X As Single, Y As Single, X2 As Single, Y2 As Single, CX As Single, CY As Single, CX2 As Single, CY2 As Single

AddCurve

Curve As CurveShape

AddCurveAt

Index As Integer, Curve As CurveShape

AddLine

X As Single, Y As Single, X2 As Single, Y2 As Single

AddQuad

X As Single, Y As Single, X2 As Single, Y2 As Single, CX As Single, CY As Single

CurveAt

index as Integer

CurveShape

index as Integer, Assigns value As CurveShape

RemoveCurve

Curve As CurveShape

RemoveCurveAt

Index As Integer

Property descriptions


FigureShape.BorderColor

BorderColor As Color

The color of the object's border.


FigureShape.BorderOpacity

BorderOpacity As Double

Indicates the level of opacity.

Degrees of transparency is currently supported only on macOS and Windows. On other platforms, the border is either visible (100%) or invisible.

The following code adds a border to an FigureShape:

Var a As New FigureShape
a.BorderOpacity = 100
g.DrawObject(a)

FigureShape.BorderWidth

BorderWidth As Double

The width of the border, in points. The default is 1.

The width a Double value with a default of 1.0.


FigureShape.Count

Count As Integer

The number of CurveShapes.

This property is read-only.

Var fx As New FigureShape
.
.
Label1.Text = Str(fx.Count)

FigureShape.FillColor

FillColor As Color

The color of the interior of the shape.


FigureShape.FillOpacity

FillOpacity As Double

The opacity of the interior, from 0 (completely transparent) to 100 (opaque).

This example sets the Fill to 50% opacity.

Var a As New FigureShape
a.BorderOpacity = 100
a.BorderColor = Color.Black
a.BorderWidth = 2.75
a.FillOpacity = 50
g.DrawObject(a)

FigureShape.Rotation

Rotation As Double

Clockwise rotation, in radians, around the X, Y point. Only set the rotation after you have drawn all your objects.

This code rotates the arc 0.9 radians.

Var a As New FigureShape
a.Rotation = 0.90
a.BorderOpacity = 100
a.BorderColor = Color.Black
a.BorderWidth = 2.75
g.DrawObject(a)

FigureShape.Scale

Scale As Double

The scaling factor relative to the object's original size.

The following code rescales the arc by a factor of 1.5.

Var a As New FigureShape
a.Scale = 1.5
a.Rotation = .90
a.BorderOpacity = 100
a.BorderColor = &c0000ff
a.BorderWidth = 2.75
g.DrawObject(a)

FigureShape.ValueAt

ValueAt As CurveShape

Gets or sets the specified curve.

The following gets the color of the first CurveShape.

Var c As Color
c = fx.ValueAt(0).FillColor

FigureShape.X

X As Double

The horizontal position of the center or main anchor point.

This example sets the horizontal position to 100 pixels from the left of the containing Canvas.

Var a As New FigureShape
a.X = 100
a.BorderOpacity = 100
a.BorderColor = &c0000ff
g.DrawObject(a)

FigureShape.Y

Y As Double

The vertical position (down from top) position of the center or anchor point.

This example moves the position of the shape down 100 pixels from the top of the containing Canvas.

Var a As New FigureShape
a.Y = 100
a.BorderOpacity = 100
a.BorderColor = &c0000ff
g.DrawObject(a)

Method descriptions


FigureShape.AddCubic

AddCubic(X As Single, Y As Single, X2 As Single, Y2 As Single, CX As Single, CY As Single, CX2 As Single, CY2 As Single)

Adds a cubic curve to the figure.

The starting and ending points are x,y and x2, y2, respectively. This is a shortcut for adding a CurveShape. CX, CY, CX2, and CY2 are the control points, Control X(i) and ControlY(i) in a CurveShape.


FigureShape.AddCurve

AddCurve(Curve As CurveShape)

Adds the passed CurveShape to the figure.


FigureShape.AddCurveAt

AddCurveAt(Index As Integer, Curve As CurveShape)

Adds the passed CurveShape at the position indicated by Index.


FigureShape.AddLine

AddLine(X As Single, Y As Single, X2 As Single, Y2 As Single)

Adds a straight line to the figure.

X and Y are the starting coordinates; X2 and Y2 are the end coordinates.

The following example draws a triangle. The code is placed in the Paint event of a Window or Canvas.

Var fx As New FigureShape
fx.AddLine(0, 100, 50, 0)
fx.AddLine(50, 0, -50, 0)
fx.Border = 100 ' opaque border
fx.BorderColor = Color.Red
fx.FillColor = Color.Yellow
g.DrawObject(fx)

FigureShape.AddQuad

AddQuad(X As Single, Y As Single, X2 As Single, Y2 As Single, CX As Single, CY As Single)

Adds a quadratic curve to the figure.

The starting and ending points are x,y and x2, y2, respectively. This is a shortcut for adding a CurveShape. CX, CY, CX2, and CY2 are the control points, Control X(i) and ControlY(i) in a CurveShape.


FigureShape.CurveAt

CurveAt(index As Integer) As CurveShape

Returns the CurveShape at the index passed.


CurveAt(index As Integer, Assigns value As CurveShape)

Assigns the value to the index passed.


FigureShape.RemoveCurve

RemoveCurve(Curve As CurveShape)

Removes the specified curve.


FigureShape.RemoveCurveAt

RemoveCurveAt(Index As Integer)

Removes the curve at the specified index.

Notes

A figure is formed by drawing each curve it contains in order, joining the endpoint of one to the starting point of the next. The figure is degenerate if doing so does not enclose any area. This will be the case for a figure containing only one line, for example. The appearance of a degenerate figure is undefined.

AddLine, AddCubic, and AddQuad are convenience methods that make it easier to add curves to the figure. You could instead create your own CurveShapes, and add them with the AddCurve or AddCurveAt methods.

Sample code

The following example draws a triangle. The code is placed in the Paint event of a Window or Canvas.

Var fx As New FigureShape
fx.AddLine(0, 100, 50, 0)
fx.AddLine(50, 0, -50, 0)
fx.Border = 100  ' opaque border
fx.BorderColor = Color.Red
fx.FillColor = Color.Yellow
g.DrawObject(fx)

Compatibility

Desktop and web project types on all supported operating systems.