Class
Group2D
Description
Used to group Object2D objects.
Properties
Name |
Type |
Read-Only |
Shared |
---|---|---|---|
Methods
Name |
Parameters |
Returns |
Shared |
---|---|---|---|
object2D As Object2D |
|||
index As Integer |
|||
object2D As Object2D |
|||
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.
The following code adds a border to an ArcShape:
Var a As New ArcShape
a.ArcAngle = 1.57
a.StartAngle = -1.57
a.BorderOpacity = 100
a.FillColor = Color.RGB(255, 0, 127)
g.DrawObject(a, 100, 100)
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 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.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).
This example sets the Fill to 50% opacity.
Var a As New ArcShape
a.ArcAngle = 1.57
a.StartAngle = -1.57
a.BorderOpacity = 100
a.BorderColor = &c0000ff
a.BorderWidth = 2.75
a.FillOpacity = 50
a.FillColor = Color.RGB(255, 0, 127)
g.DrawObject(a, 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)
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 a As New ArcShape
a.Height = 150
a.Width = 150
a.ArcAngle = 1.57
a.StartAngle = -1.57
a.X = 100
a.Border = 100
a.BorderColor = &c0000ff
a.Fill = 50
a.FillColor = Color.RGB(255, 0, 127)
g.DrawObject(a, 100, 100)
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 arc down 100 pixels from the top of the containing Canvas.
Var a As New ArcShape
a.Height = 150
a.Width = 150
a.ArcAngle = 1.57
a.StartAngle = -1.57
a.Y = 100
a.Border = 100
a.BorderColor = &c0000ff
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.
See also
Object2D parent class; ArcShape, CurveShape, FigureShape, FolderItem, Graphics, OvalShape, Picture, PixmapShape, RectShape, RoundRectShape, TextShape classes.