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_snowflake(color):
    for item in _coordinates:
        if color is None:
            _color = (sd.random_number(0, 255), sd.random_number(0, 255),
                      sd.random_number(0, 255))
        else:
            _color = color
        point = sd.get_point(x=item[0], y=item[1])
        sd.snowflake(center=point, color=_color, length=item[2])
def draw_snowflakes(color=sd.COLOR_WHITE):
    for snowflakes_nim, snowflakes_parameter in _snowflakes.items():
        start_point = sd.get_point(x=snowflakes_parameter['x'],
                                   y=snowflakes_parameter['y'])
        sd.snowflake(center=start_point,
                     length=snowflakes_parameter['length'],
                     color=color,
                     factor_a=snowflakes_parameter['factor_a'],
                     factor_b=snowflakes_parameter['factor_b'],
                     factor_c=snowflakes_parameter['factor_c'])
Ejemplo n.º 4
0
def snowflake_freeze(snowflakes_freeze):
    for it_snowflake_stop in snowflakes_freeze:
        point = sd.get_point(x_coordinates_list.pop(it_snowflake_stop),
                             y_coordinates_list.pop(it_snowflake_stop))
        sd.snowflake(center=point, length=length_list.pop(it_snowflake_stop))
        x_coordinates_list.insert(it_snowflake_stop,
                                  sd.random_number(-20, 1200))
        y_coordinates_list.insert(it_snowflake_stop,
                                  sd.random_number(500, 900))
        length_list.insert(it_snowflake_stop, sd.random_number(10, 100))
Ejemplo n.º 5
0
def draw_snowflakes(color=sd.COLOR_WHITE):
    """Нарисовать снежинки цветом color """
    global _snowflakes
    for snowflake in _snowflakes:
        sd.snowflake(center=sd.get_point(snowflake['x'], snowflake['y']),
                     length=snowflake['length'],
                     color=color,
                     factor_a=snowflake['factor_a'],
                     factor_b=snowflake['factor_b'],
                     factor_c=snowflake['factor_c'])
Ejemplo n.º 6
0
 def draw(self, color=sd.COLOR_WHITE):
     point_snow = sd.get_point(self.x, self.y)
     sd.snowflake(
         center=point_snow,
         length=self.length,
         color=color,
         factor_a=self.factor_a,
         factor_b=self.factor_b,
         factor_c=self.factor_c
     )
Ejemplo n.º 7
0
 def clear_previous_picture(self):
     point_snow = sd.get_point(self.x, self.y)
     sd.snowflake(
         center=point_snow,
         length=self.length,
         color=sd.background_color,
         factor_a=self.factor_a,
         factor_b=self.factor_b,
         factor_c=self.factor_c
     )
Ejemplo n.º 8
0
def draw_snowflake_color(color=sd.background_color):
    global snowflakes
    for snowflake in snowflakes:
        point = sd.get_point(snowflake[0], snowflake[1])
        sd.snowflake(center=point,
                     length=snowflake[2],
                     color=color,
                     factor_a=snowflake[3],
                     factor_b=snowflake[4],
                     factor_c=snowflake[5])
Ejemplo n.º 9
0
    def snowfalls(_x, _y, _variation, _color=sd.COLOR_WHITE):
        snowfalls_list = []
        for _i in range(10):
            x = _x // 3 + _variation[_i][0]
            y = _y // 3 + _variation[_i][1]
            snowfalls_list.append((x, y))

        for _i, snowfall in enumerate(snowfalls_list):
            sd.snowflake(center=sd.get_point(snowfall[0], snowfall[1]),
                         length=length_list[_i],
                         color=_color)
Ejemplo n.º 10
0
def for_painting(length):
    x_list = []
    y_list = []
    N = 50

    for x in range(0, N - 1):
        k = sd.random_number(0, 300)
        x_list.insert(x, k)

    for y in range(0, N - 1):
        k = sd.random_number(600, 800)
        y_list.insert(y, k)

    for i in range(N - 1):
        x = x_list[i]
        y = y_list[i]

        while True:
            sd.start_drawing()
            sd.snowflake(center=sd.get_point(x, y),
                         length=length,
                         color=sd.background_color)

            y -= 20

            sd.snowflake(center=sd.get_point(x, y),
                         length=length,
                         color=sd.COLOR_WHITE)

            sd.sleep(0.005)

            if 0 <= i < N - 30:
                if y < 75:
                    y = 70
                    break
            elif N - 30 <= i < N - 20:
                if y < 95:
                    y = 90
                    break
            elif N - 20 <= i < N - 12:
                if y < 111:
                    y = 110
                    break
            elif N - 12 <= i < N - 5:
                if y < 121:
                    y = 120
                    break
            elif N - 5 <= i < N:
                if y < 141:
                    y = 140
                    break
            sd.finish_drawing()
            if sd.user_want_exit():
                break
