X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=test4%2FPsychlopsMain.cs;h=ad9a4c1503f1ca025a6b8779be1d3df4a1874e38;hb=a1aee2b11bf1d315eaf4a2bbd8a96464d3848202;hp=859b016004144470336c39fcbc55b8a805096833;hpb=0aaced545d70ae3bd6cdd440e0ce676f6a602761;p=psychlops%2Fsilverlight.git diff --git a/test4/PsychlopsMain.cs b/test4/PsychlopsMain.cs index 859b016..ad9a4c1 100644 --- a/test4/PsychlopsMain.cs +++ b/test4/PsychlopsMain.cs @@ -1,72 +1,100 @@  -///+ 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(); - } - } + Canvas window = new Canvas(300,300); + + Rectangle figure = new Rectangle(); + figure.set(100, 100); + figure.fill = new Color(1, 1, 1); + figure.centering().shift(0, 0); - //img.cache(); //Move offscreen from main memory to video RAM. (Optional) - ///- 1 Initialize + int frame = 0; + int looming_direction = 1, motion_dir = 1; - ///+ 2 drawing - ////drawing offscreen while (!Keyboard.esc.pushed()) { + window.clear(0); + + if (frame % 30 == 0) + { + looming_direction = looming_direction * -1; + } + if (frame % 90 == 0) + { + motion_dir *= -1; + } + + figure.resize(figure.getWidth() + looming_direction * 1, + figure.getHeight() + looming_direction * 1); + figure.shift(motion_dir * 1, motion_dir * 0); - 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. + figure.draw(); window.flip(); + + frame++; } - ///- 2 drawing } - ///- Main Routine } +} + +/* +using Psychlops; +//Position Bias Program +namespace PsychlopsSilverlightApp +{ + + public class PsychlopsMain + { + Canvas cnvs; + Image img, img2, img3; + int isize = 80; + int frames; + Psychlops.Widgets.Slider tfreq; + Psychlops.Widgets.Slider contrast; + Psychlops.Widgets.Slider lambda; + + public void psychlops_main() + { + cnvs = new Canvas(300, 600); + Interval rng = new Interval(); + tfreq = new Psychlops.Widgets.Slider("Temporal Frequency(Hz)", -5 <= rng <= 5, 3.0); + contrast = new Psychlops.Widgets.Slider("Contrast", 0.0 <= rng <= 1.0, 0.25); + lambda = new Psychlops.Widgets.Slider("Wave Length", 10.0 <= rng <= 120.0, 30); + + img = new Image(isize * 2, isize * 2); + img2 = new Image(isize * 2, isize * 2); + img3 = new Image(isize * 2, isize * 2); + + + while (true) + { + cnvs.clear(new Color(0.5)); + + Figures.drawGabor(ref img, isize / 6, 1/lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60); + Figures.drawGabor(ref img2, isize / 6, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * -tfreq / 60); + Figures.drawGabor(ref img3, isize / 6, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60); + + img.centering().shift(0, -isize * 1.5).draw(); + img2.centering().draw(); + img3.centering().shift(0, isize * 1.5).draw(); + + if (!Mouse.left.pressed()) frames++; + + cnvs.flip(); + } + } + } } +*/