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 width { get { return Math.abs(v1.x - v2.x); } }
\r
125 public double height { get { return Math.abs(v1.y - v2.y); } }
\r
128 public static implicit operator System.Windows.Rect(Rectangle d)
\r
130 return new System.Windows.Rect(d.v1.x, d.v1.y, d.v2.x, d.v2.y);
\r
136 public class Ellipse : Shape
\r
138 public Point datum;
\r
139 public double xdiameter, ydiameter;
\r
141 public Figure shift(Point p)
\r
146 public Figure centering(Point p)
\r
152 public void draw(Color c)
\r
154 Main.drawable.ellipse(this, c);
\r
158 Main.drawable.ellipse(this, Color.white);
\r
163 public class Polygon : Shape
\r
165 public Point datum;
\r
166 public System.Collections.Generic.List<Point> vertices;
\r
170 vertices = new System.Collections.Generic.List<Point>();
\r
172 public Polygon append(Point p) { vertices.Add(p); return this; }
\r
173 public Polygon append(double x, double y) { return append(new Point(x, y, 0.0)); }
\r
174 public Polygon append(double x, double y, double z) { return append(new Point(x, y, z)); }
\r
177 public Figure shift(Point p)
\r
182 public Figure centering(Point p)
\r
188 public void draw(Color c)
\r
190 Main.drawable.polygon(this, c);
\r
194 Main.drawable.polygon(this, Color.white);
\r