Esempio 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
def draw_branches_recursion(start_point, _length, _angle=0):
    if _length < 10:
        return
    v1 = sd.get_vector(start_point=start_point,
                       angle=_angle + 30,
                       length=_length,
                       width=3)
    v1.draw(color=sd.random_color())
    v2 = sd.get_vector(start_point=start_point,
                       angle=_angle - 30,
                       length=_length,
                       width=3)
    v2.draw(color=sd.random_color())
    next_point = v1.end_point
    next_angle = _angle + 30
    next_length = _length * .75
    draw_branches_recursion(start_point=next_point,
                            _angle=next_angle,
                            _length=next_length)
    next_point = v2.end_point
    next_angle = _angle - 30
    next_length = _length * .75
    draw_branches_recursion(start_point=next_point,
                            _angle=next_angle,
                            _length=next_length)
Esempio n. 3
0
def smile(x, y):
    sd.ellipse(left_bottom=sd.get_point(x - 40, y - 45), right_top=sd.get_point(x + 40, y + 45),
               color=sd.random_color())
    face_color = sd.random_color()
    sd.ellipse(left_bottom=sd.get_point(x + 10, y + 8), right_top=sd.get_point(x + 30, y + 20),
               color=face_color, width=2)
    sd.ellipse(left_bottom=sd.get_point(x - 27, y + 8), right_top=sd.get_point(x - 7, y + 20),
               color=face_color, width=2)
    sd.circle(sd.get_point(x + 18, y + 14), radius=2, color=face_color)
    sd.circle(sd.get_point(x - 19, y + 14), radius=2, color=face_color)
    sd.line(start_point=sd.get_point(x, y - 8), end_point=sd.get_point(x, y + 13), color=face_color, width=4)
    sd.line(start_point=sd.get_point(x - 4, y - 8), end_point=sd.get_point(x + 5, y - 8), color=face_color, width=4)
    sd.line(start_point=sd.get_point(x - 10, y - 18), end_point=sd.get_point(x + 11, y - 18), color=face_color, width=4)
    sd.line(start_point=sd.get_point(x + 11, y - 18), end_point=sd.get_point(x + 16, y - 15), color=face_color, width=4)
    sd.line(start_point=sd.get_point(x - 10, y - 18), end_point=sd.get_point(x - 15, y - 15), color=face_color, width=4)
Esempio n. 4
0
def draw_random_branches(start_point, angle, length):
    global v
    v += 1
    # print('vetki =', v)
    color = (125, 78, 8)
    width = int(length / 10)
    if width < 1:
        width = 1
    if length < 40:
        color = (66, 80, 0)
        if length < 9.5:
            # color = (0, sd.random_number(150, 255), 0)
            color = sd.random_color()
            width = 10

            if length < 9:
                return
    v1 = sd.get_vector(start_point, angle, length, width=width)
    v1.draw(color)
    for i in range(sd.random_number(1, 2)):
        draw_random_branches(v1.end_point, angle - sd.random_number(25, 40),
                             length * sd.random_number(65, 75) / 100)
        draw_random_branches(v1.end_point, angle + sd.random_number(25, 40),
                             length * sd.random_number(65, 75) / 100)
    draw_random_branches(v1.end_point, angle + sd.random_number(-15, 15),
                         length * sd.random_number(75, 90) / 100)
Esempio n. 5
0
def printSmileRandom():

    for _ in range(100):

        colorSmile = simple_draw.random_color()

        pointSmile = simple_draw.random_point()
        
        radiusSmile = 66

        startPointX = pointSmile.x

        startPointY = pointSmile.y

        eyeLeft = simple_draw.get_point(startPointX - 20, startPointY + 20)
        eyeRight = simple_draw.get_point(startPointX + 20, startPointY + 20)
        eyeRadius = 6

        lipCornerLeft = simple_draw.get_point(startPointX - 20, startPointY - 20)
        lipCornerRight = simple_draw.get_point(startPointX + 20, startPointY - 20)
        lipCornerCenter = simple_draw.get_point(startPointX, startPointY - 40)


        simple_draw.circle(pointSmile, radiusSmile, colorSmile, 2)

        simple_draw.circle(eyeLeft, eyeRadius, colorSmile, 2)

        simple_draw.circle(eyeRight, eyeRadius, colorSmile, 2)

        simple_draw.lines((lipCornerLeft, lipCornerCenter, lipCornerRight), colorSmile, True, 2)
