X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=test4%2FPsychlopsMain.cs;h=859b016004144470336c39fcbc55b8a805096833;hb=0aaced545d70ae3bd6cdd440e0ce676f6a602761;hp=32ba5e8618340bafb89a5850ff59f40481c7ea9a;hpb=2d16c7bc232e1d8e0f57404c4b37e3a8db6ab207;p=psychlops%2Fsilverlight.git diff --git a/test4/PsychlopsMain.cs b/test4/PsychlopsMain.cs index 32ba5e8..859b016 100644 --- a/test4/PsychlopsMain.cs +++ b/test4/PsychlopsMain.cs @@ -1,151 +1,72 @@  +///+ Prefix linkto BasicCode1 +//// Lines for set up Psychlops environment using Psychlops; -namespace PsychlopsSilverlight4test +namespace PsychlopsSilverlightApp { + public class PsychlopsMain - { - public void psychlops_main() - { - var figure_type = 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"); + {///- Prefix linkto BasicCode1 - Canvas window = new Canvas(300, 300); - var figure_r = new Rectangle(); - var figure_e = new Ellipse(); - Shape figure = figure_r; - - while (!Keyboard.esc.pushed()) + ///+ Main Routine + //// Psychlops runs at the first line of this function psychlops_main(). + public void psychlops_main() + { + ///+ 0 Declaration + ////Prepare global parameters + Canvas window = new Canvas(Canvas.window); + Image img; + Rectangle centerrect = new Rectangle(10, 10); + int imageHsize = 100; + int imageVsize = 60; + double R, G, B; + ///- 0 Declaration + + + + ///+ 1 Initialize + ////Initialize image and set color to each pixel. + img = new Image(imageHsize, imageVsize); //Allocate offscreen in main memory. + Color col = new Color(0,0,0); + for (int i = 0; i < imageHsize; i++) { - if (System.String.Compare(figure_type, "Rectangle") == 0) + for (int j = 0; j < imageVsize; j++) { - figure_r.set(size_x, size_y); - figure = figure_r; + ///+ 1.1 set1 + ////set colors for each pixels + R = Math.random(1.0) * 0.5; //Set R values. + G = Math.random(1.0) * 0.5; //Set G values. + B = Math.random(1.0) * 0.5; //Set B values. + col.set(R, G, B); + img.pix(i, j, col); + ///- 1.1 set1 + centerrect.centering(); } - else - { - figure_e.set(size_x, size_y); - figure = figure_e; - } - figure.fill = new Color(color_r, color_g, color_b); - - window.clear(Color.black); - figure.centering().shift(shift_x, shift_y).draw(); - window.flip(); } - } - } -} + //img.cache(); //Move offscreen from main memory to video RAM. (Optional) + ///- 1 Initialize + ///+ 2 drawing + ////drawing offscreen - -/* -using Psychlops; - -namespace Psychlops -{ - - 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) + while (!Keyboard.esc.pushed()) { - dot.centering(p).draw(); - } - } - } -} - - -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