OSDN Git Service

12
authorHOSOKAWA Kenchi <hskwk@inter7.jp>
Sat, 13 Mar 2010 07:58:06 +0000 (16:58 +0900)
committerHOSOKAWA Kenchi <hskwk@inter7.jp>
Sat, 13 Mar 2010 07:58:06 +0000 (16:58 +0900)
dev3/PsychlopsSilverlight3.csproj
dev3/psychlops/extention/standard/figures.cs [new file with mode: 0644]

index 7d45238..0b09745 100644 (file)
@@ -56,6 +56,7 @@
     <Compile Include="psychlops\core\graphic\canvas.cs" />\r
     <Compile Include="psychlops\core\graphic\module.cs" />\r
     <Compile Include="psychlops\core\math\util.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
diff --git a/dev3/psychlops/extention/standard/figures.cs b/dev3/psychlops/extention/standard/figures.cs
new file mode 100644 (file)
index 0000000..6d512f6
--- /dev/null
@@ -0,0 +1,54 @@
+namespace Psychlops\r
+{\r
+\r
+    public static class Figures\r
+    {\r
+        /*\r
+           public static void drawGrating(out Image img, int width , int height, double frequency, double contrast, double orientation, double phase)\r
+           {\r
+                   if(img.width != width || img.height != height) img = new Image(width, height);\r
+                   double xp, yp, r, freq = frequency*2*PI;\r
+                   for(int y=0; y<height; y++) {\r
+                           yp = y-height/2.0;\r
+                           for(int x=0; x<width; x++) {\r
+                                   xp = x-width/2.0;\r
+                                   r = sqrt(xp*xp+yp*yp);\r
+                                   img.pix_raw(x,y,\r
+                                     Color(\r
+                                           0.5+0.5 * contrast* cos(freq* (sin(orientation)*xp-cos(orientation)*yp) + phase)\r
+                                     )\r
+                                   );\r
+                           }\r
+                   }\r
+           }\r
+\r
+        public static void drawGaussian(out Image img, double sigma, double factor)\r
+           {\r
+            const int width = (int)(sigma * 8), height = (int)(sigma * 8);\r
+            if (img.width != width || img.height != height) img = new Image(width, height);\r
+            double xp, yp, r, r2;\r
+                   for(int y=0; y<height; y++) {\r
+                           yp = y-height/2.0;\r
+                           for(int x=0; x<width; x++) {\r
+                                   xp = x-width/2.0;\r
+                                   r = sqrt(xp*xp+yp*yp);\r
+                                   r2 = -(r*r) / (2.0*sigma*sigma);\r
+                                   img.pix_raw(x,y,Color(factor*(exp(r2))));\r
+                           }\r
+                   }\r
+           }\r
+         * */\r
+\r
+        public static void drawGabor(out Image img, double sigma, double wavelength, double contrast, double orientation, double phase)\r
+           {\r
+            int width = (int)(sigma * 8), height = (int)(sigma * 8);\r
+            //if (img.width != width || img.height != height)\r
+                img = new Image(width, height);\r
+            double freq = 2 * Math.PI / wavelength;\r
+                       img.field(\r
+                (x, y) => new Color(.5 + Math.gaussian(Math.radius(x - width, y - height), width / 8.0) * .5 * Math.sin(phase + x * freq))\r
+                       );\r
+           }\r
+\r
+    }\r
+}\r