<Compile Include="psychlops\extention\media\dom.cs" />\r
<Compile Include="psychlops\extention\media\svg.cs" />\r
<Compile Include="psychlops\extention\standard\CIEColor.cs" />\r
+ <Compile Include="psychlops\extention\standard\shader.cs" />\r
<Compile Include="psychlops\extention\standard\figures.cs" />\r
<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\Gabor.ps" />\r
+ <Resource Include="Shader\GaborAlpha.ps" />\r
</ItemGroup>\r
<ItemGroup>\r
<None Include="Pages\BinomialSolver.xaml">\r
<Generator>MSBuild:Compile</Generator>\r
</None>\r
</ItemGroup>\r
+ <ItemGroup />\r
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />\r
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
Other similar extension points exist, see Microsoft.Common.targets.\r
--- /dev/null
+/// <summary>Amplitude of Grating</summary>\r
+/// <minValue>0</minValue>\r
+/// <maxValue>1</maxValue>\r
+/// <defaultValue>1</defaultValue>\r
+float contrast : register(C1);\r
+\r
+/// <summary>Phase of Grating</summary>\r
+/// <minValue>0</minValue>\r
+/// <maxValue>100</maxValue>\r
+/// <defaultValue>100</defaultValue>\r
+float frequency: register(C2);\r
+\r
+/// <summary>Phase of Grating</summary>\r
+/// <minValue>0</minValue>\r
+/// <maxValue>6.283184</maxValue>\r
+/// <defaultValue>0</defaultValue>\r
+float phase: register(C3);\r
+\r
+/// <summary>Orientation of Grating</summary>\r
+/// <minValue>0</minValue>\r
+/// <maxValue>6.283184</maxValue>\r
+/// <defaultValue>0</defaultValue>\r
+float orientation: register(C4);\r
+\r
+/// <summary>Half bandwidth of envelope</summary>\r
+/// <minValue>2</minValue>\r
+/// <maxValue>8</maxValue>\r
+/// <defaultValue>4</defaultValue>\r
+float sigma : register(C5);\r
+\r
+/// <summary>Transparency of Figure</summary>\r
+/// <minValue>0</minValue>\r
+/// <maxValue>1</maxValue>\r
+/// <defaultValue>1</defaultValue>\r
+float alpha : register(C6);\r
+\r
+\r
+float rp(float2 uv)\r
+{\r
+ const float2 Center = float2(0.5,0.5);\r
+ float2 dir = uv - Center; // vector from center to pixel\r
+ float dist = length(dir);\r
+ //dir /= dist;\r
+ return dist;\r
+}\r
+\r
+float4 main(float2 uv : TEXCOORD) : COLOR\r
+//float4 main(float2 uv : VPOS ) : COLOR\r
+{\r
+ //float _r = rp(uv)*sigma*4.0;\r
+ //float env = exp( -(_r*_r) / 2.0 ) * alpha;\r
+ float _r = rp(uv)*8;\r
+ float env = exp( -(_r*_r) / (2.0) ) * alpha;\r
+\r
+ float _x = sin(orientation)*uv[0]-cos(orientation)*uv[1];\r
+ float l = 0.5+env*contrast*0.5*cos(frequency*_x + phase);\r
+ \r
+ float4 color = float4(l,l,l,1.0);\r
+ return color;\r
+}\r
{\r
public static System.Threading.Thread routine;\r
public static System.Threading.AutoResetEvent canvas_flag;\r
+ public static System.Windows.Controls.Canvas layoutRoot;\r
public static System.Windows.Controls.TextBlock statusBar;\r
public static System.Windows.Controls.StackPanel widgetStack;\r
\r
internal int lineStackN = 0;\r
internal Rectangle[] rectStack;\r
internal int rectStackN = 0;\r
+ internal ShaderField[] shaderStack;\r
+ internal int shaderStackN = 0;\r
internal Ellipse[] ellipseStack;\r
internal int ellipseStackN = 0;\r
internal Polygon[] polygonStack;\r
lineStack = new Line[CONST.MOBJ_N];\r
rectStack = new Rectangle[CONST.MOBJ_N];\r
ellipseStack = new Ellipse[CONST.MOBJ_N];\r
+ shaderStack = new ShaderField[CONST.COBJ_N];\r
polygonStack = new Polygon[CONST.COBJ_N];\r
lettersStack = new Letters[CONST.COBJ_N];\r
imageStack = new Image[CONST.HOBJ_N];\r
}\r
for (int i = 0; i < CONST.COBJ_N; i++)\r
{\r
+ shaderStack[i] = new ShaderField();\r
polygonStack[i] = new Polygon();\r
lettersStack[i] = new Letters();\r
}\r
imageStack[i] = new Image();\r
// groupStack[i] = new Group();\r
}\r
+\r
+\r
}\r
\r
public void clear() { clear(Color.black); }\r
public virtual void letters(Letters drawee) { drawee.copyToStack(this); }\r
public virtual void image(Image drawee) { drawee.copyToStack(this); }\r
public virtual void group(Group drawee) { drawee.copyToStack(this); }\r
+ public virtual void shader(ShaderField drawee) { drawee.copyToStack(this); }\r
\r
public void msg(string str, double x, double y) { msg(str, x, y, Color.white); }\r
public virtual void msg(string dstr, double x, double y, Color col)\r
internal System.Windows.Shapes.Rectangle[] dummyRectPool;\r
internal System.Windows.Shapes.Rectangle[] rectPool;\r
internal int rectPoolN;\r
+ internal System.Windows.Shapes.Rectangle[] shaderPool;\r
+ internal int shaderPoolN;\r
internal System.Windows.Shapes.Ellipse[] ellipsePool;\r
internal int ellipsePoolN;\r
internal System.Windows.Shapes.Polygon[] polygonPool;\r
\r
#region initializer\r
\r
- internal delegate void TwoIntProcedure(int x, int y);\r
- internal delegate void SimpleProcedure();\r
- SimpleProcedure flipexec;\r
+ Action flipexec;\r
+ public static IList<Action> initialize_at_canvas_initialize__ = new List<Action>();\r
\r
public static System.Windows.Controls.UserControl default_panel;\r
public static System.Windows.Controls.Canvas default_api_canvas;\r
}\r
\r
protected bool AsyncInitBool;\r
+ internal void beginInvoke(Action a) { api_canvas.Dispatcher.BeginInvoke(a); }\r
protected void initialize(int wid, int hei)\r
{\r
before = new Clock();\r
AsyncInitBool = false;\r
width_ = wid;\r
height_ = hei;\r
- api_canvas.Dispatcher.BeginInvoke(new TwoIntProcedure(initialize__), wid, hei);\r
+ api_canvas.Dispatcher.BeginInvoke(new Action<int,int>(initialize__), wid, hei);\r
while (!AsyncInitBool)\r
{\r
after.update();\r
\r
back_panel = new Rectangle(wid, hei);\r
\r
- flipexec = new SimpleProcedure(executeFlip);\r
+ flipexec = new Action(executeFlip);\r
}\r
protected void initialize__(int wid, int hei)\r
{\r
rectPool[i] = new System.Windows.Shapes.Rectangle();\r
ellipsePool[i] = new System.Windows.Shapes.Ellipse();\r
}\r
+ shaderPool = new System.Windows.Shapes.Rectangle[CONST.COBJ_N];\r
polygonPool = new System.Windows.Shapes.Polygon[CONST.COBJ_N];\r
lettersPool = new System.Windows.Controls.TextBlock[CONST.COBJ_N];\r
for (int i = 0; i < CONST.COBJ_N; i++)\r
{\r
+ shaderPool[i] = new System.Windows.Shapes.Rectangle();\r
polygonPool[i] = new System.Windows.Shapes.Polygon();\r
lettersPool[i] = new System.Windows.Controls.TextBlock();\r
}\r
}\r
\r
AsyncInitBool = true;\r
+\r
+ // initialize at Canvas initializing\r
+ //Figures.ShaderGabor.initialize__();\r
}\r
\r
internal int findEmptyInPool(Dictionary<int, bool> pool)\r
//pointStackN = 0;\r
lineStackN = 0;\r
rectStackN = 0;\r
+ shaderStackN = 0;\r
polygonStackN = 0;\r
ellipseStackN = 0;\r
lettersStackN = 0;\r
// AppState.statusBar = ((after - before).at_msec().ToString()) + " msec";\r
\r
Line lineS;\r
+ ShaderField shaderS;\r
Rectangle rectS;\r
Ellipse ellipseS;\r
Polygon polygonS;\r
Group groupS;\r
System.Windows.Shapes.Line lineP;\r
System.Windows.Shapes.Rectangle rectP;\r
+ System.Windows.Shapes.Rectangle shaderP;\r
System.Windows.Shapes.Ellipse ellipseP;\r
System.Windows.Shapes.Polygon polygonP;\r
System.Windows.Controls.TextBlock lettersP;\r
{\r
for (int i = 0; i < stackN; i++)\r
{\r
- if( null != (rectS = stack[i] as Rectangle) )\r
+ if (null != (shaderS = stack[i] as ShaderField))\r
+ {\r
+ if (null != (shaderP = cnv.Children[0] as System.Windows.Shapes.Rectangle))\r
+ {\r
+ shaderS.modifyNative(shaderP, this);\r
+ }\r
+ else\r
+ {\r
+ cnv.Children.Clear();\r
+ cnv.Children.Add(stack[i].poolNative(this));\r
+ }\r
+ }\r
+ else if( null != (rectS = stack[i] as Rectangle) )\r
{\r
if (null != (rectP = cnv.Children[0] as System.Windows.Shapes.Rectangle))\r
{\r
}\r
\r
#endregion\r
+ \r
+ #region ShaderField\r
+\r
+ partial class ShaderField\r
+ {\r
+ public System.Windows.Media.Effects.Effect shader;\r
+ protected static System.Windows.Media.SolidColorBrush dummyfill = null;\r
+\r
+ protected static void initializeShader()\r
+ {\r
+ dummyfill = new SolidColorBrush(System.Windows.Media.Colors.Blue);\r
+ }\r
+\r
+ public UIElement toNative() { return null; }\r
+ public void copyToStack(Templates.StackableDrawable d)\r
+ {\r
+ var tmp = d.shaderStack[d.shaderStackN];\r
+ tmp.initialize__ = initialize__;\r
+ tmp.setParameters = setParameters;\r
+ tmp.v1 = v1;\r
+ tmp.v2 = v2;\r
+ tmp.shader = shader;\r
+ d.stack[d.stackN] = tmp;\r
+ d.shaderStackN++;\r
+ d.stackN++;\r
+ }\r
+ public UIElement poolNative(Canvas d)\r
+ {\r
+ var tmp = d.shaderPool[d.shaderPoolN];\r
+ tmp.Width = width;\r
+ tmp.Height = height;\r
+ if (!initialized) { initialize__(); }\r
+ setParameters();\r
+ tmp.Effect = shader;\r
+ tmp.Fill = dummyfill;\r
+ System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
+ System.Windows.Controls.Canvas.SetTop(tmp, top);\r
+ tmp.Visibility = Visibility.Visible;\r
+ d.shaderPoolN++;\r
+ return tmp;\r
+ }\r
+ public void modifyNative(System.Windows.Shapes.Rectangle tmp, Canvas d)\r
+ {\r
+ tmp.Width = width;\r
+ tmp.Height = height;\r
+ if (!initialized) { initialize__(); }\r
+ setParameters();\r
+ tmp.Effect = shader;\r
+ tmp.Fill = dummyfill;\r
+ System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
+ System.Windows.Controls.Canvas.SetTop(tmp, top);\r
+ tmp.Visibility = Visibility.Visible;\r
+ }\r
+ }\r
+\r
+ #endregion\r
\r
#region Ellipse\r
\r
internal void initialize__(int wid, int hei)\r
{\r
AsyncBool = false;\r
- Canvas.default_api_canvas.Dispatcher.BeginInvoke(new Canvas.TwoIntProcedure(create__), wid, hei);\r
+ Canvas.default_api_canvas.Dispatcher.BeginInvoke(new Action<int,int>(create__), wid, hei);\r
while (!AsyncBool) { System.Threading.Thread.Sleep(10); }\r
}\r
internal void create__(int wid, int hei)\r
{\r
internal void initialize__()\r
{\r
- Canvas.default_api_canvas.Dispatcher.BeginInvoke(new Canvas.SimpleProcedure(create__));\r
+ Canvas.default_api_canvas.Dispatcher.BeginInvoke(new Action(create__));\r
}\r
internal void create__()\r
{\r
void letters(Letters drawee);\r
void image(Image drawee);\r
void group(Group drawee);\r
+ void shader(ShaderField drawee);\r
void msg(string s, double x, double y, Color c);\r
}\r
\r
}\r
}\r
\r
+\r
+\r
+ public partial class ShaderField : Internal.PrimitiveFigure\r
+ {\r
+ public Point v1, v2;\r
+ \r
+ public ShaderField()\r
+ {\r
+ set(0,0);\r
+ }\r
+ public ShaderField(double wid, double hei)\r
+ {\r
+ initialized = false;\r
+ set(wid, hei);\r
+ }\r
+ public ShaderField(Rectangle another)\r
+ {\r
+ v1 = another.v1;\r
+ v2 = another.v2;\r
+ }\r
+ public ShaderField set(double wid, double hei)\r
+ {\r
+ v1.set(0, 0, 0);\r
+ v2.set(wid, hei, 0);\r
+ return this;\r
+ }\r
+ ShaderField set(Point po1, Point po2)\r
+ {\r
+ v1 = po1;\r
+ v2 = po2;\r
+ return this;\r
+ }\r
+ public ShaderField set(double l, double t, double r, double b)\r
+ {\r
+ v1.set(l, t, 0);\r
+ v2.set(r, b, 0);\r
+ return this;\r
+ }\r
+ public ShaderField set(ShaderField another)\r
+ {\r
+ v1 = another.v1;\r
+ v2 = another.v2;\r
+ return this;\r
+ }\r
+\r
+ public ShaderField resize(double width, double height)\r
+ {\r
+ Point po = center;\r
+ set(width, height);\r
+ centering(po);\r
+ return this;\r
+ }\r
+\r
+\r
+ public Point datum\r
+ {\r
+ get { return v1; }\r
+ set { double w = width, h = height; v1 = value; v2 = v1 + new Point(w,h); }\r
+ }\r
+ public ShaderField move_to(Point p) { datum = p; return this; }\r
+ public ShaderField move_to(double x, double y, double z = 0.0) { datum = new Point(x, y, z); return this; }\r
+ public ShaderField locate(Point p) { datum = p; return this; }\r
+ public ShaderField locate(double x, double y, double z = 0.0) { datum = new Point(x, y, z); return this; }\r
+\r
+ public Figure shift(Point p)\r
+ {\r
+ v1 += p;\r
+ v2 += p;\r
+ return this;\r
+ }\r
+ public Figure centering(Point p)\r
+ {\r
+ double h = width, v = height;\r
+ v1.x = p.x - h / 2.0;\r
+ v1.y = p.y - v / 2.0;\r
+ v2.x = v1.x + h;\r
+ v2.y = v1.y + v;\r
+ return this;\r
+ }\r
+\r
+ public virtual void draw()\r
+ {\r
+ Main.drawable.shader(this);\r
+ }\r
+\r
+ internal Action setParameters = initialize___;\r
+ internal Action initialize__ = initialize___;\r
+ private static void initialize___() {}\r
+ internal bool initialized = false;\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 Point center\r
+ {\r
+ get { return new Point((left + right) / 2, (top + bottom) / 2); }\r
+ set { centering(value); }\r
+ }\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
+ public Point getCenter() { return center; }\r
+ }\r
+\r
}
\ No newline at end of file
namespace Psychlops\r
{\r
\r
- public static class Figures\r
+ public static partial class Figures\r
{\r
\r
public static void drawGrating(ref Image img, int width, int height, double wavelength, double contrast, double orientation, double phase)\r
--- /dev/null
+//------------------------------------------------------------------------------\r
+// <auto-generated>\r
+// このコードはツールによって生成されました。\r
+// ランタイム バージョン:4.0.30319.1\r
+//\r
+// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、\r
+// コードが再生成されるときに損失したりします。\r
+// </auto-generated>\r
+//------------------------------------------------------------------------------\r
+\r
+using System;\r
+using System.Windows;\r
+using System.Windows.Media;\r
+using System.Windows.Media.Effects;\r
+using System.Windows.Media.Media3D;\r
+\r
+\r
+namespace Psychlops\r
+{\r
+\r
+\r
+ public static partial class Figures\r
+ {\r
+\r
+\r
+ public class ShaderGabor : ShaderField\r
+ {\r
+ protected Shader.GaborProgram ps = null;\r
+ public ShaderGabor()\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.GaborProgram();\r
+ initializeShader();\r
+ }\r
+ shader = ps;\r
+ initialized = true;\r
+ }\r
+ }\r
+\r
+ //public double contrast { get; set; }\r
+ //public double frequency { get; set; }\r
+ //public double phase { get; set; }\r
+ //public double orientation { get; set; }\r
+ public double contrast = 1.0, wavelength = 20.0, phase = 0.0, orientation = 0.0, alpha = 1.0;\r
+ public ShaderGabor setSigma(double s)\r
+ {\r
+ set(s*8, s*8);\r
+ return this;\r
+ }\r
+ \r
+ public void setParameters__()\r
+ {\r
+ ps.Contrast = contrast;\r
+ ps.WaveLength = wavelength;\r
+ ps.Phase = phase;\r
+ ps.Orientation = orientation;\r
+ ps.Sigma = 4.0;\r
+ ps.Size = width;\r
+ ps.Alpha = alpha;\r
+ ps.Update();\r
+ }\r
+\r
+\r
+ }\r
+ }\r
+\r
+\r
+ namespace Shader\r
+ {\r
+ internal static partial class Connector\r
+ {\r
+ internal delegate void PixelShaderConnector(ShaderEffect q, Uri s);\r
+ }\r
+\r
+\r
+ public abstract class ShaderProgram : ShaderEffect\r
+ {\r
+ }\r
+\r
+ public class GaborProgram : ShaderProgram\r
+ {\r
+ public static readonly Uri ps = new Uri(@"/PsychlopsSilverlight4;component/Shader/Gabor.ps", UriKind.Relative);\r
+\r
+ public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(GaborProgram), 0);\r
+ public static readonly DependencyProperty ContrastProperty = DependencyProperty.Register("Contrast", typeof(double), typeof(GaborProgram), new PropertyMetadata(((double)(1D)), PixelShaderConstantCallback(1)));\r
+ public static readonly DependencyProperty FrequencyProperty = DependencyProperty.Register("Frequency", typeof(double), typeof(GaborProgram), new PropertyMetadata(((double)(100D)), PixelShaderConstantCallback(2)));\r
+ public static readonly DependencyProperty PhaseProperty = DependencyProperty.Register("Phase", typeof(double), typeof(GaborProgram), new PropertyMetadata(((double)(0D)), PixelShaderConstantCallback(3)));\r
+ public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register("Orientation", typeof(double), typeof(GaborProgram), new PropertyMetadata(((double)(0D)), PixelShaderConstantCallback(4)));\r
+ public static readonly DependencyProperty SigmaProperty = DependencyProperty.Register("Sigma", typeof(double), typeof(GaborProgram), new PropertyMetadata(((double)(4D)), PixelShaderConstantCallback(5)));\r
+ public static readonly DependencyProperty AlphaProperty = DependencyProperty.Register("Alpha", typeof(double), typeof(GaborProgram), new PropertyMetadata(((double)(1D)), PixelShaderConstantCallback(6)));\r
+ public GaborProgram()\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(SigmaProperty);\r
+ this.UpdateShaderValue(AlphaProperty);\r
+\r
+ Size = 200;\r
+ Contrast = 1.0;\r
+ WaveLength = 100.0;\r
+ Orientation = 0.0;\r
+ Sigma = 4.0;\r
+ Alpha = 1.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(SigmaProperty);\r
+ this.UpdateShaderValue(AlphaProperty);\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>Half bandwidth of envelope</summary>\r
+ public double Sigma\r
+ {\r
+ get\r
+ {\r
+ return ((double)(this.GetValue(SigmaProperty)));\r
+ }\r
+ set\r
+ {\r
+ this.SetValue(SigmaProperty, value);\r
+ }\r
+ }\r
+ /// <summary>Transparency of Figure</summary>\r
+ public double Alpha\r
+ {\r
+ get\r
+ {\r
+ return ((double)(this.GetValue(AlphaProperty)));\r
+ }\r
+ set\r
+ {\r
+ this.SetValue(AlphaProperty, value);\r
+ }\r
+ }\r
+ }\r
+\r
+ \r
+ }\r
+}
\ No newline at end of file
}\r
*/\r
\r
+ public class Button\r
+ {\r
+ public static Color bgcolor;\r
+\r
+ internal System.Windows.Controls.Button uibutton;\r
+\r
+ public Button(string l)\r
+ {\r
+ uibutton = new System.Windows.Controls.Button();\r
+ uibutton.Content = l;\r
+ }\r
+ public void str(string l) { }\r
+ }\r
\r
public class Slider\r
{\r
}\r
\r
\r
- internal static class Connector\r
+ internal static partial class Connector\r
{\r
internal delegate void VoidString(string s);\r
internal delegate void VoidStringObject(String s, System.Object o);\r
<ColumnDefinition Width="0" />\r
<ColumnDefinition Width="*" />\r
</Grid.ColumnDefinitions>\r
+\r
+\r
<StackPanel x:Name="Controller" Grid.Column="0">\r
</StackPanel>\r
+ \r
<Canvas x:Name="LayoutRoot" Grid.Column="1"></Canvas>\r
+\r
</Grid>\r
<TextBlock x:Name="AppStatusBar" Height="20">Loading...</TextBlock>\r
</StackPanel>\r
using Psychlops;\r
+using System;\r
+using System.Windows;\r
+using System.Windows.Media;\r
+using System.Windows.Media.Effects;\r
+using System.Windows.Media.Media3D;\r
+\r
\r
namespace PsychlopsSilverlight4test\r
{\r
//main_routine = main.psychlops_main();\r
\r
Psychlops.Internal.Main.statusBar = AppStatusBar;\r
+ Psychlops.Internal.Main.layoutRoot = LayoutRoot;\r
//Psychlops.Internal.Main.widgetStack = Controller;\r
AppStatusBar.Text = "Now starting Psychlops environment... please wait a minute";\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 img = new System.Windows.Controls.Image();\r
- img.Source = bitmap;\r
- System.Windows.Controls.Canvas.SetLeft(img, 100);\r
- System.Windows.Controls.Canvas.SetTop(img, 100);\r
- Controller.Children.Add(img);\r
- * */\r
- \r
- \r
+\r
+//eff__ = new Psychlops.Shader.GaborProgram();\r
+//rect__ = new System.Windows.Shapes.Rectangle();\r
+//rect__.Width = 200;\r
+//rect__.Height = 200;\r
+//rect__.Effect = eff__;\r
+//rect__.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Blue);\r
}\r
protected void getFocusMouseEnter(object sender, System.Windows.Input.MouseEventArgs e) {\r
this.Focus();\r
+//if(!b) { LayoutRoot.Children.Add(rect__); b = true; }\r
}\r
+//System.Windows.Shapes.Rectangle rect__;\r
+//Psychlops.Shader.GaborProgram eff__;\r
+//bool b = false;\r
\r
private void CompositionTarget_Rendering(object sender, System.EventArgs e)\r
{\r
}\r
\r
}\r
+\r
+\r
+\r
}\r
\r
-//Two types of plaid motion\r
+\r
+/*\r
+//Two types of plaid motion\r
//E. H. Adelson and J. A. Movshon (1982).\r
//Phenomenal coherence of moving visual patterns. Nature 300, 523-525\r
\r
}\r
}\r
}\r
+*/\r
\r
\r
\r
-\r
-/*\r
using Psychlops;\r
//Position Bias Program\r
namespace PsychlopsSilverlightApp\r
{\r
Canvas cnvs;\r
Image img, img2, img3;\r
- int isize = 80; \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
img2 = new Image(isize * 2, isize * 2);\r
img3 = new Image(isize * 2, isize * 2);\r
\r
+ Figures.ShaderGabor[] 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.orientation = Math.random(2*Math.PI);\r
+ }\r
\r
while (true)\r
- {\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
+ 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
- img.centering().shift(0, -isize * 1.5).draw();\r
- img2.centering().draw();\r
- img3.centering().shift(0, isize * 1.5).draw();\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
}\r
}\r
}\r
-\r
-*/
\ No newline at end of file