X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=test4%2FPsychlopsMain.cs;h=e69a680907e928b65a738b126b2ef198cfc5d847;hb=refs%2Fheads%2Fsilverlight4;hp=5fe3ea756556731c729a3b1831f8646bfa6b523d;hpb=30ffbb3015380f28275c1160f625d9764e9bd2c4;p=psychlops%2Fsilverlight.git diff --git a/test4/PsychlopsMain.cs b/test4/PsychlopsMain.cs index 5fe3ea7..e69a680 100644 --- a/test4/PsychlopsMain.cs +++ b/test4/PsychlopsMain.cs @@ -1,4 +1,218 @@ - +using Psychlops; + +namespace PsychlopsSilverlightApp +{ + + public class PsychlopsMain + { + + + public void psychlops_main() { + + Canvas display = new Canvas(768,768); + + double rect_size = 100; + double rect_lum = 0.5; + double bg_lum = 0.5; + double size = 250.0; + double sigma; + sigma = size/6.0; + double lambda; + lambda = 6*sigma; + int envelopemode = 0; + double refresh = display.getRefreshRate(); + double[] SF=new double[2]; + + SF[0]=4.0; + SF[1]=4.0; + + double phase=0; + + double[] initphase = new double[2]; + double _i, _j, _x, _y, _x2, _y2, col; + double amplitude = 1.0; + + Rectangle fixation1 = new Rectangle(3,9); + Rectangle fixation2 = new Rectangle(9,3); + fixation1.centering(); + fixation2.centering(); + Rectangle contrastrect = new Rectangle(); + contrastrect.set(760,760); + + Image envelope = new Image(); + Psychlops.Color bglum= new Color(0.5,0.5,0.5); + Psychlops.Color masklum = new Color(0.5,0.5,0.5,0.5); + + Interval rng = new Interval(); + + + Psychlops.Widgets.Slider TF; + TF = new Psychlops.Widgets.Slider("TF", 0.25<=rng<=2.0 , 0.1); + TF.value=0.75; + + + + Psychlops.Widgets.Slider SFs; + SFs = new Psychlops.Widgets.Slider("SF", 4.0<=rng<=16.0 , 4.0); + SFs.value = 4.0; + + Psychlops.Widgets.Slider contrast; + contrast= new Psychlops.Widgets.Slider("Contrast", 0.0<=rng<=1.0 , 0.1); + contrast.value = 0.1; + + + var element = StaticFunctions.NewArray(2); + for (int i = 0; i < element.Length; i++){ + element[i].setSigma(sigma); // set a size of patch as a halfwidth of Gaussian + element[i].orientation = Math.PI/4.0+Math.PI/2.0*(1-i);//Math.PI/2*(rand()%2);// //set orientations + initphase[i]=0; + } + + + + envelope.set(size, size); + envelope.clear(bglum); + + for(int i=0; i0){ + envelope.centering().shift(size*0.6,-size*0.6).draw(); + envelope.centering().shift(-size*0.6,size*0.6).draw(); + } + masklum.set(bg_lum, bg_lum, bg_lum, 1-contrast); + contrastrect.centering(); + contrastrect.draw(masklum); + fixation1.centering().shift(size*2,0.0); + fixation1.draw(Color.red); + fixation2.centering().shift(size*2,0.0); + fixation2.draw(Color.red); + + Display.var(Mouse.x, 300, 300); + Display.var(Mouse.y, 300, 320); + + Display.flip(); + + + } + +} + + + + } + +} +/* + +using Psychlops; +//Position Bias Program +namespace PsychlopsSilverlightApp +{ + + public class PsychlopsMain + { + Canvas cnvs; + Image img, img2, img3; + int isize = 40; + 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); + + var gabor1 = StaticFunctions.NewArray(100); + foreach (var g in gabor1) + { + g.setSigma(isize/8).centering().shift(Math.random(300) - 150, Math.random(600) - 300); + //g.setSize(isize).centering().shift(Math.random(300) - 150, Math.random(600) - 300); + g.orientation = Math.random(2 * Math.PI); + //g.orientation2 = Math.random(2 * Math.PI); + } + + while (true) + { + cnvs.clear(new Color(0.5)); + + Figures.drawGabor(ref img, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60); + Figures.drawGabor(ref img2, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * -tfreq / 60); + Figures.drawGabor(ref img3, isize / 8, 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(); + + + //foreach (var g in gabor1) + for (int i = 0; i < gabor1.Length; i++) + { + gabor1[i].wavelength = lambda; + gabor1[i].phase = (double)frames * 2.0 * Math.PI * tfreq / 60; + gabor1[i].contrast = contrast; + //g.wavelength2 = lambda * 2; + //g.phase2 = (double)frames * 2.0 * Math.PI * tfreq / 60; + //g.contrast2 = contrast / 2; + gabor1[i].draw(); + } + + if (!Mouse.left.pressed()) frames++; + + cnvs.flip(); + } + } + } +} + + +/* ///+ Prefix linkto BasicCode1 //// Lines for set up Psychlops environment using Psychlops; @@ -70,6 +284,7 @@ namespace PsychlopsSilverlightApp } } + * */ /* @@ -539,72 +754,3 @@ using Psychlops; } } */ - - -/* -using Psychlops; -//Position Bias Program -namespace PsychlopsSilverlightApp -{ - - public class PsychlopsMain - { - Canvas cnvs; - Image img, img2, img3; - int isize = 40; - 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); - - var gabor1 = StaticFunctions.NewArray(100); - foreach(var g in gabor1) - { - g.setSigma(isize / 8).centering().shift(Math.random(300) - 150, Math.random(600) - 300); - g.orientation = Math.random(2*Math.PI); - } - - while (true) - { - cnvs.clear(new Color(0.5)); - - Figures.drawGabor(ref img, isize / 8, 1/lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60); - Figures.drawGabor(ref img2, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * -tfreq / 60); - Figures.drawGabor(ref img3, isize / 8, 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(); - - - foreach (var g in gabor1) - { - g.wavelength = lambda; - g.phase = (double)frames * 2.0 * Math.PI * tfreq / 60; - g.contrast = contrast; - g.draw(); - } - - if (!Mouse.left.pressed()) frames++; - - cnvs.flip(); - } - } - } -} -*/ \ No newline at end of file