///+ Prefix linkto BasicCode1 //// Lines for set up Psychlops environment #include <psychlops.h> using namespace Psychlops; ///- Prefix linkto BasicCode1 ///+ Main Routine //// Psychlops runs at the first line of this function psychlops_main(). void psychlops_main() { ///+ 0 SetGlobal ////Prepare global parameters ///+ 0.1 linkto BasicCode3_1a const int maxrectnum = 300; int rectnum = 300/*ID:rectnumber 25.0 300.0 25.0*/; double rectsize = 3.0/*ID:dotsize 1.0 10.0 1.0*/; Psychlops::Rectangle rect[maxrectnum]; double rectcolorR[maxrectnum]; double rectcolorG[maxrectnum]; double rectcolorB[maxrectnum]; ///- 0.1 linkto BasicCode3_1a double noisefield_Hsize = 100.0/*ID:fieldH 50.0 200.0 50*/; double noisefield_Vsize = 100.0/*ID:fieldV 50.0 200.0 50*/; double tempcol; ///- 0 SetGlobal Canvas window(Canvas::window); ///+ 1 Initialize ////Initialize for(int i=0; i < rectnum; i++){ ///+ 1.1 set1 ////set positions and sizes ///+ 1.1.1 linkto basiccode3_1a rect[i].set(rectsize, rectsize); //Set a size of rectangles. rect[i].centering(); ///- 1.1.1 linkto basiccode3_1a rect[i].shift((random(noisefield_Hsize) - 0.5 * noisefield_Hsize), (random(noisefield_Vsize) - 0.5 * noisefield_Vsize)); //Move Rectangles to initial positions ///- 1.1 set1 ///+ 1.2 set2 ////set colors tempcol=random(1.0); rectcolorR[i]=tempcol * 0.5/*ID:RGain 0.0 1.0 0.5*/; //Set R values. Note that "i" and "rectnum" is converted to double-type. rectcolorG[i]=tempcol * 0.5/*ID:GGain 0.0 1.0 0.5*/; //Set G values. Note that "i" and "rectnum" is converted to double-type. rectcolorB[i]=tempcol * 0.5/*ID:BGain 0.0 1.0 0.5*/; //Set B values. Note that "i" and "rectnum" is converted to double-type. ///- 1.2 set2 } ///- 1 Initialize ///+ 2 linkto basiccode3_1a ////drawing objects while(!Keyboard::esc.pushed()){ window.clear(Color::black); for(int i=0; i < rectnum; i++){ rect[i].draw(Color(rectcolorR[i], rectcolorG[i], rectcolorB[i])); //draw objects by designated colors. } window.flip(); } ///- 2 linkto basiccode3_1a } ///- Main Routine
./3_1c.xap