Mercurial > projects > doodle
diff doodle/tk/geometry.d @ 100:a274d16ab6ce
struct initialisers
author | David Bryant <bagnose@gmail.com> |
---|---|
date | Mon, 18 Oct 2010 18:10:02 +1030 |
parents | 535bae7a7305 |
children | bc5baa585b32 |
line wrap: on
line diff
--- a/doodle/tk/geometry.d Wed Oct 06 13:03:38 2010 +1030 +++ b/doodle/tk/geometry.d Mon Oct 18 18:10:02 2010 +1030 @@ -24,8 +24,6 @@ // struct Point { - static immutable Point DEFAULT = Point(0.0, 0.0); - this(in double x, in double y) { _x = x; _y = y; @@ -51,7 +49,7 @@ double y() const { return _y; } private { - double _x, _y; + double _x = 0.0, _y = 0.0; } } @@ -68,8 +66,6 @@ // struct Vector { - static Vector DEFAULT = Vector(0.0, 0.0); - this(in double x, in double y) { _x = x; _y = y; @@ -109,7 +105,7 @@ double y() const { return _y; } private { - double _x, _y; + double _x = 0.0, _y = 0.0; } } @@ -135,12 +131,6 @@ // struct Rectangle { - static Rectangle DEFAULT; - - static this() { - DEFAULT = Rectangle(Point.DEFAULT, Vector.DEFAULT); - } - /* static Rectangle from_arbitrary_corners(in Point corner1, in Point corner) { } @@ -177,14 +167,14 @@ // Intersection Rectangle opAnd(in Rectangle r) const { if (invalid() || r.invalid()) { - return DEFAULT; + return Rectangle(); } else { Point max = minExtents(corner1(), r.corner1()); Point min = maxExtents(corner0(), r.corner0()); if (max.x < min.x || max.y < min.y) { - return DEFAULT; + return Rectangle(); } else { return Rectangle(min, max);