Esempio n. 1
0
def snowflake():
    ground_level = 50
    k = 0
    while True:
        sd.start_drawing()
        for i in snowflakes_param:
            x = i[0]
            y = i[1]
            point = sd.get_point(x, y)
            snowflake_length = i[2]
            sd.snowflake(center=point,
                         length=snowflake_length,
                         color=sd.background_color)
            i[1] -= sd.random_number(0, 20)
            i[0] += sd.random_number(-20, 20)
            point_1 = sd.get_point(i[0], i[1])
            sd.snowflake(center=point_1,
                         length=snowflake_length,
                         color='white')
            if y < ground_level:
                ind = snowflakes_param.index(i)
                fallen.append(snowflakes_param.pop(ind))
                flake_add(snowflakes_param, 1)
                k += 1
        if k >= 10:
            ground_level += 5
            k = 0
        sd.finish_drawing()
        sd.sleep(0.1)
        if sd.user_want_exit():
            break
Esempio n. 2
0
def snowfall(coordinates_snowflakes):
    coordinate_snowflake = {
        "x": sd.random_number(30, 130),
        "y": sd.random_number(400, 500),
        "length": sd.random_number(10, 20),
    }
    coordinates_snowflakes.append(coordinate_snowflake)

    for coordinate_snowflake in coordinates_snowflakes:
        sd.start_drawing()
        random_change_x = sd.random_number(1, 2)
        if random_change_x == 1:
            coordinate_snowflake["x"] -= 2
            point_invisible = sd.get_point(x=coordinate_snowflake["x"] + 2,
                                           y=coordinate_snowflake["y"] + 10)
        else:
            coordinate_snowflake["x"] += 2
            point_invisible = sd.get_point(x=coordinate_snowflake["x"] - 2,
                                           y=coordinate_snowflake["y"] + 10)
        sd.snowflake(center=point_invisible,
                     length=coordinate_snowflake["length"],
                     color=sd.background_color)
        point = sd.get_point(x=coordinate_snowflake["x"],
                             y=coordinate_snowflake["y"])
        if coordinate_snowflake["y"] <= 100:
            coordinate_snowflake["y"] += 400
        sd.snowflake(center=point, length=coordinate_snowflake["length"])
        sd.finish_drawing()
Esempio n. 3
0
def snowfall(N):
    snowflake = []
    for _ in range(N):
        snowflake.append(([sd.random_number(-50, 1250), sd.random_number(550, 1600), sd.random_number(23, 47)]))

    while True:
        sd.start_drawing()
        for snow in snowflake:
            x, y, length = snow
            point = sd.get_point(x, y)

            sd.snowflake(center=point, length=length, color=sd.background_color, factor_a=0.6)
            if y > 50:
                snow[1] -= 10
                snow[0] -= 10
                point_fall = sd.get_point(x, y)
                sd.snowflake(point_fall, length=length, color=sd.COLOR_WHITE)
            else:
                last_point = sd.get_point(x, y - 1)
                sd.snowflake(last_point, length, color=sd.COLOR_WHITE)
                snow[1] += 1250

        sd.finish_drawing()
        sd.sleep(0.05)
        if sd.user_want_exit():
            break
        sd.clear_screen()
Esempio n. 4
0
def show_snow(count_flake):
    snow_params = []

    for _ in range(count_flake):
        snow_params.append([sd.random_number(0, 1000), sd.random_number(500, 600), sd.random_number(20, 40)])

    while True:
        for flake in snow_params:
            x, y, length = flake
            draw_flake(x, y, length, sd.COLOR_WHITE)

        sd.finish_drawing()
        sd.sleep(0.1)

        for key, flake in enumerate(snow_params):
            x, y, length = flake
            draw_flake(x, y, length, sd.background_color)

            snow_params[key][0] += sd.random_number(-25, 25)
            snow_params[key][1] -= sd.random_number(1, 25)

        if y < 0:
            break

        if sd.user_want_exit():
            break
