Skip to content

Instantly share code, notes, and snippets.

@zachaysan
Created June 6, 2012 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zachaysan/2884183 to your computer and use it in GitHub Desktop.
Save zachaysan/2884183 to your computer and use it in GitHub Desktop.
My version of the sq thing
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