Class

RoundRectShape

Shape


Description

Draws a (two-dimensional) rounded rectangle in a vector graphics environment.

Methods

Name

Parameters

Returns

Shared

Contains

x As Double, y As Double

Boolean

Property descriptions


RoundRectShape.BorderColor

BorderColor As Color

The color of the object's border.


RoundRectShape.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 a rounded rectangle:

Var shape As New RoundRectShape

shape.X = 200
shape.Y = 200
shape.BorderColor = Color.Blue
shape.BorderOpacity = 50
shape.BorderWidth = 3.0
shape.CornerWidth = 16
shape.CornerHeight = 16
shape.FillColor = Color.Red

g.DrawObject(shape)

RoundRectShape.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.


RoundRectShape.CornerHeight

CornerHeight As Double

The height of the inset corner oval.


RoundRectShape.CornerWidth

CornerWidth As Double

The width of the inset corner oval.


RoundRectShape.FillColor

FillColor As Color

The color of the interior of the shape.


RoundRectShape.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 shape As New RoundRectShape

shape.X = 200
shape.Y = 200

shape.BorderColor = Color.Blue
shape.BorderOpacity = 50
shape.BorderWidth = 3.0
shape.CornerWidth = 16
shape.CornerHeight = 16
shape.FillColor = Color.Red
shape.FillOpacity = 50

g.DrawObject(shape)

RoundRectShape.Height

Height As Double

The height of the rectangle.

This example sets the height and width of the shape to 150 pixels.

Var shape As New RoundRectShape

shape.X = 150
shape.Y = 150

shape.CornerWidth = 16
shape.CornerHeight = 16
shape.FillColor = Color.Red

g.DrawObject(shape)

RoundRectShape.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 rounded rectangle 0.9 radians.

Var shape As New RoundRectShape

shape.X = 150
shape.Y = 150

shape.CornerWidth = 16
shape.CornerHeight = 16
shape.FillColor = Color.Red
shape.Rotation = 0.9

g.DrawObject(shape)

RoundRectShape.Scale

Scale As Double

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

The following code rescales the rounded rectangle by a factor of 1.5.

Var shape As New RoundRectShape

shape.X = 150
shape.Y = 150

shape.CornerWidth = 16
shape.CornerHeight = 16
shape.FillColor = Color.Red
shape.Scale = 1.5

g.DrawObject(shape)

RoundRectShape.Segments

Segments As Integer

The number of polygon sides to use when approximation is needed. Zero means it's up to the renderer.


RoundRectShape.Width

Width As Double

The width of the rectangle.

This example sets the Width to 150 pixels.

Var shape As New RoundRectShape

shape.X = 150
shape.Y = 150

shape.CornerWidth = 16
shape.CornerHeight = 16
shape.FillColor = Color.Red

g.DrawObject(shape)

RoundRectShape.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 shape As New RoundRectShape

shape.X = 100
shape.Y = 150

shape.CornerWidth = 16
shape.CornerHeight = 16
shape.FillColor = Color.Red

g.DrawObject(shape)

RoundRectShape.Y

Y As Double

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

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

Var shape As New RoundRectShape

shape.X = 150
shape.Y = 100

shape.CornerWidth = 16
shape.CornerHeight = 16
shape.FillColor = Color.Red

g.DrawObject(shape)

Method descriptions


RoundRectShape.Contains

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

Tests whether the object contains the point x, y. Returns True if the rectangle contains the point specified by x, y.

Note

If you want to use Contains, make sure to set the X and Y properties and do not pass the these to the Graphics.DrawObject method. Graphics.DrawObject parameters are the offset where the object will be drawn.

This code tests whether the RoundRectShape contains the passed point:

Var shape As New RoundRectShape

shape.Width = 75
shape.Height = 75
shape.BorderOpacity = 100
shape.Bordercolor = Color.Black
shape.FillColor = Color.Teal
shape.BorderWidth = 2.5
shape.Rotation = -0.78

If shape.Contains(50, 50) Then
' draw something here..
End If

g.DrawObject(shape)

Sample code

The following method in the Paint event of a window draws a square with rounded corners.

Var shape As New RoundRectShape

shape.Width = 75
shape.Height = 75
shape.BorderOpacity = 100
shape.BorderColor = Color.RGB(0, 0, 0)
shape.BorderWidth = 2.5
shape.FillColor = Color.RGB(255, 102, 102)
shape.CornerHeight = 15
shape.CornerWidth = 15

g.DrawObject(shape, 50, 50)

Compatibility

Project Types

Console, Desktop, Web

Operating Systems

All