def snow():
    x_list = []
    y_list = []
    flake_length_list = []
    number_of_snowflakes = 20
    for _ in range(number_of_snowflakes):
        x_list.append(sd.random_number(0, sd.resolution[0]))
        y_list.append(sd.random_number(sd.resolution[1], sd.resolution[1] * 2))
        flake_length_list.append(sd.random_number(20, 50))
    while True:
        sd.start_drawing()
        for x, y, length, i in zip(x_list, y_list, flake_length_list,
                                   range(number_of_snowflakes)):
            if y_list[i] > 65:
                sd.snowflake(sd.get_point(x, y),
                             length,
                             color=sd.background_color)
            x_list[i] += sd.random_number(-15, 15)
            y_list[i] -= sd.random_number(4, 30)
            if y_list[i] < 50:
                y_list[i] = sd.random_number(sd.resolution[1],
                                             sd.resolution[1] * 2)
            sd.snowflake(sd.get_point(x_list[i], y_list[i]), length)
        sd.finish_drawing()
        sd.sleep(0.1)
        if sd.user_want_exit():
            break
Esempio n. 6
0
def snowflakes(quantity):
    x_list = []
    y_list = []
    size_list = []
    length_list = []
    for _ in range(quantity):
        new_x = sd.random_number(50, 1150)
        x_list.append(new_x)
        new_y = sd.random_number(0, 600)
        y_list.append(new_y)
        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)
    while True:
        sd.start_drawing()
        sd.clear_screen()
        for i, x in enumerate(x_list):
            if y_list[i] < 0:
                y_list[i] = 600
            point = sd.get_point(x_list[i], y_list[i])
            sd.snowflake(center=point, length=size_list[i], factor_b=length_list[i])
            y_list[i] -= 10
        sd.finish_drawing()
        sd.sleep(0.1)
        if sd.user_want_exit():
            break
Esempio n. 7
0
def draw_snowflakes_color(color):
    sd.start_drawing()
    for i, snowflake in enumerate(snowflakes):
        sd.snowflake(center=sd.get_point(snowflake['x'], snowflake['y']),
                     length=snowflake['length'],
                     color=color)
    sd.finish_drawing()
Esempio n. 8
0
def snow(y_drop):
    drift = 5

    sd.start_drawing()

    for snowflake in range(N):
        point = sd.get_point(x_coordinates_list[snowflake],
                             y_coordinates_list[snowflake])
        sd.snowflake(center=point,
                     length=length_list[snowflake],
                     color=sd.background_color)
        if y_coordinates_list[snowflake] > drift and x_coordinates_list[
                snowflake] < 300:
            y_coordinates_list[snowflake] -= y_drop
            random_vector = sd.random_number(-8, 8)
            if length_list[snowflake] < 35:
                x_coordinates_list[snowflake] = x_coordinates_list[
                    snowflake] + random_vector * 1.4
            else:
                x_coordinates_list[
                    snowflake] = x_coordinates_list[snowflake] + random_vector
            point_new = sd.get_point(x_coordinates_list[snowflake],
                                     y_coordinates_list[snowflake])
            sd.snowflake(center=point_new, length=length_list[snowflake])
        else:
            sd.snowflake(center=point, length=length_list[snowflake])
            x_coordinates_list[snowflake] = sd.random_number(30, 200)
            y_coordinates_list[snowflake] = sd.random_number(500, 900)
            length_list[snowflake] = sd.random_number(1, 10)
            drift += 0.1

    sd.finish_drawing()

    sd.sleep(0.02)
def falling_snowflake():
    snowflakes_length = [sd.random_number(10, 101) for _ in range(20)]
    snowflakes_point = {
        i: [sd.random_number(0, 500), 500, i]
        for i in range(20)
    }
    old_points_arr = [[snowflakes_point[key][0], snowflakes_point[key][1]]
                      for key, val in snowflakes_point.items()]
    while True:
        sd.start_drawing()
        for i in range(20):
            if len(old_points_arr) < 20:
                sd.snowflake(center=old_points_arr[i],
                             length=snowflakes_length[i],
                             color=sd.background_color)
            x, y, delay = snowflakes_point[i]
            if delay < 1:
                point = sd.get_point(x, y)
                sd.snowflake(center=sd.Point(old_points_arr[i][0],
                                             old_points_arr[i][1]),
                             length=snowflakes_length[i],
                             color=sd.background_color)
                sd.snowflake(center=point, length=snowflakes_length[i])
                if y < 20:
                    snowflakes_point[i][1] = 500
                    continue
                snowflakes_point[i][1] -= 9
                snowflakes_point[i][0] += sd.random_number(-10, 10)
                old_points_arr[i] = [x, y]
            snowflakes_point[i][2] -= .2
        sd.finish_drawing()
        sd.sleep(0.1)
        if sd.user_want_exit():
            break
