def main():
    # CMD argument parsing
    parser = argparse.ArgumentParser()
    parser.add_argument('--old_img')
    parser.add_argument('--avg_filter_size')
    parser.add_argument('--gauss_filter_size')
    parser.add_argument('--circle_radius')
    args = parser.parse_args()

    old_img_path = args.old_img
    avg_filter_size = args.avg_filter_size
    gauss_filter_size = args.gauss_filter_size
    circle_radius = args.circle_radius

    if type(old_img_path) is not str:
        print("Original image path is not a string!")
        return

    old_image = Image.open(old_img_path)

    to_greyscale(old_image, old_img_path)

    average_filter(old_image, old_img_path, avg_filter_size)

    gauss(old_image, old_img_path, gauss_filter_size)

    laplace(old_image, old_img_path)

    circle(circle_radius)

    scale_down(old_image, old_img_path)
Пример #2
0
def test_compare():
    c1 = circle(2)
    c2 = circle(3)
    c3 = circle(2)
    assert((c1 < c2) is True)
    assert((c1 == c2) is False)
    assert((c3 == c1) is True)
    assert((c2 > c3) is True)
    assert((c1 <= c2) is True)
Пример #3
0
def test_sort():
    c1 = circle(1)
    c2 = circle(4)
    c3 = circle(2)
    c4 = circle(6)
    circles = [c1, c2, c3, c4]
    circles.sort()
    assert (circles == [circle(1), circle(2), circle(4), circle(6)])
Пример #4
0
def main():
    c1 = circle()  #Default Circle Object
    print("The radius is", c1.getRadius())
    print("The area is", c1.getArea())
    print("The perimeter is", c1.getPerimeter(), "\n")

    c1.setRadius(10)  #Radius is set to 10
    print("The radius is", c1.getRadius())
    print("The area is", c1.getArea())
    print("The perimeter is", c1.getPerimeter())
