Class

Group2D


Description

Used to group Object2D objects.

Methods

Name

Parameters

Returns

Shared

AddObject

object2D As Object2D

AddObjectAt

index As Integer, object2D As Object2D

Item

index As Integer

RemoveObject

object2D As Object2D

RemoveObjectAt

index As Integer

Property descriptions


Group2D.BorderColor

BorderColor As Color

The color of the object's border.


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


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


Group2D.Count

Count As Integer

The number of Object2D objects the group contains.

This example reports that there are two objects in the Group2D.

Var px As PixmapShape
Var tshape As TextShape
Var group As New Group2D
Var i As Integer

px = New PixmapShape(DSC_0343)
group.Add(px)

tshape = New TextShape
tshape.Y = 70
tshape.Text = "This is what I call a REAL car!"
tshape.FontName = "Helvetica"
tshape.Bold = True
group.Add(t)
i = group.Count
TextField1.Text = i.ToString
g.DrawObject(group)

Group2D.FillColor

FillColor As Color

The color of the interior of the shape.


Group2D.FillOpacity

FillOpacity As Double

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


Group2D.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 oval As New OvalShape
oval.Width = 60
oval.Height = 120
oval.FillColor = Color.Red

Var group As New Group2D
group.AddObject(oval)
group.Rotation = 0.90
group.BorderWidth = 2.75
g.DrawObject(oval)

Group2D.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 oval As New OvalShape
oval.Width = 60
oval.Height = 120
oval.FillColor = Color.Red

Var group As New Group2D
group.AddObject(oval)
group.Scale = 1.5
group.Rotation = .90
group.Border = 100
group.BorderColor = &c0000ff
group.BorderWidth = 2.75
group.FillOpacity = 50
group.FillColor = Color.Blue
g.DrawObject(group)

Group2D.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 oval As New OvalShape
oval.Width = 60
oval.Height = 120
oval.FillColor = Color.Red

Var group As New Group2D
group.AddObject(oval)
group.X = 100
group.Border = 100
group.BorderColor = &c0000ff
group.FillOpacity = 50
group.FillColor = Color.Blue
g.DrawObject(group)

Group2D.Y

Y As Double

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

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

Var oval As New OvalShape
oval.Width = 60
oval.Height = 120
oval.FillColor = Color.Red

Var group As New Group2D
group.AddObject(o)
group.Y = 100
group.Border = 100
group.BorderColor = Color.Black
group.FillOpacity = 50
group.FillColor = Color.Yellow
g.DrawObject(group)

Method descriptions


Group2D.AddObject

AddObject(object2D As Object2D)

Adds the object passed to it.

This example uses add the passed object twice to construct the Group2D object.

Var px As PixmapShape
Var tshape As TextShape
Var group As New Group2D

px = New PixmapShape(DSC_0343)
group.Add(px)

tshape = New TextShape
tshape.Y = 70
tshape.Text = "This is what I call a REAL car!"
tshape.FontName = "Helvetica"
tshape.Bold = True
group.AddObject(tshape)

g.DrawObject(group)

Group2D.AddObjectAt

AddObjectAt(index As Integer, object2D As Object2D)

Adds the object passed to it at the specified location.

This example adds text as the second object in the Group2D.

Var px As PixmapShape
Var tShape As TextShape
Var tShape2 As TextShape
Var group As New Group2D
Var o As New Object2D

px = New PixmapShape(DSC_0343)
d.AddObject(px)

tShape = New TextShape
tShape.Y = 70
tShape.Text = "This is what I call a REAL car!"
tShape.FontName = "Helvetica"
tShape.Bold = True
d.AddObject(tShape)

tShape2 = New TextShape

tShape2.Y = 20
tShape2.Text = "This is inserted text!"
tShape2.FontName = "Helvetica"
tShape2.Bold = True
group.AddObjectAt(1, tShape2)

g.DrawObject(group)

Group2D.Item

Item(index As Integer)

Returns the Object2D object specified by Index.

This code gets the first object in the Group2D.

Var px As PixmapShape
Var tShape As TextShape
Var group As New Group2D
Var o As New Object2D

px = New PixmapShape(DSC_0343)
d.Add(px)

tShape = New TextShape
tShape.Y = 70
tShape.Text = "This is what I call a REAL car!"
tShape.TextFont = "Helvetica"
tShape.Bold = True
group.Add(t)

g.DrawObject(group)

o = group.Item(0)

Group2D.RemoveObject

RemoveObject(object2D As Object2D)

Removes the specified object.


Group2D.RemoveObjectAt

RemoveObjectAt(index As Integer)

Removes an object specified by its reference.

This code removes the first object, which is the image:

Var px As PixmapShape
Var tShape As TextShape
Var group As New Group2D
Var o As New Object2D

px = New PixmapShape(DSC_0343)
group.AddObject(px)

tShape = New TextShape
tShape.Y = 70
tShape.Text = "This is what I call a REAL car!"
tShape.FontName = "Helvetica"
tShape.Bold = True
group.AddObject(tShape)

group.RemoveObjectAt(0)
g.DrawObject(group)

This example also removes the second item, which is the text.

Var px As PixmapShape
Var tShape As TextShape
Var group As New Group2D
Var o As New Object2D

px = New PixmapShape(DSC_0343)
group.Add(px)

tShape = New TextShape
tShape.Y = 70
tShape.Text = "This is what I call a REAL car!"
tShape.FontName = "Helvetica"
tShape.IsBold = True
group.Add(tShape)

d.Remove(group.Item(1))
g.DrawObject(group)

Notes

Use the Objects property of the Picture class to associate a Group2D object with a picture and the DrawObject method of the Graphics class to draw the object.

A Group2D is a container for Object2D shapes (including other Group2Ds). When a Group2D is rotated, translated, or scaled, all of its contents are updated accordingly. This means that all objects use the same coordinate system, but you can quickly transform an entire set of objects by transforming their group.

Sample code

This code adds a PixMapShape and a TextShape to the Group2D object and displays it in the window. The code is in the Paint event. The picture DSC_0343 has been added to the Project.

Var px As PixmapShape
Var tShape As TextShape
Var group As New Group2D

px = New PixmapShape(DSC_0343) ' added to the project
group.AddObject(px)

tShape = New TextShape
tShape.Y=70
tShape.Text = "This is what I call a REAL car!"
tShape.FontName="Helvetica"
tShape.Bold = True
group.AddObject(tShape)
g.DrawObject(group)

Compatibility

All project types on all supported operating systems.