Convert dtiled's pixel-space coordinates to your own types:
1 // your own representation may be a struct 2 struct MyVector(T) { T x, y; } 3 4 assert(PixelCoord(5, 10).as!(MyVector!double) == MyVector!double(5, 10)); 5 assert(PixelCoord(5.5, 10.2).as!(MyVector!int) == MyVector!int(5, 10)); 6 7 // or it may be a tuple 8 alias MyPoint(T) = Tuple!(T, "x", T, "y"); 9 10 assert(PixelCoord(5, 10).as!(MyPoint!double) == MyPoint!double(5, 10)); 11 assert(PixelCoord(5.5, 10.2).as!(MyPoint!int) == MyPoint!int(5, 10)); 12 13 // std.conv.to is used internally, so it should detect overflow 14 import std.conv : ConvOverflowException; 15 import std.exception : assertThrown; 16 assertThrown!ConvOverflowException(PixelCoord(-1, -1).as!(MyVector!ulong));
Convert a PixelCoord to a user-defined (x,y) numeric pair.