///+ 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 Declaration ////Prepare global parameters Canvas window(Canvas::window); Psychlops::Image img; //Prepare "Image" class variable to make offscreen movie. Psychlops::Rectangle centerrect(10,10); int imageHsize = 100; //Width for offscreeen. int imageVsize = 60; //Height for offscreeen. double R,G,B; ///- 0 Declaration ///+ 1 Initialize ////Initialize image and set color to each pixel. img.set(imageHsize, imageVsize); //Allocate offscreen in main memory. for(int i=0; i < imageHsize; i++){ for(int j=0; j < imageVsize; j++){ ///+ 1.1 set1 ////set colors for each pixels R=random(1.0) * 0.5/*ID:RGain 0.0 1.0 0.5*/; //Set R values. G=random(1.0) * 0.5/*ID:GGain 0.0 1.0 0.5*/; //Set G values. B=random(1.0) * 0.5/*ID:BGain 0.0 1.0 0.5*/; //Set B values. img.pix(i,j, Color(R,G,B)); ///- 1.1 set1 centerrect.centering(); } } img.cache(); //Move offscreen from main memory to video RAM. (Optional) ///- 1 Initialize ///+ 2 drawing ////drawing offscreen while(!Keyboard::esc.pushed()){ window.clear(Color::black); //Clear screen with black img.centering(); //centering the position to copy offscreen img.shift(100,100); //centering the position to copy offscreen img.draw(); // copy offscreen onto the reverse side of window buffer. centerrect.draw(Color::red);// draw reference rectangle at the center. window.flip(); } ///- 2 drawing } ///- Main Routine
./4_1a.xap