Esempio n. 6
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)
Esempio n. 7
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())
Esempio n. 8
0
def block(start_x=0, start_y=0, width=100, high=50, step=1):
    start_x *= width * step
    start_y *= high
    a = sd.get_point(start_x, start_y)
    b = sd.get_point(start_x, start_y + high)
    c = sd.get_point(start_x + width, start_y + high)
    d = sd.get_point(start_x + width, start_y)
    sd.lines([a, b, c, d], color=sd.random_color())
Esempio n. 9
0
def random_circles():
    for i in range(100):
        point = sd.random_point()
        width = 2
        radius = sd.random_number(a=width)
        sd.circle(center_position=point,
                  radius=radius,
                  color=sd.random_color(),
                  width=width)
Esempio n. 10
0
def bubble(point, step):
    radius = 50
    # Нарисовать пузырек - три вложенных окружностей с шагом 5 пикселей
    for _ in range(3):
        radius += step
        sd.circle(center_position=point,
                  radius=radius,
                  width=2,
                  color=sd.random_color())
Esempio n. 11
0
def draw_bunches(start_point, angle, length):
    if length <= 5:
        return
    v1 = sd.get_vector(start_point, angle, length, width=2)
    v1.draw(color=sd.random_color())
    angle_deviation = random.uniform(0, 0.4) * 30
    length_deviation = random.uniform(0, 0.2) * 0.75
    draw_bunches(v1.end_point, angle + 30 + angle_deviation,
                 length * 0.75 + length_deviation)
    draw_bunches(v1.end_point, angle - 30 - angle_deviation,
                 length * 0.75 + length_deviation)
Esempio n. 12
0
def show_figure2():
    word = "skillbox"
    dist = 15

    start_spell = sd.get_point(100, 250)
    sd.start_drawing()
    clear_screen()
    snakes = []
    angle = 360 / len(word)
    for idx, ch in enumerate(word):
        scale_val = 0.3
        figure = Figure()
        figure.radius = 0
        figure.points = copy(segments[ch]['data'])
        figure.prepare_points()

        figure.scale([scale_val, scale_val, 1])

        figure.origin = start_spell
        # figure.draw()
        start_spell = sd.get_point(x=start_spell.x +
                                   segments[ch]['width'] * scale_val + dist,
                                   y=start_spell.y)

        snake = Snake(figure)
        snake.color = sd.random_color()

        center = sd.get_point(400, 300)
        radius = 1000
        x = sd.sin(angle * idx) * radius + center.x
        y = sd.cos(angle * idx) * radius + center.y
        snake.set_start_position([x, y])
        snakes.append(snake)

    sd.sleep(0.1)
    sd.finish_drawing()

    dist = 15
    for step in range(210):
        dist -= step / 500
        sd.start_drawing()
        clear_screen()
        for snake in snakes:
            snake.go_forward(dist)
            snake.draw()

        sd.sleep(0.1)
        sd.finish_drawing()
        if sd.user_want_exit():
            break
Esempio n. 13
0
def second_screen():
    sd.start_drawing()
    sd.vector(start=sd.Point(x=230, y=260),
              angle=70,
              length=200,
              color=sd.COLOR_PURPLE,
              width=2)
    for i in range(10):
        point = sd.random_point()
        color = sd.random_color()
        radius = sd.random_number(20, 60)
        sd.circle(center_position=point, radius=radius, color=color, width=0)
    sd.finish_drawing()
    if TAKE_SNAPSHOTS:
        sd.take_snapshot(file_name='second_screen.png', path=SNAPSHOTS_PATH)
