OSDN Git Service

main
[psychlops/silverlight.git] / dev4 / psychlops / core / graphic / shape.cs
index b007b7f..9c7ed2b 100644 (file)
@@ -59,6 +59,8 @@ namespace Psychlops{
                        color = c;\r
                        thick = t;\r
                }\r
+               public static readonly Stroke null_line = new Stroke(Color.null_color, 0);\r
+               public static readonly Stroke hair_line = new Stroke(Color.white, 1);\r
        }\r
 \r
        public partial class Line : Shape\r
@@ -88,14 +90,20 @@ namespace Psychlops{
 \r
                public Line()\r
                {\r
+                       fill = Color.white;\r
+                       stroke = Stroke.hair_line;\r
                        set(0,0,0,0);\r
                }\r
                public Line(double x1, double y1, double x2, double y2)\r
                {\r
+                       fill = Color.white;\r
+                       stroke = Stroke.hair_line;\r
                        set(x1, y1, x2, y2);\r
                }\r
                public Line(Point v1, Point v2)\r
                {\r
+                       fill = Color.white;\r
+                       stroke = Stroke.hair_line;\r
                        set(v1, v2);\r
                }\r
                public Line set(double x1, double y1, double x2, double y2)\r
@@ -149,6 +157,34 @@ namespace Psychlops{
                public Stroke stroke { get; set; }\r
        }\r
 \r
+       public partial class Rectangle_\r
+       {\r
+               public Point v1, v2;\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 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
+\r
+\r
+\r
+               public Color fill { get; set; }\r
+               public Stroke stroke { get; set; }\r
+\r
+               public override string ToString()\r
+               {\r
+                       return "Left:" + left.ToString() + " Top:" + top.ToString() + " Right:" + right.ToString() + " Bottom:" + bottom.ToString();\r
+               }\r
+       }\r
+\r
 \r
        public partial class Rectangle : Shape\r
        {\r
@@ -172,14 +208,20 @@ namespace Psychlops{
 \r
                public Rectangle()\r
                {\r
+                       fill = Color.white;\r
+                       stroke = Stroke.null_line;\r
                        set(0,0);\r
                }\r
                public Rectangle(double wid, double hei)\r
                {\r
+                       fill = Color.white;\r
+                       stroke = Stroke.null_line;\r
                        set(wid, hei);\r
                }\r
                public Rectangle(Rectangle another)\r
                {\r
+                       fill = Color.white;\r
+                       stroke = Stroke.null_line;\r
                        v1 = another.v1;\r
                        v2 = another.v2;\r
                }\r
@@ -348,10 +390,14 @@ namespace Psychlops{
 \r
                public Ellipse()\r
                {\r
+                       fill = Color.white;\r
+                       stroke = Stroke.null_line;\r
                        set(0,0);\r
                }\r
                public Ellipse(double wid, double hei)\r
                {\r
+                       fill = Color.white;\r
+                       stroke = Stroke.null_line;\r
                        set(wid, hei);\r
                }\r
 \r
@@ -415,10 +461,14 @@ namespace Psychlops{
 \r
                public Polygon()\r
                {\r
+                       fill = Color.white;\r
+                       stroke = Stroke.null_line;\r
                        vertices = new System.Collections.Generic.List<Point>();\r
                }\r
                public Polygon(double[] verts)\r
                {\r
+                       fill = Color.white;\r
+                       stroke = Stroke.null_line;\r
                        vertices = new System.Collections.Generic.List<Point>();\r
                        for (int i=0; i < verts.Length; i+=2)\r
                        {\r
@@ -428,6 +478,8 @@ namespace Psychlops{
                }\r
                public Polygon(Point[] verts)\r
                {\r
+                       fill = Color.white;\r
+                       stroke = Stroke.null_line;\r
                        vertices = new System.Collections.Generic.List<Point>();\r
                        foreach (Point p in verts)\r
                        {\r