Ejemplo n.º 11
0
def snowball(x=sd.random_number(0, 500),
             y=sd.random_number(0, 500),
             radius=200,
             quantity=50):
    for i in range(quantity):
        snowflake_point = sd.get_point(
            x + sd.random_number(-radius / 2, radius / 2),
            y=sd.random_number(-radius / 2, radius / 2))
        sd.snowflake(snowflake_point, sd.random_number(10, 30), sd.COLOR_WHITE,
                     sd.random_number(1, 100) / 100,
                     sd.random_number(1, 100) / 100, sd.random_number(1, 100))
Ejemplo n.º 12
0
def snowfall(n):
    speed, coord, length = [], [], []
    for i in range(n):
        speed.append(random.randint(10, 50))
        x = random.randint(10, 250)
        y = random.randint(300, 350)
        coord.append([x, y])
        length.append(random.randint(5, 10))

    while True:
        for i in range(n):
            sd.start_drawing()
            wind = random.randint(-20, 20)

            point = sd.get_point(coord[i][0], coord[i][1])
            sd.snowflake(center=point,
                         length=length[i],
                         color=sd.background_color)
            coord[i][0] -= wind
            coord[i][1] -= speed[i]

            x0, y0 = coord[i][0], coord[i][1]
            point = sd.get_point(x0, y0)
            sd.snowflake(center=point, length=length[i])

            if coord[i][1] <= 20 and speed != 0:
                speed[i] = 0
                coord[i].pop()
                coord[i].pop()

            sd.finish_drawing()

            if speed[i] == 0:
                speed.pop(i)
                speed.insert(i, random.randint(5, 30))

            if len(coord[i]) == 0:
                length.pop(i)
                length.insert(i, random.randint(5, 10))
                coord.remove([])
                x = random.randint(10, 250)
                y = random.randint(300, 350)
                coord.insert(i, [x, y])

        sd.sleep(0.1)
        if sd.user_want_exit():
            break
    # sd.pause()


# def main():
#     snowfall(10)

# main()
Ejemplo n.º 13
0
def move_snowflakes():
    for coordinate in snowflakes:
        if coordinate[1] > 50:
            coordinate[1] -= 20
            coordinate[0] -= 4
            point_fall = sd.get_point(coordinate[0], coordinate[1])
            sd.snowflake(point_fall, length=coordinate[2], color=sd.COLOR_WHITE)
        else:
            last_point = sd.get_point(coordinate[0], coordinate[1] - 1)
            sd.snowflake(last_point, coordinate[2], color=sd.COLOR_WHITE)
            coordinate[1] += 1250
Ejemplo n.º 14
0
 def die(self):
     x, y = self.get_position()
     dimension = 40
     if self.get_obj_type() == self.BLOCKMORTALTYPE:
         dimension = 60
         self.parent.remove_stationary_item(self)
     if self.get_obj_type() == self.BLOCKTYPE:
         dimension = 80
         self.block_init(*(self.parent.get_resolution()))
     if self.get_obj_type() == self.BALLTYPE:
         self.ball_init()
     sd.snowflake(sd.get_point(x, y), dimension)
Ejemplo n.º 15
0
def delete_snowflake(number):
    """удаляет снежинки с номерами из списка"""
    global snow
    for number in number:
        if number in snow:
            sd.snowflake(center=sd.get_point(number['x'], number['y']),
                         length=number['length'],
                         color=sd.background_color,
                         factor_a=number['factor_a'],
                         factor_b=number['factor_b'],
                         factor_c=number['factor_c'])
            snow.remove(number)
Ejemplo n.º 16
0
def color_snowflakes(color=sd.COLOR_WHITE):
    global x_list, y_list, size_list
    sd.start_drawing()
    for i, x in enumerate(x_list):
        if y_list[i] <= 0:
            color = sd.background_color
        point = sd.get_point(x_list[i], y_list[i])
        sd.snowflake(center=point,
                     length=size_list[i],
                     color=color,
                     factor_b=length_list[i])
    sd.finish_drawing()
