1 module ws.gui.point;
2 
3 
4 public import ws.math: x, y;
5 
6 alias w = x;
7 alias h = y;
8 
9 
10 Point a(int[2] data){
11 	return Point(data);
12 }
13 
14 
15 struct Point {
16 
17 	int[2] data = [0,0];
18 
19 	this(int x, int y){
20 		data = [x, y];
21 	}
22 	
23 	this(int[2] d){
24 		data = d;
25 	}
26 
27 	Point opBinary(string op, T)(T[2] other) if(__traits(isArithmetic,T)) {
28 		mixin("
29 			return Point(
30 				data[0] " ~ op ~ " cast(int)other[0],
31 				data[1] " ~ op ~ " cast(int)other[1]
32 			);
33 		");
34 	}
35 
36 	Point opBinary(string op)(Point other){
37 		return opBinary!op(other.data);
38 	}
39 
40 	Point opBinary(string op)(double other){
41 		mixin("
42 			return Point(
43 				cast(int)(data[0] " ~ op ~ " other),
44 				cast(int)(data[1] " ~ op ~ " other)
45 			);
46 		");	
47 	}
48 
49 	Point opOpAssign(string op)(int[2] other){
50 		mixin("this = this " ~ op ~ "other;");
51 		return this;
52 	}
53 
54 	alias data this;
55 	
56 }