OSDN Git Service

shader
authorHOSOKAWA Kenchi <hskwk@users.sourceforge.jp>
Mon, 23 May 2011 23:11:28 +0000 (08:11 +0900)
committerHOSOKAWA Kenchi <hskwk@users.sourceforge.jp>
Mon, 23 May 2011 23:11:28 +0000 (08:11 +0900)
dev4/PsychlopsSilverlight4.csproj
dev4/Shader/Grating.fx
dev4/Shader/Plaid.fx
dev4/psychlops/extention/standard/shader.cs
test4/PsychlopsMain.cs

index 37bd4af..571b9cb 100644 (file)
@@ -93,6 +93,8 @@
     <Compile Include="psychlops\extention\standard\widget.cs" />\r
     <Compile Include="psychlops\psychlops.cs" />\r
     <Compile Include="psychlops\core\graphic\shape.cs" />\r
+    <Resource Include="Shader\Grating.ps" />\r
+    <Resource Include="Shader\Plaid.ps" />\r
     <Resource Include="Shader\Gabor.ps" />\r
     <Resource Include="Shader\GaborAlpha.ps" />\r
   </ItemGroup>\r
index 88d73b8..f3ddd05 100644 (file)
@@ -22,6 +22,17 @@ float phase: register(C3);
 /// <defaultValue>0</defaultValue>\r
 float orientation: register(C4);\r
 \r
