Mercurial > projects > doodle
diff doodle/tk/geometry.d @ 48:1b4c9ba58673
Stylistic overhaul.
author | daveb |
---|---|
date | Tue, 03 Aug 2010 17:37:21 +0930 |
parents | f2e4e1d29b98 |
children | 0eaf39fda206 |
line wrap: on
line diff
--- a/doodle/tk/geometry.d Tue Aug 03 16:57:06 2010 +0930 +++ b/doodle/tk/geometry.d Tue Aug 03 17:37:21 2010 +0930 @@ -61,11 +61,11 @@ } } -Point min_extents(in Point a, in Point b) { +Point minExtents(in Point a, in Point b) { return Point(min(a.x, b.x), min(a.y, b.y)); } -Point max_extents(in Point a, in Point b) { +Point maxExtents(in Point a, in Point b) { return Point(max(a.x, b.x), max(a.y, b.y)); } @@ -164,12 +164,12 @@ this(corner1.x, corner1.y, corner.x - corner1.x, corner.y - corner1.y); } - alias position min_corner; + alias position minCorner; Point position() const { return _position; } Vector size() const { return _size; } - Point max_corner() const { return _position + _size; } + Point maxCorner() const { return _position + _size; } bool valid() const { return _size.x > 0.0 && _size.y > 0.0; } @@ -183,8 +183,8 @@ return DEFAULT; } else { - Point max = min_extents(max_corner(), r.max_corner()); - Point min = max_extents(min_corner(), r.min_corner()); + Point max = minExtents(maxCorner(), r.maxCorner()); + Point min = maxExtents(minCorner(), r.minCorner()); if (max.x < min.x || max.y < min.y) { return DEFAULT; @@ -204,8 +204,8 @@ return this; } else { - return Rectangle(min_extents(min_corner(), r.min_corner()), - max_extents(max_corner(), r.max_corner())); + return Rectangle(minExtents(minCorner(), r.minCorner()), + maxExtents(maxCorner(), r.maxCorner())); } } @@ -213,7 +213,7 @@ // FIXME this method is all about pixels. Not sure it belongs in // this file, let alone this class. - void get_quantised(out int x, out int y, out int w, out int h) const { + void getQuantised(out int x, out int y, out int w, out int h) const { x = cast(int)floor(_position.x); y = cast(int)floor(_position.y); w = cast(int)ceil(_position.x + _size.x) - x; @@ -288,7 +288,7 @@ // The function returns false if the lines are parallel or nearly so. // // Influenced by http://ozviz.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/ - bool compute_intersection(in Point pa1, in Point pa2, out double ua, + bool computeIntersection(in Point pa1, in Point pa2, out double ua, in Point pb1, in Point pb2, out double ub) { double den = (pb2.y - pb1.y) * (pa2.x - pa1.x) - (pb2.x - pb1.x) * (pa2.y - pa1.y); @@ -360,7 +360,7 @@ Vector vb = b.gradient; double ub; - if (compute_intersection(pa, pa + va, ua, pb, pb + vb, ub)) { + if (computeIntersection(pa, pa + va, ua, pb, pb + vb, ub)) { // We could just have easily evaluated for line b... p = pa + ua * va; // p = pb + ub * vb; @@ -406,7 +406,7 @@ Point pb2 = b.end; double ub; - if (compute_intersection(pa1, pa2, ua, pb1, pb2, ub)) { + if (computeIntersection(pa1, pa2, ua, pb1, pb2, ub)) { if (ua >= 0.0 && ua <= 1.0 && // inside of segment a ub >= 0.0 && ub <= 1.0) { // inside of segment b // We could just have easily evaluated for line b... @@ -432,7 +432,7 @@ Vector vb = b.gradient; double ub; - if (compute_intersection(pa1, pa2, ua, pb, pb + vb, ub)) { + if (computeIntersection(pa1, pa2, ua, pb, pb + vb, ub)) { if (ua >= 0.0 && ua <= 1.0) { // inside of segment // We could just have easily evaluated for line b... p = pa1 + ua * (pa2 - pa1);