Last active
December 25, 2015 15:29
-
-
Save boxmein/6999154 to your computer and use it in GitHub Desktop.
Splits a square defined by its side w into four equal squares defined by their relative coordinates to the top left corner.
This file contains hidden or 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
# split a square defined by its side w into four equals | |
# for Doxin | |
class Point: | |
def __init__(self, x, y): | |
self.x = x | |
self.y = y | |
class Square: | |
def __init__(self, x1, y1, x2, y2): | |
self.tl = Point(x1, y1) | |
self.br = Point(x2, y2) | |
def splitasquare(w): | |
# 1 2 | |
# 3 4 | |
square1 = Square(0, 0, w/2,w/2) | |
square2 = Square(w/2, 0, w, w/2) | |
square3 = Square(0, w/2, w/2, w) | |
square4 = Square(w/2, w/2, w, w) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment