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 Color fill { get; set; }
\r
19 Stroke stroke { get; set; }
\r
21 public static class ShapeExtention
\r
24 public static void draw(this Shape drawee)
\r
26 drawee.draw(Color.white);
\r
31 public partial struct Stroke
\r
33 public double thick;
\r
35 public void set(Color c, double t)
\r
42 public partial class Line : Shape
\r
44 public Point begin, end;
\r
46 public Line(double x1, double y1, double x2, double y2)
\r
48 set(x1, y1, x2, y2);
\r
50 public Line(Point v1, Point v2)
\r
54 public void set(double x1, double y1, double x2, double y2)
\r
59 public void set(Point v1, Point v2)
\r
65 public Figure shift(Point p)
\r
71 public Figure centering(Point p)
\r
73 double h = width, v = height;
\r
74 begin.x = p.x - h / 2.0;
\r
75 begin.y = p.y - v / 2.0;
\r
76 end.x = begin.x + h;
\r
77 end.y = begin.y + v;
\r
81 public void draw(Color c)
\r
83 Main.drawable.line(this, c);
\r
87 Main.drawable.line(this);
\r
90 public double left { get { return begin.x < end.x ? begin.x : end.x; } }
\r
91 public double top { get { return begin.y < end.y ? begin.y : end.y; ; } }
\r
92 public double right { get { return begin.x > end.x ? begin.x : end.x; ; } }
\r
93 public double bottom { get { return begin.y > end.y ? begin.y : end.y; ; } }
\r
94 public double width { get { return Math.abs(begin.x - end.x); } }
\r
95 public double height { get { return Math.abs(begin.y - end.y); } }
\r
97 public Color fill { get; set; }
\r
98 public Stroke stroke { get; set; }
\r
102 public partial class Rectangle : Shape
\r
104 public Point v1, v2;
\r
110 public Rectangle(double wid, double hei)
\r
115 public Rectangle set(double wid, double hei)
\r
118 v2.set(wid, hei, 0);
\r
122 public Figure shift(Point p)
\r
128 public Figure centering(Point p)
\r
130 double h = width, v = height;
\r
131 v1.x = p.x - h / 2.0;
\r
132 v1.y = p.y - v / 2.0;
\r
138 public void draw(Color c)
\r
140 Main.drawable.rect(this, c);
\r
144 Main.drawable.rect(this);
\r
147 public double left { get { return v1.x; } }
\r
148 public double top { get { return v1.y; } }
\r
149 public double right { get { return v2.x; } }
\r
150 public double bottom { get { return v2.y; } }
\r
151 public double width { get { return Math.abs(v1.x - v2.x); } }
\r
152 public double height { get { return Math.abs(v1.y - v2.y); } }
\r
155 public Color fill { get; set; }
\r
156 public Stroke stroke { get; set; }
\r
161 public partial class Ellipse : Shape
\r
163 public Point datum;
\r
164 public double xdiameter, ydiameter;
\r
170 public Ellipse(double wid, double hei)
\r
175 public Ellipse set(double wid, double hei)
\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.ellipse(this, c);
\r
198 Main.drawable.ellipse(this);
\r
201 public double left { get { return datum.x - xdiameter/2.0; } }
\r
202 public double top { get { return datum.y - ydiameter / 2.0; } }
\r
203 public double right { get { return datum.x + xdiameter / 2.0; } }
\r
204 public double bottom { get { return datum.y + ydiameter / 2.0; } }
\r
205 public double width { get { return Math.abs(xdiameter); } }
\r
206 public double height { get { return Math.abs(ydiameter); } }
\r
208 public Color fill { get; set; }
\r
209 public Stroke stroke { get; set; }
\r
213 public partial class Polygon : Shape
\r
215 public Point datum;
\r
216 public System.Collections.Generic.List<Point> vertices;
\r
220 vertices = new System.Collections.Generic.List<Point>();
\r
222 public Polygon(double[] verts)
\r
224 vertices = new System.Collections.Generic.List<Point>();
\r
225 for (int i=0; i < verts.Length; i+=2)
\r
227 vertices.Add(new Point(verts[i], verts[i+1]));
\r
231 public Polygon(Point[] verts)
\r
233 vertices = new System.Collections.Generic.List<Point>();
\r
234 foreach (Point p in verts)
\r
240 public Polygon append(Point p) { vertices.Add(p); return this; }
\r
241 public Polygon append(double x, double y) { return append(new Point(x, y, 0.0)); }
\r
242 public Polygon append(double x, double y, double z) { return append(new Point(x, y, z)); }
\r
245 public Figure shift(Point p)
\r
250 public Figure centering(Point p)
\r
256 public void draw(Color c)
\r
258 Main.drawable.polygon(this, c);
\r
262 Main.drawable.polygon(this);
\r
265 public Color fill { get; set; }
\r
266 public Stroke stroke { get; set; }
\r