I try to use this code to make a grid

i try to use this code to make a grid, the horizontal line are fine, but the Vertical line are very strange, it skip some pixels. why?? i think it is very simple.

for (int i=0; i<500; i++) {
    ofLine(0, i*2, ofGetWidth(), i*2);
    ofLine(i*2,0 , i*2, ofGetHeight());


I don’t know the cause of your monitor’s strange output for sure, but I think your monitor is the source of the trouble. Would you like to check into the matter by using another monitor.
And the interval of lines may be too short. ofLine’s width is 2 pixels by default, so If the interval is more than three, the problem will be solved.

I would be glad if I could help you even just a little.


I think that something is happening because of aliasing which basiclly is that pixel of your screen are hiding pixels of your app.

Try with another line width (ofSetLineWidth()), some smoothing (ofEnableAntiAliasing() ofEnableSmoothing()) or a bigger step between your lines (as10 instead of 2 to understand what’s really happening.

This works for me:

ofSetColor(255, 0, 0);

for (int i=0; i<500; i++) {

    ofRect(0, i*2, ofGetWidth(), 1);
    ofRect(i*2,0 , 1, ofGetHeight());