Class

CurveShape


Description

Used for drawing lines and curves in a vector graphics environment.

Property descriptions


CurveShape.BorderColor

BorderColor As Color

The color of the object's border. In the case of a line (CurveShape), it's the color of the line itself.


CurveShape.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 CurveShape:

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

CurveShape.BorderWidth

BorderWidth As Double

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


CurveShape.ControlX

ControlX As Double

Use the zero-based index to access control points (horizontal position).

The following method is in the MouseDown event of a Window. It draws a simple curve when the user presses the mouse button. The negative value of ControlY(0) places the control point above the imaginary straight line from x,y to x2,y2.

Var c As New CurveShape
c.ControlX(0) = 120
c.ControlY(0) = -40
c.Order = 1
c.X = 10
c.Y = 100
c.X2 = 250
c.Y2 = 100

g.DrawObject(c, c.X, c.Y)

CurveShape.ControlY

ControlY As Double

Use the zero-based index to access control points (vertical position).

The following method is in the Paint event of a Window. It draws a simple curve when the user presses the mouse button. The negative value of ControlY(0) places the control point above the imaginary straight line from x,y to x2,y2.

Var c As New CurveShape
c.ControlX(0) = 120
c.ControlY(0) = -40
c.Order = 1
c.X = 10
c.Y = 100
c.X2 = 250
c.Y2 = 100

g.DrawObject(c, c.X, c.Y)

CurveShape.FillColor

FillColor As Color

The color of the interior of the shape.


CurveShape.FillOpacity

FillOpacity As Double

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

Note

FillOpacity has no effect on CurveShape objects because there is no area that is filled with a color.


CurveShape.Order

Order As Integer

The number of off-curve control points that are used.

It is one of the following values:

Value

Description

0

A straight line from X, Y to X2,Y2 is used.

1

A quadratic Bezier curve is drawn using one control point.

2

A cubic Bezier curve is drawn using two control points.

When following code is in the Paint event of a DesktopCanvas it draws a simple curve. The negative value of ControlY(0) places the control point above the imaginary straight line from X,Y to X2,Y2.

Var c As New CurveShape
c.ControlX(0) = 120
c.ControlY(0) = -40
c.Order = 1
c.X = 10
c.Y = 100
c.X2 = 250
c.Y2 = 100

g.DrawObject(c, c.X, c.Y)

CurveShape.Rotation

Rotation As Double

Clockwise rotation, in radians, around the X, Y point.

This code rotates the arc 0.9 radians.

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

CurveShape.Scale

Scale As Double

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

The following code draws two lines changing the scale of the second to 2:

Var a As New CurveShape
a.BorderOpacity = 100
a.BorderColor = Color.Black
a.BorderWidth = 2.75

Var b As New CurveShape
b.X = 50
b.Scale = 2
b.BorderOpacity = 100
b.BorderColor = Color.Red
b.BorderWidth = 2.75

g.DrawObject(a)
g.DrawObject(b)

CurveShape.Segments

Segments As Integer

The number of straight line segments to use to approximate a curve. The default value of zero will cause a "sensible" number of segments to be used.

When following code is in the Paint event of a DesktopCanvas it draws a simple curve. The negative value of ControlY(0) places the control point above the imaginary straight line from X,Y to X2,Y2.

Var c As New CurveShape
c.ControlX(0) = 120
c.ControlY(0) = -40
c.Order = 1
c.Segments = 3
c.X = 10
c.Y = 100
c.X2 = 250
c.Y2 = 100

g.DrawObject(c, c.X, c.Y)

CurveShape.X

X As Double

The horizontal position of the start of line or curve. The default value is 0.

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

Var a As New CurveShape
a.X = 100
a.BorderOpacity = 100
a.BorderColor = Color.Black
g.DrawObject(a)

CurveShape.X2

X2 As Double

The horizontal position of the end of the line or curve. The default value is X + 100.

The following method is in the Paint event of a Window. It draws a simple curve. The negative value of ControlY(0) places the control point above the imaginary straight line from X,Y to X2,Y2.

Var c As New CurveShape
c.ControlX(0) = 120
c.ControlY(0) = -40
c.Order = 1
c.X = 10
c.Y = 100
c.X2 = 250
c.Y2 = 100

g.DrawObject(c, c.X, c.Y)

CurveShape.Y

Y As Double

The vertical position of the end of the line or curve. The default value is 0.

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

Var a As New CurveShape
a.Y = 100
a.BorderOpacity = 100
a.BorderColor = Color.Black
g.DrawObject(a)

CurveShape.Y2

Y2 As Double

The vertical position of the end of the line or curve. The default value is Y + 100.

The following method is in the Paint event of a Window. It draws a simple curve. The negative value of ControlY(0) places the control point above the imaginary straight line from X,Y to X2,Y2.

Var c As New CurveShape
c.ControlX(0) = 120
c.ControlY(0) = -40
c.Order = 1
c.X = 10
c.Y = 100
c.X2 = 250
c.Y2 = 100

g.DrawObject(c, c.X, c.Y)

Notes

For CurveShapes, the default value for the BorderOpacity property is 100 and the default value for FillColor is 0.

When you set Order to zero, you get a straight line from X,Y to X2,Y2. You use control points when you want to 'bend' the line in a particular way. When you set Order to 1, the line bends towards ControlX(0),ControlY(0) on its way from X,Y to X2,Y2. This is what happens in the example. The further away the control point is, the more the line will deviate in that direction.

If Order is set to 2, there are two control points. The line will bend first towards ControlX(0),ControlY(0), and then towards ControlX(1),ControlY(1). At the end points, the curve points directly at the associated control point. The curve is guaranteed to always stay within the polygon formed by the endpoints and the control points (if any).

Sample code

The following method is in the Paint event of a Window. It draws a simple curve. The negative value of ControlY(0) places the control point above the imaginary straight line from X,Y to X2,Y2.

Var c As New CurveShape
c.ControlX(0) = 120
c.ControlY(0) = -40
c.Order = 1
c.X = 10
c.Y = 100
c.X2 = 250
c.Y2 = 100

g.DrawObject(c, c.X, c.Y)

Compatibility

Desktop and web project types on all supported operating systems.