OSDN Git Service

sasas
[psychlops/silverlight.git] / dev4 / psychlops / core / graphic / shape.cs
index 82f19b7..b007b7f 100644 (file)
@@ -19,6 +19,10 @@ namespace Psychlops{
        }\r
        public static class ShapeExtention\r
        {\r
+               public static void draw(this Shape drawee, double c)\r
+               {\r
+                       drawee.draw( new Color(c) );\r
+               }\r
                public static void draw(this Shape drawee, Color c)\r
                {\r
                        Color tmp_col = drawee.fill;\r
@@ -66,6 +70,26 @@ namespace Psychlops{
                        set { begin = value; }\r
                }\r
 \r
+               //public static Line[] this[int x] { get { return Array(x); } }\r
+               //public static Line[,] this[int x, int y] { get { return Array(x, y); } }\r
+               public static Line[] Array(int ind)\r
+               {\r
+                       Line[] l = new Line[ind];\r
+                       for(int i=0; i<ind; i++) { l[i] = new Line(); }\r
+                       return l;\r
+               }\r
+               public static Line[,] Array(int indx, int indy)\r
+               {\r
+                       Line[,] l = new Line[indx, indy];\r
+                       for (int i = 0; i < indx; i++) { for (int j = 0; j < indy; j++) { l[i, j] = new Line(); } }\r
+                       return l;\r
+               }\r
+\r
+\r
+               public Line()\r
+               {\r
+                       set(0,0,0,0);\r
+               }\r
                public Line(double x1, double y1, double x2, double y2)\r
                {\r
                        set(x1, y1, x2, y2);\r
@@ -74,15 +98,17 @@ namespace Psychlops{
                {\r
                        set(v1, v2);\r
                }\r
-               public void set(double x1, double y1, double x2, double y2)\r
+               public Line set(double x1, double y1, double x2, double y2)\r
                {\r
                        begin.set(x1, y1);\r
                        end.set(x2, y2);\r
+                       return this;\r
                }\r
-               public void set(Point v1, Point v2)\r
+               public Line set(Point v1, Point v2)\r
                {\r
                        begin = v1;\r
                        end   = v2;\r
+                       return this;\r
                }\r
 \r
                public Figure shift(Point p)\r
@@ -101,7 +127,7 @@ namespace Psychlops{
                        return this;\r
                }\r
 \r
-               public void draw()\r
+               public virtual void draw()\r
                {\r
                        Main.drawable.line(this);\r
                }\r
@@ -128,6 +154,22 @@ namespace Psychlops{
        {\r
                public Point v1, v2;\r
 \r
+               //public static Rectangle[] this[int x] { get { return Array(x); } }\r
+               //public static Rectangle[,] this[int x, int y] { get { return Array(x, y); } }\r
+               public static Rectangle[] Array(int ind)\r
+               {\r
+                       Rectangle[] l = new Rectangle[ind];\r
+                       for (int i = 0; i < ind; i++) { l[i] = new Rectangle(); }\r
+                       return l;\r
+               }\r
+               public static Rectangle[,] Array(int indx, int indy)\r
+               {\r
+                       Rectangle[,] l = new Rectangle[indx, indy];\r
+                       for (int i = 0; i < indx; i++) { for (int j = 0; j < indy; j++) { l[i, j] = new Rectangle(); } }\r
+                       return l;\r
+               }\r
+\r
+\r
                public Rectangle()\r
                {\r
                        set(0,0);\r
@@ -180,9 +222,9 @@ namespace Psychlops{
                        set { double w = width, h = height; v1 = value; v2 = v1 + new Point(w,h); }\r
                }\r
                public Rectangle move_to(Point p) { datum = p; return this; }\r
-               public Rectangle move_to(double x, double y, double z) { datum = new Point(x, y, z); return this; }\r
+               public Rectangle move_to(double x, double y, double z = 0.0) { datum = new Point(x, y, z); return this; }\r
                public Rectangle locate(Point p) { datum = p; return this; }\r
-               public Rectangle locate(double x, double y, double z) { datum = new Point(x, y, z); return this; }\r
+               public Rectangle 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
@@ -200,7 +242,7 @@ namespace Psychlops{
                        return this;\r
                }\r
 \r
-               public void draw()\r
+               public virtual void draw()\r
                {\r
                        Main.drawable.rect(this);\r
                }\r
@@ -289,6 +331,21 @@ namespace Psychlops{
                public Point datum { get; set; }\r
                public double xdiameter, ydiameter;\r
 \r
+               //public static Ellipse[] this[int x] { get { return Array(x); } }\r
+               //public static Ellipse[,] this[int x, int y] { get { return Array(x, y); } }\r
+               public static Ellipse[] Array(int ind)\r
+               {\r
+                       Ellipse[] l = new Ellipse[ind];\r
+                       for (int i = 0; i < ind; i++) { l[i] = new Ellipse(); }\r
+                       return l;\r
+               }\r
+               public static Ellipse[,] Array(int indx, int indy)\r
+               {\r
+                       Ellipse[,] l = new Ellipse[indx, indy];\r
+                       for (int i = 0; i < indx; i++) { for (int j = 0; j < indy; j++) { l[i, j] = new Ellipse(); } }\r
+                       return l;\r
+               }\r
+\r
                public Ellipse()\r
                {\r
                        set(0,0);\r
@@ -304,6 +361,13 @@ namespace Psychlops{
                        ydiameter = hei;\r
                        return this;\r
                }\r
+               public Ellipse resize(double width, double height)\r
+               {\r
+                       Point po = center;\r
+                       set(width, height);\r
+                       centering(po);\r
+                       return this;\r
+               }\r
                public Figure shift(Point p)\r
                {\r
                        datum += p;\r
@@ -315,7 +379,7 @@ namespace Psychlops{
                        return this;\r
                }\r
 \r
-               public void draw()\r
+               public virtual void draw()\r
                {\r
                        Main.drawable.ellipse(this);\r
                }\r
@@ -387,7 +451,7 @@ namespace Psychlops{
                        return this;\r
                }\r
 \r
-               public void draw()\r
+               public virtual void draw()\r
                {\r
                        Main.drawable.polygon(this);\r
                }\r