# Crazy pixels with MovieClip.graphics.drawRect(...)

**URL:** <https://forum.kirupa.com/t/crazy-pixels-with-movieclip-graphics-drawrect/237109>\
**Category:** flash\
**Created:** [August 27, 2007, 12:40pm UTC](https://forum.kirupa.com/t/crazy-pixels-with-movieclip-graphics-drawrect/237109 "2007-08-27T12:40:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zomis](https://avatars.discourse-cdn.com/v4/letter/z/e56c9b/32.png) [@Zomis](https://forum.kirupa.com/u/Zomis)\
**Post date:** [August 27, 2007, 12:40pm UTC](https://forum.kirupa.com/t/crazy-pixels-with-movieclip-graphics-drawrect/237109/1 "2007-08-27T12:40:22Z")

</div>

I wanted to create a matrix of squares, each square has a side of 4 pixels.  
I wanted these squares to be placed with an empty space between them of 4 pixels.  
Something like this:  
X#X

### 

X#X  
Where “X” indicates square and “#” indicates empty space

So I started doing some code… and my code didn’t turn out as expected. Somehow, the height of my squares got a little bigger than the width… I got a rectangle of 5x10 or 6x10 pixels (and an additional black border of 1 pixels, as expected) so I had to decrease the height of the rectangle…

```auto
var size = 4;
var i=0;
for (var x1=4;x1<200;x1+=size+4)
for (var y1=4;y1<100;y1+=size+4) {
    var c = 0xFF0000;
    i++;
    mc2.graphics.lineStyle(0);
    mc2.graphics.beginFill(c);
    mc2.graphics.drawRect(x1,y1,size,size-1.5);
    mc2.graphics.endFill();
}

```

This gave me squares of 6x6 pixels. But the distance (border to border) between them is  
6 width but 15 height… if I decrease the “4” in the code “y1+=size+4” it helps. But I wonder why  
mc2.graphics.drawRect(x1,y1,size,size);  
doesn’t give me equally sized squares of 4x4??

I guess it’s something basic I’ve missed, I’m just not sure WHAT…
