X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=test4%2FPsychlopsMain.cs;h=ad9a4c1503f1ca025a6b8779be1d3df4a1874e38;hb=a1aee2b11bf1d315eaf4a2bbd8a96464d3848202;hp=b9b3d5762b451a8a8522472d579bf5ef886628ad;hpb=c07b32733b2c41afbef57da474b9c7a9e5c0e048;p=psychlops%2Fsilverlight.git diff --git a/test4/PsychlopsMain.cs b/test4/PsychlopsMain.cs index b9b3d57..ad9a4c1 100644 --- a/test4/PsychlopsMain.cs +++ b/test4/PsychlopsMain.cs @@ -1,132 +1,100 @@ -using Psychlops; + +using Psychlops; -namespace PsychlopsSilverlight4test +namespace PsychlopsSilverlightApp { + public class PsychlopsMain { + public void psychlops_main() { - var elem = Psychlops.Widgets.Browser.Element.byID("TheInput"); + Canvas window = new Canvas(300,300); - Canvas window = new Canvas(500,500); + Rectangle figure = new Rectangle(); + figure.set(100, 100); + figure.fill = new Color(1, 1, 1); + figure.centering().shift(0, 0); - var figure = new Rectangle(); - figure.set( 100, 100 ); - figure.fill = new Color(1.0, 0.0, 0.0); - - while (!Keyboard.esc.pushed()) - { - window.clear(Color.black); - figure.centering().shift(elem.getValueAsDouble(), 1).draw(); - window.flip(); - } - } - } - -} + int frame = 0; + int looming_direction = 1, motion_dir = 1; + while (!Keyboard.esc.pushed()) + { + window.clear(0); + if (frame % 30 == 0) + { + looming_direction = looming_direction * -1; + } + if (frame % 90 == 0) + { + motion_dir *= -1; + } -/* -using Psychlops; + figure.resize(figure.getWidth() + looming_direction * 1, + figure.getHeight() + looming_direction * 1); + figure.shift(motion_dir * 1, motion_dir * 0); -namespace Psychlops -{ + figure.draw(); + window.flip(); - 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(); + frame++; } + } - } + } } - -namespace PsychlopsSilverlight4test + +/* +using Psychlops; +//Position Bias Program +namespace PsychlopsSilverlightApp { public class PsychlopsMain { Canvas cnvs; - Image img; - Rectangle fixation; - Shape shape; - Color col; - int isize = 100; - double tfreq = 1; + Image img, img2, img3; + int isize = 80; int frames; - RandomDots dots; + Psychlops.Widgets.Slider tfreq; + Psychlops.Widgets.Slider contrast; + Psychlops.Widgets.Slider lambda; - public void psychlops_main() + 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; + 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); - 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(); + img = new Image(isize * 2, isize * 2); + img2 = new Image(isize * 2, isize * 2); + img3 = new Image(isize * 2, isize * 2); - 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; + while (true) + { + cnvs.clear(new Color(0.5)); - fixation.shift(100,100); - fixation.draw(new Stroke(Color.blue, 3)); + 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); - for (int i=0; i