Пример #1
0
def cloud(x, y, r, n):  # n - parameter that sets the size
    penColor(0, 0, 0)  # of the cloud x, y - coordinates
    brushColor(255, 255, 255)  # of the upper left corner of a rectangle
    circle(x + 10 * n, y + 20 * n, r * n)  # with the (50*n; 30*n)
    circle(x + 20 * n, y + 20 * n, r * n)  # dimensios described
    circle(x + 30 * n, y + 20 * n, r * n)  # around the cloud
    circle(x + 40 * n, y + 20 * n, r * n)
    circle(x + 18 * n, y + 10 * n, r * n)
    circle(x + 32 * n, y + 10 * n, r * n)
Пример #2
0
def sun(x, y, r):
    """
        Рисует Солнце.
        (x, y) -- координаты центра окружности Солнца;
        r -- радиус Солнца.
    """
    graph.brushColor("yellow")
    graph.penSize(0)
    graph.circle(x, y, r)
Пример #3
0
def ufo_ship(x, y, size):
    # main body
    brushColor(168, 168, 168)
    penColor(168, 168, 168)
    ellips(x, y, 20 * size, 5 * size, 0)
    # glass
    brushColor(180, 220, 220)
    penColor(180, 220, 220)
    ellips(x, y - 3 * size, 12 * size, 4 * size, 0)
Пример #4
0
def left_arm(length, angle, x_coord):
    brushColor(233, 200, 176)
    penColor(200, 200, 200)
    polygon([(x_coord - 233, 569), (x_coord - 193, 549),
             (x_coord - 193 - length * cos(angle), 549 + length * sin(angle)),
             (x_coord - 233 - length * cos(angle), 569 + length * sin(angle))])
    penColor('white')
    circle(
        (2 * x_coord - length * cos(angle) - 233 - length * cos(angle) - 193) /
        2, (549 + length * sin(angle) + 569 + length * sin(angle)) / 2, 40)
Пример #5
0
def clouds(x1, y1, radius):
    graph.penColor("black")
    graph.brushColor("white")
    graph.circle(x1 + 2 * radius, y1, radius)
    graph.circle(x1 - 2 * radius, y1, radius)
    graph.circle(x1 - radius, y1 - radius, radius)
    graph.circle(x1 + radius, y1 + radius, radius)
    graph.circle(x1 - radius, y1 + radius, radius)
    graph.circle(x1 + radius, y1 - radius, radius)
    graph.circle(x1, y1, radius)
Пример #6
0
def clouds(x, y, s):
    # s - size's cloud
    b_c = 21 * s  # between_clouds
    r_c = 30 * s  # radius of cloud
    graph.brushColor('#ffffff')
    graph.circle(x, y, r_c)
    graph.circle(x + b_c, y + b_c, r_c)
    graph.circle(x + 2 * b_c, y, r_c)
    graph.circle(x + 3 * b_c, y + b_c, r_c)
    graph.circle(x + 4 * b_c, y, r_c)
Пример #7
0
def cloud(x, y, size, color):
    """
    just 3 elipses along each other
    """
    colinc = 10
    brushColor(color + colinc, color + colinc, color + colinc)
    penColor(color + colinc, color + colinc, color + colinc)
    ellips(x - 1.2 * size, y, size, size, 0)
    ellips(x, y, size, size, 0)
    ellips(x + 1.2 * size, y, size, size, 0)
Пример #8
0
def right_arm(length, angle, x_coord):
    brushColor(233, 200, 176)
    penColor(200, 200, 200)
    polygon([(x_coord + 167, 549), (x_coord + 207, 569),
             (x_coord + 207 + length * cos(angle), 569 - length * sin(angle)),
             (x_coord + 167 + length * cos(angle), 549 - length * sin(angle))])
    penColor('white')
    circle(
        (2 * x_coord + length * cos(angle) + 207 + length * cos(angle) + 167) /
        2, (569 - length * sin(angle) + 549 - length * sin(angle)) / 2, 40)
