X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=dev5%2Fpsychlops%2Fcore%2Fgraphic%2Fimage.cs;fp=dev5%2Fpsychlops%2Fcore%2Fgraphic%2Fimage.cs;h=64f3c1efe6cde1c59e6421322be7615f0ecf7d45;hb=7fe25aa821826f09903fb14def74d6b0376e3b5a;hp=0000000000000000000000000000000000000000;hpb=af114e9e36fd9c2cdf79f95313e0b8712e253ed3;p=psychlops%2Fsilverlight.git diff --git a/dev5/psychlops/core/graphic/image.cs b/dev5/psychlops/core/graphic/image.cs new file mode 100644 index 0000000..64f3c1e --- /dev/null +++ b/dev5/psychlops/core/graphic/image.cs @@ -0,0 +1,154 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + + +namespace Psychlops{ + + + public partial class Image : Internal.PrimitiveFigure + { + public WriteableBitmap buffer; + public Point datum { get; set; } + public Point getDatum() { return datum; } + public Point setDatum(Point p) { datum = p; return datum; } + public Rectangle self_rect; + protected bool AsyncBool; + + public Image() + { + self_rect = new Rectangle(1, 1); + initialize__(1, 1); + } + + public Image(string uri) + { + self_rect = new Rectangle(); + load__(uri); + } + + public Image(int wid, int hei) + { + self_rect = new Rectangle(wid, hei); + initialize__(wid, hei); + } + public Image(double wid, double hei) + { + self_rect = new Rectangle(Math.round(wid), Math.round(hei)); + initialize__((int)Math.round(wid), (int)Math.round(hei)); + } + + public Image set(int wid, int hei) + { + self_rect = new Rectangle(wid, hei); + initialize__(wid, hei); + return this; + } + public Image set(double wid, double hei) + { + self_rect = new Rectangle(Math.round(wid), Math.round(hei)); + initialize__((int)Math.round(wid), (int)Math.round(hei)); + return this; + } + + public Figure shift(Point p) + { + datum = datum + p; + return this; + } + public Figure centering(Point p) + { + datum = new Point( p.x - width / 2.0, p.y - height / 2.0); + return this; + } + public Image move_to(Point p) { datum = p; return this; } + public Image move_to(double x, double y, double z) { datum = new Point(x, y, z); return this; } + public Image locate(Point p) { datum = p; return this; } + public Image locate(double x, double y, double z) { datum = new Point(x, y, z); return this; } + + public void pix(int x, int y, Color col) + { + buffer.SetPixel(x, y, col); + } + + public void release() + { + } + + public void cache(bool on_off = true) + { + } + + public void alpha(int x, int y, double a) + { + buffer.SetPixel(x, y, (byte)(a*255), buffer.GetPixel(x, y)); + } + + public void clear(Color col) + { + for (int y = 0; y < height; y++) + { + for (int x = 0; x < width; x++) + { + pix(x, y, col); + } + } + } + + + public void field(System.Func func) + { + field__(func); + } + public void field(System.Func func) + { + field__(func); + } + public void each(System.Func func) + { + field__(func); + } + public void each(System.Func func) + { + field__(func); + } + + public void load(string uri) + { + load__(uri); + } + + public void draw() + { + Main.drawable.image(this); + } + + + public double width { get { return self_rect.width; } } + public double height { get { return self_rect.height; } } + public Point center { get { return new Point(width/2.0, height/2.0); } } + public double getWidth() { return width; } + public double getHeight() { return height; } + public Point getCenter() { return center; } + public double getHcenter() { return width / 2.0; } + public double getVcenter() { return height / 2.0; } + + public double left { get { return datum.x; } } + public double right { get { return datum.x + width; } } + public double top { get { return datum.y; } } + public double bottom { get { return datum.y + height; } } + public double getLeft() { return left; } + public double getRight() { return right; } + public double getTop() { return top; } + public double getBottom() { return bottom; } + + } + + +} \ No newline at end of file