///+ Prefix linkto BasicCode1 //// Lines for set up Psychlops environment using Psychlops; namespace PsychlopsSilverlightApp { public class PsychlopsMain {///- Prefix linkto BasicCode1 ///+ Main Routine //// Psychlops runs at the first line of this function psychlops_main(). public void psychlops_main() { ///+ 0 Declaration ////Prepare global parameters Canvas window = new Canvas(Canvas.window); Image img; Rectangle centerrect = new Rectangle(10, 10); int imageHsize = 100; int imageVsize = 60; double R, G, B; ///- 0 Declaration ///+ 1 Initialize ////Initialize image and set color to each pixel. img = new Image(imageHsize, imageVsize); //Allocate offscreen in main memory. Color col = new Color(0,0,0); for (int i = 0; i < imageHsize; i++) { for (int j = 0; j < imageVsize; j++) { ///+ 1.1 set1 ////set colors for each pixels R = Math.random(1.0) * 0.5; //Set R values. G = Math.random(1.0) * 0.5; //Set G values. B = Math.random(1.0) * 0.5; //Set B values. col.set(R, G, B); img.pix(i, j, col); ///- 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 } }