Esempio n. 10
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)
def snowfall():
    flakes = dict(x=[], y=[], size=[])

    for i in range(N):
        flakes['x'].append(sd.random_number(0, sd.resolution[0] // 5))
        flakes['y'].append(sd.random_number(sd.resolution[1] - 400, sd.resolution[1] - 200))
        flakes['size'].append(sd.random_number(5, 30))

    while True:
        sd.start_drawing()
        if 'points' in locals():
            for index in range(N):
                sd.snowflake(center=points[index], length=flakes['size'][index], color=sd.background_color)
        points = []
        for index in range(N):
            point = sd.get_point(flakes['x'][index], flakes['y'][index])
            points.append(point)
            sd.snowflake(center=point, length=flakes['size'][index])
            if flakes['y'][index] > sd.random_number(130, 160):
                flakes['y'][index] -= sd.random_number(2, 10)
                flakes['x'][index] += sd.random_number(-5, 5)

        sd.finish_drawing()
        sd.sleep(0.1)
        if sd.user_want_exit():
            break
Esempio n. 12
0
def falling():
    while True:
        sd.start_drawing()
        for i in range(N - 1):
            size = size_list[i]

            sd.snowflake(center=sd.get_point(x=x_list[i], y=y_list[i]),
                         length=size,
                         color=sd.background_color)
            y_list[i] -= speed_list[i]
            sd.snowflake(center=sd.get_point(x=x_list[i], y=y_list[i]),
                         length=size,
                         color=sd.COLOR_WHITE)
            if y_list[i] < 40:
                y_list[i] = 600
            point1 = sd.get_point(x_list[i], y_list[i])
            sd.snowflake(center=point1,
                         length=size,
                         color=sd.COLOR_WHITE,
                         factor_a=0.6,
                         factor_b=0.35,
                         factor_c=60)
            sd.sleep(0.001)

        sd.finish_drawing()

        if sd.user_want_exit():
            break
Esempio n. 13
0
def leaves_fall(x_coordinates, y_coordinates, endpoint_of_laves_fall):
    sd.start_drawing()
    for index, x in enumerate(x_coordinates):
        if y_coordinates[index] > endpoint_of_laves_fall:
            # Назначаю рандомное значение падения и отклонения на каждом шагу
            random_step_x = sd.random_number(-30, 30)
            random_step_y = sd.random_number(5, 15)
            # Создаю точку и рисую снежинку цветом фона
            left_bottom_point = sd.get_point(x_coordinates[index],
                                             y_coordinates[index])
            right_top_point = sd.get_point(x_coordinates[index] + 3,
                                           y_coordinates[index] + 3)
            sd.ellipse(left_bottom=left_bottom_point,
                       right_top=right_top_point,
                       color=sd.background_color)
            # Изменяю координаты
            x_coordinates[index] += random_step_x
            y_coordinates[index] -= random_step_y
            # Создаю точку и рисую лист
            left_bottom_point = sd.get_point(x_coordinates[index],
                                             y_coordinates[index])
            right_top_point = sd.get_point(x_coordinates[index] + 3,
                                           y_coordinates[index] + 3)
            sd.ellipse(left_bottom=left_bottom_point,
                       right_top=right_top_point,
                       color=sd.COLOR_DARK_RED)
    sd.finish_drawing()
Esempio n. 14
0
 def clear_previous_picture(self):
     sd.start_drawing()
     point = sd.get_point(self.x, self.y)
     sd.snowflake(center=point,
                  length=self.length,
                  color=sd.background_color)
     sd.finish_drawing()
Esempio n. 15
0
def smailik(point, radius):
    #eyes
    eye1 = simple_draw.get_point(point.x-radius*.35, point.y+radius*.35)
    eye2 = simple_draw.get_point(point.x + radius*.35, point.y + radius*.35)
    simple_draw.circle(center_position=eye1, radius=radius*.1, color=simple_draw.COLOR_GREEN, width=0)
    simple_draw.circle(center_position=eye2, radius=radius*.1, color=simple_draw.COLOR_GREEN, width=0)
    #nose
    nose_point1 = simple_draw.get_point(point.x, point.y + radius*.5)
    nose_point2 = simple_draw.get_point(point.x, point.y - radius*.25)
    simple_draw.line(nose_point1, nose_point2, width=2)
    #mouth
    mouth_point1 = simple_draw.get_point(point.x - radius*.3, point.y - radius*.4)
    mouth_point2 = simple_draw.get_point(point.x + radius*.3, point.y - radius*.4)
    simple_draw.line(mouth_point1, mouth_point2, width=1)
    simple_draw.get_vector(start_point=mouth_point1, angle=150, length=radius*.25).draw()
    simple_draw.get_vector(start_point=mouth_point2, angle=30, length=radius * .25).draw()
    #full face
    simple_draw.circle(center_position=point, radius=radius)
    #body
    body_point1 = simple_draw.get_point(point.x, point.y - radius)
    body = simple_draw.get_vector(start_point=body_point1, angle=270, length=radius*2)
    body.draw()
    #legs
    simple_draw.get_vector(start_point=body.end_point, angle=240, length=radius*1.7).draw()
    simple_draw.get_vector(start_point=body.end_point, angle=300, length=radius*1.7).draw()
    #arms
    arm_point = simple_draw.get_point(point.x, point.y - radius*1.7)
    simple_draw.get_vector(start_point=arm_point, angle=140, length=radius*1.6).draw()
    simple_draw.get_vector(start_point=arm_point, angle=40, length=radius * 1.6).draw()

    simple_draw.finish_drawing()
Esempio n. 16
0
def draw_snowflakes(color=sd.COLOR_WHITE):
    """Функция отрисовывает снежинки

    Parameters
    ----------
    color: tuple(int, int, int), default=(255, 255, 0)
        Цвет снежинок. Это кортеж (red, green, blue),
        где для каждый из трёх элементов цвета принимает значения от 0 до 255 включительно

    Returns
    -------
    """
    # мне кажется, что для большей гибкости кода и лучших результатов (уменьшения мерцания)
    # sd.start_drawing и sd.finish_drawing лучше вынести в основной модуль,
    # но поскольку в задании чётко указано обращаться ТОЛЬКО к функциям из этого модуля,
    # то я перенёс работу с фреймбуфером (кажется так это называется) в эту функцию
    global _blizzard
    sd.start_drawing()
    for snowflake in _blizzard:
        point = sd.get_point(snowflake['x'], snowflake['y'])
        sd.snowflake(
            center=point,
            length=snowflake['length'],
            factor_a=snowflake['factor_a'],
            factor_b=snowflake['factor_b'],
            factor_c=snowflake['factor_c'],
            color=color,
        )
    sd.finish_drawing()
Esempio n. 17
0
def snowfall1(n=5):
    quantity_snowflakes = n
    snowflake_dict = {}
    for number_x in range(quantity_snowflakes):
        x = sd.random_number(50, 100)
        y = sd.random_number(800, 850)
        length = sd.random_number(5, 15)
        snowflake_dict[number_x] = [x, y, length]

    while True:
        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()
        sd.sleep(0.1)
Esempio n. 18
0
def delete_snowflakes(count):
    center = sd.get_point(_point_x[count], _point_y[count])
    sd.start_drawing()
    sd.snowflake(center=center, length=50, color=sd.background_color)
    sd.finish_drawing()
    del _point_x[count]
    del _point_y[count]
def snowfall(coord_x=0, coord_y=500):
    count_snowfall = 20

    x = []
    for _ in range(count_snowfall):
        x.append(sd.random_number(coord_x, coord_y))
    y = []
    for _ in range(count_snowfall):
        y.append(sd.random_number(coord_x, coord_y))

    while True:
        sd.start_drawing()
        for i in range(len(x)):
            if i > 0:
                point1 = sd.get_point(x[i - 1], y[i - 1])
                sd.snowflake(center=point1, length=10, color=sd.COLOR_WHITE)
            point = sd.get_point(x[i], y[i])
            if y[i] > 50:
                sd.snowflake(center=point,
                             length=10,
                             color=sd.background_color)
                y[i] -= sd.random_number(-1, 15)
                x[i] = x[i] + sd.random_number(-15, 15)
        sd.finish_drawing()
        sd.sleep(0.1)
Esempio n. 20
0
def snowflakes(_x1, _y1, _x2, _y2):
    def new_snowflake():
        _x = sd.random_number(_x1, _y1)
        _y = sd.random_number(_x2, _y2)
        _length = sd.random_number(10, 20)
        _my_dict = {'x': _x, 'y': _y, 'length': _length}
        snowflakes[i] = _my_dict

    snowflakes = {}

    for i in range(50):
        new_snowflake()

    while True:
        sd.start_drawing()
        for i, snowflake in snowflakes.items():

            sd.snowflake(center=sd.get_point(snowflake['x'], snowflake['y']), length=snowflake['length'],
                         color=sd.background_color)
            snowflake['y'] -= 10
            if snowflake['x'] >= 340:
                snowflake['x'] += sd.random_number(-51, -50)
            snowflake['x'] += sd.random_number(-50, 50)
            sd.snowflake(center=sd.get_point(snowflake['x'], snowflake['y']), length=snowflake['length'],
                         color=sd.COLOR_WHITE)
            if snowflake['y'] < snowflake['length']:
                new_snowflake()
                continue
            sd.sleep(0.005)

        sd.finish_drawing()
        if sd.user_want_exit():
            break
    sd.pause()
Esempio n. 21
0
def draw_snow_color(color):
    sd.start_drawing()
    for i in range(len(_point_x)):
        center = sd.get_point(_point_x[i], _point_y[i])
        #  - отрисовка снежинки с цветом color
        sd.snowflake(center=center, length=50, color=color)

    sd.finish_drawing()
Esempio n. 22
0
def snowflakes_color(snowflake_color=sd.COLOR_WHITE):
    sd.start_drawing()
    for i in range(len(_snowflakes_x)):
        snowflake_center = sd.get_point(_snowflakes_x[i], _snowflakes_y[i])
        sd.snowflake(center=snowflake_center,
                     length=_snowflakes_d[i],
                     color=snowflake_color)
    sd.finish_drawing()
Esempio n. 23
0
 def move(self):
     delta_x = sd.random_number(-30, 30)
     delta_y = sd.random_number(0, 30)
     self.x += delta_x
     self.y -= delta_y
     sd.snowflake(sd.get_point(self.x, self.y), self.sf_lengths,
                  sd.COLOR_WHITE, self.sf_a, self.sf_b, self.sf_c)
     sd.finish_drawing()
Esempio n. 24
0
def act_nine():
    for deg in range(40):
        sd.start_drawing()
        clear_screen()
        plain.rotateY(angle_deg=2)
        plain.render(color=COLOR, color_back=COLOR_BACK, need_edge=True)
        sd.finish_drawing()
        sd.sleep(0.1)
Esempio n. 25
0
def draw_flake(color=sd.COLOR_WHITE):
    sd.start_drawing()
    for flake in _snow_params:
        x, y, length = flake
        point = sd.get_point(x, y)

        sd.snowflake(center=point, length=length, color=color)
    sd.finish_drawing()
Esempio n. 26
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()
Esempio n. 27
0
def paint_snowflake_color(color=sd.COLOR_WHITE):
    """отрисовывает все снежинки цветом color"""
    for i in snow:
        sd.start_drawing()
        first_point = sd.get_point(i['x'], i['y'])
        sd.snowflake(center=first_point, length=i['length'], color=color,
                     factor_a=i['factor_a'], factor_b=i['factor_b'], factor_c=i['factor_c'])
    sd.finish_drawing()
Esempio n. 28
0
def main():
    sd.start_drawing()
    plain.render(color=COLOR, need_edge=True)
    sd.finish_drawing()
    sd.sleep(5)
    rotate_paper(360, 240)

    sd.pause()
Esempio n. 29
0
 def draw_items(self):
     sd.start_drawing()  # removes  blinking
     for statObj in self.static_objects:
         statObj.draw_item()
     for dinObj in self.mobile_objects:
         dinObj.draw_item()
     sd.finish_drawing()  # removes  blinking
     sd.sleep(0.06)
     sd.draw_background()
Esempio n. 30
0
def rotate_paper(angle, steps):
    angle = angle / steps
    for _ in range(steps):
        sd.start_drawing()
        clear_screen()
        plain.rotate(angle)
        plain.render(color=COLOR, color_back=COLOR_BACK)
        sd.finish_drawing()
        sd.sleep(0.05)