Пример #9
0
def ufo_light(x, y, size):
    # light - light pillar of an ufo
    penSize(0)
    brushColor(210, 250, 210)
    penColor(210, 250, 210)
    light = []
    light.append((x, y))
    light.append((x - 20 * size, y + 20 * size))
    light.append((x + 20 * size, y + 20 * size))
    polygon(light)
def fish():
    """The Fish"""
    penSize(1)
    penColor('black')
    brushColor('#9c292d')
    fish_objs = [
        polygon([(60, 85), (110, 93), (110, 107), (60, 115),
                 (80, 100)]),  # Tail
        polygon([(140, 100), (135, 70), (162, 74), (188, 68), (205, 76),
                 (200, 100)]),  # Upper fin
        polygon([(134, 110), (150, 110), (152, 130),
                 (130, 127)]),  # Lower hind fin
        polygon([(185, 110), (197, 110), (200, 128), (187, 131)])
    ]  # Lower front fin
    brushColor('#9fbde6')
    penColor(brushColor())
    fish_objs.extend([
        polygon([(195, 85), (190, 115), (235, 100)]),  # Head
        ellipse_sr(120, 80, 210, 120, 1, False),  # Body
        polygon([(95, 91), (95, 109), (130, 113), (130, 87)])
    ])  # Ass
    brushColor('green')
    fish_objs.append(circle(206, 96, 5))  # Eyeball
    brushColor('black')
    penColor('black')
    fish_objs.append(circle(207, 95, 2))  # Eye pupil
    return fish_objs
Пример #11
0
def waves(y):
    # Enter y coordinate of border between sea and sand.
    penSize(0)
    r = 40
    n = 15
    for i in range(n):
        x = i * r * 2 * sqrt(3)
        brushColor(0, 0, 205)
        circle(x - r * sqrt(3) / 2, y - r / 2, r)
        brushColor(255, 229, 124)
        circle(x + r * sqrt(3) / 2, y + r / 2, r)
Пример #12
0
def tree(x, y, r, n):  # x, y - coordinates of the upper left corner
    penColor(0, 0, 0)  # of a rectangle with the (70*n; 100*n)
    brushColor(0, 0, 0)  # dimensios described around the cloud
    rectangle(x + 30 * n, y + 50 * n, x + 40 * n, y + 100 * n)
    brushColor(0, 90, 0)  # n - parameter that sets the size of the tree
    circle(x + 35 * n, y + 15 * n, r * n)
    circle(x + 15 * n, y + 25 * n, r * n)  # r - radius
    circle(x + 55 * n, y + 25 * n, r * n)
    circle(x + 35 * n, y + 35 * n, r * n)
    circle(x + 20 * n, y + 50 * n, r * n)
    circle(x + 50 * n, y + 50 * n, r * n)
Пример #13
0
def sail(x, y, deck_lenght, carcass_height):
    """
           Рисует двойной парус.
           (x, y) -- координаты правой верхней точки прямоугольника-палубы.
           deck_lenght, carcass_height -- длина прямоугольника-палубы и высота корпуса.
       """
    graph.brushColor('white')
    graph.polygon([(x + 0.03*deck_lenght + deck_lenght/3, y), (x + 0.8*deck_lenght, y - 2.5*carcass_height/2),
                   (x + 0.12*deck_lenght + deck_lenght/3, y - 2.5*carcass_height/2), (x + 0.03*deck_lenght + deck_lenght/3, y)])
    graph.polygon([(x + 0.03*deck_lenght + deck_lenght / 3, y - 2.5*carcass_height), (x + 0.8 * deck_lenght, y - 2.5 * carcass_height / 2),
                   (x + 0.12*deck_lenght + deck_lenght / 3, y - 2.5 * carcass_height / 2), (x + 5 + deck_lenght / 3, y - 2.5*carcass_height)])
