X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=test4%2FPsychlopsMain.cs;h=f5df20f5ae8f495158ec670704cfbdcbe95205d5;hb=9f47dcd91507b95984913358b5b313f1e304a091;hp=3fd2ba9f6621b4235e6d9591fc2de06fef58f33f;hpb=e7ec2e7cdb0c8c7e9c0db62998be4b2803180fdc;p=psychlops%2Fsilverlight.git diff --git a/test4/PsychlopsMain.cs b/test4/PsychlopsMain.cs index 3fd2ba9..f5df20f 100644 --- a/test4/PsychlopsMain.cs +++ b/test4/PsychlopsMain.cs @@ -1,46 +1,103 @@  -/* using Psychlops; namespace PsychlopsSilverlight4test { - public class PsychlopsMain { - Canvas cnvs; + Psychlops.Widgets.Slider rect_size; + Psychlops.Widgets.Slider rect_lum; + Psychlops.Widgets.Slider bg_lum; + + + void RectLuminance() + { + Canvas display = new Canvas(Canvas.window); + Interval rng = new Interval(); + rect_size = new Psychlops.Widgets.Slider("Rect Size", 1 < rng < 500, 10.0); + rect_lum = new Psychlops.Widgets.Slider("Rect Luminance", 0.0 <= rng <= 1.0, 0.1); + bg_lum = new Psychlops.Widgets.Slider("BG Luminance", 0.0 <= rng <= 1.0, 0.1); + Ellipse drawee = new Ellipse(100, 100); + display.showFPS(); + display.watchFPS(); + + Rectangle rect = new Rectangle(rect_size, rect_size); + rect.centering(); + + + Clock before = new Clock(), after = new Clock(); + while (!Keyboard.esc.pushed()) + { + Display.clear(bg_lum); + rect.resize(rect_size, rect_size).draw(rect_lum); + after.update(); + display.var((after - before).at_msec(), 100, 100, Color.green); + display.var((after - before).at_msec(), 100, 200, Color.green); + drawee.centering().shift(Math.random(100), 0); + drawee.draw(Color.black); + Display.flip(); + } + + } + + + public void psychlops_main() + { + RectLuminance(); + } + + + } + +} + + + + + + + + + + + +/* + using Psychlops; + +namespace PsychlopsSilverlight4test +{ + + public class PsychlopsMain + { + + Psychlops.Canvas cnvs; int i; - object xxx; double x, y, z, t, p, temp, xx, yy; //Set Target Initial Value double TargetEcce = 100.0, TargetSize = 5.0, TargetNumber = 5, Rotate = 0.0; //Set Background Initial Value - double DotNumber = 50, thetaSpeed = 3.0, Axis = 0.0, BGRadii = 150, BGSize = 5.0; - Psychlops.Widgets.Slider DotNumberS; + double Axis = 0.0, BGRadii = 150, BGSize = 5.0; + Psychlops.Widgets.Slider thetaSpeed, DotNumber; + Image img; + + public void psychlops_main() { - //DotNumberS = new Psychlops.Widgets.Slider("test", new Interval(10, 500)); - //Independent ind = new Independent(); - cnvs = new Canvas(500, 500); - Image img = new Image(100, 100); - img.field(delegate(int x, int y) { return new Color(0.5 + 0.5 * Math.sin(x + y)); }); - Image img2 = new Image(100, 100); - img2.field(delegate(int x, int y) { return new Color(0.5 + 0.5 * Math.sin(x + y)); }); - /* - for (int x = 0; x < 20; x++) - { - for (int y = 0; y < 20; y++) - { -// img.pix(x, y, new Color(Math.sin(x + y))); - } - } + Psychlops.Solver.BinomialLikelihood.showWindow(Math.cumulativeNormalDistibution); + + img = new Image("Resources/logo.png"); + + Interval rng = new Interval(); + thetaSpeed = new Psychlops.Widgets.Slider("Label", -10 <= rng <= 10, 3.0); + DotNumber = new Psychlops.Widgets.Slider("DotNum", 0 <= rng <= 100, 50.0); //Declare background dots and target Rectangle[] BGDot = new Rectangle[2048]; @@ -78,11 +135,11 @@ namespace PsychlopsSilverlight4test for(int i=0; i<10; i++)Target[i].set(TargetSize, TargetSize); double COS, SIN; - DotNumber = 100; + //DotNumber = 200; //Main stimulus loop while(true){ //Clear the main window - cnvs.clear(Color.green); + cnvs.clear(); temp=Axis/360*2*Math.PI; @@ -108,25 +165,26 @@ namespace PsychlopsSilverlight4test //Set Dotsize and Draw them BGDot[i].set(BGSize, BGSize); BGDot[i].centering().shift(xx,yy); - BGDot[i].draw( Color.blue); + BGDot[i].draw( Color.blue ); } //Calculate positions of targets and set them temp=Rotate*2*Math.PI/360.0; - cnvs.msg(TargetNumber.ToString(), 0, 30); for (int i = 0; i < 5; i++) { - cnvs.msg(i.ToString(), 50+50*i, 30); t = 2.0 * Math.PI/TargetNumber; - x = 10.0 * i;//TargetEcce*Math.cos(i*t+temp); - y = 10.0 * i;//TargetEcce*Math.sin(i*t+temp); + x = TargetEcce*Math.cos(i*t+temp); + y = TargetEcce*Math.sin(i*t+temp); Target[i].centering().shift(x,y); Target[i].fill = Color.yellow; Target[i].draw(); } - img.centering().draw(); - img2.centering().draw(); + img.centering(Mouse.position).draw(); + + cnvs.var(Mouse.position.x, 100, 100); + cnvs.var(Mouse.position.y, 100, 140); + //Reflect drawing at the next frame; cnvs.flip(); } @@ -134,10 +192,10 @@ namespace PsychlopsSilverlight4test } } +*/ -/* -using Psychlops; +/*using Psychlops; namespace PsychlopsSilverlight4test { @@ -184,10 +242,9 @@ namespace PsychlopsSilverlight4test } - * - * */ +/* using Psychlops; namespace Psychlops @@ -216,7 +273,6 @@ namespace Psychlops - namespace PsychlopsSilverlight4test { @@ -224,19 +280,24 @@ namespace PsychlopsSilverlight4test { Canvas cnvs; Image img; - Rectangle fixation; + Ellipse fixation; Shape shape; Color col; int isize = 100; double tfreq = 1; int frames; RandomDots dots; + Group g; public void psychlops_main() { cnvs = new Canvas(500, 500); + g = new Group(); img = new Image(isize * 2, isize * 2); - fixation = new Rectangle(10, 10); + Figures.drawGrating(ref img, 200, 200, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60); + g.append(img); + g.rotation = 50; + fixation = new Ellipse(10, 10); fixation.fill = Color.red; //var poly = new Rectangle(100, 100); var poly = new Letters("日本語"); @@ -248,7 +309,7 @@ namespace PsychlopsSilverlight4test shape = poly; var rng = new Interval(); - var slider = new Psychlops.Widgets.Slider("tesrt", 0 <= rng <= 5); + var slider = new Psychlops.Widgets.Slider("tesrt", -100 <= rng <= 100); dots = new RandomDots(); @@ -257,37 +318,92 @@ namespace PsychlopsSilverlight4test { frames++; + cnvs.clear(new Color(Mouse.left.pressed() ? 0.75 : 0.5)); col.set(Math.random(1.0)); - fixation.centering(); + /*if (frames % 2 == 0) + { + fixation.centering().shift(100, 100); + fixation.draw(new Stroke(Color.blue, 3)); + }* / + + fixation.centering().shift(slider, 0); 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(); + //Figures.drawGrating(ref img, 200, 200, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60); + //img.centering(Mouse.position); + //img.draw(); + g.centering(Mouse.position).draw(); + g.rotation += 1; 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; + cnvs.var(frames, 0, 20); + //slider.value = frames / 100.0; - fixation.shift(100, 100); - fixation.draw(new Stroke(Color.blue, 3)); + /*if (frames % 2 != 0) + { + fixation.shift(100, 100); + fixation.draw(new Stroke(Color.green, 3)); + }* / for (int i = 0; i < dots.cood.Length; i++) { dots.cood[i].set(Math.random(500), Math.random(500)); } + cnvs.var((double)slider, 200, 200); dots.draw(); cnvs.flip(); } } } +} +**/ + + +/* + +using Psychlops; +namespace PsychlopsSilverlight4test +{ + + public class PsychlopsMain + { + Canvas cnvs; + Rectangle[] rect; + int n; + + public void psychlops_main() + { + n = 1; + cnvs = new Canvas(500, 500); + rect = new Rectangle[n]; + for (int i = 0; i < n; i++) + { + rect[i] = new Rectangle(10, 10); + rect[i].fill = Color.red; + } + Interval rng = new Interval(); + var slider = new Psychlops.Widgets.Slider("Label", -100 <= rng <= 100); + + while (true) + { + cnvs.clear(); + for (int i = 0; i < n; i++) + { + rect[i].centering().shift(slider * i*3, i*3).draw(); + } + cnvs.flip(); + } + } + } } + +*/ \ No newline at end of file