X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=dev3%2Fpsychlops%2Fcore%2Fgraphic%2Fmodule.cs;h=ac8000e57ea20f59ab228efb993b931f4c960fcc;hb=1a2f942e3be2ba03d789df4d17c3bf237d9b635f;hp=b21784c5e6bfff6b6a9083d1de4d077c33c5ba01;hpb=de61bd82025b7cbad753e4b9ea272705ed47cbf6;p=psychlops%2Fsilverlight.git diff --git a/dev3/psychlops/core/graphic/module.cs b/dev3/psychlops/core/graphic/module.cs index b21784c..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) @@ -66,6 +58,13 @@ namespace Psychlops r = g = b = lum; a = 1.0; } + public Color(double red, double green, double blue) + { + r = red; + g = green; + b = blue; + a = 1.0; + } public Color(double red, double green, double blue, double alpha) { r = red; @@ -73,9 +72,29 @@ namespace Psychlops b = blue; a = alpha; } - public static implicit operator System.Windows.Media.Color(Color d) + public void set(double lum) { - return System.Windows.Media.Color.FromArgb((byte)(d.a * 255), (byte)(d.r * 255), (byte)(d.g * 255), (byte)(d.b * 255)); + r = g = b = lum; + a = 1.0; + } + public void set(double red, double green, double blue) + { + r = red; + g = green; + b = blue; + a = 1.0; + } + public void set(double red, double green, double blue, double alpha) + { + r = red; + g = green; + b = blue; + a = alpha; + } + + public override string ToString() + { + return "R:" + r.ToString() + " G:" + g.ToString() + " B:" + b.ToString() + " A:" + a.ToString(); } public static readonly Color @@ -87,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); } @@ -97,11 +117,13 @@ 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 line(Line drawee); + void rect(Rectangle drawee); + void ellipse(Ellipse drawee); + void polygon(Polygon drawee); + void letters(Letters drawee); void image(Image drawee); - void polygon(Polygon drawee, Color col); + void msg(string s, double x, double y, Color c); } @@ -122,63 +144,17 @@ namespace Psychlops { return target.centering(Main.drawable.getCenter()); } - } - - - - public class Image : Figure - { - 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) - { - datum += p; - return this; - } - 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) + public static Figure centering(this Figure target, double x, double y) { - buffer.SetPixel(x, y, col); - } - - - public void field(System.Func func) - { - buffer.ForEach(func); - } - public void field(System.Func func) - { - buffer.ForEach(func); + return target.centering(new Point(x, y)); } + } - public void draw() + namespace Internal + { + public interface PrimitiveFigure : Figure { - Main.drawable.image(this); + UIElement toNative(); } - - public double width { get { return self_rect.width; } } - public double height { get { return self_rect.height; } } - } - } \ No newline at end of file