Created
June 6, 2012 19:40
-
-
Save zachaysan/2884183 to your computer and use it in GitHub Desktop.
My version of the sq thing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Point(object): | |
def __init__(self): | |
self.x = None | |
self.y = None | |
a = Point() | |
b = Point() | |
a.x = 20 | |
a.y = 1 | |
b.x = 1 | |
b.y = 20 | |
def get_top_corner(point1, point2): | |
top_corner = Point() | |
top_corner.x = min(point1.x, point2.x) | |
top_corner.y = min(point1.y, point2.y) | |
return top_corner | |
def get_width(point1, point2): | |
return abs(point1.x - point2.x) | |
def get_height(point1, point2): | |
return abs(point1.y - point2.y) | |
top_corner = get_top_corner(a, b) | |
width = get_width(a, b) | |
height = get_height(a, b) | |
print "with (%s,%s) (%s,%s)" % (a.x, a.y, b.x, b.y) | |
print "x: " + str(top_corner.x) | |
print "y: " + str(top_corner.y) | |
print "width: " + str(width) | |
print "height: " + str(height) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment