1 module gfx.graal.types;
2 
3 import std.traits : isIntegral;
4 
5 /// An integer interval from a start until an end.
6 /// end is one past last, such as end-start = length
7 struct Interval(T)
8 if (isIntegral!T)
9 {
10     /// start of interval
11     T start;
12     /// one past last
13     T end;
14 
15     /// end-start
16     @property T length() const {
17         return end - start;
18     }
19 }
20 
21 /// Interval build helper
22 auto interval(T)(T start, T end)
23 if (isIntegral!T)
24 {
25     import std.traits : Unqual;
26     return Interval!(Unqual!T)(start, end);
27 }
28 
29 /// A transition from one state to another
30 struct Trans(T) {
31     /// state before
32     T from;
33     /// state after
34     T to;
35 }
36 
37 /// Transition build helper
38 auto trans(T)(T from, T to)
39 if (!is(T : Object))
40 {
41     import std.traits : Unqual;
42     return Trans!(Unqual!T)(from, to);
43 }
44 
45 struct Offset2D {
46     uint x;
47     uint y;
48 }
49 
50 struct Extent2D {
51     uint width;
52     uint height;
53 }
54 
55 struct Rect {
56     uint x;
57     uint y;
58     uint width;
59     uint height;
60 }
61 
62 struct Viewport {
63     float x;
64     float y;
65     float width;
66     float height;
67     float minDepth  = 0f;
68     float maxDepth  = 1f;
69 }