Esempio n. 14
0
def smile(x=sd.randint(0, 1200), y=sd.randint(0, 600),
          color=sd.random_color()):
    smile_cencer = sd.get_point(x, y)
    left_bottom = sd.get_point(x - 100, y - 75)
    right_top = sd.get_point(x + 100, y + 75)
    sd.ellipse(left_bottom, right_top, width=1, color=color)
    left_eye_center = sd.get_point(x - 40, y + 25)
    sd.circle(left_eye_center, 20, color=color)
    right_eye_center = sd.get_point(x + 40, y + 25)
    sd.circle(right_eye_center, 25, color=color)
    point_1 = sd.get_point(x - 50, y - 25)
    point_2 = sd.get_point(x - 25, y - 35)
    point_3 = sd.get_point(x + 25, y - 35)
    point_4 = sd.get_point(x + 50, y - 25)
    point_list = [point_1, point_2, point_3, point_4]
    sd.lines(point_list, color=color)
Esempio n. 15
0
def figure_draw(**kwargs):
    # расчет переменных
    start_point_figure = kwargs['start_point_figure']
    user_angle = kwargs['user_angle']
    angle1 = kwargs['angle']
    length1 = kwargs['length']
    width1 = kwargs['width']
    color = sd.random_color()
    point2 = start_point_figure
    angle_start = angle1
    angle_step = round(360 / user_angle)
    angle_finish = 361 - angle_step
    for angle_draw in range(angle_start, angle_finish, angle_step):  # рисование фигур
        arm = sd.get_vector(start_point=point2, angle=angle_draw, length=length1, width=width1)
        arm.draw(color=color)
        point2 = arm.end_point
    sd.line(start_point=start_point_figure, end_point=point2, color=color, width=width1)
Esempio n. 16
0
def bubble(center, radius, color, width, step):
    """
    Рисуем пузырь, три вложенных оружности
    :param center: центр окружности
    :param radius: радиус
    :param color: цвет, кротеж (123, 123, 123), если не кортеж, то выбираем случайный цвет
    :param width: толщина линии
    :param step: расстояние между вложенными окружностями
    """
    if not isinstance(color, tuple):
        color = sd.random_color()

    for _ in range(3):
        sd.circle(center_position=center,
                  radius=radius,
                  color=color,
                  width=width)
        radius = radius + step + width
Esempio n. 17
0
def third_screen():
    for i in range(10):
        point = sd.random_point()
        color = sd.random_color()
        dx = sd.random_number(30, 100)
        dy = sd.random_number(30, 100)
        right_top = sd.Point(x=point.x + dx, y=point.y + dy)
        sd.ellipse(left_bottom=point, right_top=right_top, color=color)
    v3 = sd.Vector(start_point=sd.Point(0, 0), direction=90, length=50)
    for direction in range(0, 181, 20):
        v = sd.Vector(start_point=sd.Point(x=300, y=300),
                      direction=direction,
                      length=100)
        v.draw(width=3)
        v2 = sd.Vector(start_point=v.end_point,
                       direction=direction + 30,
                       length=50)
        v2.draw(color=sd.COLOR_GREEN, width=2)
        v2.add(v3)
        v2.draw(color=sd.COLOR_ORANGE)
    sd.snowflake(center=sd.Point(), length=60, factor_b=0.2, factor_c=100)
    if TAKE_SNAPSHOTS:
        sd.take_snapshot(path=SNAPSHOTS_PATH)
Esempio n. 18
0
def brench(start_point, angle, length, delta_angle=50):

    if length < 5:
        return
    width = 4
    if length < 40:
        width = 1
    elif length < 100:
        width = 2

    vector = sd.get_vector(start_point=start_point,
                           angle=angle,
                           length=length,
                           width=width)
    vector.draw(sd.random_color())
    brench(start_point=vector.end_point,
           angle=angle - (delta_angle + randint(10, 20)),
           length=length * (randint(60, 80) / 100),
           delta_angle=delta_angle)
    brench(start_point=vector.end_point,
           angle=angle + (delta_angle + randint(10, 20)),
           length=length * (randint(60, 80) / 100),
           delta_angle=delta_angle)
