using System;\r
using System.Windows;\r
-using System.Windows.Controls;\r
-using System.Windows.Documents;\r
-using System.Windows.Input;\r
-using System.Windows.Media;\r
-using System.Windows.Media.Animation;\r
-using System.Windows.Media.Imaging;\r
-using System.Windows.Shapes;\r
-\r
\r
\r
namespace Psychlops\r
{\r
\r
- public struct Point\r
+ public partial struct Point\r
{\r
public double x, y, z;\r
public Point(double dx, double dy, double dz)\r
{\r
return new Point(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z);\r
}\r
- public static implicit operator System.Windows.Point(Point d)\r
+ public override string ToString()\r
{\r
- return new System.Windows.Point(d.x, d.y);\r
+ return "X:"+ x.ToString() + " Y:"+ y.ToString() + " Z:"+ z.ToString();\r
}\r
}\r
\r
\r
- public struct Color\r
+ public partial struct Color\r
{\r
public double r, g, b, a;\r
public Color(double lum)\r
r = g = b = lum;\r
a = 1.0;\r
}\r
+ public Color(double red, double green, double blue)\r
+ {\r
+ r = red;\r
+ g = green;\r
+ b = blue;\r
+ a = 1.0;\r
+ }\r
public Color(double red, double green, double blue, double alpha)\r
{\r
r = red;\r
b = blue;\r
a = alpha;\r
}\r
- public static implicit operator System.Windows.Media.Color(Color d)\r
+ public void set(double lum)\r
{\r
- return System.Windows.Media.Color.FromArgb((byte)(d.a * 255), (byte)(d.r * 255), (byte)(d.g * 255), (byte)(d.b * 255));\r
+ r = g = b = lum;\r
+ a = 1.0;\r
+ }\r
+ public void set(double red, double green, double blue)\r
+ {\r
+ r = red;\r
+ g = green;\r
+ b = blue;\r
+ a = 1.0;\r
+ }\r
+ public void set(double red, double green, double blue, double alpha)\r
+ {\r
+ r = red;\r
+ g = green;\r
+ b = blue;\r
+ a = alpha;\r
+ }\r
+\r
+ public override string ToString()\r
+ {\r
+ return "R:" + r.ToString() + " G:" + g.ToString() + " B:" + b.ToString() + " A:" + a.ToString();\r
}\r
\r
public static readonly Color\r
magenta = new Color(1, 0, 1, 1),\r
cyan = new Color(0, 1, 1, 1),\r
white = new Color(1, 1, 1, 1),\r
- gray = new Color(.5, .5, .5, 1);\r
+ gray = new Color(.5, .5, .5, 1),\r
+ null_color = new Color(0, 0, 0, 0);\r
\r
}\r
\r
Point getCenter();\r
void clear(Color col);\r
void pix(int x, int y, Color col);\r
- void line(Line drawee, Color col);\r
- void rect(Rectangle drawee, Color col);\r
- void ellipse(Ellipse drawee, Color col);\r
+ void line(Line drawee);\r
+ void rect(Rectangle drawee);\r
+ void ellipse(Ellipse drawee);\r
+ void polygon(Polygon drawee);\r
+ void letters(Letters drawee);\r
void image(Image drawee);\r
- void polygon(Polygon drawee, Color col);\r
+ void msg(string s, double x, double y, Color c);\r
}\r
\r
\r
{\r
return target.centering(Main.drawable.getCenter());\r
}\r
- }\r
-\r
-\r
-\r
- public class Image : Figure\r
- {\r
- public WriteableBitmap buffer;\r
- public Point datum;\r
- public Rectangle self_rect;\r
-\r
- public Image(int wid, int hei)\r
- {\r
- buffer = new WriteableBitmap(wid, hei);\r
- self_rect = new Rectangle(wid, hei);\r
- }\r
-\r
- /*public Image shift(double x, double y)\r
- {\r
- datum.x += x;\r
- datum.y += y;\r
- return this;\r
- }*/\r
- public Figure shift(Point p)\r
- {\r
- 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
- return this;\r
- }\r
-\r
- public void pix(int x, int y, Color col)\r
+ public static Figure centering(this Figure target, double x, double y)\r
{\r
- buffer.SetPixel(x, y, col);\r
- }\r
-\r
-\r
- public void field(System.Func<int,int,System.Windows.Media.Color> func)\r
- {\r
- buffer.ForEach(func);\r
- }\r
- public void field(System.Func<int, int, System.Windows.Media.Color, System.Windows.Media.Color> func)\r
- {\r
- buffer.ForEach(func);\r
+ return target.centering(new Point(x, y));\r
}\r
+ }\r
\r
- public void draw()\r
+ namespace Internal\r
+ {\r
+ public interface PrimitiveFigure : Figure\r
{\r
- Main.drawable.image(this);\r
+ UIElement toNative();\r
}\r
-\r
- public double width { get { return self_rect.width; } }\r
- public double height { get { return self_rect.height; } }\r
-\r
}\r
-\r
}
\ No newline at end of file