Пример #5
0
    def __init__(self, game):

        self.game = game
        x = self.game.screen_weight
        y = self.game.screen_height
        _x = int(x / 10)
        _y = int(y / 10)
        self.difficulty = 300

        ######################## how difficulty ########################################
        if (self.game.difficulty == "super easy"):
            self.difficulty = 800
        elif (self.game.difficulty == "easy"):
            self.difficulty = 600
        elif (self.game.difficulty == "medium"):
            self.difficulty = 300
        elif (self.game.difficulty == "hard"):
            self.difficulty = 150
        elif (self.game.difficulty == "hardcore"):
            self.difficulty = 50
        else:
            self.difficulty = 350
        ############################ levels  ###########################################
        # level 1
        if (self.game.level == 1):
            # tworzenie kół(bakterii)
            self.team1_1 = circle(game, _x, int(y / 2), 2, "player")

            self.team2_1 = circle(game, int(_x * 9), int(y / 2), 2, "enemy")

            self.neutral_1 = circle(game, int(_x * 3), int(_y * 2), 1,
                                    "neutral")
            self.neutral_2 = circle(game, int(_x * 3), int(_y * 8), 1,
                                    "neutral")
            self.neutral_3 = circle(game, int(_x * 6), int(_y * 2), 1,
                                    "neutral")
            self.neutral_4 = circle(game, int(_x * 6), int(_y * 8), 1,
                                    "neutral")
            # tablica wszystkich kół(bakterii)
            self.circles = [
                self.team1_1, self.neutral_1, self.neutral_2, self.team2_1,
                self.neutral_3, self.neutral_4
            ]

            # Połączenie miedzy danymi kołami
            self.connectons_array = [
                self.team1_1, self.neutral_1, self.team1_1, self.neutral_2,
                self.neutral_1, self.neutral_3, self.neutral_2, self.neutral_4,
                self.neutral_1, self.neutral_2, self.neutral_3, self.team2_1,
                self.neutral_4, self.team2_1
            ]

        #level 2
        if (self.game.level == 2):
            # tworzenie kół(bakterii)

            team1_1 = circle(game, _x, int(y / 2), 2, "player")
            team2_1 = circle(game, int(_x * 9), int(y / 2), 2, "enemy")
            neutral_1 = circle(game, int(_x * 3), int(_y * 2), 1, "neutral")
            neutral_2 = circle(game, int(_x * 3), int(_y * 8), 1, "neutral")
            neutral_3 = circle(game, int(_x * 6), int(_y * 2), 1, "neutral")
            neutral_4 = circle(game, int(_x * 6), int(_y * 8), 1, "neutral")
            team3_1 = circle(game, int(x / 2), int(y / 2), 3, "enemy2")
            # tablica wszystkich kół(bakterii)
            self.circles = [
                team1_1, neutral_1, neutral_2, team2_1, neutral_3, neutral_4,
                team3_1
            ]

            # Połączenie miedzy danymi kołami
            self.connectons_array = [
                team1_1,
                neutral_1,
                team1_1,
                neutral_2,
                neutral_1,
                neutral_3,
                neutral_2,
                neutral_4,
                neutral_1,
                neutral_2,
                neutral_3,
                team2_1,
                neutral_4,
                team2_1,
                team3_1,
                neutral_1,
                team3_1,
                neutral_2,
                team3_1,
                neutral_3,
                team3_1,
                neutral_4,
            ]

        #level 3
        if (self.game.level == 3):
            # tworzenie kół(bakterii)

            team1_1 = circle(game, _x * 2, _y, 2, "player")
            team1_2 = circle(game, _x * 2, _y * 4, 1, "player")
            team1_3 = circle(game, _x * 2, _y * 7, 1, "player")
            team1_4 = circle(game, _x * 5, _y * 7, 1, "player")

            team2_1 = circle(game, _x * 8, _y, 4, "enemy")
            # tablica wszystkich kół(bakterii)
            self.circles = [team1_1, team1_2, team1_3, team2_1, team1_4]

            # Połączenie miedzy danymi kołami
            self.connectons_array = [
                team1_1, team1_2, team1_2, team1_3, team1_3, team1_4, team1_4,
                team2_1
            ]
        # level 4
        if (self.game.level == 4):
            team1_1 = circle(game, _x * 5, _y * 2, 3, "player")
            neutral_1 = circle(game, _x * 2, _y * 4, 2, "neutral")
            neutral_2 = circle(game, _x * 8, _y * 4, 2, "neutral")
            team2_1 = circle(game, _x * 2, _y * 8, 2, "enemy")
            team2_2 = circle(game, _x * 8, _y * 8, 2, "enemy")

            self.circles = [team1_1, neutral_1, neutral_2, team2_1, team2_2]

            self.connectons_array = [
                team1_1, neutral_1, team1_1, neutral_2, team2_1, neutral_1,
                team2_2, neutral_2
            ]
        # level 5
        if (self.game.level == 5):
            team1_1 = circle(game, _x * 5, _y * 2, 3, "enemy")
            neutral_1 = circle(game, _x * 2, _y * 4, 2, "neutral")
            neutral_2 = circle(game, _x * 8, _y * 4, 2, "neutral")
            team2_1 = circle(game, _x * 2, _y * 8, 2, "player")
            team2_2 = circle(game, _x * 8, _y * 8, 2, "player")

            self.circles = [team1_1, neutral_1, neutral_2, team2_1, team2_2]

            self.connectons_array = [
                team1_1, neutral_1, team1_1, neutral_2, team2_1, neutral_1,
                team2_2, neutral_2
            ]
        # level 6
        if (self.game.level == 6):
            team1_1 = circle(game, _x * 5, _y * 5, 4, "player")

            neutral_1 = circle(game, _x * 3, _y * 1, 1, "neutral")
            neutral_2 = circle(game, _x * 3, _y * 3, 1, "neutral")
            neutral_3 = circle(game, _x * 3, _y * 5, 1, "neutral")
            neutral_4 = circle(game, _x * 3, _y * 7, 1, "neutral")
            neutral_5 = circle(game, _x * 3, _y * 9, 1, "neutral")

            team2_1 = circle(game, _x, _y * 5, 4, "enemy")

            neutral_6 = circle(game, _x * 7, _y * 1, 1, "neutral")
            neutral_7 = circle(game, _x * 7, _y * 3, 1, "neutral")
            neutral_8 = circle(game, _x * 7, _y * 5, 1, "neutral")
            neutral_9 = circle(game, _x * 7, _y * 7, 1, "neutral")
            neutral_10 = circle(game, _x * 7, _y * 9, 1, "neutral")

            team3_1 = circle(game, _x * 9, _y * 5, 4, "enemy2")

            self.circles = [
                team1_1, neutral_1, neutral_2, neutral_3, neutral_4, neutral_5,
                neutral_6, neutral_7, neutral_8, neutral_9, neutral_10,
                team2_1, team3_1
            ]
            self.connectons_array = [
                team1_1, neutral_1, team2_1, neutral_1, team1_1, neutral_2,
                team2_1, neutral_2, team1_1, neutral_3, team2_1, neutral_3,
                team1_1, neutral_4, team2_1, neutral_4, team1_1, neutral_5,
                team2_1, neutral_5, team1_1, neutral_6, team3_1, neutral_6,
                team1_1, neutral_7, team3_1, neutral_7, team1_1, neutral_8,
                team3_1, neutral_8, team1_1, neutral_9, team3_1, neutral_9,
                team1_1, neutral_10, team3_1, neutral_10
            ]

        #level 7
        if (self.game.level == 7):
            team1_1 = circle(game, _x * 5, _y * 5, 4, "neutral")
            team1_2 = circle(game, _x * 1, _y * 5, 4, "player")
            team1_3 = circle(game, _x * 1, _y * 5, 4, "player")

            neutral_1 = circle(game, _x * 3, _y * 1, 1, "player")
            neutral_2 = circle(game, _x * 3, _y * 3, 1, "player")
            neutral_3 = circle(game, _x * 3, _y * 5, 1, "player")
            neutral_4 = circle(game, _x * 3, _y * 7, 1, "player")
            neutral_5 = circle(game, _x * 3, _y * 9, 1, "player")

            team2_1 = circle(game, _x, _y * 5, 4, "enemy")
            team2_2 = circle(game, _x, _y * 5, 4, "enemy")
            team2_3 = circle(game, _x, _y * 5, 4, "enemy")

            neutral_6 = circle(game, _x * 7, _y * 1, 1, "player")
            neutral_7 = circle(game, _x * 7, _y * 3, 1, "player")
            neutral_8 = circle(game, _x * 7, _y * 5, 1, "player")
            neutral_9 = circle(game, _x * 7, _y * 7, 1, "player")
            neutral_10 = circle(game, _x * 7, _y * 9, 1, "player")

            team3_1 = circle(game, _x * 9, _y * 5, 4, "enemy2")
            team3_2 = circle(game, _x * 9, _y * 5, 4, "enemy2")
            team3_3 = circle(game, _x * 9, _y * 5, 4, "enemy2")

            self.circles = [
                team1_1, neutral_1, neutral_2, neutral_3, neutral_4, neutral_5,
                neutral_6, neutral_7, neutral_8, neutral_9, neutral_10,
                team2_1, team3_1
            ]
            self.connectons_array = [
                team1_1, neutral_1, team2_1, neutral_1, team1_1, neutral_2,
                team2_1, neutral_2, team1_1, neutral_3, team2_1, neutral_3,
                team1_1, neutral_4, team2_1, neutral_4, team1_1, neutral_5,
                team2_1, neutral_5, team1_1, neutral_6, team3_1, neutral_6,
                team1_1, neutral_7, team3_1, neutral_7, team1_1, neutral_8,
                team3_1, neutral_8, team1_1, neutral_9, team3_1, neutral_9,
                team1_1, neutral_10, team3_1, neutral_10
            ]

        #level 8
        if (self.game.level == 8):
            team1_1 = circle(game, _x * 2, _y * 2, 1, "player")
            team1_2 = circle(game, _x * 8, _y * 8, 1, "player")

            team1_3 = circle(game, _x * 1, _y * 5, 4, "player")

            neutral_1 = circle(game, _x * 2, _y * 8, 2, "neutral")
            neutral_2 = circle(game, _x * 8, _y * 2, 2, "neutral")

            neutral_3 = circle(game, _x * 3, _y * 5, 2, "player")
            neutral_4 = circle(game, _x * 3, _y * 7, 1, "player")
            neutral_5 = circle(game, _x * 3, _y * 9, 1, "player")

            team2_1 = circle(game, _x * 5, _y * 5, 4, "enemy")

            team2_2 = circle(game, _x, _y * 5, 4, "enemy")
            team2_3 = circle(game, _x, _y * 5, 4, "enemy")

            neutral_6 = circle(game, _x * 7, _y * 1, 1, "player")
            neutral_7 = circle(game, _x * 7, _y * 3, 1, "player")
            neutral_8 = circle(game, _x * 7, _y * 5, 1, "player")
            neutral_9 = circle(game, _x * 7, _y * 7, 1, "player")
            neutral_10 = circle(game, _x * 7, _y * 9, 1, "player")

            team3_1 = circle(game, _x * 9, _y * 5, 4, "enemy2")
            team3_2 = circle(game, _x * 9, _y * 5, 4, "enemy2")
            team3_3 = circle(game, _x * 9, _y * 5, 4, "enemy2")

            self.circles = [team1_1, team1_2, neutral_1, neutral_2, team2_1]

            self.connectons_array = [
                team1_1, neutral_1, team2_1, neutral_1, team2_1, neutral_2,
                team1_1, neutral_2, team1_2, neutral_2, team1_2, neutral_1
            ]
        #level 9
        if (self.game.level == 9):
            team1_1 = circle(game, _x, _y, 1, "player")
            team2_1 = circle(game, _x, _y * 9, 1, "enemy")
            team2_2 = circle(game, _x * 9, _y * 1, 1, "enemy")
            team3_1 = circle(game, _x * 9, _y * 5, 1, "enemy2")

            neutral_1 = circle(game, _x * 1, _y * 5, 1, "neutral")
            neutral_2 = circle(game, _x * 3, _y * 2, 1, "neutral")
            neutral_3 = circle(game, _x * 5, _y * 8, 1, "neutral")
            neutral_4 = circle(game, _x * 5, _y * 5, 3, "neutral")

            neutral_5 = circle(game, _x * 3, _y * 8, 1, "neutral")
            neutral_6 = circle(game, _x * 3, _y * 5, 1, "neutral")

            neutral_7 = circle(game, _x * 7, _y * 2, 1, "neutral")
            neutral_8 = circle(game, _x * 7, _y * 5, 1, "neutral")
            neutral_9 = circle(game, _x * 7, _y * 8, 1, "neutral")

            neutral_10 = circle(game, _x * 5, _y * 1, 1, "neutral")

            self.circles = [
                neutral_1, neutral_2, neutral_3, neutral_4, neutral_5, team2_2,
                neutral_6, neutral_7, neutral_8, neutral_9, team1_1,
                neutral_10, team2_1, team3_1
            ]
            self.connectons_array = []
            if (False):
                self.connectons_array = [
                    team1_1, neutral_1, team2_1, neutral_1, team1_1, neutral_2,
                    team2_1, neutral_2, team1_1, neutral_3, team2_1, neutral_3,
                    team1_1, neutral_4, team2_1, neutral_4, team1_1, neutral_5,
                    team2_1, neutral_5, team1_1, neutral_6, team3_1, neutral_6,
                    team1_1, neutral_7, team3_1, neutral_7, team1_1, neutral_8,
                    team3_1, neutral_8, team1_1, neutral_9, team3_1, neutral_9,
                    team1_1, neutral_10, team3_1, neutral_10
                ]

            else:
                self.all_connections()
                self.range = 10

        ##############################################################################
        #Global
        self.time = -200
        self.range = 4
Пример #6
0
def test_radius():
    c1 = circle(1)
    assert(c1.radius == 1)
Пример #7
0
def test_add():
    c1 = circle(2)
    c2 = circle(4)
    assert ((c1 + c2).radius == circle(6).radius)
Пример #8
0
def test_mult():
    c1 = circle(2)
    assert ((c1 * 3).radius == circle(6).radius)
Пример #9
0
def test_repr():
    c1 = circle(4)
    assert (repr(c1) == 'Circle(4)')
Пример #10
0
def test_str():
    c1 = circle(4)
    assert (str(c1) == 'Circle with radius: 4')
Пример #11
0
def test_area():
    c1 = circle(1)
    assert (c1.area == math.pi)
Пример #12
0
def test_setdiameter():
    c1 = circle(2)
    c1.diameter = 2
    assert (c1.radius == 1)
    assert (c1.diameter == 2)
Пример #13
0
def test_diameter():
    c1 = circle(1)
    c1.diameter = 4
    assert (c1.radius == 2)
    assert (c1.diameter == 4)