X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;ds=sidebyside;f=test4%2FPsychlopsMain.cs;fp=test4%2FPsychlopsMain.cs;h=120388a6eba0751cf94b0d5eab3266f76b8f2a57;hb=892d07a825dbe4e84ee7f3e480ece30d1f97a4d8;hp=859b016004144470336c39fcbc55b8a805096833;hpb=97a97a46267462940a24f18ad5bbd0f77006dfd9;p=psychlops%2Fsilverlight.git diff --git a/test4/PsychlopsMain.cs b/test4/PsychlopsMain.cs index 859b016..120388a 100644 --- a/test4/PsychlopsMain.cs +++ b/test4/PsychlopsMain.cs @@ -1,5 +1,5 @@  -///+ Prefix linkto BasicCode1 +///+ Prefix //// Lines for set up Psychlops environment using Psychlops; @@ -7,62 +7,64 @@ namespace PsychlopsSilverlightApp { public class PsychlopsMain - {///- Prefix linkto BasicCode1 - + {///- Prefix ///+ 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(); - } - } + ///+ 1 + //// Set a window for drawing stimulus + Canvas window = new Canvas(300, 300); //Create a window. Here, window variables are preset mode. + // You can write this statement as" Canvas window = new Canvas(Canvas.fullscreen); " for fullscreen mode + // or as " Canvas window = new Canvas(1024, 768, 32, 60.0); " This statement changes screenmode to 1024 x 768, 32bit color, 60 Hz refresh. + ///- 1 - //img.cache(); //Move offscreen from main memory to video RAM. (Optional) - ///- 1 Initialize + var FIGURE = Psychlops.Widgets.Browser.Element.byID("FIGURE"); + var SIZE_X = Psychlops.Widgets.Browser.Element.byID("SIZE_X"); + var SIZE_Y = Psychlops.Widgets.Browser.Element.byID("SIZE_Y"); + var SHIFT_X = Psychlops.Widgets.Browser.Element.byID("SHIFT_X"); + var SHIFT_Y = Psychlops.Widgets.Browser.Element.byID("SHIFT_Y"); + var COLOR_R = Psychlops.Widgets.Browser.Element.byID("COLOR_R"); + var COLOR_G = Psychlops.Widgets.Browser.Element.byID("COLOR_G"); + var COLOR_B = Psychlops.Widgets.Browser.Element.byID("COLOR_B"); - ///+ 2 drawing - ////drawing offscreen + ///+ 2 + //// Set a figure size, position and color. + Rectangle figure = new Rectangle(); + Ellipse figure2 = new Ellipse(); + + window.flip(); // Reflect the drawing for the display by flipping frame buffers. + // Till this point, you will not see drawn figures. + ///- 2 + + ///+ 3 + //// Detect a Keyboard input 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.clear(); + + if ("Rectangle".Equals(FIGURE)) + { + figure.set(SIZE_X, SIZE_Y); // Set the size of figure. + figure.centering(); // Centering the figure in the window + figure.shift(SHIFT_X, SHIFT_Y); // Displacing the figure by designated vector. + figure.draw(new Color(COLOR_R, COLOR_G, COLOR_B)); // Drawing the rectangle with a designated color. + } + else + { + figure2.set(SIZE_X, SIZE_Y); // Set the size of figure. + figure2.centering(); // Centering the figure in the window + figure2.shift(SHIFT_X, SHIFT_Y); // Displacing the figure by designated vector. + figure2.draw(new Color(COLOR_R, COLOR_G, COLOR_B)); // Drawing the rectangle with a designated color. + } + window.flip(); - } - ///- 2 drawing + + } //exit a program when the escape key is pressed down. + ///- 3 } ///- Main Routine @@ -70,3 +72,5 @@ namespace PsychlopsSilverlightApp } } + +