2 using System.Windows;
\r
3 using System.Windows.Controls;
\r
4 using System.Windows.Documents;
\r
5 using System.Windows.Input;
\r
6 using System.Windows.Media;
\r
7 using System.Windows.Media.Animation;
\r
8 using System.Windows.Media.Imaging;
\r
9 using System.Windows.Shapes;
\r
13 namespace Psychlops{
\r
15 public interface Shape : Figure
\r
18 public static class ShapeExtention
\r
21 public static void draw(this Shape drawee)
\r
23 drawee.draw(Color.white);
\r
29 public class Line : Shape
\r
31 public Point begin, end;
\r
33 public Line(Point v1, Point v2)
\r
39 public Figure shift(Point p)
\r
45 public Figure centering(Point p)
\r
47 double h = width, v = height;
\r
48 begin.x = p.x - h / 2.0;
\r
49 begin.y = p.y - v / 2.0;
\r
50 end.x = begin.x + h;
\r
51 end.y = begin.y + v;
\r
55 public void draw(Color c)
\r
57 Main.drawable.line(this, c);
\r
61 Main.drawable.line(this, Color.white);
\r
64 public double width { get { return Math.abs(begin.x - end.x); } }
\r
65 public double height { get { return Math.abs(begin.y - end.y); } }
\r
67 public static implicit operator System.Windows.Shapes.Line(Line d)
\r
69 var tmp = new System.Windows.Shapes.Line();
\r
79 public class Rectangle : Shape
\r
81 public Point v1, v2;
\r
87 public Rectangle(double wid, double hei)
\r
92 public Rectangle set(double wid, double hei)
\r
95 v2.set(wid, hei, 0);
\r
99 public Figure shift(Point p)
\r
105 public Figure centering(Point p)
\r
107 double h = width, v = height;
\r
108 v1.x = p.x - h / 2.0;
\r
109 v1.y = p.y - v / 2.0;
\r
115 public void draw(Color c)
\r
117 Main.drawable.rect(this, c);
\r
121 Main.drawable.rect(this, Color.white);
\r
124 public double left { get { return v1.x; } }
\r
125 public double top { get { return v1.y; } }
\r
126 public double right { get { return v2.x; } }
\r
127 public double bottom { get { return v2.y; } }
\r
128 public double width { get { return Math.abs(v1.x - v2.x); } }
\r
129 public double height { get { return Math.abs(v1.y - v2.y); } }
\r
132 public static implicit operator System.Windows.Rect(Rectangle d)
\r
134 return new System.Windows.Rect(d.v1.x, d.v1.y, d.v2.x, d.v2.y);
\r
140 public class Ellipse : Shape
\r
142 public Point datum;
\r
143 public double xdiameter, ydiameter;
\r
145 public Figure shift(Point p)
\r
150 public Figure centering(Point p)
\r
156 public void draw(Color c)
\r
158 Main.drawable.ellipse(this, c);
\r
162 Main.drawable.ellipse(this, Color.white);
\r
167 public class Polygon : Shape
\r
169 public Point datum;
\r
170 public System.Collections.Generic.List<Point> vertices;
\r
174 vertices = new System.Collections.Generic.List<Point>();
\r
176 public Polygon append(Point p) { vertices.Add(p); return this; }
\r
177 public Polygon append(double x, double y) { return append(new Point(x, y, 0.0)); }
\r
178 public Polygon append(double x, double y, double z) { return append(new Point(x, y, z)); }
\r
181 public Figure shift(Point p)
\r
186 public Figure centering(Point p)
\r
192 public void draw(Color c)
\r
194 Main.drawable.polygon(this, c);
\r
198 Main.drawable.polygon(this, Color.white);
\r