Пример #14
0
def eyes(x, y, size, mirror):
    """
    draws two black circles and two ellipses inside them, the coord of middle point is (x,y), can be mirrored
    """
    penSize(1)
    brushColor('black')
    circle(x + 1 * size, y - 2.8 * size, size // 2)
    circle(x - 1 * size, y - 2.8 * size, size // 2)
    brushColor('white')
    ellips(x + 1.2 * size * mirror, y - 2.9 * size, size // 6, size // 4, 0)
    ellips(x - 0.8 * size * mirror, y - 2.9 * size, size // 6, size // 4, 0)
Пример #15
0
def main_body(color, x_coord):
    penColor(color)
    brushColor(color)
    circle(x_coord, 769, 300)
    penColor('black')
    brushColor(color)
    # shoulders
    polygon([(x_coord - 163, 629), (x_coord - 243, 629), (x_coord - 253, 539),
             (x_coord - 183, 489), (x_coord - 143, 549)])
    polygon([(x_coord + 237, 629), (x_coord + 157, 629), (x_coord + 147, 539),
             (x_coord + 217, 489), (x_coord + 257, 549)])
Пример #16
0
def updatePolygons():
    global polygons_screen, polygonTypeV, polygons
    for polygon in polygons_screen:
        gr.deleteObject(polygon)

    for i in polygons:
        gr.brushColor(i['color'][0], i['color'][1], i['color'][2])
        gr.penColor(i['color'][0], i['color'][1], i['color'][2])
        if polygonTypeV == 'full':
            polygons_screen.append(gr.polygon(i['points']))
        else:
            polygons_screen.append(gr.polyline(i['points']))
Пример #17
0
def ghost(x, y, r, g, b):
    brushColor(r, g, b)
    a = polygon([(350 + x, 400 + y), (355 + x, 410 + y), (360 + x, 405 + y),
                 (365 + x, 410 + y), (370 + x, 407 + y), (375 + x, 403 + y),
                 (380 + x, 400 + y), (385 + x, 403 + y), (390 + x, 400 + y),
                 (395 + x, 407 + y), (400 + x, 405 + y), (405 + x, 407 + y),
                 (400 + x, 420 + y), (395 + x, 390 + y), (393 + x, 393 + y),
                 (390 + x, 390 + y), (385 + x, 387 + y), (380 + x, 385 + y),
                 (376 + x, 380 + y), (373 + x, 376 + y), (370 + x, 360 + y),
                 (368 + x, 345 + y), (365 + x, 343 + y), (360 + x, 340 + y),
                 (357 + x, 343 + y), (351 + x, 357 + y), (350 + x, 400 + y)])
    return a
Пример #18
0
def update():
    for object_ in objects_of_ship_2:
        g.moveObjectBy(object_, dx, 0)

    g.penColor('white')
    g.brushColor('white')
    g.rectangle(0, 0, frame_thickness, window_height)
    g.rectangle(window_width - frame_thickness, 0, window_width, window_height)

    if g.xCoord(stern_of_ship) > window_width:
        for object_ in objects_of_ship_2:
            g.moveObjectBy(object_, -window_width - ship_length, 0)
Пример #19
0
def update_mouth():
    step = g.xCoord(mouth_help)
    global m
    m = 1 / (step + 2)
    g.brushColor('red')
    g.polygon([(600 / z, 500 / z + 150 / z),
               (600 / z + 150 * m / z, 500 / z + 60 / z),
               (600 / z - 150 * m / z, 500 / z + 60 / z),
               (600 / z, 500 / z + 150 / z)])
    step += 1
    if step >= 7:
        g.moveObjectBy(mouth_help, -7, 0)
Пример #20
0
def horns(x, y, size, color="red"):
    """
    note: it is possible to change the cf alien's ball (horn balls)
    """
    penSize(0.5 * size)
    line(x + 1.6 * size, y - 3 * size, x + 2.2 * size, y - 4 * size)
    line(x - 1.6 * size, y - 3 * size, x - 2.2 * size, y - 4 * size)

    brushColor(color)
    penSize(0.15 * size)
    circle(x + 2.3 * size, y - 4.1 * size, 0.3 * size)
    circle(x - 2.3 * size, y - 4.1 * size, 0.3 * size)
Пример #21
0
def tree(bottom_tree_x, bottom_tree_y, barrel_length):
    """
    bottom_tree_x and bottom_tree_y -- центральные координаты низа дерева.
    barrel_length -- высота дерева

    barrel_lengt/8 -- ширина этого дерева
    У всех шариков радиусы barrel_length/4

    Центры двух нижних шариков находятся на той же выстое,
    что и макушка дерева,
    и они на расстоянии barrel_length/4 от центральной оси симметрии.
    Их координаты:
    левая: (bottom_tree_x - barrel_length/4, bottom_tree_y - barrel_length)
    правая -- (bottom_tree_x + barrel_length/4, bottom_tree_y - barrel_length)

    Третий шарик считая снизу выше макушки дерева на barrel_length/5
    Он находится по центру
    координата x -- bottom_tree_x
    координата y -- bottom_tree_y - 6/5 * barrel_length)

    Четвёртый и пятый шарик считая снизу выше маушки дерева на barrel_length/3,
    и они на расстоянии barrel_length/3 от центральной оси симметрии
    левый шарик:
    координата x -- bottom_tree_x - barrel_length/3
    кооридината y -- bottom_tree_y - 4/3 * barrel_length)
    правый шарик:
    координата x -- bottom_tree_x + barrel_length/3,
    координата y -- bottom_tree_y - 4/3 * barrel_length)

    Наивысшый шарик выше макушки дерева на 4/7*barrel_length,
    и он расположен по центру
    координата x  -- bottom_tree_x
    координата y -- bottom_tree_y - 27 / 17 * barrel_length), barrel_length/4)

    """
    # barrel
    graph.penColor("black")
    graph.brushColor("black")
    graph.rectangle(bottom_tree_x - barrel_length / 16,
                    bottom_tree_y,
                    bottom_tree_x + barrel_length / 16,
                    bottom_tree_y - barrel_length)
    # leaves
    graph.penSize(1)
    graph.penColor("black")
    graph.brushColor("green")
    graph.circle(bottom_tree_x, bottom_tree_y - 27 / 17 * barrel_length, barrel_length / 4)
    graph.circle(bottom_tree_x - barrel_length/3, bottom_tree_y - (barrel_length + barrel_length/3), barrel_length/4)
    graph.circle(bottom_tree_x + barrel_length/3, bottom_tree_y - (barrel_length + barrel_length/3), barrel_length/4)
    graph.circle(bottom_tree_x, bottom_tree_y - (barrel_length + barrel_length/5), barrel_length/4)
    graph.circle(bottom_tree_x - barrel_length/4, bottom_tree_y - barrel_length, barrel_length/4)
    graph.circle(bottom_tree_x + barrel_length/4, bottom_tree_y - barrel_length, barrel_length/4)
Пример #22
0
def sun(x_center, y_center, radius, wave_height, definition, N):
    brushColor("yellow")  # N - number of rays
    penColor(255, 100, 10)
    verts = []
    t = 0
    while t < (10 * N * definition + 1):
        z_1 = (pi / (N * definition)) * t
        z_2 = (pi / definition) * t
        x = x_center + radius * (1 + wave_height * sin(z_2)) * cos(z_1)
        y = y_center + radius * (1 + wave_height * sin(z_2)) * sin(z_1)
        verts.append((x, y))
        t += 1
    polygon(verts)
Пример #23
0
def sun(x, y, r, ray):
    # Enter x, y - center coordinates, r - rad, ray - ray length + rad.
    brushColor('yellow')
    penColor('yellow')
    penSize(0)
    v = 40
    # v is the number of rays.
    for i in range(v):
        phi1 = 2 * i * pi / v
        phi2 = 2 * (i + 1) * pi / v
        polygon([(x, y), (x + r * cos(phi1), y + r * sin(phi1)),
                 (x + ray * cos(phi1 + pi / v), y + ray * sin(phi1 + pi / v)),
                 (x + r * cos(phi2), y + r * sin(phi2))])
Пример #24
0
def mtn_line3():
    penColor(51, 0, 51)
    brushColor(51, 0, 51)
    polygon([(1000, 500), (0, 500), (0, 240), (100, 265), (200, 365),
             (xf5[0], yf5[0]), (xf5[1], yf5[1]), (xf5[2], yf5[2]),
             (xf5[3], yf5[3]), (xf5[4], yf5[4]), (xf5[5], yf5[5]),
             (xf5[6], yf5[6]), (xf5[7], yf5[7]), (xf5[8], yf5[8]),
             (xf5[9], yf5[9]), (650, 435), (675, 450), (xf6[0], yf6[0]),
             (xf6[1], yf6[1]), (xf6[2], yf6[2]), (xf6[3], yf6[3]),
             (xf6[4], yf6[4]), (xf6[5], yf6[5]), (xf6[6], yf6[6]),
             (xf6[7], yf6[7]), (xf6[8], yf6[8]), (xf6[9], yf6[9]),
             (xf6[10], yf6[10]), (xf6[11], yf6[11]), (xf6[12], yf6[12]),
             (xf6[13], yf6[13])])
Пример #25
0
def the_wallpaper(r0, g0, b0):
    # making an array of RGB per square 2x2
    # the RGB is the mean of upper-left and upper-right neighbor +- random
    # to make horizontal clusters that look like waves
    # instead of diagonally clusters when going by lines

    rgb_array = [[0] * 500 for k in range(500)]

    for diagonal_number in range(1000):

        if diagonal_number > 499:
            number_of_lines_in_the_diagonal = 499 - (diagonal_number - 499)
        else:
            number_of_lines_in_the_diagonal = diagonal_number

        for almost_y in range(number_of_lines_in_the_diagonal, -1, -1):

            if diagonal_number > 499:
                x = diagonal_number - 499 +\
                    number_of_lines_in_the_diagonal - almost_y
                y = (499 - number_of_lines_in_the_diagonal) + almost_y
            else:
                x = diagonal_number - almost_y
                y = almost_y

            # for the first column and line just making them standard
            if x == 0:
                R, G, B = r0, g0, b0

            elif y == 499 or y == 0:
                R, G, B = r0, g0, b0

            else:
                R = (rgb_array[x - 1][y - 1][0] +
                     rgb_array[x - 1][y + 1][0]) // 2
                G = (rgb_array[x - 1][y - 1][1] +
                     rgb_array[x - 1][y + 1][1]) // 2
                B = (rgb_array[x - 1][y - 1][2] +
                     rgb_array[x - 1][y + 1][2]) // 2

            R += randint(-10, 10)
            G += randint(-10, 10)
            B += randint(-10, 10)

            R, G, B = whether_matches_rgb(R, G, B, 10, 60)
            rgb_array[x][y] = [R, G, B]

            # drawing the square
            brushColor(R, G, B)
            penColor(R, G, B)
            rectangle(2 * x, 2 * y, 2 * x + 2, 2 * y + 2)
Пример #26
0
def mtn_line2():
    penColor(153, 0, 0)
    brushColor(153, 0, 0)
    polygon([(1000, 300), (0, 350), (0, 245), (5, 245), (25, 265),
             (xf3[0], yf3[0]), (xf3[1], yf3[1]), (xf3[2], yf3[2]),
             (xf3[3], yf3[3]), (xf3[4], yf3[4]), (xf3[5], yf3[5]),
             (xf3[6], yf3[6]), (xf3[7], yf3[7]), (xf3[8], yf3[8]),
             (xf3[9], yf3[9]), (xf3[10], yf3[10]), (175, 240), (235, 275),
             (255, 215), (320, 235), (385, 270), (520, 250), (xf4[0], yf4[0]),
             (xf4[1], yf4[1]), (xf4[2], yf4[2]), (xf4[3], yf4[3]),
             (xf4[4], yf4[4]), (xf4[5], yf4[5]), (xf4[6], yf4[6]),
             (xf4[7], yf4[7]), (xf4[8], yf4[8]), (xf4[9], yf4[9]),
             (xf4[10], yf4[10]), (xf4[11], yf4[11]), (750, 250), (800, 210),
             (835, 235), (860, 205), (930, 210), (1000, 160)])
Пример #27
0
def cloud(x, y, r):
    """
        Рисует облако с круглыми перьями.
        (x, y) -- координаты центра окружности левого верхнего пера облака;
        r -- радиус пера облака. 
    """
    graph.brushColor('white')
    graph.penSize(2)
    number_of_feather = 4
    number_of_row = 2
    for i in range(number_of_feather):
        for j in range(number_of_row):
            graph.circle(x - 25*j + 25*i, y + 25*j, r)
    graph.circle(x - 25*number_of_row + 25*(number_of_feather + 1), y + 25*(number_of_row - 1), r)
Пример #28
0
def backgroung(length_sky):
    """
    Эта функция берёт длинну неба
    и заполняет остальное пространство кроме неба травой.
    Также она отвечает за ширину и высоту экрана
    """
    main_screen_width = 1600
    main_screen_height = 1000
    graph.windowSize(main_screen_width, main_screen_height)
    graph.penSize(0)
    graph.brushColor("skyblue")
    graph.rectangle(0, 0, main_screen_width, length_sky)
    graph.brushColor("limegreen")
    graph.rectangle(0, length_sky, main_screen_width, main_screen_height)
Пример #29
0
def sheep(x, y, n):
    coordintes = []

    for i in range(20):
        coordintes.append([-i * mod / 20, 1 - (i / 20)**2])

    coordintes.append([3 * mod, 0])

    for i in range(20):
        coordintes.append([(3 - i / 20) * mod, (i / 20)**2])

    for i in range(len(coordintes)):
        coordintes[i] = [n * coordintes[i][0] + x, n * coordintes[i][1] + y]

    brushColor('red')
    penColor('black')
    rectangle(mod * n * (3 / 4) + x, y, mod * n + x, y - (2 / 2) * n)
    brushColor('light grey')
    rectangle(x, +n / 2 + y, x + n * mod, y - n * (1 / 2))
    polygon(coordintes)
    brushColor('grey')
    circle(x + mod * n / 4, y - 0.25 * n, n // 6)
    brushColor("light grey")
    penColor("light grey")
    circle(x + (n + n // 7) * mod, y - 1.5 * n, n // 8)
    circle(x + (n + n // 2) * mod, y - 2.0 * n, n // 7)
    circle(x + mod * 2.2 * n, y - 2.5 * n, n // 6)
Пример #30
0
def window(x1, y1, x2, y2):
    penColor(255, 255, 255)
    brushColor(255, 255, 255)
    rectangle(x1, y1, x2, y2)

    penColor(0, 231, 255)
    brushColor(141, 207, 255)
    rectangle(0.95 * x1 + 0.05 * x2, 0.95 * y1 + 0.05 * y2,
              0.55 * x1 + 0.45 * x2, 0.75 * y1 + 0.25 * y2)
    rectangle(0.45 * x1 + 0.55 * x2, 0.95 * y1 + 0.05 * y2,
              0.05 * x1 + 0.95 * x2, 0.75 * y1 + 0.25 * y2)
    rectangle(0.95 * x1 + 0.05 * x2, 0.67 * y1 + 0.33 * y2,
              0.55 * x1 + 0.45 * x2, 0.05 * y1 + 0.95 * y2)
    rectangle(0.45 * x1 + 0.55 * x2, 0.67 * y1 + 0.33 * y2,
              0.05 * x1 + 0.95 * x2, 0.05 * y1 + 0.95 * y2)