#include <psychlops.h>
using namespace Psychlops;

const int dotsize=4;
const int width=100;
double height=50;
double temp1;
double speed=1;
double phase=0;
int frame=0;
Psychlops::Rectangle rect1[width];
Psychlops::Color col;
Psychlops::Image Noise1[width];

void psychlops_main() {

	Canvas sampleA(Canvas::fullscreen);
	
 	for(int x=0; x<width; x++){
		Noise1[x].set(dotsize,height*dotsize);
		rect1[x].set(dotsize, dotsize);
		for(int y=0; y<height; y++){
			temp1=Psychlops::random();
			col.set(temp1);
			Noise1[x].rect(rect1[x],col);
			rect1[x].shift(0, dotsize);
		}	
	}
	while(!Input::get(Keyboard::spc)){
 		for(int x=0; x<width; x++){
 			phase=(double)-1/2*(width*dotsize)+(int)(x*dotsize+frame*speed*dotsize)%(int)(width*dotsize);
			Noise1[x].centering().shift(phase,0);
			Noise1[x].draw();
		}
		sampleA.flip();
		frame++;
	}
}