From: unknown Date: Thu, 15 Apr 2010 02:40:29 +0000 (+0900) Subject: .0 X-Git-Url: http://git.osdn.jp/view?a=commitdiff_plain;h=9827cf379e0eefec2919d5942a146baa50f75b95;p=psychlops%2Fsilverlight.git .0 --- diff --git a/dev3/psychlops/core/graphic/canvas.cs b/dev3/psychlops/core/graphic/canvas.cs index 9dfe031..0adfc4e 100644 --- a/dev3/psychlops/core/graphic/canvas.cs +++ b/dev3/psychlops/core/graphic/canvas.cs @@ -288,6 +288,10 @@ namespace Psychlops partial class Line { + public Line dup() + { + return (Line)MemberwiseClone(); + } public Line clone() { return (Line)MemberwiseClone(); @@ -304,6 +308,10 @@ namespace Psychlops partial class Rectangle { + public Rectangle dup() + { + return (Rectangle)MemberwiseClone(); + } public Rectangle clone() { return (Rectangle)MemberwiseClone(); @@ -325,6 +333,10 @@ namespace Psychlops partial class Ellipse { + public Ellipse dup() + { + return (Ellipse)MemberwiseClone(); + } public Ellipse clone() { return (Ellipse)MemberwiseClone(); @@ -342,6 +354,10 @@ namespace Psychlops partial class Polygon { + public Polygon dup() + { + return (Polygon)MemberwiseClone(); + } public Polygon clone() { return (Polygon)MemberwiseClone(); @@ -383,6 +399,10 @@ namespace Psychlops LETTERS_H_ALIGN_BRIDGE.Add(Letters.HorizontalAlign.not_specified, TextAlignment.Left); } #endregion + public Letters dup() + { + return (Letters)MemberwiseClone(); + } public Letters clone() { return (Letters)MemberwiseClone(); diff --git a/dev3/psychlops/core/graphic/font.cs b/dev3/psychlops/core/graphic/font.cs index 981b478..e3a4b41 100644 --- a/dev3/psychlops/core/graphic/font.cs +++ b/dev3/psychlops/core/graphic/font.cs @@ -59,7 +59,7 @@ namespace Psychlops protected string str_; protected Font font_; protected double width_, height_; - public Point datum; + public Point datum { get; set; } public enum HorizontalAlign { not_specified=-1, left=0, center, right }; //public const HorizontalAlign NOT_SPECIFIED=HorizontalAlign.not_specified, TEXT_ALIGN_LEFT=HorizontalAlign.left, TEXT_ALIGN_CENTER = HorizontalAlign.center, TEXT_ALIGN_RIGHT=HorizontalAlign.right; @@ -106,7 +106,7 @@ namespace Psychlops } public Figure shift(Point p) { - datum += p; + datum = datum + p; return this; } public Letters locate(Point p) @@ -116,7 +116,7 @@ namespace Psychlops } public Letters locate(double x, double y) { - datum.set(x,y); + datum = new Point(x,y); return this; } diff --git a/dev3/psychlops/core/graphic/image.cs b/dev3/psychlops/core/graphic/image.cs index 06d0641..c3df14e 100644 --- a/dev3/psychlops/core/graphic/image.cs +++ b/dev3/psychlops/core/graphic/image.cs @@ -15,7 +15,9 @@ namespace Psychlops{ public partial class Image : Internal.PrimitiveFigure { public WriteableBitmap buffer; - public Point datum; + public Point datum { get; set; } + public Point getDatum() { return datum; } + public Point setDatum(Point p) { datum = p; return datum; } public Rectangle self_rect; public Image(int wid, int hei) @@ -32,15 +34,18 @@ namespace Psychlops{ }*/ public Figure shift(Point p) { - datum += p; + datum = datum + p; return this; } public Figure centering(Point p) { - datum.x = p.x - width / 2.0; - datum.y = p.y - height / 2.0; + 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) { @@ -58,14 +63,31 @@ namespace Psychlops{ field__(func); //buffer.ForEach(func); } + public void each(System.Func func) + { + field__(func); + //buffer.ForEach(func); + } + public void each(System.Func func) + { + field__(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; } } + 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; } } diff --git a/dev3/psychlops/core/graphic/module.cs b/dev3/psychlops/core/graphic/module.cs index ac8000e..7afeeaf 100644 --- a/dev3/psychlops/core/graphic/module.cs +++ b/dev3/psychlops/core/graphic/module.cs @@ -130,12 +130,22 @@ namespace Psychlops public interface Figure { + Point datum { get; set; } Figure shift(Point p); Figure centering(Point p); void draw(); } public static class FigureExtention { + public static Point getDatum(this Figure target) + { + return target.datum; + } + public static Point setDatum(this Figure target, Point p) + { + target.datum = p; + return target.datum; + } public static Figure shift(this Figure target, double x, double y) { return target.shift(new Point(x, y)); diff --git a/dev3/psychlops/core/graphic/shape.cs b/dev3/psychlops/core/graphic/shape.cs index f92e989..82f19b7 100644 --- a/dev3/psychlops/core/graphic/shape.cs +++ b/dev3/psychlops/core/graphic/shape.cs @@ -60,6 +60,11 @@ namespace Psychlops{ public partial class Line : Shape { public Point begin, end; + public Point datum + { + get { return begin; } + set { begin = value; } + } public Line(double x1, double y1, double x2, double y2) { @@ -107,6 +112,12 @@ namespace Psychlops{ public double bottom { get { return begin.y > end.y ? begin.y : end.y; ; } } public double width { get { return Math.abs(begin.x - end.x); } } public double height { get { return Math.abs(begin.y - end.y); } } + public double getLeft() { return left; } + public double getTop() { return top; } + public double getRight() { return right; } + public double getBottom() { return bottom; } + public double getWidth() { return width; } + public double getHeight() { return height; } public Color fill { get; set; } public Stroke stroke { get; set; } @@ -125,13 +136,53 @@ namespace Psychlops{ { set(wid, hei); } - + public Rectangle(Rectangle another) + { + v1 = another.v1; + v2 = another.v2; + } public Rectangle set(double wid, double hei) { v1.set(0, 0, 0); v2.set(wid, hei, 0); return this; } + Rectangle set(Point po1, Point po2) { + v1 = po1; + v2 = po2; + return this; + } + public Rectangle set(double l, double t, double r, double b) + { + v1.set(l, t, 0); + v2.set(r, b, 0); + return this; + } + public Rectangle set(Rectangle another) + { + v1 = another.v1; + v2 = another.v2; + return this; + } + + public Rectangle resize(double width, double height) + { + Point po = center; + set(width, height); + centering(po); + return this; + } + + + public Point datum + { + get { return v1; } + set { double w = width, h = height; v1 = value; v2 = v1 + new Point(w,h); } + } + public Rectangle move_to(Point p) { datum = p; return this; } + public Rectangle move_to(double x, double y, double z) { datum = new Point(x, y, z); return this; } + public Rectangle locate(Point p) { datum = p; return this; } + public Rectangle locate(double x, double y, double z) { datum = new Point(x, y, z); return this; } public Figure shift(Point p) { @@ -153,6 +204,55 @@ namespace Psychlops{ { Main.drawable.rect(this); } + public bool include(double x, double y) + { + return (top <= y) && (left <= x) && (bottom >= y) && (right >= x); + } + public bool include(Point p) + { + return (top <= p.y) && (left <= p.x) && (bottom >= p.y) && (right >= p.x); + } + public bool include(Rectangle rect) + { + return (top <= rect.top) && (left <= rect.left) && (bottom >= rect.bottom) && (right >= rect.right); + } + + public Rectangle alignLeft(double lef) + { + return move_to(lef, getTop(), datum.z); + } + public Rectangle alignTop(double to_) + { + return move_to(getLeft(), to_, datum.z); + } + public Rectangle alignRight(double rig) + { + return move_to(rig - getWidth(), getTop(), datum.z); + } + public Rectangle alignBottom(double bot) + { + return move_to(getLeft(), bot - getHeight(), datum.z); + } + + public void clipped_by(Rectangle source) + { + double t = top, l = left, b = bottom, r = right; + if (top < source.top) { t = source.top; } + if (left < source.left) { l = source.left; } + if (bottom > source.bottom) { b = source.bottom; } + if (right > source.right) { r = source.right; } + set(l, t, r, b); + } + public void clip(Rectangle target) + { + double t = top, l = left, b = bottom, r = right; + if (top < target.top) { t = target.top; } + if (left < target.left) { l = target.left; } + if (bottom > target.bottom) { b = target.bottom; } + if (right > target.right) { r = target.right; } + set(l, t, r, b); + } + public double left { get { return v1.x; } } public double top { get { return v1.y; } } @@ -160,6 +260,18 @@ namespace Psychlops{ public double bottom { get { return v2.y; } } public double width { get { return Math.abs(v1.x - v2.x); } } public double height { get { return Math.abs(v1.y - v2.y); } } + public Point center { + get { return new Point((left + right) / 2, (top + bottom) / 2); } + set { centering(value); } + } + public double getLeft() { return left; } + public double getTop() { return top; } + public double getRight() { return right; } + public double getBottom() { return bottom; } + public double getWidth() { return width; } + public double getHeight() { return height; } + public Point getCenter() { return center; } + public Color fill { get; set; } @@ -174,7 +286,7 @@ namespace Psychlops{ public partial class Ellipse : Shape { - public Point datum; + public Point datum { get; set; } public double xdiameter, ydiameter; public Ellipse() @@ -214,6 +326,18 @@ namespace Psychlops{ public double bottom { get { return datum.y + ydiameter / 2.0; } } public double width { get { return Math.abs(xdiameter); } } public double height { get { return Math.abs(ydiameter); } } + public Point center + { + get { return new Point((left + right) / 2, (top + bottom) / 2); } + set { centering(value); } + } + public double getLeft() { return left; } + public double getTop() { return top; } + public double getRight() { return right; } + public double getBottom() { return bottom; } + public double getWidth() { return width; } + public double getHeight() { return height; } + public Point getCenter() { return center; } public Color fill { get; set; } public Stroke stroke { get; set; } @@ -222,7 +346,7 @@ namespace Psychlops{ public partial class Polygon : Shape { - public Point datum; + public Point datum { get; set; } public System.Collections.Generic.List vertices; public Polygon() @@ -254,7 +378,7 @@ namespace Psychlops{ public Figure shift(Point p) { - datum += p; + datum = datum + p; return this; } public Figure centering(Point p)