Esempio n. 19
0
# (определение функций)
import simple_draw as sd


def smile(x, y, color):
    rad = 50
    radius = 10
    point = sd.get_point(x, y)
    point2 = sd.get_point(x-20, y+20)
    point3 = sd.get_point(x + 25, y + 20)
    point4 = sd.get_point(x-10, y-25)
    point5 = sd.get_point(x + 10, y-25)
    point6 = sd.get_point(x - 20, y - 20)
    point7 = sd.get_point(x + 22, y - 20)
    sd.circle(center_position=point, radius=rad, color=color,  width=1)
    sd.circle(center_position=point2, radius=radius, color=color, width=1)
    sd.circle(center_position=point3, radius=radius, color=color, width=1)
    sd.line(start_point=point4, end_point=point5, color=color, width=1)
    sd.line(start_point=point4, end_point=point6, color=color, width=1)
    sd.line(start_point=point5, end_point=point7, color=color, width=1)


for _ in range(10):
    x1 = sd.random_number(10, 500)
    y1 = sd.random_number(10, 500)
    color1 = sd.random_color()
    smile(x=x1, y=y1, color=color1)

sd.pause()

#зачет!
Esempio n. 20
0
    #sd.background_color = (255, 255, 255)
    if angle_count == 1:
        length = length + 0
        angle = angle + 2
    if angle_count < 1:
        return
    v1 = sd.get_vector(start_point=point, angle=angle, length=length, width=3)
    v1.draw(color=the_color)

    optiangle(angle_count=angle_count - 1,
              point=v1.end_point,
              angle=angle + step,
              length=length,
              step=step,
              the_color=the_color)


user_angle = input('Выберите фигуру :\n1.3angl\n2.4angl\n3.5angl\n4.6angl\n\n')
if user_angle == '1':
    optiangle(3, point_center, 30, 75, 120, sd.random_color())
elif user_angle == '2':
    optiangle(4, point_center, 30, 75, 90, sd.random_color())
elif user_angle == '3':
    optiangle(5, point_center, 30, 75, 72, sd.random_color())
elif user_angle == '4':
    optiangle(6, point_center, 30, 75, 60, sd.random_color())
else:
    print('Mudak')

sd.pause()
def hexagon_v2(_point, _length=200, _angle=0):
    shape_draw(_point=_point,
               _length=_length,
               _angle=_angle,
               _n_corner=6,
               _color=sd.random_color())
Esempio n. 22
0
def bubble(point, step):
    radius = 30
    for _ in range(3):
        color = sd.random_color()
        radius += step
        sd.circle(center_position=point, radius=radius, color=color, width=2)
Esempio n. 23
0
    for _ in range(3):
        radius += step
        sd.circle(center_position=point, radius=radius, width=2, color=color)


# point = sd.get_point(300, 300)
# bubble(point=point, step=10)

# Нарисовать 10 пузырьков в ряд
# TODO здесь ваш код
# for x in range(100, 1001, 100):
#     point = sd.get_point(x, 100)
#     bubble(point=point, step=5)

# Нарисовать три ряда по 10 пузырьков
# TODO здесь ваш код
# for y in range(100, 301, 100):
#     for x in range(100, 1001, 100):
#         point = sd.get_point(x, y)
#         bubble(point=point, step=5)

# Нарисовать 100 пузырьков в произвольных местах экрана случайными цветами
# TODO здесь ваш код
for _ in range(100):
    point = sd.random_point()
    color = sd.random_color()
    step = random.randint(2, 10)
    bubble(point=point, step=step, color=color)

sd.pause()
Esempio n. 24
0
import simple_draw as sd

sd.resolution = (1200, 600)


def bubble_paint(x, y, step):
    point = sd.get_point(x, y)
    radius = 50
    for _ in range(3):
        sd.circle(center_position=point, radius=radius, width=2)
        radius += step


# Нарисовать три ряда по 10 пузырьков
for y in range(100, 400, 100):
    for x in range(100, 1000, 90):
        bubble_paint(x, y, 5)

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

