Ejemplo n.º 1
1
def main():
    points = [Point(x=230, y=450), Point(x=240, y=460), Point(x=230, y=470), Point(x=240, y=480)]
    polygon(point_list=points)
    points2 = [Point(p.x + 20, p.y + 20) for p in points]
    lines(point_list=points2, color=COLOR_DARK_ORANGE)
    line(start_point=Point(x=20, y=20), end_point=Point(x=40, y=300))
    square(left_bottom=Point(400, 300, ), side=100)
    rectangle(
        left_bottom=Point(x=200, y=200),
        right_top=Point(x=300, y=300),
        color=COLOR_DARK_GREEN
    )
    rectangle(
        left_bottom=Point(x=400, y=300),
        right_top=Point(x=300, y=400),
        color=COLOR_DARK_GREEN
    )
    sleep(2)
    clear_screen()
    vector(start=Point(x=230, y=260), angle=70, length=200, color=COLOR_PURPLE)
    for i in range(10):
        point = random_point()
        color = random_color()
        radius = random_number(20, 60)
        circle(center_position=point, radius=radius, color=color, width=0)
    sleep(2)
    clear_screen()
    for i in range(10):
        point = random_point()
        color = random_color()
        dx = random_number(30, 100)
        dy = random_number(30, 100)
        right_top = Point(x=point.x + dx, y=point.y + dy)
        ellipse(left_bottom=point, right_top=right_top, color=color)
    v3 = Vector(start_point=Point(0, 0), direction=45, length=50)
    for direction in range(0, 181, 20):
        v = Vector(start_point=Point(x=300, y=300), direction=direction, length=100)
        v.draw()
        v2 = Vector(start_point=v.end_point, direction=direction + 30, length=50)
        v2.draw(color=COLOR_GREEN)
        v2.add(v3)
        v2.draw(color=COLOR_ORANGE)
    snowflake(center=Point(), length=60, factor_b=0.2, factor_c=100)
    sleep(2)
    for k in range(2):
        y = 500
        for i in range(10):
            clear_screen()
            y -= 30
            for x in [100, 200, 300, 400, 500]:
                radius = random_number(30, 50)
                point = Point(x=x, y=y)
                snowflake(center=point, length=radius)
                mouse_point, mouse_buttons = get_mouse_state()
                print("mouse_state is {} + {}".format(mouse_point, mouse_buttons))
            if user_want_exit(sleep_time=0.1):
                break
        if user_want_exit(0):
            break
Ejemplo n.º 2
0
def draw_bubble(center,
                inner_radius=60,
                step=5,
                color=(255, 255, 0),
                line_width=2):
    """Draws a bubble of three circles.

    Parameters
    ----------
    center : simple_draw Point
        Center of bubble

    inner_radius : int, default=60
        Radius of inner circle

    step : int, default=5
        Step of increasing the radius of the circles

    color : tuple(int, int, int), default=(255, 255, 0)
        Color of circles. Accepts tuple(red, green, blue),
        where color value between 0 and 255, including both of them

    line_width : int, default=2
        Circle line width

    """
    # Вроде бы оверкилл, но я должен был попробовать запилить такой докстринг
    for _ in range(3):
        sd.circle(center, inner_radius, color, line_width)
        inner_radius += step
Ejemplo n.º 3
0
def arm(color1, color2, color3, angle1, angle2):
    try:
        # для костей характеристики
        start_bp_point = sd.get_point(200, 400)  # parent_bone
        bone_length = 300
        bone_width = 30
        angle1_rad = math.radians(angle1)
        start_cb_point = sd.get_point(start_bp_point.x + bone_length * math.cos(angle1_rad),
                                      start_bp_point.y + bone_length * math.sin(angle1_rad))  # child-bone
        # для рукава(мышц)
        sleeve_width = 80
        sleeve(start_point=start_bp_point, angle=angle1, angle2=angle2, length=bone_length, width=sleeve_width,
               color1=color3, color2=color2)
        bone(start_point=start_bp_point, angle=angle1, length=bone_length, width=bone_width, color1=color1,
             color2=color2)
        bone(start_point=start_cb_point, angle=angle2, length=bone_length, width=bone_width, color1=color1,
             color2=color2)
        # сустав
        joint_center = sd.get_point(
            start_bp_point.x + bone_length * math.cos(angle1_rad),
            start_bp_point.y + bone_length * math.sin(angle1_rad))
        sd.circle(center_position=joint_center, radius=bone_width / 2 + 10, color=color1, width=0)
        sd.circle(center_position=joint_center, radius=bone_width / 2 + 10, color=color2, width=2)

    except ZeroDivisionError:
        pass
