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
16 public partial struct Point
\r
18 public double x, y, z;
\r
19 public Point(double dx, double dy, double dz)
\r
25 public Point(double dx, double dy)
\r
31 public Point set(double dx, double dy, double dz)
\r
38 public Point set(double dx, double dy)
\r
46 public static Point operator +(Point lhs, Point rhs)
\r
48 return new Point(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z);
\r
50 public static Point operator -(Point lhs, Point rhs)
\r
52 return new Point(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z);
\r
57 public partial struct Color
\r
59 public double r, g, b, a;
\r
60 public Color(double lum)
\r
65 public Color(double red, double green, double blue)
\r
72 public Color(double red, double green, double blue, double alpha)
\r
79 public void set(double lum)
\r
84 public void set(double red, double green, double blue)
\r
91 public void set(double red, double green, double blue, double alpha)
\r
99 public static readonly Color
\r
100 black = new Color(0, 0, 0, 1),
\r
101 red = new Color(1, 0, 0, 1),
\r
102 green = new Color(0, 1, 0, 1),
\r
103 blue = new Color(0, 0, 1, 1),
\r
104 yellow = new Color(1, 1, 0, 1),
\r
105 magenta = new Color(1, 0, 1, 1),
\r
106 cyan = new Color(0, 1, 1, 1),
\r
107 white = new Color(1, 1, 1, 1),
\r
108 gray = new Color(.5, .5, .5, 1);
\r
113 public interface Drawable
\r
116 void clear(Color col);
\r
117 void pix(int x, int y, Color col);
\r
118 void line(Line drawee);
\r
119 void line(Line drawee, Color col);
\r
120 //void line(Line drawee, Stroke strk);
\r
121 void rect(Rectangle drawee);
\r
122 void rect(Rectangle drawee, Color col);
\r
123 //void rect(Rectangle drawee, Stroke strk);
\r
124 void ellipse(Ellipse drawee);
\r
125 void ellipse(Ellipse drawee, Color col);
\r
126 //void ellipse(Ellipse drawee, Stroke strk);
\r
127 void polygon(Polygon drawee);
\r
128 void polygon(Polygon drawee, Color col);
\r
129 //void polygon(Polygon drawee, Stroke strk);
\r
130 void letters(Letters drawee);
\r
131 void letters(Letters drawee, Color col);
\r
132 //void letters(Letters drawee, Stroke strk);
\r
133 void image(Image drawee);
\r
134 void msg(string s, double x, double y, Color c);
\r
139 public interface Figure
\r
141 Figure shift(Point p);
\r
142 Figure centering(Point p);
\r
144 UIElement toNative();
\r
146 public static class FigureExtention
\r
148 public static Figure shift(this Figure target, double x, double y)
\r
150 return target.shift(new Point(x, y));
\r
152 public static Figure centering(this Figure target)
\r
154 return target.centering(Main.drawable.getCenter());
\r
156 public static Figure centering(this Figure target, double x, double y)
\r
158 return target.centering(new Point(x, y));
\r
162 public partial class Image : Figure
\r
164 public WriteableBitmap buffer;
\r
165 public Point datum;
\r
166 public Rectangle self_rect;
\r
168 public Image(int wid, int hei)
\r
170 initialize__(wid, hei);
\r
171 self_rect = new Rectangle(wid, hei);
\r
174 /*public Image shift(double x, double y)
\r
180 public Figure shift(Point p)
\r
185 public Figure centering(Point p)
\r
187 datum.x = p.x - width / 2.0;
\r
188 datum.y = p.y - height / 2.0;
\r
192 public void pix(int x, int y, Color col)
\r
194 buffer.SetPixel(x, y, col);
\r
198 public void field(System.Func<int,int,System.Windows.Media.Color> func)
\r
201 //buffer.ForEach(func);
\r
203 public void field(System.Func<int, int, System.Windows.Media.Color, System.Windows.Media.Color> func)
\r
206 //buffer.ForEach(func);
\r
211 Main.drawable.image(this);
\r
214 public double width { get { return self_rect.width; } }
\r
215 public double height { get { return self_rect.height; } }
\r