X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=test4%2FPsychlopsMain.cs;h=120388a6eba0751cf94b0d5eab3266f76b8f2a57;hb=2025e2db455b85eae3dec989bdfd39f3c1292df1;hp=b9b3d5762b451a8a8522472d579bf5ef886628ad;hpb=c07b32733b2c41afbef57da474b9c7a9e5c0e048;p=psychlops%2Fsilverlight.git diff --git a/test4/PsychlopsMain.cs b/test4/PsychlopsMain.cs index b9b3d57..120388a 100644 --- a/test4/PsychlopsMain.cs +++ b/test4/PsychlopsMain.cs @@ -1,132 +1,76 @@ -using Psychlops; + +///+ Prefix +//// Lines for set up Psychlops environment +using Psychlops; -namespace PsychlopsSilverlight4test +namespace PsychlopsSilverlightApp { + public class PsychlopsMain - { + {///- Prefix + + ///+ Main Routine + //// Psychlops runs at the first line of this function psychlops_main(). public void psychlops_main() { - var elem = Psychlops.Widgets.Browser.Element.byID("TheInput"); - - Canvas window = new Canvas(500,500); - - var figure = new Rectangle(); - figure.set( 100, 100 ); - figure.fill = new Color(1.0, 0.0, 0.0); - + ///+ 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. + 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); - figure.centering().shift(elem.getValueAsDouble(), 1).draw(); - window.flip(); - } - } - } - -} - + 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. + } -/* -using Psychlops; + window.flip(); -namespace Psychlops -{ + } //exit a program when the escape key is pressed down. + ///- 3 - public class RandomDots - { - Rectangle dot; - public Point[] cood; - public RandomDots() - { - cood = new Point[250]; - dot = new Rectangle(5, 5); - } - public void draw() - { - dot.fill = Color.white; - foreach (Point p in cood) - { - dot.centering(p).draw(); - } } + ///- Main Routine + } } -namespace PsychlopsSilverlight4test -{ - - public class PsychlopsMain - { - Canvas cnvs; - Image img; - Rectangle fixation; - Shape shape; - Color col; - int isize = 100; - double tfreq = 1; - int frames; - RandomDots dots; - - public void psychlops_main() - { - cnvs = new Canvas(500, 500); - img = new Image(isize * 2, isize * 2); - fixation = new Rectangle(10, 10); - fixation.fill = Color.red; - //var poly = new Rectangle(100, 100); - var poly = new Letters("日本語"); - //var poly = new Polygon(); poly.append(0, 100); poly.append(-100, 0); poly.append(0, -100); poly.append(100, 0); - //var poly = new Ellipse(100, 100); - //var poly = new Line(0,0,100, 0); - poly.fill = Color.red; - poly.stroke = new Stroke { color = Color.yellow, thick = 1 }; - shape = poly; - - var rng = new Interval(); - var slider = new Psychlops.Widgets.Slider("tesrt", 0 <= rng <= 5); - - dots = new RandomDots(); - - - while(true) { - frames++; - - cnvs.clear(new Color(Mouse.left.pressed() ? 0.75 : 0.5)); - col.set(Math.random(1.0)); - - fixation.centering(); - fixation.draw(Color.red); - - //Figures.drawGabor(ref img, 20, 100, 1, 0, frames * 2.0 * Math.PI / tfreq / 60); - //Figures.drawGaussian(ref img, 20, 1); - Figures.drawGrating(ref img, 30, 30, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60); - img.centering(Mouse.position); - img.draw(); - - shape.centering(Mouse.position).shift(100,0); - shape.draw(); - if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100); - - cnvs.var(frames, 20, 20); - slider.value = frames/100.0; - - fixation.shift(100,100); - fixation.draw(new Stroke(Color.blue, 3)); - - for (int i=0; i