OSDN Git Service

many
[psychlops/silverlight.git] / dev3 / psychlops / core / graphic / image.cs
diff --git a/dev3/psychlops/core/graphic/image.cs b/dev3/psychlops/core/graphic/image.cs
new file mode 100644 (file)
index 0000000..06d0641
--- /dev/null
@@ -0,0 +1,73 @@
+using System;\r
+using System.Windows;\r
+using System.Windows.Controls;\r
+using System.Windows.Documents;\r
+using System.Windows.Input;\r
+using System.Windows.Media;\r
+using System.Windows.Media.Animation;\r
+using System.Windows.Media.Imaging;\r
+using System.Windows.Shapes;\r
+\r
+\r
+namespace Psychlops{\r
+\r
+\r
+       public partial class Image : Internal.PrimitiveFigure\r
+       {\r
+               public WriteableBitmap buffer;\r
+               public Point datum;\r
+               public Rectangle self_rect;\r
+\r
+               public Image(int wid, int hei)\r
+               {\r
+                       initialize__(wid, hei);\r
+                       self_rect = new Rectangle(wid, hei);\r
+               }\r
+\r
+               /*public Image shift(double x, double y)\r
+               {\r
+                       datum.x += x;\r
+                       datum.y += y;\r
+                       return this;\r
+               }*/\r
+               public Figure shift(Point p)\r
+               {\r
+                       datum += p;\r
+                       return this;\r
+               }\r
+               public Figure centering(Point p)\r
+               {\r
+                       datum.x = p.x - width / 2.0;\r
+                       datum.y = p.y - height / 2.0;\r
+                       return this;\r
+               }\r
+\r
+               public void pix(int x, int y, Color col)\r
+               {\r
+                       buffer.SetPixel(x, y, col);\r
+               }\r
+\r
+\r
+               public void field(System.Func<int, int, System.Windows.Media.Color> func)\r
+               {\r
+                       field__(func);\r
+                       //buffer.ForEach(func);\r
+               }\r
+               public void field(System.Func<int, int, System.Windows.Media.Color, System.Windows.Media.Color> func)\r
+               {\r
+                       field__(func);\r
+                       //buffer.ForEach(func);\r
+               }\r
+\r
+               public void draw()\r
+               {\r
+                       Main.drawable.image(this);\r
+               }\r
+\r
+               public double width { get { return self_rect.width; } }\r
+               public double height { get { return self_rect.height; } }\r
+\r
+       }\r
+\r
+\r
+}
\ No newline at end of file