1 module uim.html.core.jscanvas;
2 
3 import uim.html;
4 //
5 //class DJSCanvas : DJS {
6 //	string idName;
7 //	string contextName = "context";
8 //
9 //	this(string name) { super(); idName = name; }
10 //	this(DJS aListener, string name, bool inABlock = false) { super(aListener, inABlock); idName = name; }
11 //
12 //	override string toString() {
13 //		auto j = new DJS;
14 //		return j.Var("canvas", `document.getElementById('%s')`.format(idName))
15 //			.If("canvas", 
16 //				`var %s = canvas.getContext('2d');
17 //			if (%s) { 
18 //				%s
19 //			}`.format(contextName, contextName, super.toString)
20 //				).toString;
21 //	}	
22 //
23 //	// Canvas Functions
24 //	@property auto Font(string name) { add(contextName~".font = %s;".format(name)); return this; }
25 //
26 //	auto FillRect(string x, string y, string w, string h) { add(contextName~".fillRect(%s, %s, %s, %s);".format(x, y, w, h)); return this; }
27 //	auto FillRect(double x, double y, double w, double h) { add(contextName~".fillRect(%s, %s, %s, %s);".format(x, y, w, h)); return this; }
28 //
29 //	/* fillStyle
30 //	 * Setter or Getter for color, gradient, or pattern used to fill a drawing.
31 //	 * Default: 	#000000
32 //	 * Syntax: 	context.fillStyle=color|gradient|pattern;
33 //	 */
34 //	@property auto FillStyle(string style) {
35 //		add(contextName~".fillStyle = %s;".format(style));
36 //		return this;
37 //	}
38 //	@property auto ShadowColor(string color) {
39 //		add(contextName~".shadowColor = %s;".format(color));
40 //		return this;
41 //	}
42 //	auto ClearRect(double x, double y, double w, double h) {
43 //		add(contextName~".clearRect(%s, %s, %s, %s);".format(x, y, w, h));
44 //		return this;
45 //	}
46 //	@property auto StrokeStyle(string style) {
47 //		add(contextName~".strokeStyle = %s;".format(style));
48 //		return this;
49 //	}
50 //
51 //	auto StrokeRect(string x, string y, string w, string h) { add(contextName~".strokeRect(%s, %s, %s, %s);".format(x, y, w, h)); return this; }
52 //	auto StrokeRect(double x, double y, double w, double h) { add(contextName~".strokeRect(%s, %s, %s, %s);".format(x, y, w, h)); return this; }
53 //
54 //	auto BeginPath() {
55 //		add(contextName~".beginPath();"); return this;
56 //	}
57 //	auto MoveTo(double x, double y) { 
58 //		add(contextName~".moveTo(%s, %s);".format(x, y)); return this;
59 //	}
60 //	auto LineTo(double x, double y) { 
61 //		add(contextName~".lineTo(%s, %s);".format(x, y)); return this;
62 //	}
63 //	auto ClosePath() {
64 //		add(contextName~".closePath();"); return this;
65 //	}
66 //	auto Stroke() {
67 //		add(contextName~".stroke();"); return this;
68 //	}
69 //	auto Fill() {
70 //		add(contextName~".fill();"); return this;
71 //	}
72 //	auto Arc(double x, double y, double w, double h, double r, bool b) { 
73 //		add(contextName~".arc(%s, %s, %s, %s, %s, %s);".format(x, y, w, h, r, b ? "true" : "false")); return this;
74 //	}
75 //	auto BezierCurveTo(double x, double y, double w, double h, double r, double b) { 
76 //		add(contextName~".bezierCurveTo(%s, %s, %s, %s, %s, %s);".format(x, y, w, h, r, b)); return this;
77 //	}
78 //	auto QuadraticCurveTo(double x, double y, double w, double h) { 
79 //		add(contextName~".quadraticCurveTo(%s, %s, %s, %s);".format(x, y, w, h)); return this;
80 //	}
81 //
82 //	@property auto LineWidth() { add(contextName~".lineWidth;"); return this; }
83 //	@property auto LineWidth(double value) { add(contextName~".lineWidth = %s;".format(value)); return this; }
84 //	@property auto LineWidth(string value) { add(contextName~".lineWidth = %s;".format(value)); return this; }
85 //
86 //	@property auto LineCap() { add(contextName~".lineCap"); return this; }
87 //	@property auto LineCap(string value) { add(contextName~".lineCap = %s;".format(value)); return this; }
88 //
89 //	@property auto LineJoin(string value) { add(contextName~".lineJoin = %s;".format(value)); return this; }
90 //
91 //	@property auto ShadowBlur() { add(contextName~".shadowBlur"); return this; }
92 //	@property auto ShadowBlur(double value) { add(contextName~".shadowBlur = %s;".format(value)); return this; }
93 //	@property auto ShadowBlur(string value) { add(contextName~".shadowBlur = %s;".format(value)); return this; }
94 //
95 //	@property auto ShadowOffsetY() { add(contextName~".shadowOffsetY"); return this; }
96 //	@property auto ShadowOffsetY(double value) { add(contextName~".shadowOffsetY = %s;".format(value)); return this; }
97 //	@property auto ShadowOffsetY(string value) { add(contextName~".shadowOffsetY = %s;".format(value)); return this; }
98 //
99 //	@property auto ShadowOffsetX() { add(contextName~".shadowOffsetX"); return this; }
100 //	@property auto ShadowOffsetX(double value) { add(contextName~".shadowOffsetX = %s;".format(value)); return this; }
101 //	@property auto ShadowOffsetX(string value) { add(contextName~".shadowOffsetX = %s;".format(value)); return this; }
102 //
103 //	auto StrokeText(string text, string x, string y) { 
104 //		add(contextName~".strokeText(%s, %s, %s);".format(text, x, y)); return this;
105 //	}
106 //
107 //	//Dispatcher
108 //	override public DJS call(string mName) {
109 //		switch(mName) {
110 //			case "BeginPath": return BeginPath(); 
111 //			case "ClosePath": return ClosePath(); 
112 //			case "Stroke": return Stroke(); 
113 //			case "Fill": return Fill(); 
114 //			default: break;
115 //		}
116 //		return super.call(mName);
117 //	}
118 //	override public DJS call(string mName, string value) {
119 //		switch(mName) {
120 //			case "Font": return Font(value); 
121 //			case "FillStyle": return FillStyle(value); 
122 //			case "StrokeStyle": return StrokeStyle(value); 
123 //			case "LineCap": return LineCap(value); 
124 //			case "LineJoin": return LineJoin(value); 
125 //			case "LineWidth": return LineWidth(value); 
126 //			default: break;
127 //		}
128 //		return super.call(mName, value);
129 //	}
130 //	override public DJS call(string mName, double value) {
131 //		switch(mName) {
132 //			case "LineWidth": return LineWidth(value); 
133 //			default: break;
134 //		}
135 //		return super.call(mName, value);
136 //	}
137 //
138 //	override DJS call(string mName, double[] values...) { 
139 //		if (values.length == 4) {
140 //			switch(mName) {
141 //				case "FillRect": return FillRect(values[0], values[1], values[2], values[3]); 
142 //				case "StrokeRect": return StrokeRect(values[0], values[1], values[2], values[3]);
143 //				default: break;
144 //			}
145 //		}
146 //		return super.call(mName, values);
147 //	}
148 //	override DJS call(string mName, string[] values...) { 
149 //		switch(values.length) {
150 //			case 3: 
151 //				switch(mName) {
152 //					case "StrokeText": return StrokeText(values[0], values[1], values[2]); 
153 //					default: break;
154 //				} break;
155 //			case 4: 
156 //				switch(mName) {
157 //					case "FillRect": return FillRect(values[0], values[1], values[2], values[3]); 
158 //					case "StrokeRect": return StrokeRect(values[0], values[1], values[2], values[3]);
159 //					default: break;
160 //				} break;
161 //			default: break;
162 //		}
163 //		return super.call(mName, values);
164 //	}
165 //}
166 //mixin(Shortcut!("DJSCanvas", "JSCanvas", "name", "string name"));
167 
168 unittest {
169 	
170 }