summaryrefslogtreecommitdiffhomepage
path: root/dragon/geometry.rb
diff options
context:
space:
mode:
authorAmir Rajan <[email protected]>2020-08-06 08:12:27 -0500
committerAmir Rajan <[email protected]>2020-08-06 08:12:27 -0500
commit64046616ce54fff32c3dd949a4b7702136f38a3e (patch)
tree1fff22cf553b2cf3eb5fe8095b572fd0cce63196 /dragon/geometry.rb
parent161d498dc905f04b595c927309993acdcb4d394c (diff)
downloaddragonruby-game-toolkit-contrib-64046616ce54fff32c3dd949a4b7702136f38a3e.tar.gz
dragonruby-game-toolkit-contrib-64046616ce54fff32c3dd949a4b7702136f38a3e.zip
Synced with 1.14
Diffstat (limited to 'dragon/geometry.rb')
-rw-r--r--dragon/geometry.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/dragon/geometry.rb b/dragon/geometry.rb
index 59f1865..b16c5b7 100644
--- a/dragon/geometry.rb
+++ b/dragon/geometry.rb
@@ -90,6 +90,30 @@ center_inside_rect for self #{self} and other_rect #{other_rect}. Failed with ex
S
end
+ def center_inside_rect_y other_rect
+ offset_y = (other_rect.h - h).half
+ new_rect = self.shift_rect(0, 0)
+ new_rect.y = other_rect.y + offset_y
+ new_rect
+ rescue Exception => e
+ raise e, <<-S
+* ERROR:
+center_inside_rect_y for self #{self} and other_rect #{other_rect}. Failed with exception #{e}.
+S
+ end
+
+ def center_inside_rect_x other_rect
+ offset_x = (other_rect.w - w).half
+ new_rect = self.shift_rect(0, 0)
+ new_rect.x = other_rect.x + offset_x
+ new_rect
+ rescue Exception => e
+ raise e, <<-S
+* ERROR:
+center_inside_rect_x for self #{self} and other_rect #{other_rect}. Failed with exception #{e}.
+S
+ end
+
# Returns a primitive that is anchored/repositioned based off its retangle.
# @gtk
def anchor_rect anchor_x, anchor_y