+/// <summary>Width of envelope</summary>\r
+/// <minValue>1</minValue>\r
+/// <maxValue>1024</maxValue>\r
+/// <defaultValue>32</defaultValue>\r
+float SizeH : register(C5);\r
+\r
+/// <summary>Height of envelope</summary>\r
+/// <minValue>1</minValue>\r
+/// <maxValue>1024</maxValue>\r
+/// <defaultValue>32</defaultValue>\r
+float SizeV : register(C6);\r
 \r
 float rp(float2 uv)\r
 {\r
index e8635d1..1441994 100644 (file)
@@ -46,6 +46,18 @@ float phase2: register(C7);
 /// <defaultValue>0.785398</defaultValue>\r
 float orientation2: register(C8);\r
 \r
+/// <summary>Width of envelope</summary>\r
+/// <minValue>1</minValue>\r
+/// <maxValue>1024</maxValue>\r
+/// <defaultValue>32</defaultValue>\r
+float SizeH : register(C9);\r
+\r
+/// <summary>Height of envelope</summary>\r
+/// <minValue>1</minValue>\r
+/// <maxValue>1024</maxValue>\r
+/// <defaultValue>32</defaultValue>\r
+float SizeV : register(C10);\r
+\r
 \r
 float rp(float2 uv)\r
 {\r
index 8a511b6..7d7c935 100644 (file)
@@ -22,6 +22,109 @@ namespace Psychlops
        public static partial class Figures\r
        {\r
 \r
+               public class ShaderGrating : ShaderField\r
+               {\r
+                       protected Shader.GratingProgram ps = null;\r
+                       public ShaderGrating()\r
+                       {\r
+                               initialize__ = initialize___;\r
+                               setParameters = setParameters__;\r
+                       }\r
+                       internal void initialize()\r
+                       {\r
+                               if (!initialized)\r
+                               {\r
+                                       Main.canvas.beginInvoke(initialize___);\r
+                                       initialized = true;\r
+                               }\r
+                       }\r
+                       internal void initialize___()\r
+                       {\r
+                               if (!initialized)\r
+                               {\r
+                                       if (ps == null)\r
+                                       {\r
+                                               ps = new Shader.GratingProgram();\r
+                                               initializeShader();\r
+                                       }\r
+                                       shader = ps;\r
+                                       initialized = true;\r
+                               }\r
+                       }\r
+\r
+                       public double contrast = 1.0, wavelength = 20.0, phase = 0.0, orientation = 0.0;\r
+                       public ShaderGrating setSize(double s) { set(s, s); return this; }\r
+                       public ShaderGrating setSize(double h, double v) { set(h, v); return this; }\r
+\r
+                       public void setParameters__()\r
+                       {\r
+                               ps.Contrast = contrast;\r
+                               ps.WaveLength = wavelength;\r
+                               ps.Phase = phase;\r
+                               ps.Orientation = orientation;\r
+                               ps.SizeH = width;\r
+                               ps.SizeV = height;\r
+                               ps.Update();\r
+                       }\r
+\r
+\r
+               }\r
+\r
+\r
+               public class ShaderPlaid : ShaderField\r
+               {\r
+                       protected Shader.PlaidProgram ps = null;\r
+                       public ShaderPlaid()\r
+                       {\r
+                               initialize__ = initialize___;\r
+                               setParameters = setParameters__;\r
+                       }\r
+                       internal void initialize()\r
+                       {\r
+                               if (!initialized)\r
+                               {\r
+                                       Main.canvas.beginInvoke(initialize___);\r
+                                       initialized = true;\r
+                               }\r
+                       }\r
+                       internal void initialize___()\r
+                       {\r
+                               if (!initialized)\r
+                               {\r
+                                       if (ps == null)\r
+                                       {\r
+                                               ps = new Shader.PlaidProgram();\r
+                                               initializeShader();\r
+                                       }\r
+                                       shader = ps;\r
+                                       initialized = true;\r
+                               }\r
+                       }\r
+\r
+                       public double contrast = 0.5, wavelength = 20.0, phase = 0.0, orientation = 0.0;\r
+                       public double contrast2 = 0.5, wavelength2 = 20.0, phase2 = 0.0, orientation2 = Math.PI / 4;\r
+                       public ShaderPlaid setSize(double s) { set(s, s); return this; }\r
+                       public ShaderPlaid setSize(double h, double v) { set(h, v); return this; }\r
+\r
+                       public void setParameters__()\r
+                       {\r
+                               ps.Contrast = contrast;\r
+                               ps.WaveLength = wavelength;\r
+                               ps.Phase = phase;\r
+                               ps.Orientation = orientation;\r
+                               ps.Size = width;\r
+                               ps.Contrast2 = contrast;\r
+                               ps.WaveLength2 = wavelength;\r
+                               ps.Phase2 = phase;\r
+                               ps.Orientation2 = orientation;\r
+                               ps.SizeH = width;\r
+                               ps.SizeV = height;\r
+                               ps.Update();\r
+                       }\r
+\r
+\r
+               }\r
+\r
 \r
                public class ShaderGabor : ShaderField\r
                {\r
@@ -150,6 +253,334 @@ namespace Psychlops
                {\r
                }\r
 \r
+               #region GratingProgram\r
+               public class GratingProgram : ShaderProgram\r
+               {\r
+                       public static readonly Uri ps = new Uri(@"/PsychlopsSilverlight4;component/Shader/Grating.ps", UriKind.Relative);\r
+\r
+                       public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(GratingProgram), 0);\r
+                       public static readonly DependencyProperty ContrastProperty = DependencyProperty.Register("Contrast", typeof(double), typeof(GratingProgram), new PropertyMetadata(((double)(1D)), PixelShaderConstantCallback(1)));\r
+                       public static readonly DependencyProperty FrequencyProperty = DependencyProperty.Register("Frequency", typeof(double), typeof(GratingProgram), new PropertyMetadata(((double)(100D)), PixelShaderConstantCallback(2)));\r
+                       public static readonly DependencyProperty PhaseProperty = DependencyProperty.Register("Phase", typeof(double), typeof(GratingProgram), new PropertyMetadata(((double)(0D)), PixelShaderConstantCallback(3)));\r
+                       public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register("Orientation", typeof(double), typeof(GratingProgram), new PropertyMetadata(((double)(0D)), PixelShaderConstantCallback(4)));\r
+                       public static readonly DependencyProperty SizeHProperty = DependencyProperty.Register("SizeH", typeof(double), typeof(GratingProgram), new PropertyMetadata(((double)(32D)), PixelShaderConstantCallback(5)));\r
+                       public static readonly DependencyProperty SizeVProperty = DependencyProperty.Register("SizeV", typeof(double), typeof(GratingProgram), new PropertyMetadata(((double)(32D)), PixelShaderConstantCallback(6)));\r
+                       public GratingProgram()\r
+                       {\r
+                               PixelShader pixelShader = new PixelShader();\r
+                               pixelShader.UriSource = ps;\r
+                               this.PixelShader = pixelShader;\r
+\r
+                               this.UpdateShaderValue(InputProperty);\r
+                               this.UpdateShaderValue(ContrastProperty);\r
+                               this.UpdateShaderValue(FrequencyProperty);\r
+                               this.UpdateShaderValue(PhaseProperty);\r
+                               this.UpdateShaderValue(OrientationProperty);\r
+                               this.UpdateShaderValue(SizeHProperty);\r
+                               this.UpdateShaderValue(SizeVProperty);\r
+\r
+                               Size = 200;\r
+                               Contrast = 1.0;\r
+                               WaveLength = 100.0;\r
+                               Orientation = 0.0;\r
+                               SizeH = 32.0;\r
+                               SizeV = 32.0;\r
+                       }\r
+\r
+                       public void Update()\r
+                       {\r
+                               this.UpdateShaderValue(InputProperty);\r
+                               this.UpdateShaderValue(ContrastProperty);\r
+                               this.UpdateShaderValue(FrequencyProperty);\r
+                               this.UpdateShaderValue(PhaseProperty);\r
+                               this.UpdateShaderValue(OrientationProperty);\r
+                               this.UpdateShaderValue(SizeHProperty);\r
+                               this.UpdateShaderValue(SizeVProperty);\r
+                       }\r
+\r
+\r
+                       private double size__, wavelength__;\r
+                       public double Size { get { return size__; } set { size__ = value; setFrequency(); } }\r
+                       private void setFrequency()\r
+                       {\r
+                               double freq = size__ * 2.0 * Math.PI / (wavelength__);\r
+                               this.SetValue(FrequencyProperty, freq);\r
+                       }\r
+\r
+                       /// <summary>Amplitude of Grating</summary>\r
+                       public double Contrast\r
+                       {\r
+                               get\r
+                               {\r
+                                       return ((double)(this.GetValue(ContrastProperty))) * 2.0;\r
+                               }\r
+                               set\r
+                               {\r
+                                       this.SetValue(ContrastProperty, value / 2.0);\r
+                               }\r
+                       }\r
+                       /// <summary>Phase of Grating</summary>\r
+                       public double WaveLength\r
+                       {\r
+                               get\r
+                               {\r
+                                       return wavelength__;\r
+                               }\r
+                               set\r
+                               {\r
+                                       wavelength__ = value;\r
+                                       setFrequency();\r
+                               }\r
+                       }\r
+                       /// <summary>Phase of Grating</summary>\r
+                       public double Phase\r
+                       {\r
+                               get\r
+                               {\r
+                                       return ((double)(this.GetValue(PhaseProperty)));\r
+                               }\r
+                               set\r
+                               {\r
+                                       this.SetValue(PhaseProperty, value);\r
+                               }\r
+                       }\r
+                       /// <summary>Orientation of Grating</summary>\r
+                       public double Orientation\r
+                       {\r
+                               get\r
+                               {\r
+                                       return ((double)(this.GetValue(OrientationProperty)));\r
+                               }\r
+                               set\r
+                               {\r
+                                       this.SetValue(OrientationProperty, value);\r
+                               }\r
+                       }\r
+                       /// <summary>Width of envelope</summary>\r
+                       public double SizeH\r
+                       {\r
+                               get\r
+                               {\r
+                                       return ((double)(this.GetValue(SizeHProperty)));\r
+                               }\r
+                               set\r
+                               {\r
+                                       this.SetValue(SizeHProperty, value);\r
+                               }\r
+                       }\r
+                       /// <summary>Height of Figure</summary>\r
+                       public double SizeV\r
+                       {\r
+                               get\r
+                               {\r
+                                       return ((double)(this.GetValue(SizeVProperty)));\r
+                               }\r
+                               set\r
+                               {\r
+                                       this.SetValue(SizeVProperty, value);\r
+                               }\r
+                       }\r
+               }\r
+               #endregion\r
+\r
+               #region PlaidProgram\r
+               public class PlaidProgram : ShaderProgram\r
+               {\r
+                       public static readonly Uri ps = new Uri(@"/PsychlopsSilverlight4;component/Shader/Plaid.ps", UriKind.Relative);\r
+\r
+                       public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(PlaidProgram), 0);\r
+                       public static readonly DependencyProperty ContrastProperty = DependencyProperty.Register("Contrast", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(0.5D)), PixelShaderConstantCallback(1)));\r
+                       public static readonly DependencyProperty FrequencyProperty = DependencyProperty.Register("Frequency", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(100D)), PixelShaderConstantCallback(2)));\r
+                       public static readonly DependencyProperty PhaseProperty = DependencyProperty.Register("Phase", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(0D)), PixelShaderConstantCallback(3)));\r
+                       public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register("Orientation", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(0D)), PixelShaderConstantCallback(4)));\r
+                       public static readonly DependencyProperty Contrast2Property = DependencyProperty.Register("Contrast2", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(0.5D)), PixelShaderConstantCallback(5)));\r
+                       public static readonly DependencyProperty Frequency2Property = DependencyProperty.Register("Frequency2", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(100D)), PixelShaderConstantCallback(6)));\r
+                       public static readonly DependencyProperty Phase2Property = DependencyProperty.Register("Phase2", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(0D)), PixelShaderConstantCallback(7)));\r
+                       public static readonly DependencyProperty Orientation2Property = DependencyProperty.Register("Orientation2", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(0.785398D)), PixelShaderConstantCallback(8)));\r
+                       public static readonly DependencyProperty SizeHProperty = DependencyProperty.Register("SizeH", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(32D)), PixelShaderConstantCallback(9)));\r
+                       public static readonly DependencyProperty SizeVProperty = DependencyProperty.Register("SizeV", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(32D)), PixelShaderConstantCallback(10)));\r
+                       public PlaidProgram()\r
+                       {\r
+                               PixelShader pixelShader = new PixelShader();\r
+                               pixelShader.UriSource = ps;\r
+                               this.PixelShader = pixelShader;\r
+\r
+                               this.UpdateShaderValue(InputProperty);\r
+                               this.UpdateShaderValue(ContrastProperty);\r
+                               this.UpdateShaderValue(FrequencyProperty);\r
+                               this.UpdateShaderValue(PhaseProperty);\r
+                               this.UpdateShaderValue(OrientationProperty);\r
+                               this.UpdateShaderValue(Contrast2Property);\r
+                               this.UpdateShaderValue(Frequency2Property);\r
+                               this.UpdateShaderValue(Phase2Property);\r
+                               this.UpdateShaderValue(Orientation2Property);\r
+                               this.UpdateShaderValue(SizeHProperty);\r
+                               this.UpdateShaderValue(SizeVProperty);\r
+\r
+                               Size = 200;\r
+                               Contrast = 0.5;\r
+                               WaveLength = 100.0;\r
+                               Phase = 0.0;\r
+                               Orientation = 0.0;\r
+                               Contrast2 = 0.5;\r
+                               WaveLength2 = 100.0;\r
+                               Phase2 = 0.0;\r
+                               Orientation2 = Math.PI/4;\r
+                               SizeH = 32.0;\r
+                               SizeV = 32.0;\r
+                       }\r
+\r
+                       public void Update()\r
+                       {\r
+                               this.UpdateShaderValue(InputProperty);\r
+                               this.UpdateShaderValue(ContrastProperty);\r
+                               this.UpdateShaderValue(FrequencyProperty);\r
+                               this.UpdateShaderValue(PhaseProperty);\r
+                               this.UpdateShaderValue(OrientationProperty);\r
+                               this.UpdateShaderValue(Contrast2Property);\r
+                               this.UpdateShaderValue(Frequency2Property);\r
+                               this.UpdateShaderValue(Phase2Property);\r
+                               this.UpdateShaderValue(Orientation2Property);\r
+                               this.UpdateShaderValue(SizeHProperty);\r
+                               this.UpdateShaderValue(SizeVProperty);\r
+                       }\r
+\r
+\r
+                       private double size__, wavelength__, wavelength2__;\r
+                       public double Size { get { return size__; } set { size__ = value; setFrequency(); } }\r
+                       private void setFrequency()\r
+                       {\r
+                               double freq = size__ * 2.0 * Math.PI / (wavelength__);\r
+                               this.SetValue(FrequencyProperty, freq);\r
+                               double freq2 = size__ * 2.0 * Math.PI / (wavelength2__);\r
+                               this.SetValue(Frequency2Property, freq);\r
+                       }\r
+\r
+                       /// <summary>Amplitude of Grating</summary>\r
+                       public double Contrast\r
+                       {\r
+                               get\r
+                               {\r
+                                       return ((double)(this.GetValue(ContrastProperty))) * 2.0;\r
+                               }\r
+                               set\r
+                               {\r
+                                       this.SetValue(ContrastProperty, value / 2.0);\r
+                               }\r
+                       }\r
+                       /// <summary>Phase of Grating</summary>\r
+                       public double WaveLength\r
+                       {\r
+                               get\r
+                               {\r
+                                       return wavelength__;\r
+                               }\r
+                               set\r
+                               {\r
+                                       wavelength__ = value;\r
+                                       setFrequency();\r
+                               }\r
+                       }\r
+                       /// <summary>Phase of Grating</summary>\r
+                       public double Phase\r
+                       {\r
+                               get\r
+                               {\r
+                                       return ((double)(this.GetValue(PhaseProperty)));\r
+                               }\r
+                               set\r
+                               {\r
+                                       this.SetValue(PhaseProperty, value);\r
+                               }\r
+                       }\r
+                       /// <summary>Orientation of Grating</summary>\r
+                       public double Orientation\r
+                       {\r
+                               get\r
+                               {\r
+                                       return ((double)(this.GetValue(OrientationProperty)));\r
+                               }\r
+                               set\r
+                               {\r
+                                       this.SetValue(OrientationProperty, value);\r
+                               }\r
+                       }\r
+                       /// <summary>Amplitude of Grating</summary>\r
+                       public double Contrast2\r
+                       {\r
+                               get\r
+                               {\r
+                                       return ((double)(this.GetValue(Contrast2Property))) * 2.0;\r
+                               }\r
+                               set\r
+                               {\r
+                                       this.SetValue(Contrast2Property, value / 2.0);\r
+                               }\r
+                       }\r
+                       /// <summary>Phase of Grating</summary>\r
+                       public double WaveLength2\r
+                       {\r
+                               get\r
+                               {\r
+                                       return wavelength2__;\r
+                               }\r
+                               set\r
+                               {\r
+                                       wavelength2__ = value;\r
+                                       setFrequency();\r
+                               }\r
+                       }\r
+                       /// <summary>Phase2 of Grating</summary>\r
+                       public double Phase2\r
+                       {\r
+                               get\r
+                               {\r
+                                       return ((double)(this.GetValue(Phase2Property)));\r
+                               }\r
+                               set\r
+                               {\r
+                                       this.SetValue(Phase2Property, value);\r
+                               }\r
+                       }\r
+                       /// <summary>Orientation2 of Grating</summary>\r
+                       public double Orientation2\r
+                       {\r
+                               get\r
+                               {\r
+                                       return ((double)(this.GetValue(Orientation2Property)));\r
+                               }\r
+                               set\r
+                               {\r
+                                       this.SetValue(Orientation2Property, value);\r
+                               }\r
+                       }\r
+                       /// <summary>Width of envelope</summary>\r
+                       public double SizeH\r
+                       {\r
+                               get\r
+                               {\r
+                                       return ((double)(this.GetValue(SizeHProperty)));\r
+                               }\r
+                               set\r
+                               {\r
+                                       this.SetValue(SizeHProperty, value);\r
+                               }\r
+                       }\r
+                       /// <summary>Height of Figure</summary>\r
+                       public double SizeV\r
+                       {\r
+                               get\r
+                               {\r
+                                       return ((double)(this.GetValue(SizeVProperty)));\r
+                               }\r
+                               set\r
+                               {\r
+                                       this.SetValue(SizeVProperty, value);\r
+                               }\r
+                       }\r
+               }\r
+               #endregion\r
+\r
                #region GaborProgram\r
                public class GaborProgram : ShaderProgram\r
                {\r
index 7a79979..16acfd8 100644 (file)
@@ -1,4 +1,79 @@
-/*\r
+\r
+\r
+\r
+using Psychlops;\r
+//Position Bias Program\r
+namespace PsychlopsSilverlightApp\r
+{\r
+\r
+       public class PsychlopsMain\r
+       {\r
+               Canvas cnvs;\r
+               Image img, img2, img3;\r
+               int isize = 40;\r
+               int frames;\r
+               Psychlops.Widgets.Slider tfreq;\r
+               Psychlops.Widgets.Slider contrast;\r
+               Psychlops.Widgets.Slider lambda;\r
+\r
+\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
+                       var gabor1 = StaticFunctions.NewArray<Figures.ShaderGabor>(100);\r
+                       foreach (var g in gabor1)\r
+                       {\r
+                               g.setSigma(isize/8).centering().shift(Math.random(300) - 150, Math.random(600) - 300);\r
+                               //g.setSize(isize).centering().shift(Math.random(300) - 150, Math.random(600) - 300);\r
+                               g.orientation = Math.random(2 * Math.PI);\r
+                               //g.orientation2 = Math.random(2 * Math.PI);\r
+                       }\r
+\r
+                       while (true)\r
+                       {\r
+                               cnvs.clear(new Color(0.5));\r
+\r
+                               Figures.drawGabor(ref img, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60);\r
+                               Figures.drawGabor(ref img2, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * -tfreq / 60);\r
+                               Figures.drawGabor(ref img3, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60);\r
+\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
+\r
+                               foreach (var g in gabor1)\r
+                               {\r
+                                       g.wavelength = lambda;\r
+                                       g.phase = (double)frames * 2.0 * Math.PI * tfreq / 60;\r
+                                       g.contrast = contrast;\r
+                                       //g.wavelength2 = lambda * 2;\r
+                                       //g.phase2 = (double)frames * 2.0 * Math.PI * tfreq / 60;\r
+                                       //g.contrast2 = contrast / 2;\r
+                                       g.draw();\r
+                               }\r
+\r
+                               if (!Mouse.left.pressed()) frames++;\r
+\r
+                               cnvs.flip();\r
+                       }\r
+               }\r
+       }\r
+}\r
+\r
+\r
+/*\r
 ///+ Prefix linkto BasicCode1\r
 //// Lines for set up Psychlops environment\r
 using Psychlops;\r
@@ -540,75 +615,3 @@ using Psychlops;
        }\r
 }\r
 */\r
-\r
-\r
-\r
-using Psychlops;\r
-//Position Bias Program\r
-namespace PsychlopsSilverlightApp\r
-{\r
-\r
-    public class PsychlopsMain\r
-    {\r
-        Canvas cnvs;\r
-        Image img, img2, img3;\r
-        int isize = 40;        \r
-        int frames;\r
-        Psychlops.Widgets.Slider tfreq;\r
-        Psychlops.Widgets.Slider contrast;\r
-        Psychlops.Widgets.Slider lambda;\r
-               \r
-\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
-<<<<<<< HEAD
-                       var gabor1 = StaticFunctions.NewArray<Figures.ShaderGabor>(100);\r
-=======
-                       var gabor1 = StaticFunctions.NewArray<Figures.ShaderGaborAlpha>(100);\r
->>>>>>> remotes/psychlopssilverlight/master
-                       foreach(var g in gabor1)\r
-                       {\r
-                               g.setSigma(isize / 8).centering().shift(Math.random(300) - 150, Math.random(600) - 300);\r
-                               g.orientation = Math.random(2*Math.PI);\r
-                       }\r
-\r
-            while (true)\r
-                       {\r
-                cnvs.clear(new Color(0.5));\r
-\r
-                Figures.drawGabor(ref img, isize / 8, 1/lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60);\r
-                               Figures.drawGabor(ref img2, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * -tfreq / 60);\r
-                               Figures.drawGabor(ref img3, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60);\r
-\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
-\r
-                               foreach (var g in gabor1)\r
-                               {\r
-                                       g.wavelength = lambda;\r
-                                       g.phase = (double)frames * 2.0 * Math.PI * tfreq / 60;\r
-                                       g.contrast = contrast;\r
-                                       g.draw();\r
-                               }\r
-                \r
-                if (!Mouse.left.pressed()) frames++;\r
-\r
-                cnvs.flip();\r
-            }\r
-        }\r
-    }\r
-}\r