for _ in range(100):
    sd.circle(sd.random_point(), 50, sd.random_color())

sd.pause()
Esempio n. 25
0
    sd.circle(center_position=point, radius=radius, width=3)


# Написать функцию рисования пузырька, принммающую 2 (или более) параметра: точка рисовании и шаг
# TODO здесь ваш код
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())


buble(point, step=10, color=sd.random_color())
# Нарисовать 10 пузырьков в ряд
# TODO здесь ваш код
# for x in range(100,1100,100):
#     point = sd.get_point(x,100)
#     buble(point=point,step=5)
# Нарисовать три ряда по 10 пузырьков
# TODO здесь ваш код
# for x in range(100,1100,100):
#     for y in range(100,301,100):
#         point = sd.get_point(x, y)
#         buble(point=point,step=5)
# Нарисовать 100 пузырьков в произвольных местах экрана случайными цветами
# TODO здесь ваш код
for _ in range(100):
    point = sd.random_point()
Esempio n. 26
0
def bubble(x, y, step, colors, radius):
    for _ in range(step):
        radius += step
        circle(center_position=Point(x, y), radius=radius, color=colors)


# bubble(100, 100, 52, sd.COLOR_GREEN, 25)

# Нарисовать 10 пузырьков в ряд

# for x in range(100,1100,100):
#     circle(center_position=Point(x, 100), radius=50, color=sd.COLOR_DARK_RED)

# Нарисовать три ряда по 10 пузырьков

for y in range(100, 400, 100):
    for x in range(100, 1100, 100):
        circle(center_position=Point(x, y), radius=50, color=sd.COLOR_DARK_RED)

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

for i in range(100):
    x = random.randint(100, 1000)
    y = random.randint(100, 600)
    circle(center_position=Point(x, y), radius=40, color=sd.random_color())

sd.pause()

# зачет!
Esempio n. 27
0
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import simple_draw as sd

def smile_draw(x, y, color):
    radius = 80
    sd.circle(center_position=sd.get_point(x, y), color=color, radius=radius, width=2)

    for step in (-25, 25):
        eye = sd.get_point(x + step, y + 15)
        sd.circle(center_position=eye, color=color, radius=5, width=2)

    for i in range(45, 140):
        start_point = sd.get_point(x - 90 + i, y + 50 - 100 * sd.sin(i))
        end_point = sd.get_point(x - 90 + i, y + 50 - 100 * sd.sin(i))
        sd.line(start_point=start_point, end_point=end_point, color=color, width=2)

for _ in range(10):
    smile_draw(x=sd.random_point().x, y=sd.random_point().y, color=sd.random_color())

sd.pause()
Esempio n. 28
0
# (определение функций)
import simple_draw as sd

# Написать функцию отрисовки смайлика по заданным координатам
# Форма рожицы-смайлика на ваше усмотрение
# Параметры функции: кордината X, координата Y, цвет.
# Вывести 10 смайликов в произвольных точках экрана.


def smile(x, y, color):
    radius = 50
    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)
    left_point = sd.get_point(x=x - radius // 2, y=y - radius // 3)
    right_point = sd.get_point(x=x + radius // 2, y=y - radius // 3)
    sd.line(start_point=left_point, end_point=right_point, width=3, color=sd.COLOR_BLACK)


for _ in range(10):
    smile(sd.random_number(50, 500), sd.random_number(50, 500), sd.random_color())
sd.pause()

# Зачёт!
Esempio n. 29
0
def draw_bubble(center_coordinate, radius):
    for _ in range(3):
        radius += 5
        sd.circle(center_position=center_coordinate, radius=radius, color=sd.random_color())
Esempio n. 30
0
    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))


for _ in range(10):
    draw_smile(sd.randint(100, 600), sd.randint(100, 600), sd.random_color())

sd.pause()
def square_v2(_point, _length=200, _angle=0):
    shape_draw(_point=_point,
               _length=_length,
               _angle=_angle,
               _n_corner=4,
               _color=sd.random_color())