I am trying to draw a gray code pattern on screen using ofDrawLine, but I am experiencing some strange artifacts. What is causing them? (im on osx)
The artifact looks like this: http://i.imgur.com/l1CmzEX.png
It is supposed to be two solid blocks of blackness, but somehow it goes wrong.
Any input is highly welcomed.
Kind regards
Jesper
Here is my code:
#include “ofApp.h”
void ofApp::setup(){
ofBackground(255,255,255);
ofSetFrameRate(60);
ofDisableAntiAliasing();
}
void ofApp::draw(){
//ofSetBackgroundAuto(false);
ofSetLineWidth(1.0);
for(int i=0; i<1680; i++)
{
int d = 0;
if( (i & (1 << bit)) != 0)
{
d++;
}
if( (i & (1 << (bit+1))) != 0)
{
//d++;
}
if(d == 1)
{
ofSetColor(255,255,255);
ofDrawLine(i,0,i,300);
}
else
{
ofSetColor(0,0,0);
ofDrawLine(i,0,i,300);
}
}
}
void ofApp::keyPressed(int key){
bit += 1;
if (bit > 11)
{
bit = 0;
}
}