Ejemplo n.º 17
0
    def draw(self, color=None):
        if color is None:
            color = self.color

        point = sd.get_point(self.x, self.y)
        sd.snowflake(
            center=point,
            length=self.length,
            factor_a=self.factor_a,
            factor_b=self.factor_b,
            factor_c=self.factor_c,
            color=color,
        )
Ejemplo n.º 18
0
 def draw_snow_flake(self, color=sd.COLOR_WHITE):
     """
         factor_a=0.6, factor_b=0.35, factor_c=60
         factor_a - место ответвления лучиков
         factor_b - длина лучиков
         factor_c - угол отклонения лучиков
     """
     if (-70 < self.x < 1270) and self.y < 700:
         point = sd.get_point(self.x, self.y)
         sd.snowflake(center=point, length=self.len_beam, color=color,
                      factor_a=self.factor_a,
                      factor_b=self.factor_b,
                      factor_c=self.factor_c)
Ejemplo n.º 19
0
def delete_snowflakes(snowflakes_for_del):
    """Удалить снежинки, которые есть в списке snowflakes_for_del из списка снежинок"""
    global _snowflakes
    for snowflake_for_del in snowflakes_for_del:
        if snowflake_for_del in _snowflakes:
            sd.snowflake(center=sd.get_point(snowflake_for_del['x'],
                                             snowflake_for_del['y']),
                         length=snowflake_for_del['length'],
                         color=sd.background_color,
                         factor_a=snowflake_for_del['factor_a'],
                         factor_b=snowflake_for_del['factor_b'],
                         factor_c=snowflake_for_del['factor_c'])
            _snowflakes.remove(snowflake_for_del)
Ejemplo n.º 20
0
def draw_snowflake(x,
                   y,
                   length,
                   color=sd.COLOR_WHITE,
                   factor_a=0.6,
                   factor_b=0.35,
                   factor_c=60):
    point = sd.get_point(x, y)
    sd.snowflake(center=point,
                 length=length,
                 color=color,
                 factor_a=factor_a,
                 factor_b=factor_b,
                 factor_c=factor_c)
Ejemplo n.º 21
0
def flake():
    for i in range(0, N):
        k = sd.random_number(0, sd.resolution[0])
        x_list.insert(i, k)
        k = sd.random_number(sd.resolution[1] - 100, sd.resolution[1])
        y_list.insert(i, k)
        k = sd.random_number(10, 100)
        size_list.insert(i, k)
        size = size_list[i]

        sd.snowflake(
            center=sd.get_point(x=x_list[i], y=y_list[i]),
            length=size,
        )
Ejemplo n.º 22
0
def snowfall(snows=None, snowfall_left=0, snowfall_right=250):
    snowdrift = snows

    for i in range(len(snows)):
        sd.start_drawing()
        for j in range(len(snowdrift)):
            sd.snowflake(center=sd.get_point(snowdrift[j][0], snowdrift[j][1]),
                         length=snowdrift[j][2],
                         factor_a=snowdrift[j][3],
                         factor_b=snowdrift[j][4],
                         factor_c=snowdrift[j][5])
        sd.snowflake(center=sd.get_point(snows[i][0], snows[i][1]),
                     length=snows[i][2],
                     factor_a=snows[i][3],
                     factor_b=snows[i][4],
                     factor_c=snows[i][5],
                     color=sd.background_color)
        if snows[i][1] > 0:
            snows[i][0] = snows[i][0] + sd.random_number(-3, 3)
            if snows[i][0] > snowfall_right:
                snows[i][0] -= 3
            if snows[i][0] < snowfall_left:
                snows[i][0] += 3
            snows[i][1] -= 1
            sd.snowflake(center=sd.get_point(snows[i][0], snows[i][1]),
                         length=snows[i][2],
                         factor_a=snows[i][3],
                         factor_b=snows[i][4],
                         factor_c=snows[i][5],
                         color=sd.background_color)
        else:
            sd.snowflake(center=sd.get_point(snows[i][0], snows[i][1]),
                         length=snows[i][2],
                         factor_a=snows[i][3],
                         factor_b=snows[i][4],
                         factor_c=snows[i][5])
            snows.remove(snows[i])
            create_snow(snow_number=i,
                        snowfall_left=snowfall_left,
                        snowfall_right=snowfall_right,
                        replacement=True,
                        snows=snows)
        sd.snowflake(center=sd.get_point(snows[i][0], snows[i][1]),
                     length=snows[i][2],
                     factor_a=snows[i][3],
                     factor_b=snows[i][4],
                     factor_c=snows[i][5])

        sd.finish_drawing()
