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
12 namespace Psychlops{
\r
15 public partial class Image : Internal.PrimitiveFigure
\r
17 public WriteableBitmap buffer;
\r
18 public Point datum { get; set; }
\r
19 public Point getDatum() { return datum; }
\r
20 public Point setDatum(Point p) { datum = p; return datum; }
\r
21 public Rectangle self_rect;
\r
22 protected bool AsyncBool;
\r
26 self_rect = new Rectangle(1, 1);
\r
30 public Image(string uri)
\r
32 self_rect = new Rectangle();
\r
36 public Image(int wid, int hei)
\r
38 self_rect = new Rectangle(wid, hei);
\r
39 initialize__(wid, hei);
\r
41 public Image(double wid, double hei)
\r
43 self_rect = new Rectangle(Math.round(wid), Math.round(hei));
\r
44 initialize__((int)Math.round(wid), (int)Math.round(hei));
\r
47 public Image set(int wid, int hei)
\r
49 self_rect = new Rectangle(wid, hei);
\r
50 initialize__(wid, hei);
\r
53 public Image set(double wid, double hei)
\r
55 self_rect = new Rectangle(Math.round(wid), Math.round(hei));
\r
56 initialize__((int)Math.round(wid), (int)Math.round(hei));
\r
60 public Figure shift(Point p)
\r
65 public Figure centering(Point p)
\r
67 datum = new Point( p.x - width / 2.0, p.y - height / 2.0);
\r
70 public Image move_to(Point p) { datum = p; return this; }
\r
71 public Image move_to(double x, double y, double z) { datum = new Point(x, y, z); return this; }
\r
72 public Image locate(Point p) { datum = p; return this; }
\r
73 public Image locate(double x, double y, double z) { datum = new Point(x, y, z); return this; }
\r
75 public void pix(int x, int y, Color col)
\r
77 buffer.SetPixel(x, y, col);
\r
80 public void pix_raw(int x, int y, Color col)
\r
82 buffer.SetPixel(x, y, col);
\r
85 public void pix_direct(int x, int y, Color col)
\r
87 buffer.SetPixel(x, y, col);
\r
90 public void pix_direct(int x, int y, double r, double g, double b, double a)
\r
92 buffer.SetPixel(x, y, new Color(r,g,b,a));
\r
95 public void release()
\r
99 public void cache(bool on_off = true)
\r
103 public void alpha(int x, int y, double a)
\r
105 buffer.SetPixel(x, y, (byte)(a*255), buffer.GetPixel(x, y));
\r
108 public void clear(Color col)
\r
110 each((x, y) => col);
\r
114 public void field(System.Func<int, int, System.Windows.Media.Color> func)
\r
118 public void field(System.Func<int, int, System.Windows.Media.Color, System.Windows.Media.Color> func)
\r
122 public void each(System.Func<int, int, System.Windows.Media.Color> func)
\r
126 public void each(System.Func<int, int, System.Windows.Media.Color, System.Windows.Media.Color> func)
\r
131 public void load(string uri)
\r
138 Main.drawable.image(this);
\r
142 public double width { get { return self_rect.width; } }
\r
143 public double height { get { return self_rect.height; } }
\r
144 public Point center { get { return new Point(width/2.0, height/2.0); } }
\r
145 public double getWidth() { return width; }
\r
146 public double getHeight() { return height; }
\r
147 public Point getCenter() { return center; }
\r
148 public double getHcenter() { return width / 2.0; }
\r
149 public double getVcenter() { return height / 2.0; }
\r
151 public double left { get { return datum.x; } }
\r
152 public double right { get { return datum.x + width; } }
\r
153 public double top { get { return datum.y; } }
\r
154 public double bottom { get { return datum.y + height; } }
\r
155 public double getLeft() { return left; }
\r
156 public double getRight() { return right; }
\r
157 public double getTop() { return top; }
\r
158 public double getBottom() { return bottom; }
\r