// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。\r
// アセンブリに関連付けられている情報を変更するには、\r
// これらの属性値を変更してください。\r
-[assembly: AssemblyTitle("PsychlopsSilverlight3")]\r
+[assembly: AssemblyTitle("PsychlopsSilverlight4")]\r
[assembly: AssemblyDescription("")]\r
[assembly: AssemblyConfiguration("")]\r
[assembly: AssemblyCompany("")]\r
-[assembly: AssemblyProduct("PsychlopsSilverlight3")]\r
+[assembly: AssemblyProduct("PsychlopsSilverlight4")]\r
[assembly: AssemblyCopyright("Copyright © 2010")]\r
[assembly: AssemblyTrademark("")]\r
[assembly: AssemblyCulture("")]\r
<ErrorReport>prompt</ErrorReport>\r
<WarningLevel>4</WarningLevel>\r
</PropertyGroup>\r
+ <PropertyGroup>\r
+ <SignAssembly>false</SignAssembly>\r
+ </PropertyGroup>\r
<ItemGroup>\r
<Reference Include="System.Windows" />\r
<Reference Include="mscorlib" />\r
<Reference Include="system" />\r
<Reference Include="System.Core" />\r
<Reference Include="System.Windows.Controls, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />\r
- <Reference Include="System.Windows.Controls.Data, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />\r
- <Reference Include="System.Windows.Controls.Toolkit, Version=4.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />\r
<Reference Include="System.Xml" />\r
<Reference Include="System.Net" />\r
<Reference Include="System.Windows.Browser" />\r
internal Group[] groupStack;\r
internal int groupStackN = 0;\r
\r
-\r
public StackableDrawable()\r
{\r
stack = new Internal.PrimitiveFigure[CONST.MAX_OBJ_N];\r
}\r
for (int i = 0; i < CONST.HOBJ_N; i++)\r
{\r
- imageStack[i] = new Image(1, 1);\r
- groupStack[i] = new Group();\r
+ imageStack[i] = new Image();\r
+// groupStack[i] = new Group();\r
}\r
}\r
\r
public virtual void line(Line drawee) { drawee.copyToStack(this); }\r
public virtual void rect(Rectangle drawee) { drawee.copyToStack(this); }\r
public virtual void ellipse(Ellipse drawee) { drawee.copyToStack(this); }\r
+ public virtual void oval(Ellipse drawee) { drawee.copyToStack(this); }\r
public virtual void polygon(Polygon drawee) { drawee.copyToStack(this); }\r
public virtual void letters(Letters drawee) { drawee.copyToStack(this); }\r
public virtual void image(Image drawee) { drawee.copyToStack(this); }\r
{\r
before = new Clock();\r
before.update();\r
+ var after = new Clock();\r
AsyncInitBool = false;\r
width_ = wid;\r
height_ = hei;\r
api_canvas.Dispatcher.BeginInvoke(new TwoIntProcedure(initialize__), wid, hei);\r
- while(!AsyncInitBool)\r
+ while (!AsyncInitBool)\r
{\r
+ after.update();\r
+ if ((after - before).at_msec() > 1000) break;\r
}\r
Mouse._prime = api_canvas;\r
Main.drawable = this;\r
back_panel = new Rectangle(wid, hei);\r
\r
flipexec = new SimpleProcedure(executeFlip);\r
- AppState.statusBar = "";\r
}\r
protected void initialize__(int wid, int hei)\r
{\r
HtmlElement htmlHost = HtmlPage.Document.GetElementById("silverlightControlHost");\r
//if (htmlHost != null) HtmlPage.Window.Alert("silverlightControlHost is null");\r
htmlHost.SetStyleAttribute("width", (wid).ToString()+"px");\r
- htmlHost.SetStyleAttribute("height", (20+hei).ToString() + "px");\r
+ htmlHost.SetStyleAttribute("height", (hei).ToString() + "px");\r
htmlHost.SetStyleAttribute("margin", "2em auto auto auto");\r
\r
pointPool = new System.Windows.Point[CONST.MOBJ_N];\r
dummyRectPool[i].Visibility = Visibility.Collapsed;\r
}\r
\r
-\r
AsyncInitBool = true;\r
}\r
\r
#region version modifyNative2\r
public void executeFlip()\r
{\r
- Clock after = new Clock();\r
- after.update();\r
- AppState.statusBar = ((after - before).at_msec().ToString()) + " msec";\r
+// Clock after = new Clock();\r
+// after.update();\r
+// AppState.statusBar = ((after - before).at_msec().ToString()) + " msec";\r
\r
Line lineS;\r
Rectangle rectS;\r
}\r
#endregion\r
\r
+\r
+\r
#region version modifyNative\r
/*\r
public void executeFlip()\r
public Stroke stroke { get; set; }\r
}\r
\r
+ public partial class Rectangle_\r
+ {\r
+ public Point v1, v2;\r
+\r
+ public double left { get { return v1.x; } }\r
+ public double top { get { return v1.y; } }\r
+ public double right { get { return v2.x; } }\r
+ public double bottom { get { return v2.y; } }\r
+ public double width { get { return Math.abs(v1.x - v2.x); } }\r
+ public double height { get { return Math.abs(v1.y - v2.y); } }\r
+ public double getLeft() { return left; }\r
+ public double getTop() { return top; }\r
+ public double getRight() { return right; }\r
+ public double getBottom() { return bottom; }\r
+ public double getWidth() { return width; }\r
+ public double getHeight() { return height; }\r
+\r
+\r
+\r
+ public Color fill { get; set; }\r
+ public Stroke stroke { get; set; }\r
+\r
+ public override string ToString()\r
+ {\r
+ return "Left:" + left.ToString() + " Top:" + top.ToString() + " Right:" + right.ToString() + " Bottom:" + bottom.ToString();\r
+ }\r
+ }\r
+\r
\r
public partial class Rectangle : Shape\r
{\r
}\r
}\r
**/\r
+ public class Procedure\r
+ {\r
+ System.Action acc;\r
+ System.Action<Canvas> acc_c;\r
+ int func = 0;\r
+\r
+ public void setDesign()\r
+ {\r
+ }\r
+ public void setProcedure(System.Action ac)\r
+ {\r
+ acc = ac;\r
+ func = 1;\r
+ }\r
+ public void setProcedure(System.Action<Canvas> ac)\r
+ {\r
+ acc_c = ac;\r
+ func = 2;\r
+ }\r
+ public void run()\r
+ {\r
+ if (func == 1)\r
+ {\r
+ acc();\r
+ }\r
+ }\r
+ public void run(Canvas c)\r
+ {\r
+ if (func == 2)\r
+ {\r
+ acc_c(c);\r
+ }\r
+ }\r
+ }\r
\r
public static class Display\r
{\r
public static void line(Line drawee) { Main.canvas.line(drawee); }\r
public static void rect(Rectangle drawee) { Main.canvas.rect(drawee); }\r
public static void ellipse(Ellipse drawee) { Main.canvas.ellipse(drawee); }\r
+ public static void oval(Ellipse drawee) { Main.canvas.ellipse(drawee); }\r
public static void polygon(Polygon drawee) { Main.canvas.polygon(drawee); }\r
public static void letters(Letters drawee) { Main.canvas.letters(drawee); }\r
public static void image(Image drawee) { Main.canvas.image(drawee); }\r
System.Windows.Controls.ChildWindow page = new PsychlopsSilverlight4.Pages.BinomialSolver(f);\r
page.Show();\r
}\r
- * */\r
+ */\r
\r
public int iteration;\r
\r
img = new Image(width, height);\r
double freq = 2 * Math.PI / wavelength;\r
img.field(\r
- (x, y) => new Color(.5 +.5 * Math.sin(phase + (Math.sin(orientation)*x-Math.cos(orientation)*y) * freq))\r
+ (x, y) => new Color(.5 + contrast * .5 * Math.sin(phase + (Math.sin(orientation)*x-Math.cos(orientation)*y) * freq))\r
);\r
}\r
public static void drawGaussian(ref Image img, double sigma, double factor)\r
);\r
}\r
\r
- public static void drawGabor(ref Image img, double sigma, double wavelength, double contrast, double orientation, double phase)\r
+ public static void drawGabor(ref Image img, double sigma, double frequency, double contrast, double orientation, double phase)\r
{\r
int width = (int)(sigma * 8), height = (int)(sigma * 8);\r
double width_half = width / 2.0, height_half = height / 2.0;\r
if (img==null || img.width != width || img.height != height)\r
img = new Image(width, height);\r
- double freq = 2 * Math.PI / wavelength;\r
+ double freq = 2 * Math.PI * frequency;\r
img.field(\r
- (x, y) => new Color(.5 + Math.gaussian(Math.radius(x - width_half, y - height_half), width / 8.0) * .5 * Math.sin(phase + (Math.sin(orientation)*x-Math.cos(orientation)*y) * freq))\r
+ (x, y) => new Color(.5 + contrast * Math.gaussian(Math.radius(x - width_half, y - height_half), width / 8.0) * .5 * Math.sin(phase + (Math.sin(orientation) * x - Math.cos(orientation) * y) * freq))\r
);\r
}\r
\r
\r
/*\r
var ur = new System.Uri("Resources/Benham.png", System.UriKind.RelativeOrAbsolute);\r
- var bitmap = new System.Windows.Media.Imaging.BitmapImage(ur);\r
+ var bitmap = new System.Windows.Media.Imaging.BitmapImage(ur);\r
var img = new System.Windows.Controls.Image();\r
img.Source = bitmap;\r
System.Windows.Controls.Canvas.SetLeft(img, 100);\r
-\r
-///+ Prefix\r
-//// Lines for set up Psychlops environment\r
-using Psychlops;\r
-\r
+using Psychlops;\r
+//Position Bias Program\r
namespace PsychlopsSilverlightApp\r
{\r
\r
- public class PsychlopsMain\r
- {///- Prefix\r
-\r
- ///+ Main Routine\r
- //// Psychlops runs at the first line of this function psychlops_main().\r
- public void psychlops_main()\r
- {\r
- ///+ 1\r
- //// Set a window for drawing stimulus\r
- Canvas window = new Canvas(300, 300); //Create a window. Here, window variables are preset mode.\r
- // You can write this statement as" Canvas window = new Canvas(Canvas.fullscreen); " for fullscreen mode\r
- // or as " Canvas window = new Canvas(1024, 768, 32, 60.0); " This statement changes screenmode to 1024 x 768, 32bit color, 60 Hz refresh.\r
- ///- 1\r
-\r
- var FIGURE = Psychlops.Widgets.Browser.Element.byID("FIGURE");\r
- var SIZE_X = Psychlops.Widgets.Browser.Element.byID("SIZE_X");\r
- var SIZE_Y = Psychlops.Widgets.Browser.Element.byID("SIZE_Y");\r
- var SHIFT_X = Psychlops.Widgets.Browser.Element.byID("SHIFT_X");\r
- var SHIFT_Y = Psychlops.Widgets.Browser.Element.byID("SHIFT_Y");\r
- var COLOR_R = Psychlops.Widgets.Browser.Element.byID("COLOR_R");\r
- var COLOR_G = Psychlops.Widgets.Browser.Element.byID("COLOR_G");\r
- var COLOR_B = Psychlops.Widgets.Browser.Element.byID("COLOR_B");\r
-\r
-\r
- ///+ 2\r
- //// Set a figure size, position and color.\r
- Rectangle figure = new Rectangle();\r
- Ellipse figure2 = new Ellipse();\r
-\r
- window.flip(); // Reflect the drawing for the display by flipping frame buffers.\r
- // Till this point, you will not see drawn figures.\r
- ///- 2\r
-\r
- ///+ 3 \r
- //// Detect a Keyboard input\r
- while (!Keyboard.esc.pushed())\r
- {\r
-\r
- window.clear();\r
-\r
- if ("Rectangle".Equals(FIGURE))\r
- {\r
- figure.set(SIZE_X, SIZE_Y); // Set the size of figure.\r
- figure.centering(); // Centering the figure in the window\r
- figure.shift(SHIFT_X, SHIFT_Y); // Displacing the figure by designated vector. \r
- figure.draw(new Color(COLOR_R, COLOR_G, COLOR_B)); // Drawing the rectangle with a designated color.\r
- }\r
- else\r
- {\r
- figure2.set(SIZE_X, SIZE_Y); // Set the size of figure.\r
- figure2.centering(); // Centering the figure in the window\r
- figure2.shift(SHIFT_X, SHIFT_Y); // Displacing the figure by designated vector. \r
- figure2.draw(new Color(COLOR_R, COLOR_G, COLOR_B)); // Drawing the rectangle with a designated color.\r
- }\r
-\r
- window.flip();\r
-\r
- } //exit a program when the escape key is pressed down.\r
- ///- 3\r
-\r
- }\r
- ///- Main Routine\r
-\r
- }\r
-\r
-}\r
-\r
-\r
+ public class PsychlopsMain\r
+ {\r
+ Canvas cnvs;\r
+ Image img, img2, img3;\r
+ int isize = 80; \r
+ int frames;\r
+ Psychlops.Widgets.Slider tfreq;\r
+ Psychlops.Widgets.Slider contrast;\r
+ Psychlops.Widgets.Slider lambda;\r
+\r
+ public void psychlops_main()\r
+ {\r
+ cnvs = new Canvas(300, 600);\r
+ Interval rng = new Interval();\r
+ tfreq = new Psychlops.Widgets.Slider("Temporal Frequency(Hz)", -5 <= rng <= 5, 3.0);\r
+ contrast = new Psychlops.Widgets.Slider("Contrast", 0.0 <= rng <= 1.0, 0.25);\r
+ lambda = new Psychlops.Widgets.Slider("Wave Length", 10.0 <= rng <= 120.0, 30);\r
+\r
+ img = new Image(isize * 2, isize * 2);\r
+ img2 = new Image(isize * 2, isize * 2);\r
+ img3 = new Image(isize * 2, isize * 2);\r
+\r
+\r
+ while (true)\r
+ {\r
+ cnvs.clear(new Color(0.5));\r
+\r
+ Figures.drawGabor(ref img, isize / 6, 1/lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60);\r
+ Figures.drawGabor(ref img2, isize / 6, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * -tfreq / 60);\r
+ Figures.drawGabor(ref img3, isize / 6, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60);\r
+\r
+ img.centering().shift(0, -isize * 1.5).draw();\r
+ img2.centering().draw();\r
+ img3.centering().shift(0, isize * 1.5).draw();\r
+ \r
+ if (!Mouse.left.pressed()) frames++;\r
+\r
+ cnvs.flip();\r
+ }\r
+ }\r
+ }\r
+}
\ No newline at end of file
</PropertyGroup>\r
<ItemGroup>\r
<Reference Include="PsychlopsSilverlight4">\r
- <HintPath>..\dev4\Bin\Debug\PsychlopsSilverlight4.dll</HintPath>\r
+ <HintPath>..\dev4\Bin\Release\PsychlopsSilverlight4.dll</HintPath>\r
</Reference>\r
<Reference Include="System.Windows" />\r
<Reference Include="mscorlib" />\r
\r
\r
\r
+/*\r
+using Psychlops;\r
+\r
+namespace PsychlopsSilverlightApp\r
+{\r
+\r
+ public class PsychlopsMain\r
+ {\r
+\r
+ Psychlops.Widgets.Slider rect_size, freq, contrast;\r
+\r
+ void PositionalBiasisInMovingGabor()\r
+ {\r
+ double vel = 30.0;\r
+ double StimWidth = 120;\r
+\r
+ Interval rng = new Interval();\r
+ Psychlops.Widgets.Slider rect_size, freq, contrast;\r
+ rect_size = new Psychlops.Widgets.Slider("Rect Size", 1 < rng < 500, 120.0);\r
+ freq = new Psychlops.Widgets.Slider("Sptial Frequency", 0.0 <= rng <= 1.0, 0.125);\r
+ contrast = new Psychlops.Widgets.Slider("Contrast", 0.0 <= rng <= 1.0, 0.1);\r
+\r
+ int IMAGES = (int)vel;\r
+\r
+ Image[] GaborIMG = new Image[200];\r
+ for (int i = 0; i < 200; i++) GaborIMG[i] = new Image();\r
+\r
+ Color clrcol = new Color(), clrFP = new Color();\r
+ Display.clear(0.5);\r
+ clrcol.set(128.0 / 255.0);\r
+ clrFP.set(128.0 / 255.0, 0.0, 0.0);\r
+\r
+ int phase = 0;\r
+ double distance = rect_size;\r
+ bool changed = true, stop = false;\r
+ double prev_contrast = 0.0, prev_freq = 0.0, prev_size = 0.0;\r
+\r
+ while (!Keyboard.esc.pushed())\r
+ {\r
+ Display.clear();\r
+\r
+ if (prev_contrast != contrast || prev_freq != freq || prev_size != rect_size) changed = true;\r
+ prev_contrast = contrast;\r
+ prev_freq = freq;\r
+ prev_size = rect_size;\r
+ if (changed)\r
+ {\r
+ for (int i = 0; i < 2; i++)\r
+ {\r
+ for (int j = 0; j < IMAGES; j++)\r
+ {\r
+ Figures.drawGabor(ref GaborIMG[i * IMAGES + j], rect_size / 8.0, freq, contrast, Math.PI * 0.5, 2.0 * Math.PI * j / IMAGES);\r
+ distance = rect_size;\r
+ }\r
+ }\r
+ changed = false;\r
+ }\r
+\r
+ if (!stop)\r
+ {\r
+ Display.clear(127.0 / 255.0);\r
+ for (int i = 0; i < 3; i++)\r
+ {\r
+ switch (i)\r
+ {\r
+ case 0:\r
+ GaborIMG[IMAGES - phase - 1].centering().shift(0, -distance);\r
+ GaborIMG[IMAGES - phase - 1].draw(); break;\r
+ case 1:\r
+ GaborIMG[phase].centering().shift(0, 0);\r
+ GaborIMG[phase].draw(); break;\r
+ case 2:\r
+ GaborIMG[IMAGES - phase - 1].centering().shift(0, +distance);\r
+ GaborIMG[IMAGES - phase - 1].draw(); break;\r
+ }\r
+ }\r
+ }\r
+ if (Keyboard.spc.pushed()) stop = !stop;\r
+ //GaborIMG[0].draw();\r
+\r
+ phase++;\r
+ phase %= IMAGES;\r
+ //if (!stop) Display.flip();\r
+ Display.flip();\r
+\r
+ }\r
+\r
+ }\r
+\r
+\r
+ public void psychlops_main()\r
+ {\r
+\r
+ Canvas display = new Canvas(Canvas.window);\r
+\r
+ PositionalBiasisInMovingGabor();\r
+\r
+ }\r
+\r
+\r
+\r
+ }\r
+\r
+}\r
+ */\r
+/*\r
+ * \r
+ * using Psychlops;\r
+\r
+namespace PsychlopsSilverlightApp\r
+{\r
+\r
+ public class PsychlopsMain\r
+ {\r
+\r
+ Psychlops.Canvas cnvs;\r
+ int i;\r
+ double x, y, z, t, p, temp, xx, yy;\r
+\r
+ //Set Target Initial Value\r
+ double TargetEcce = 100.0, TargetSize = 5.0, TargetNumber = 5, Rotate = 0.0;\r
+\r
+ //Set Background Initial Value\r
+ double Axis = 0.0, BGRadii = 150, BGSize = 5.0;\r
+ Psychlops.Widgets.Slider thetaSpeed, DotNumber;\r
+ Image img;\r
+\r
+\r
+\r
+ public void psychlops_main()\r
+ {\r
+\r
+ cnvs = new Canvas(500, 500);\r
+\r
+// Psychlops.Solver.BinomialLikelihood.showWindow(Math.cumulativeNormalDistibution);\r
+// img = new Image("Resources/logo.png");\r
+\r
+ Interval rng = new Interval();\r
+ thetaSpeed = new Psychlops.Widgets.Slider("Label", -10 <= rng <= 10, 3.0);\r
+ DotNumber = new Psychlops.Widgets.Slider("DotNum", 0 <= rng <= 100, 50.0);\r
+\r
+ //Declare background dots and target\r
+ Rectangle[] BGDot = new Rectangle[2048];\r
+ for (int i = 0; i < 2048; i++)\r
+ {\r
+ BGDot[i]=new Rectangle();\r
+ }\r
+ Rectangle[] Target= new Rectangle[10];\r
+ for(int i=0; i<10; i++){\r
+ Target[i]=new Rectangle();\r
+ }\r
+\r
+\r
+\r
+ //Declare Matrix to keep back ground dots' coordinate value\r
+ double[] DotX=new double[2048];\r
+ double[] DotY = new double[2048];\r
+\r
+ AppState.statusBar = "dvcscxz";\r
+ //Set Independent variables to manipulate\r
+\r
+\r
+ //Initialize positions of background dots\r
+ for(int i=0; i<2048; i++){\r
+ t=2.0*Math.PI*Math.random(1.0);\r
+ p=2.0*Math.PI*Math.random(1.0);\r
+ DotX[i]=t;\r
+ DotY[i]=p;\r
+\r
+ x=BGRadii*Math.cos(t)*Math.cos(p);\r
+ y=BGRadii*Math.sin(t)*Math.cos(p);\r
+ BGDot[i].set(BGSize, BGSize);\r
+ BGDot[i].centering().shift(x,y);\r
+ }\r
+\r
+ //Initialize positions of targets\r
+ for(int i=0; i<10; i++)Target[i].set(TargetSize, TargetSize);\r
+\r
+ double COS, SIN;\r
+ //DotNumber = 200;\r
+ //Main stimulus loop\r
+ while(true){\r
+ //Clear the main window\r
+ cnvs.clear();\r
+\r
+\r
+ temp=Axis/360*2*Math.PI;\r
+ COS=Math.cos(temp);\r
+ SIN=Math.sin(temp);\r
+\r
+ //Calculate positions of background dots and set them\r
+ for(int i=0; i<DotNumber; i++){\r
+ //Calculate in polar coordinate\r
+ t=DotX[i]+2.0*Math.PI*thetaSpeed/360.0;\r
+ p=DotY[i];\r
+\r
+ //Save current position\r
+ DotX[i]=t;\r
+\r
+ //Convert to Decartes coordinate\r
+ x=BGRadii*Math.cos(t)*Math.cos(p);\r
+ y=BGRadii*Math.sin(t)*Math.cos(p);\r
+ z=BGRadii*Math.sin(p);\r
+ xx=x;\r
+ yy=SIN*y+COS*z;\r
+\r
+ //Set Dotsize and Draw them\r
+ BGDot[i].set(BGSize, BGSize);\r
+ BGDot[i].centering().shift(xx,yy);\r
+ BGDot[i].draw( Color.blue );\r
+ }\r
+\r
+ //Calculate positions of targets and set them\r
+ temp=Rotate*2*Math.PI/360.0;\r
+ for (int i = 0; i < 5; i++)\r
+ {\r
+ t = 2.0 * Math.PI/TargetNumber;\r
+ x = TargetEcce*Math.cos(i*t+temp);\r
+ y = TargetEcce*Math.sin(i*t+temp);\r
+ Target[i].centering().shift(x,y);\r
+ Target[i].fill = Color.yellow;\r
+ Target[i].draw();\r
+ }\r
+\r
+ // img.centering(Mouse.position).draw();\r
+\r
+ cnvs.var(Mouse.position.x, 100, 100);\r
+ cnvs.var(Mouse.position.y, 100, 140);\r
+\r
+ //Reflect drawing at the next frame;\r
+ cnvs.flip();\r
+ }\r
+ }\r
+ }\r
+\r
+}\r
+ * */\r
\r
\r
\r