Ejemplo n.º 23
0
def snow_draw(color, number_snowflakes=-1):
    if number_snowflakes == -1:
        for i in range(0, len(x_coordinates)):
            point = sd.get_point(x_coordinates[i], y_coordinates[i])
            sd.snowflake(center=point,
                         length=sizes_rays[i],
                         factor_a=0.5,
                         color=color)
    else:
        point = sd.get_point(x_coordinates[number_snowflakes],
                             y_coordinates[number_snowflakes])
        sd.snowflake(center=point,
                     length=sizes_rays[number_snowflakes],
                     factor_a=0.5,
                     color=color)
Ejemplo n.º 24
0
def sugrob(start_point, max_length):
    list = []
    N = 20
    for i in range(N):
        local = [
            sd.random_number(start_point.x - 30, start_point.x + 20),
            sd.random_number(start_point.y - 40, start_point.y + 20)
        ]
        list.append(local)

    for item in list:
        lenght = sd.random_number(10, max_length)
        point = sd.get_point(item[1], item[0])

        sd.snowflake(center=point, length=lenght, color=sd.COLOR_WHITE)
Ejemplo n.º 25
0
def snowflakes(snowflake_x_cor, snowflake_y_cor, length, snowflakes_count):
    coordinates_snowflakes = []
    for _ in range(snowflakes_count):
        coordinate_snowflake = {
            "x": sd.random_number(snowflake_x_cor - 70, snowflake_x_cor + 70),
            "y": sd.random_number(snowflake_y_cor - 20, snowflake_y_cor + 20),
            "length": length,
        }
        coordinates_snowflakes.append(coordinate_snowflake)

    for coordinate_snowflake in coordinates_snowflakes:
        sd.start_drawing()
        point = sd.get_point(x=coordinate_snowflake["x"],
                             y=coordinate_snowflake["y"])
        sd.snowflake(center=point, length=coordinate_snowflake["length"])
        sd.finish_drawing()
Ejemplo n.º 26
0
def snowflakes(quantity):
    for _ in range(quantity):
        new_x = sd.random_number(50, 1150)
        x_list.append(new_x)
        new_size = sd.random_number(10, 40)
        size_list.append(new_size)
        new_length = round(sd.random_number(10, 90) / 100, 1)
        length_list.append(new_length)
    for y in range(600, 0, -5):
        sd.clear_screen()
        for i, x in enumerate(x_list):
            point = sd.get_point(x, y)
            sd.snowflake(center=point,
                         length=size_list[i],
                         factor_b=length_list[i])
        sd.sleep(0.1)
Ejemplo n.º 27
0
def snowfall():
    sd.start_drawing()
    for sf_name, value in snowflake_dict.items():
        x = value[0]
        y = value[1]
        length = value[2]
        point = sd.get_point(x, y)
        sd.snowflake(center=point, length=length, color=sd.background_color)
        value[0] += sd.random_number(-5, 5)
        value[1] -= sd.random_number(5, 20)
        point2 = sd.get_point(value[0], value[1])
        sd.snowflake(center=point2, length=length)
        if value[1] < 60:
            value[0] = sd.random_number(50, 100)
            value[1] = value[1] + 800
    sd.finish_drawing()
