# Group2D questions

Hello,

I am writing a desktop application which need vectorial graphics with zoom an pan.
Forum readings show that Group2D is a handy way to do that.

So I have :

• a windows with a canvas named Canvas1
• a picture PictGraph
• a Group2d VectGraph

Into Canvas1.paint I have

g.DrawPicture PictGraph, 0, 0

In windows.opening :

``````Var VectGraph as new Group2D
Var PictGraph as new Picture (1000,1000,32)

// Add a rectangle to VectGraph

Var a as new RectShape
a.Height = 50
a.Width = 20
a.X = 100
a.Y = 50
a.FillColor = color.rgb(255, 0, 0)

// Add the Group2D to PictGraph
PictGraph.Graphics.DrawObject VectGraph, 0, 0

// Update Canvas1
Canvas1.Invalidate
``````

The app is running but I expect to get a rectangle into the canvas and… nothing displayed !

For sure I do something wrong but I dont understand what.

Any help appreciated.
Regards
Philippe

Is your Canvas width/heigh > 1000,1000 ?

No it is around 400x300 pixels.

You dont need PictGraph
To draw the Group2d , your canvas code can be

``````
dim VectGraph = new Group2D
// Add a rectangle to VectGraph
Var a as new RectShape
a.Height = 50
a.Width = 20
a.X = 100
a.Y = 50
a.FillColor = color.rgb(255, 0, 0)

g.drawobject(VectGraph,0,0)
``````

You could make VectGraph a property of the window, set the contents in the window opening event, and just use
if VectGraph <> nil then g.drawobject(VectGraph,0,0)
in the canvas’ Paint event

You are right the code works without PictGraph and using drawobject instead of drawpicture into Canvas1 paint event.

But always no rectangle on screen !

Have-you tried to change the X,Y values ?

I found the problem

Should use

``````VectGraph = new Group2D
``````

and not

``````Var VectGraph as new Group2D
``````