Ejemplo n.º 4
0
def smile(x, y, color):
    radius = 30
    _point = sd.get_point(x=x, y=y)
    sd.circle(center_position=_point,
              radius=radius,
              width=3,
              color=sd.COLOR_BLACK)
    sd.circle(center_position=_point, radius=radius - 2, width=0, color=color)
    left_point = sd.get_point(x=x - radius // 3, y=y + radius // 3)
    right_point = sd.get_point(x=x - radius // 5, y=y + 2 * radius // 3)
    sd.ellipse(left_bottom=left_point,
               right_top=right_point,
               color=sd.COLOR_BLACK)
    left_point = sd.get_point(x=x + radius // 5, y=y + radius // 3)
    right_point = sd.get_point(x=x + radius // 3, y=y + 2 * radius // 3)
    sd.ellipse(left_bottom=left_point,
               right_top=right_point,
               color=sd.COLOR_BLACK)
    mouth = [
        sd.Point(x=x - radius // 2, y=y - radius // 3),
        sd.Point(x=x - radius // 4, y=y - radius // 2),
        sd.Point(x=x + radius // 4, y=y - radius // 2),
        sd.Point(x=x + radius // 2, y=y - radius // 3),
    ]
    sd.lines(point_list=mouth, width=3, color=sd.COLOR_BLACK)
Ejemplo n.º 5
0
def draw_sun(x, y, length):
    global angle
    radius = length // 2
    sd.start_drawing()
    sd.vector(sd.get_point(x, y),
              angle=angle,
              length=length,
              color=sd.background_color,
              width=3)
    angle += 30
    sd.vector(sd.get_point(x, y),
              angle=angle,
              length=length,
              color=(255, 255, 0),
              width=3)
    sd.vector(sd.get_point(x, y),
              angle=angle + 30,
              length=length,
              color=(255, 255, 0),
              width=3)
    sd.vector(sd.get_point(x, y),
              angle=angle + 60,
              length=length,
              color=(255, 255, 0),
              width=3)
    sd.finish_drawing()
    sd.circle(sd.get_point(x, y), radius=radius, width=0)
    sd.sleep(0.01)
Ejemplo n.º 6
0
def draw_rainbow(x, y, radius, color_offset):
    #  используйте срезы, чтобы склеить 2 половины rainbow_colors.
    #  [1,2,3, (режем) 4,5,6]     - режем в нужном месте
    #  [4,5,6, (клеем) 1,2,3]     - склеиваем половины поменяв местами.
    #   Ответ: не понимаю. Зачем это?
    #   Была так сказать ошибочка в основном теле программы. В offset писалась инкрементированная переменная,
    #   сейчас поставил просто контанту 1, и теперь в каждом цикле рисуется сдвинутая на 1 радуга. Вроде согласно ТЗ.

    #  Ответ.
    #  Возможно 2 варианта.
    #  1. color_offset есть, и он показывает насколько сдвинуть цвета в радуге. Извне можно контролировать какой сейчас
    #     цвет будет первым;
    #       for color in rainbow_colors[color_offset:] + rainbow_colors[:color_offset].
    #  2. color_offset отсутствует. Ф-ция изменяет порядок в rainbow_colors при каждом запуске, сдвигая на 1 цвет.
    #     Указать с какого цвета начинать снаружи нельзя. Цикл в этом случае не нужен т.к. итерация только 1.
    #       rainbow_colors.append(rainbow_colors[0])
    #       rainbow_colors.pop(0)
    #  .
    #  Преимущество первого метода: он не имеет состояния. Поэтому мы можем вызвать 2 (или 100500) радуг одновременно.
    #  Преимущество второго - не нужно следить за счетчиком, вызываем и каждый раз получаем следующий набор цветов.
    #  ОТВЕТ: Недоастаток первого метода также в том, что нужно отдельно контролировать offset, так как если
    #  поставить обычный инкремент, то радуга пройдет только 1 цикл (как сейчас). С другой стороны тогда у нас
    #  переменная не будет
    #  улетать в большие значения. Это вообще критично?

    #  Да, эта проблема по хорошему будет сопутствовать все функции, которые занимаются анимацией.
    #  Подробнее написал в 04_painting.py.

    # for _ in range(color_offset):
    #     rainbow_colors.append(rainbow_colors[0])
    #     rainbow_colors.pop(0)

    for color in rainbow_colors[color_offset:] + rainbow_colors[:color_offset]:
        radius += 4
        sd.circle(sd.get_point(x, y), radius, color, 4)
Ejemplo n.º 7
0
def draw_smile(x, y, color):
    point_left = sd.get_point(x - 120, y - 100)
    point_right = sd.get_point(x, y)
    sd.ellipse(point_left, point_right, color)
    circle_point = sd.get_point(x - 35, y - 35)
    sd.circle(circle_point, 8, sd.invert_color(color))
    circle_point = sd.get_point(x - 85, y - 35)
    sd.circle(circle_point, 8, sd.invert_color(color))

    points = [
        sd.get_point(x - 85, y - 65),
        sd.get_point(x - 80, y - 70),
        sd.get_point(x - 75, y - 72),
        sd.get_point(x - 65, y - 74),
        sd.get_point(x - 61, y - 74),
        sd.get_point(x - 57, y - 74),
        sd.get_point(x - 47, y - 72),
        sd.get_point(x - 42, y - 70),
        sd.get_point(x - 37, y - 65),
        sd.get_point(x - 42, y - 75),
        sd.get_point(x - 47, y - 79),
        sd.get_point(x - 50, y - 81),
        sd.get_point(x - 57, y - 82),
        sd.get_point(x - 61, y - 82),
        sd.get_point(x - 65, y - 82),
        sd.get_point(x - 72, y - 80),
        sd.get_point(x - 75, y - 78),
        sd.get_point(x - 80, y - 75),
        sd.get_point(x - 85, y - 65),
    ]

    sd.lines(points, sd.invert_color(color))
def draw_cloud(x, y, radii=[15, 10, 8], factor_a=5, factor_b=5, factor_c=5, factor_d=5, color_bytes=[127, 192, 255]):
    """Функция рисует облако в районе точки x, y с радиусами элементов radii
            серым цветом с яркостями color_bytes (255 - белый, 0 - чёрный)

    Parameters
    ----------
    x, y: int
        точка рисования облака
    radii: list[int, int, int ], default=[15, 10, 8]
        радиусы кругов облака
    factor_a: int, default=5
        смещение первого круга по горизонтали
    factor_b: int, default=5
        смещение второго круга по горизонтали
    factor_c: int, default=5
        смещение третьего круга по горизонтали
    factor_d: int, default=5
        расстояние между кругами по вертикали
    color_bytes: list[int, int, int ], default=[127, 192, 255]
        яркости первого, второго и третьего кругов соответственно

    """
    circle_y = y
    for radius, factor, color_byte in zip(radii, [factor_a, factor_b, factor_c], color_bytes):
        origin = sd.get_point(x + factor, circle_y)
        sd.circle(
            center_position=origin,
            radius=radius,
            color=(color_byte, color_byte, color_byte),
            width=0
        )
        circle_y += factor_d
Ejemplo n.º 9
0
def paint_smile(x, y, radius_for_two_eye, color=sd.COLOR_YELLOW):
    central_point_head = sd.get_point(x, y)
    central_point_eye_1 = sd.get_point(x - 20, y + 25)
    central_point_eye_2 = sd.get_point(x + 20, y + 25)
    point_smile_1 = sd.get_point(x - 40, y - 20)
    point_smile_2 = sd.get_point(x - 35, y - 25)
    point_smile_3 = sd.get_point(x + 35, y - 25)
    point_smile_4 = sd.get_point(x + 40, y - 20)

    sd.lines((point_smile_1, point_smile_2, point_smile_3, point_smile_4),
             color, False, 4)
    sd.circle(central_point_head, 60, color, 4)

    sd.circle(center_position=central_point_eye_1,
              radius=12,
              color=sd.COLOR_BLUE,
              width=0)
    sd.circle(center_position=central_point_eye_2,
              radius=12,
              color=sd.COLOR_BLUE,
              width=0)

    radius_for_two_eye %= 12

    sd.circle(center_position=central_point_eye_1,
              radius=radius_for_two_eye,
              color=color,
              width=0)
    sd.circle(center_position=central_point_eye_2,
              radius=radius_for_two_eye,
              color=color,
              width=0)
Ejemplo n.º 10
0
def smile(x, y, color):
    glass = 0
    slope = 0
    empty = 0
    negation = 0
    sd.circle(center_position=sd.get_point(x - negation, y),
              radius=100,
              color=color,
              width=4)
    negation = 40
    for i in range(2):
        sd.circle(center_position=sd.get_point(x + glass - negation, y),
                  radius=15,
                  color=sd.COLOR_YELLOW,
                  width=0)
        glass += 90
        negation = 50
    for z in range(2):
        sd.line(start_point=sd.get_point(x + empty - negation,
                                         y + slope - negation),
                end_point=sd.get_point(x - negation, y - negation),
                color=sd.COLOR_RED,
                width=4)
        # slope += 0
        empty += 100
        negation = 50
Ejemplo n.º 11
0
def draw_smile(x, y, color):
    sd.ellipse(sd.get_point(y - 50, x - 50), sd.get_point(y + 50, x + 20), color, 2)
    sd.line(sd.get_point(y - 10, x - 30), sd.get_point(y + 10, x - 30), color, 2)
    sd.line(sd.get_point(y - 10, x - 30), sd.get_point(y - 20, x - 20), color, 2)
    sd.line(sd.get_point(y + 20, x - 20), sd.get_point(y + 10, x - 30), color, 2)
    sd.circle(sd.get_point(y + 15, x), 7, color, 1)
    sd.circle(sd.get_point(y - 15, x), 7, color, 1)
Ejemplo n.º 12
0
def my_bubble(my_point, step=5, radius=50, my_color=sd.COLOR_DARK_YELLOW):
    for _ in range(3):
        sd.circle(center_position=my_point,
                  radius=radius,
                  width=1,
                  color=my_color)
        radius += step
Ejemplo n.º 13
0
def draw_bubbles(center, rad, step, clr, width):

    for ii in range(1, 4):
        sd.circle(center_position=center,
                  radius=rad + ii * step,
                  color=clr,
                  width=width)
Ejemplo n.º 14
0
def hot_sun(angle):
    point_2 = sd.get_point(100, 500)
    sd.circle(center_position=point_2, radius=30, width=29)
    for _ in range(15):
        v = sd.get_vector(start_point=point_2, angle=angle, length=50, width=1)
        v.draw()
        angle += 30
Ejemplo n.º 15
0
def bubble(point, step, color, width):
    radius = 50
    for _ in range(3):
        radius += step
        sd.circle(center_position=point,
                  radius=radius,
                  color=color,
                  width=width)
Ejemplo n.º 16
0
def draw_bubble(bub_center, bub_radius=20, bub_color=sd.COLOR_YELLOW):
    ''' draws the bubble '''
    for _ in range(2):
        sd.circle(center_position=bub_center,
                  radius=bub_radius,
                  width=2,
                  color=bub_color)
        bub_radius *= 0.85
Ejemplo n.º 17
0
def rainbow(radius):
    for i, rainbow_color in enumerate(rainbow_colors):
        radius += 15
        start = sd.get_point(x1, y1)
        sd.circle(center_position=start,
                  radius=radius,
                  color=rainbow_color,
                  width=15)
Ejemplo n.º 18
0
def buble(point, step, color):
    radius = 50
    for _ in range(3):
        radius += step
        sd.circle(center_position=point,
                  radius=radius,
                  width=3,
                  color=sd.random_color())
Ejemplo n.º 19
0
def apples(color):
    for x in range(850, 1250, 100):
        point = sd.get_point(x=x, y=350)
        sd.circle(center_position=point, radius=15, color=sd.COLOR_GREEN, width=0)
        sd.sleep(0.05)
        sd.circle(center_position=point, radius=15, color=color, width=0)

    sd.finish_drawing()
Ejemplo n.º 20
0
def rainbow(tochka, radius):
    rainbow_colors = (sd.COLOR_RED, sd.COLOR_ORANGE, sd.COLOR_YELLOW,
                      sd.COLOR_GREEN, sd.COLOR_CYAN, sd.COLOR_BLUE,
                      sd.COLOR_PURPLE)
    for color in rainbow_colors:
        point = sd.get_point(*tochka)
        sd.circle(point, radius=radius, color=color, width=5)
        radius += 5
Ejemplo n.º 21
0
def draw_rainbow(center_rainbow=sd.get_point(500, -50), radius=500, width=20):
    step = 0
    for color in rainbow_colors:
        step += 20
        sd.circle(center_position=center_rainbow,
                  radius=radius + step,
                  width=width,
                  color=color)
Ejemplo n.º 22
0
def bubble(point, step):
    radius = 50
    for _ in range(3):
        radius += step
        sd.circle(center_position=point,
                  radius=radius,
                  width=2,
                  color=(127, 0, 0))
Ejemplo n.º 23
0
def bubble(_point, _step, _width, _color):
    _radius = 50
    for _ in range(3):
        _radius += _step
        sd.circle(center_position=_point,
                  radius=_radius,
                  width=_width,
                  color=_color)
Ejemplo n.º 24
0
def random_color_bubbles(point_3, step_3, random_colors):
    radius_3 = 27
    for _ in range(3):
        radius_3 += step_3
        sd.circle(center_position=point_3,
                  color=random_colors,
                  radius=radius_3,
                  width=3)
Ejemplo n.º 25
0
def bubble(point, step, random_color=False):
    radius = 50
    for _ in range(3):
        radius += step
        if random_color:
            sd.circle(center_position=point, radius=radius, color=sd.random_color())
        else:
            sd.circle(center_position=point, radius=radius, color=sd.COLOR_YELLOW)
Ejemplo n.º 26
0
def smile(coordinate_x, coordinate_y, color):
    sd.circle(center_position=point, radius=radius, color=color, width=2)
    sd.ellipse(left_bottom=coordinate_x,
               right_top=coordinate_y,
               color=color,
               width=0)
    sd.ellipse(left_bottom=x, right_top=y, color=color, width=0)
    sd.line(start_point=q, end_point=w, color=color, width=1)
Ejemplo n.º 27
0
def rainbow(size=1):
    rainbow_colors = (sd.COLOR_RED, sd.COLOR_ORANGE, sd.COLOR_YELLOW, sd.COLOR_GREEN,
                      sd.COLOR_CYAN, sd.COLOR_BLUE, sd.COLOR_PURPLE)
    step = 900 * size
    center_position = sd.get_point(400 * size, -100 * size,)
    for rainbow_color in rainbow_colors:
        sd.circle(center_position=center_position, radius=step, color=rainbow_color, width=20)
        step += 20 * size
Ejemplo n.º 28
0
def bubble(point, step):
    radius = 500
    rainbow_colors = (sd.COLOR_RED, sd.COLOR_ORANGE, sd.COLOR_YELLOW,
                      sd.COLOR_GREEN, sd.COLOR_CYAN, sd.COLOR_BLUE,
                      sd.COLOR_PURPLE)
    for color in rainbow_colors:
        radius += step
        sd.circle(center_position=point, radius=radius, color=color, width=5)
Ejemplo n.º 29
0
def bubble(point, step):
    radius = 50
    color_key = random.randint(0, 4)
    for _ in range(3):
        radius += step
        sd.circle(center_position=point,
                  radius=radius,
                  width=2,
                  color=color[color_key])
Ejemplo n.º 30
0
def rainbow(rainbow_colors):
    i = 0
    step = 5
    width = 4
    for colors in rainbow_colors:
        point = sd.get_point(430, -100)
        radius = 1000 - i * step
        sd.circle(center_position=point, radius=radius, width=width, color=colors)
        i += 1
Ejemplo n.º 31
0
def rainbow():
    start_point_x = 300
    start_point_y = 0
    radius = 790
    step = 20
    for color in rainbow_colors:
        center_position = sd.get_point(start_point_x, start_point_y)
        sd.circle(center_position, radius, color, width=step - 1)
        radius += step
Ejemplo n.º 32
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# нарисовать пузырёк

from simple_draw import circle, COLOR_ORANGE, end, Point

point = Point(300, 300,)

circle(point, radius=60, color=COLOR_ORANGE)

# нарисовать 10 пузырьков в линию с позиции х=100 до х=500

# нарисовать 100 пузырьков в произвольных местах экрана

# + с разными радиусами

# + разным цветом

end()