Changeset 47 for trunk/luigi/base.d
- Timestamp:
- 02/24/07 04:54:29 (2 years ago)
- Files:
-
- trunk/luigi/base.d (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/luigi/base.d
r37 r47 72 72 float y2(float v) { return h=(v-y); } 73 73 74 Point center() { return Point(x+width/2,y+height/2); } 75 Point minpos() { return Point(x1,y1); } 76 Point maxpos() { return Point(x2,y2); } 77 74 78 /** Rect constructor */ 75 79 static Rect opCall(float rx = 0, float ry = 0, float rwidth = 0, float rheight = 0) { … … 85 89 set(leftx,topy,rightx-leftx,bottomy-topy); 86 90 } 91 alias setLTRB setMinMax; 87 92 88 93 /** Point-inside-rect test */ … … 116 121 /** Grow rect to enclose point p. */ 117 122 void enclose(Point p) { 123 if (!valid) { 124 x = p.x; y=p.y; 125 w = 0; h = 0; 126 } 118 127 if (p.x < x) { w = x2-p.x; x = p.x; } 119 128 else if (p.x > x2) { x2 = p.x; } … … 122 131 } 123 132 133 134 bool valid() { 135 return !(math.isnan(x)||math.isnan(y)|| 136 math.isnan(w)||math.isnan(h)); 137 } 124 138 125 139 char[] toString() { … … 162 176 } 163 177 178 /** Return a pointer to the first element */ 179 float *ptr() { return &x; } 164 180 } 165 181
