X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=test4%2FPsychlopsMain.cs;fp=test4%2FPsychlopsMain.cs;h=261c75dd7eb2060920269f0bb53cefdf2e929825;hb=7a71cabcacaf39cef5cbfb1ab85e51cecdc91dc7;hp=f5df20f5ae8f495158ec670704cfbdcbe95205d5;hpb=9f47dcd91507b95984913358b5b313f1e304a091;p=psychlops%2Fsilverlight.git diff --git a/test4/PsychlopsMain.cs b/test4/PsychlopsMain.cs index f5df20f..261c75d 100644 --- a/test4/PsychlopsMain.cs +++ b/test4/PsychlopsMain.cs @@ -1,4 +1,107 @@ - +///+ Prefix linkto BasicCode1 +//// Lines for set up Psychlops environment +using Psychlops; + +namespace PsychlopsSilverlight4test +{ + + public class PsychlopsMain + {///- Prefix linkto BasicCode1 + + + ///+ Main Routine + //// Psychlops runs at the first line of this function psychlops_main(). + public void psychlops_main() { + ///+ 0 linkto BasicCode3_1a + ////Prepare global parameters + const int maxrectnum = 200; + int rectnum = 100/*ID:rectnumber 25.0 200.0 25.0*/; + double rectsize = 5.0/*ID:dotsize 1.0 10.0 1.0*/; + Rectangle[] rect = new Rectangle[maxrectnum]; + for (int i = 0; i < maxrectnum; i++) { rect[i] = new Rectangle(); } + double[] rectcolorR = new double[maxrectnum]; + double[] rectcolorG = new double[maxrectnum]; + double[] rectcolorB = new double[maxrectnum]; + ///- 0 linkto BasicCode3_1a + + Canvas window = new Canvas(Canvas.window); + + ///+ 1 linkto BasicCode3_1a + ////Initialize + for(int i=0; i < rectnum; i++){ + ///+ 1.1 set1 + ////set positions and sizes + rect[i].set(rectsize, rectsize); //Set a size of rectangles. + rect[i].centering(); + rect[i].shift((i - 0.5 * rectnum) * rectsize* 1.5/*ID:RectHGap 1.0 3.0 0.5*/, + (i - 0.5*rectnum) * rectsize * 1.5/*ID:RectVGap 1.0 3.0 0.5*/); //Move Rectangles to initial positions + ///- 1.1 set1 + ///+ 1.2 set2 + ////set colors + rectcolorR[i]=Math.random(1.0) * 0.5/*ID: RGain 0.0 1.0 0.5*/; //Set R values. Note that "i" is converted to double-type. + rectcolorG[i]=Math.random(1.0) * 0.5/*ID: GGain 0.0 1.0 0.5*/; //Set G values. Note that "i" is converted to double-type. + rectcolorB[i]=Math.random(1.0) * 0.5/*ID: BGain 0.0 1.0 0.5*/; //Set B values. Note that "i" is converted to double-type. + ///- 1.2 set2 + } + ///- 1 linkto BasicCode3_1a + + ///+ 2 drawing + ////drawing objects + ///+ 2.1 setlocal + ////Prepare variables for movie control; + int frame = 0; + int motion_dir = 1; + double Horizontal_shift, Vertical_shift; + ///- 2.1 setlocal + + while(!Keyboard.esc.pushed()){ + window.clear(Color.black); + + if(frame % 30/*ID:Period_Position 30 240 30*/ ==0){ // motion direction will reverse at designated frames. + motion_dir *= -1; + } + + for(int i=0; i < rectnum; i++){ + ///+ 2.2 loopset1 + ////set positions and sizes + + Horizontal_shift=motion_dir * 1.0/*ID:HSpeed 0.0 5.0 1.0*/; + Vertical_shift=motion_dir * 0.0/*ID:VSpeed 0.0 5.0 1.0*/; + + rect[i].resize(rectsize, rectsize); //Resize rectangles. + rect[i].shift(Horizontal_shift, Vertical_shift); + ///- 2.2 loopset1 + + ///+ 2.3 loopset2 + ////set colors + rectcolorR[i]=Math.random(1.0)* 0.5/*ID:RGain 0.0 1.0 0.5*/; //Set R values. Note that "i" is converted to double-type. + rectcolorG[i]=Math.random(1.0)* 0.5/*ID:GGain 0.0 1.0 0.5*/; //Set G values. Note that "i" is converted to double-type. + rectcolorB[i]=Math.random(1.0)* 0.5/*ID:BGain 0.0 1.0 0.5*/; //Set B values. Note that "i" is converted to double-type. + ///- 2.3 loopset2 + + } + + ///+ 2.4 linkto BasicCode3_1a + for(int i=0; i < rectnum; i++){ + rect[i].draw(new Color(rectcolorR[i], rectcolorG[i], rectcolorB[i])); //draw objects by designated colors. + } + window.flip(); + ///- 2.4 linkto BasicCode3_1a + + frame++; + } + ///- 2 drawing + +} + ///- Main Routine + + + } + +} + + +/* using Psychlops; namespace PsychlopsSilverlight4test @@ -52,6 +155,7 @@ namespace PsychlopsSilverlight4test } } +*/