Drawing an array of rectangles

BryanZM

Member
Joined
Jun 30, 2003
Messages
23
Location
Montclair (Oakland)CA
Hello, First of all just let me say that Im relatively new to the drawing namespace.

Here is what im trying to do:
// Declare an array of rectangles...
Rectangle[] rects = {
new Rectangle(0,0,0,0),
new Rectangle(0,0,0,0),
new Rectangle(0,0,0,0),
new Rectangle(0,0,0,0),
new Rectangle(0,0,0,0),
new Rectangle(0,0,0,0),
new Rectangle(0,0,0,0),
new Rectangle(0,0,0,0),
new Rectangle(0,0,0,0),
new Rectangle(0,0,0,0)
} ;
bTimes = 5 ;
for(int i = 0;i<bTimes;i++)
{
yway = 5 * i ;
rects = new Rectangle(xway,yway,23,12) ;

}
g.DrawRectangles(pen,rects) ;

When the loop completes there is only one rectangle, allthough im pretty sure the array is filled with rectangles and I think it should draw them....

Also how can I define a empty array of rectangles with just a specified size???
Any help would be greatly apprectiated!!!

Thanks, Bryan
 
Have you tried changing the rectangles that you create in the array initializer?

You should set their Widths and Heights, otherwise the rectangle is empty, and it wont be drawn.
You also have ten rectangles there, but youre only setting five of them in the for loop. :)
 
Back
Top