Ejemplo n.º 28
0
def snowfall_draw(x_coordinates, y_coordinates, random_length,
                  list_of_start_end_points, endpoint_of_snowfall):
    sd.start_drawing()
    old_index_list = []
    for index, x in enumerate(x_coordinates):
        # Назначаю рандомное значение падения и отклонения на каждом шагу
        random_step_x = sd.random_number(-30, 30)
        random_step_y = sd.random_number(5, 15)
        # Создаю точку и рисую снежинку цветом фона
        point = sd.get_point(x_coordinates[index], y_coordinates[index])
        sd.snowflake(center=point,
                     length=random_length[index],
                     color=sd.background_color)
        # Изменяю координаты
        x_coordinates[index] += random_step_x
        y_coordinates[index] -= random_step_y
        # Создаю точку и рисую снежинку белым цветом
        point = sd.get_point(x_coordinates[index], y_coordinates[index])
        sd.snowflake(center=point,
                     length=random_length[index],
                     color=sd.COLOR_DARK_BLUE)
        # Добавляю индекс снежинки, которая по игреку меньше пятидесяти в список "старых" индексов
        if y_coordinates[index] < endpoint_of_snowfall:
            old_index_list.append(index)
    # Сортирую список со "старыми" индексами
    old_index_list.sort(reverse=True)
    # Если в списке "старых" индексов, находится хотя бы одно значение, то захожу в цикл и
    # удаляю старые и сразу же добавляю новые значения, в списки координат и размеров снежинки,
    # по индексу из списка "старых" индексов,
    if any(old_index_list):
        for old_index in old_index_list:
            x_coordinates.pop(old_index)
            x_coordinates.insert(
                old_index,
                sd.random_number(list_of_start_end_points[0],
                                 list_of_start_end_points[1]))
            y_coordinates.pop(old_index)
            y_coordinates.insert(
                old_index,
                sd.random_number(list_of_start_end_points[2],
                                 list_of_start_end_points[3]))
            random_length.pop(old_index)
            random_length.insert(old_index, sd.random_number(10, 50))
        # Очищаю список "старых" индексов
        old_index_list.clear()

    sd.finish_drawing()
Ejemplo n.º 29
0
def snowfall():
    for k in range(2):
        y = 500
        for i in range(10):
            sd.clear_screen()
            y -= 30
            for x in [100, 200, 300, 400, 500]:
                radius = sd.random_number(30, 50)
                point = sd.Point(x=x, y=y)
                sd.snowflake(center=point, length=radius)
                mouse_point, mouse_buttons = sd.get_mouse_state()
                print("mouse_state is {} + {}".format(mouse_point,
                                                      mouse_buttons))
            if sd.user_want_exit(sleep_time=0.1):
                break
        if sd.user_want_exit(0):
            break
Ejemplo n.º 30
0
def snowflakes():
    N = 200
    y_list = []
    x_list = []
    length_list = []

    for _ in range(N):
        x_list.append(sd.random_number(0, 1200))
        y_list.append(sd.random_number(5, 30))
        length_list.append(sd.random_number(5, 20))

    for i, y in enumerate(x_list):
        point = sd.get_point(x_list[i], y_list[i])
        sd.snowflake(center=point, length=length_list[i])

        if sd.user_want_exit():
            break
Ejemplo n.º 31
0
def draw_snowfall(count=999, start_point=50, end_point=200, earth=100):

    snowfall_points_tuple = []

    for i in range(count):
        snowfall_points_tuple.append(
            sd.get_point(sd.random_point().x, sd.resolution[1]))

    for _ in range(count):
        while True:
            if sd.user_want_exit():
                break
            sd.snowflake(snowfall_points_tuple[_], 15)
            if snowfall_points_tuple[_].y < earth:
                break
            sd.snowflake(snowfall_points_tuple[_], 15, sd.background_color)
            snowfall_points_tuple[_].y -= 10
Ejemplo n.º 32
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# нарисовать снежинку с помощью функции snowflake
from simple_draw import snowflake, end

snowflake(...)

# параметризировать углы лучей снежинки, цвет рисования - передача разных параметров

snowflake(..., factor_a=0.2, ...)

end()
Ejemplo n.º 33
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# нарисовать снег - 1000 снежинок радиусом от 10 до 60 в произвольных местах экрана,
from simple_draw import snowflake, end


for i in range(...):
    position = ...
    snowflake(...)

end()


Ejemplo n.º 34
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# нарисовать снегопад - 7 движужихся снежинок радиусом от 10 до 60 
# снежинки падают с высоты 500 пикселов со скоростью 30 пикселов за такт
# на расстоянии 100 пикселов друг от друга
from simple_draw import clear_screen, Point, snowflake, sleep, end

y = 500
for i in range(10):
    clear_screen()
    y = ...  # как изменяется y для всех снежинок
    for i in range(7):
        point = Point(...)
        snowflake(point)
    sleep(0.3)

# + нарисовать снежинки разных радиусов, для этого хранить список радиусов
radiuses = [30, 20, 40, 10, 50, 70, ]

# + сделать скорость падения уникальной для каждой снежинки,
# для этого хранить список координат Y и скоростей по Y
coordinates = [...]
velocity = [...]

# ++ сделать реальный снегопад, что бы снежинки порхали из стороны в сторону

end()