public partial class Image : Internal.PrimitiveFigure\r
{\r
public WriteableBitmap buffer;\r
- public Point datum;\r
+ public Point datum { get; set; }\r
+ public Point getDatum() { return datum; }\r
+ public Point setDatum(Point p) { datum = p; return datum; }\r
public Rectangle self_rect;\r
\r
public Image(int wid, int hei)\r
}*/\r
public Figure shift(Point p)\r
{\r
- datum += p;\r
+ datum = datum + p;\r
return this;\r
}\r
public Figure centering(Point p)\r
{\r
- datum.x = p.x - width / 2.0;\r
- datum.y = p.y - height / 2.0;\r
+ datum = new Point( p.x - width / 2.0, p.y - height / 2.0);\r
return this;\r
}\r
+ public Image move_to(Point p) { datum = p; return this; }\r
+ public Image move_to(double x, double y, double z) { datum = new Point(x, y, z); return this; }\r
+ public Image locate(Point p) { datum = p; return this; }\r
+ public Image locate(double x, double y, double z) { datum = new Point(x, y, z); return this; }\r
\r
public void pix(int x, int y, Color col)\r
{\r
field__(func);\r
//buffer.ForEach(func);\r
}\r
+ public void each(System.Func<int, int, System.Windows.Media.Color> func)\r
+ {\r
+ field__(func);\r
+ //buffer.ForEach(func);\r
+ }\r
+ public void each(System.Func<int, int, System.Windows.Media.Color, System.Windows.Media.Color> func)\r
+ {\r
+ field__(func);\r
+ //buffer.ForEach(func);\r
+ }\r
\r
public void draw()\r
{\r
Main.drawable.image(this);\r
}\r
\r
+\r
public double width { get { return self_rect.width; } }\r
public double height { get { return self_rect.height; } }\r
+ public Point center { get { return new Point(width/2.0, height/2.0); } }\r
+ public double getWidth() { return width; }\r
+ public double getHeight() { return height; }\r
+ public Point getCenter() { return center; }\r
+ public double getHcenter() { return width / 2.0; }\r
+ public double getVcenter() { return height / 2.0; }\r
\r
}\r
\r
public partial class Line : Shape\r
{\r
public Point begin, end;\r
+ public Point datum\r
+ {\r
+ get { return begin; }\r
+ set { begin = value; }\r
+ }\r
\r
public Line(double x1, double y1, double x2, double y2)\r
{\r
public double bottom { get { return begin.y > end.y ? begin.y : end.y; ; } }\r
public double width { get { return Math.abs(begin.x - end.x); } }\r
public double height { get { return Math.abs(begin.y - end.y); } }\r
+ public double getLeft() { return left; }\r
+ public double getTop() { return top; }\r
+ public double getRight() { return right; }\r
+ public double getBottom() { return bottom; }\r
+ public double getWidth() { return width; }\r
+ public double getHeight() { return height; }\r
\r
public Color fill { get; set; }\r
public Stroke stroke { get; set; }\r
{\r
set(wid, hei);\r
}\r
- \r
+ public Rectangle(Rectangle another)\r
+ {\r
+ v1 = another.v1;\r
+ v2 = another.v2;\r
+ }\r
public Rectangle set(double wid, double hei)\r
{\r
v1.set(0, 0, 0);\r
v2.set(wid, hei, 0);\r
return this;\r
}\r
+ Rectangle set(Point po1, Point po2) {\r
+ v1 = po1;\r
+ v2 = po2;\r
+ return this;\r
+ }\r
+ public Rectangle set(double l, double t, double r, double b)\r
+ {\r
+ v1.set(l, t, 0);\r
+ v2.set(r, b, 0);\r
+ return this;\r
+ }\r
+ public Rectangle set(Rectangle another)\r
+ {\r
+ v1 = another.v1;\r
+ v2 = another.v2;\r
+ return this;\r
+ }\r
+\r
+ public Rectangle resize(double width, double height)\r
+ {\r
+ Point po = center;\r
+ set(width, height);\r
+ centering(po);\r
+ return this;\r
+ }\r
+\r
+\r
+ public Point datum\r
+ {\r
+ get { return v1; }\r
+ set { double w = width, h = height; v1 = value; v2 = v1 + new Point(w,h); }\r
+ }\r
+ public Rectangle move_to(Point p) { datum = p; return this; }\r
+ public Rectangle move_to(double x, double y, double z) { datum = new Point(x, y, z); return this; }\r
+ public Rectangle locate(Point p) { datum = p; return this; }\r
+ public Rectangle locate(double x, double y, double z) { datum = new Point(x, y, z); return this; }\r
\r
public Figure shift(Point p)\r
{\r
{\r
Main.drawable.rect(this);\r
}\r
+ public bool include(double x, double y)\r
+ {\r
+ return (top <= y) && (left <= x) && (bottom >= y) && (right >= x);\r
+ }\r
+ public bool include(Point p)\r
+ {\r
+ return (top <= p.y) && (left <= p.x) && (bottom >= p.y) && (right >= p.x);\r
+ }\r
+ public bool include(Rectangle rect)\r
+ {\r
+ return (top <= rect.top) && (left <= rect.left) && (bottom >= rect.bottom) && (right >= rect.right);\r
+ }\r
+\r
+ public Rectangle alignLeft(double lef)\r
+ {\r
+ return move_to(lef, getTop(), datum.z);\r
+ }\r
+ public Rectangle alignTop(double to_)\r
+ {\r
+ return move_to(getLeft(), to_, datum.z);\r
+ }\r
+ public Rectangle alignRight(double rig)\r
+ {\r
+ return move_to(rig - getWidth(), getTop(), datum.z);\r
+ }\r
+ public Rectangle alignBottom(double bot)\r
+ {\r
+ return move_to(getLeft(), bot - getHeight(), datum.z);\r
+ }\r
+\r
+ public void clipped_by(Rectangle source)\r
+ {\r
+ double t = top, l = left, b = bottom, r = right;\r
+ if (top < source.top) { t = source.top; }\r
+ if (left < source.left) { l = source.left; }\r
+ if (bottom > source.bottom) { b = source.bottom; }\r
+ if (right > source.right) { r = source.right; }\r
+ set(l, t, r, b);\r
+ }\r
+ public void clip(Rectangle target)\r
+ {\r
+ double t = top, l = left, b = bottom, r = right;\r
+ if (top < target.top) { t = target.top; }\r
+ if (left < target.left) { l = target.left; }\r
+ if (bottom > target.bottom) { b = target.bottom; }\r
+ if (right > target.right) { r = target.right; }\r
+ set(l, t, r, b);\r
+ }\r
+\r
\r
public double left { get { return v1.x; } }\r
public double top { get { return v1.y; } }\r
public double bottom { get { return v2.y; } }\r
public double width { get { return Math.abs(v1.x - v2.x); } }\r
public double height { get { return Math.abs(v1.y - v2.y); } }\r
+ public Point center {\r
+ get { return new Point((left + right) / 2, (top + bottom) / 2); }\r
+ set { centering(value); }\r
+ }\r
+ public double getLeft() { return left; }\r
+ public double getTop() { return top; }\r
+ public double getRight() { return right; }\r
+ public double getBottom() { return bottom; }\r
+ public double getWidth() { return width; }\r
+ public double getHeight() { return height; }\r
+ public Point getCenter() { return center; }\r
+\r
\r
\r
public Color fill { get; set; }\r
\r
public partial class Ellipse : Shape\r
{\r
- public Point datum;\r
+ public Point datum { get; set; }\r
public double xdiameter, ydiameter;\r
\r
public Ellipse()\r
public double bottom { get { return datum.y + ydiameter / 2.0; } }\r
public double width { get { return Math.abs(xdiameter); } }\r
public double height { get { return Math.abs(ydiameter); } }\r
+ public Point center\r
+ {\r
+ get { return new Point((left + right) / 2, (top + bottom) / 2); }\r
+ set { centering(value); }\r
+ }\r
+ public double getLeft() { return left; }\r
+ public double getTop() { return top; }\r
+ public double getRight() { return right; }\r
+ public double getBottom() { return bottom; }\r
+ public double getWidth() { return width; }\r
+ public double getHeight() { return height; }\r
+ public Point getCenter() { return center; }\r
\r
public Color fill { get; set; }\r
public Stroke stroke { get; set; }\r
\r
public partial class Polygon : Shape\r
{\r
- public Point datum;\r
+ public Point datum { get; set; }\r
public System.Collections.Generic.List<Point> vertices;\r
\r
public Polygon()\r
\r
public Figure shift(Point p)\r
{\r
- datum += p;\r
+ datum = datum + p;\r
return this;\r
}\r
public Figure centering(Point p)\r