Class

Group2D


Description

Used to group Object2D objects.

Properties

Name

Type

Read-Only

Shared

Count

Integer

Rotation

Double

Scale

Double

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.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 t As TextShape
Var d As New Group2D
Var i As Integer

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

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

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 a As New ArcShape
a.Height = 150
a.Width = 150
a.Rotation = 0.90
a.ArcAngle = 1.57
a.StartAngle = -1.57
a.Border = 100
a.BorderColor = &c0000ff
a.BorderWidth = 2.75
a.Fill = 50
a.FillColor = Color.RGB(255, 0, 127)
g.DrawObject(a, 100, 100)

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 a As New ArcShape
a.Scale = 1.5
a.Rotation = .90
a.ArcAngle = 1.57
a.StartAngle = -1.57
a.Border = 100
a.BorderColor = &c0000ff
a.BorderWidth = 2.75
a.Fill = 50
a.FillColor = Color.RGB(255, 0, 127)
g.DrawObject(a, 100, 100)

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 t As TextShape
Var d As New Group2D

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

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

g.DrawObject(d, 100, 100)

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 t As TextShape
Var t2 As TextShape
Var d As New Group2D
Var o As New Object2D

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

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

t2 = New TextShape

t2.Y = 20
t2.Value = "This is inserted text!"
t2.FontName = "Helvetica"
t2.Bold = True
d.AddObjectAt(1, t2)

g.DrawObject(d, 100, 100)

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 t As TextShape
Var d As New Group2D
Var o As New Object2D

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

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

g.DrawObject(d, 100, 100)

o = d.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 t As TextShape
Var d As New Group2D
Var o As New Object2D

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

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

d.RemoveObjectAt(0)
g.DrawObject(d, 100, 100)

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

Var px As PixmapShape
Var t As TextShape
Var d As New Group2D
Var o As New Object2D

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

t = New TextShape
t.Y = 70
t.Value = "This is what I call a REAL car!"
t.FontName = "Helvetica"
t.IsBold = True
d.Add(t)

d.Remove(d.Item(1))
g.DrawObject(d, 100, 100)

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 t As TextShape
Var d As New Group2D

px = New PixmapShape(DSC_0343) // added to the project
d.AddObject(px)

t = New TextShape
t.Y=70
t.Value = "This is what I call a REAL car!"
t.FontName="Helvetica"
t.Bold = True
d.AddObject(t)
g.DrawObject(d, 100, 100)

Compatibility

All project types on all supported operating systems.