diff tk/geometry.d @ 15:2f79aab4d385

Checkpoint
author "David Bryant <bagnose@gmail.com>"
date Sun, 12 Jul 2009 13:23:06 +0930
parents f0ade1b49fe7
children 9e63308b749c
line wrap: on
line diff
--- a/tk/geometry.d	Sun Jul 12 01:23:32 2009 +0930
+++ b/tk/geometry.d	Sun Jul 12 13:23:06 2009 +0930
@@ -174,15 +174,31 @@
         }
     }
 
-    /*
-    Rectangle moved(in Vector displacement) {
-        return Rectangle(
+    // TODO make these free functions
+
+    Rectangle moved(in Vector displacement) const {
+        return Rectangle(_position + displacement, _size);
+    }
+
+    Rectangle expanded(in Vector expand_amount) const {
+        return Rectangle(_position, _size + expand_amount);
+    }
+
+    Rectangle shrunk(in Vector shrink_amount) const {
+        return Rectangle(_position, _size - shrink_amount);
     }
-    Rectangle resized(in Vector new_size) {
+
+    Rectangle resized(in Vector new_size) const {
+        return Rectangle(_position, new_size);
     }
-    Rectangle repositioned(in Point new_position) {
+
+    Rectangle repositioned(in Point new_position) const {
+        return Rectangle(new_position, _size);
     }
-    */
+
+    Point centre() const {
+        return _position + _size / 2.0;
+    }
 
     string toString() const {
         return std.string.format("{%s, %s}", _position, _size);