X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=test4%2FPsychlopsMain.cs;h=ad9a4c1503f1ca025a6b8779be1d3df4a1874e38;hb=a1aee2b11bf1d315eaf4a2bbd8a96464d3848202;hp=120388a6eba0751cf94b0d5eab3266f76b8f2a57;hpb=892d07a825dbe4e84ee7f3e480ece30d1f97a4d8;p=psychlops%2Fsilverlight.git diff --git a/test4/PsychlopsMain.cs b/test4/PsychlopsMain.cs index 120388a..ad9a4c1 100644 --- a/test4/PsychlopsMain.cs +++ b/test4/PsychlopsMain.cs @@ -1,76 +1,100 @@  -///+ Prefix -//// Lines for set up Psychlops environment using Psychlops; namespace PsychlopsSilverlightApp { public class PsychlopsMain - {///- Prefix + { - ///+ Main Routine - //// Psychlops runs at the first line of this function psychlops_main(). public void psychlops_main() { - ///+ 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 - - 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 - //// Set a figure size, position and color. + Canvas window = new Canvas(300,300); + Rectangle figure = new Rectangle(); - Ellipse figure2 = new Ellipse(); + figure.set(100, 100); + figure.fill = new Color(1, 1, 1); + figure.centering().shift(0, 0); + + int frame = 0; + int looming_direction = 1, motion_dir = 1; - 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(0); - window.clear(); - - if ("Rectangle".Equals(FIGURE)) + if (frame % 30 == 0) { - 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. + looming_direction = looming_direction * -1; } - else + if (frame % 90 == 0) { - 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. + motion_dir *= -1; } + figure.resize(figure.getWidth() + looming_direction * 1, + figure.getHeight() + looming_direction * 1); + figure.shift(motion_dir * 1, motion_dir * 0); + + figure.draw(); window.flip(); - } //exit a program when the escape key is pressed down. - ///- 3 + frame++; + } } - ///- 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(); + } + } + } +} +*/