X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=dev3%2Fpsychlops%2Fcore%2Fgraphic%2Fmodule.cs;h=ac8000e57ea20f59ab228efb993b931f4c960fcc;hb=1a2f942e3be2ba03d789df4d17c3bf237d9b635f;hp=67bf68fee28f2b597cfbf06a7f3faf0d0541ac72;hpb=ee118c1cb2979154a0c1ed80bf1c13e7fe4e8970;p=psychlops%2Fsilverlight.git diff --git a/dev3/psychlops/core/graphic/module.cs b/dev3/psychlops/core/graphic/module.cs index 67bf68f..ac8000e 100644 --- a/dev3/psychlops/core/graphic/module.cs +++ b/dev3/psychlops/core/graphic/module.cs @@ -1,19 +1,11 @@ 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 struct Point + public partial struct Point { public double x, y, z; public Point(double dx, double dy, double dz) @@ -51,14 +43,14 @@ namespace Psychlops { return new Point(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z); } - public static implicit operator System.Windows.Point(Point d) + public override string ToString() { - return new System.Windows.Point(d.x, d.y); + return "X:"+ x.ToString() + " Y:"+ y.ToString() + " Z:"+ z.ToString(); } } - public struct Color + public partial struct Color { public double r, g, b, a; public Color(double lum) @@ -99,9 +91,10 @@ namespace Psychlops b = blue; a = alpha; } - public static implicit operator System.Windows.Media.Color(Color d) + + public override string ToString() { - return System.Windows.Media.Color.FromArgb((byte)(d.a * 255), (byte)(d.r * 255), (byte)(d.g * 255), (byte)(d.b * 255)); + return "R:" + r.ToString() + " G:" + g.ToString() + " B:" + b.ToString() + " A:" + a.ToString(); } public static readonly Color @@ -113,7 +106,8 @@ namespace Psychlops magenta = new Color(1, 0, 1, 1), cyan = new Color(0, 1, 1, 1), white = new Color(1, 1, 1, 1), - gray = new Color(.5, .5, .5, 1); + gray = new Color(.5, .5, .5, 1), + null_color = new Color(0, 0, 0, 0); } @@ -123,11 +117,11 @@ namespace Psychlops Point getCenter(); void clear(Color col); void pix(int x, int y, Color col); - void line(Line drawee, Color col); - void rect(Rectangle drawee, Color col); - void ellipse(Ellipse drawee, Color col); - void polygon(Polygon drawee, Color col); - void letters(Letters drawee, Color col); + void line(Line drawee); + void rect(Rectangle drawee); + void ellipse(Ellipse drawee); + void polygon(Polygon drawee); + void letters(Letters drawee); void image(Image drawee); void msg(string s, double x, double y, Color c); } @@ -156,59 +150,11 @@ namespace Psychlops } } - public class Image : Figure + namespace Internal { - public WriteableBitmap buffer; - public Point datum; - public Rectangle self_rect; - - public Image(int wid, int hei) - { - buffer = new WriteableBitmap(wid, hei); - self_rect = new Rectangle(wid, hei); - } - - /*public Image shift(double x, double y) - { - datum.x += x; - datum.y += y; - return this; - }*/ - public Figure shift(Point p) + public interface PrimitiveFigure : Figure { - datum += p; - return this; + UIElement toNative(); } - public Figure centering(Point p) - { - datum.x = p.x - width / 2.0; - datum.y = p.y - height / 2.0; - return this; - } - - public void pix(int x, int y, Color col) - { - buffer.SetPixel(x, y, col); - } - - - public void field(System.Func func) - { - buffer.ForEach(func); - } - public void field(System.Func func) - { - buffer.ForEach(func); - } - - public void draw() - { - Main.drawable.image(this); - } - - public double width { get { return self_rect.width; } } - public double height { get { return self_rect.height; } } - } - } \ No newline at end of file