Mercurial > projects > doodle
comparison doodle/tk/geometry.d @ 70:0e61702c6ea6
Checkpoint
author | "David Bryant <bagnose@gmail.com>" |
---|---|
date | Sat, 14 Aug 2010 20:05:55 +0930 |
parents | 31d10176415d |
children | 024a5608087f |
comparison
equal
deleted
inserted
replaced
69:d540f7e4af9e | 70:0e61702c6ea6 |
---|---|
150 | 150 |
151 this(in Point corner1, in Point corner) { | 151 this(in Point corner1, in Point corner) { |
152 this(corner1.x, corner1.y, corner.x - corner1.x, corner.y - corner1.y); | 152 this(corner1.x, corner1.y, corner.x - corner1.x, corner.y - corner1.y); |
153 } | 153 } |
154 | 154 |
155 alias position minCorner; | 155 double x0() { return _position.x; } |
156 double y0() { return _position.y; } | |
157 double w() { return _size.x; } | |
158 double h() { return _size.y; } | |
159 double x1() { return x0 + w; } | |
160 double y1() { return y0 + h; } | |
161 | |
162 alias position corner0; | |
156 Point position() const { return _position; } | 163 Point position() const { return _position; } |
157 | 164 |
158 Vector size() const { return _size; } | 165 Vector size() const { return _size; } |
159 | 166 |
160 Point maxCorner() const { return _position + _size; } | 167 Point corner1() const { return _position + _size; } |
161 | 168 |
162 bool valid() const { return _size.x > 0.0 && _size.y > 0.0; } | 169 bool valid() const { return _size.x > 0.0 && _size.y > 0.0; } |
163 | 170 |
164 bool invalid() const { return !valid(); } | 171 bool invalid() const { return !valid(); } |
165 | 172 |
169 Rectangle opAnd(in Rectangle r) const { | 176 Rectangle opAnd(in Rectangle r) const { |
170 if (invalid() || r.invalid()) { | 177 if (invalid() || r.invalid()) { |
171 return DEFAULT; | 178 return DEFAULT; |
172 } | 179 } |
173 else { | 180 else { |
174 Point max = minExtents(maxCorner(), r.maxCorner()); | 181 Point max = minExtents(corner1(), r.corner1()); |
175 Point min = maxExtents(minCorner(), r.minCorner()); | 182 Point min = maxExtents(corner0(), r.corner0()); |
176 | 183 |
177 if (max.x < min.x || max.y < min.y) { | 184 if (max.x < min.x || max.y < min.y) { |
178 return DEFAULT; | 185 return DEFAULT; |
179 } | 186 } |
180 else { | 187 else { |
190 } | 197 } |
191 else if (r.invalid()) { | 198 else if (r.invalid()) { |
192 return this; | 199 return this; |
193 } | 200 } |
194 else { | 201 else { |
195 return Rectangle(minExtents(minCorner(), r.minCorner()), | 202 return Rectangle(minExtents(corner0(), r.corner0()), |
196 maxExtents(maxCorner(), r.maxCorner())); | 203 maxExtents(corner1(), r.corner1())); |
197 } | 204 } |
198 } | 205 } |
199 | 206 |
200 // | 207 // |
201 | 208 |