Esempio n. 1
0
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)
Esempio n. 2
0
 def _build_side_spokes(center, radius_out, radius_in, offset_out):
     step_angle = 360 // 9
     offset_in = step_angle // 2
     for angle in range(0, 360, step_angle):
         point1_in = sd.get_point(x=sd.cos(angle) * radius_in + center.x,
                                  y=sd.sin(angle) * radius_in + center.y)
         point1_out = sd.get_point(
             x=sd.cos(angle + offset_out) * radius_out + center.x,
             y=sd.sin(angle + offset_out) * radius_out + center.y)
         point2_in = sd.get_point(
             x=sd.cos(angle + offset_in) * radius_in + center.x,
             y=sd.sin(angle + offset_in) * radius_in + center.y)
         point2_out = sd.get_point(
             x=sd.cos(angle - offset_out + offset_in) * radius_out +
             center.x,
             y=sd.sin(angle - offset_out + offset_in) * radius_out +
             center.y)
         sd.line(point1_in, point1_out, color=COLOR_GREY, width=2)
         sd.line(point2_in, point2_out, color=COLOR_GREY, width=2)
Esempio n. 3
0
def draw_branches(start_point, angle, lenght, width):
    lenght *= 0.8
    if width > 1:
        width -= 1
    if lenght > 10:
        sd.vector(start_point, angle - 30, lenght, color='black', width=width)
        sd.vector(start_point, angle + 30, lenght, color='black', width=width)
        new_point_1 = sd.get_point(start_point.x + sd.cos(angle - 30) * lenght,
                                   start_point.y + sd.sin(angle - 30) * lenght)
        new_point_2 = sd.get_point(start_point.x + sd.cos(angle + 30) * lenght,
                                   start_point.y + sd.sin(angle + 30) * lenght)
        draw_branches(new_point_1, angle - sd.randint(15, 45),
                      lenght * sd.randint(90, 110) / 100, width)
        draw_branches(new_point_2, angle + sd.randint(15, 45),
                      lenght * sd.randint(90, 110) / 100, width)
    else:
        new_point_1 = sd.get_point(start_point.x + sd.cos(angle - 30) * lenght,
                                   start_point.y + sd.sin(angle - 30) * lenght)
        new_point_2 = sd.get_point(start_point.x + sd.cos(angle + 30) * lenght,
                                   start_point.y + sd.sin(angle + 30) * lenght)
        color = (sd.randint(0, 100), sd.randint(140, 250), sd.randint(10, 40))
        sd.circle(new_point_1, 5, color=color, width=0)
        sd.circle(new_point_2, 5, color=color, width=0)
Esempio n. 4
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. 5
0
def flip_paper(index_points,
               index_axe_points,
               idx_purpose_first,
               steps,
               callback=None):
    points = [plain.vertices[idx] for idx in index_points]
    axe_points = [plain.vertices[idx] for idx in index_axe_points]
    radii = []
    for point in points:
        radius = distance_point_to_line(pa=point,
                                        pb1=axe_points[0],
                                        pb2=axe_points[1])
        radii.append(radius)

    # center = list(map(lambda a: (a[0] + a[1]) // 2, zip(axe_points[0], axe_points[1])))
    purpose_first = plain.vertices[idx_purpose_first]
    center = list(
        map(lambda a: (a[0] + a[1]) // 2, zip(purpose_first, points[0])))
    vector = list(map(lambda a: a[0] - a[1], zip(center, points[0])))
    normal_vector = list(map(lambda a: a / radii[0], vector))
    centers = []
    for point, radius in zip(points, radii):
        delta_vec = list(map(lambda a: int(a * radius), normal_vector))
        center_p = list(map(lambda a: (a[0] + a[1]), zip(point, delta_vec)))
        centers.append(center_p)

    for step in range(int(steps)):
        if steps // 2 - 1 == step and callback:
            result = callback()
            callback = None
            if result == "finish":
                return

        sd.start_drawing()
        clear_screen()
        angle = 180 * (step + 1) / steps
        z = sd.sin(angle)
        percent_dist = sd.cos(angle)
        for point, radius, center_p in zip(points, radii, centers):
            vec_p = list(
                map(lambda a: int(-a * radius * percent_dist), normal_vector))
            point[0] = center_p[0] + vec_p[0]
            point[1] = center_p[1] + vec_p[1]
            point[2] = center_p[2] + int(z * radius)

        plain.render(color=COLOR, color_back=COLOR_BACK)
        sd.finish_drawing()
        sd.sleep(0.1)
Esempio n. 6
0
def show_figure1():
    word = "skillbox"
    dist = 15
    for i in range(50):
        start_spell = sd.get_point(100, 250)
        sd.start_drawing()
        clear_screen()
        for idx, ch in enumerate(word):
            scale_val = abs(sd.sin(idx * 20 + i * 10)) * 0.2 + 0.2
            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.x += segments[ch]['width'] * scale_val + dist

        sd.sleep(0.1)
        sd.finish_drawing()
        if sd.user_want_exit():
            break
Esempio n. 7
0
    red_line.draw(color=color_red, width=5)
    end_point = red_line.end_point
    blue_line = sd.get_vector(start_point=end_point, angle=angle, length=50)
    blue_line.draw(color=color_blue, width=5)
    end_point = blue_line.end_point
    white_line = sd.get_vector(start_point=end_point, angle=angle, length=50)
    white_line.draw(color=color_white, width=5)


for move_wave in range(0, 600, 1):
    sd.start_drawing()
    sd.rectangle(left_bottom=sd.get_point(0, 0), right_top=sd.get_point(*sd.resolution),
                 color=sd.background_color, width=0)

    point = sd.get_point(x=200, y=-30)
    stick = sd.get_vector(start_point=point, angle=90 - sd.sin(move_wave * 10) * 30, length=150)
    point_end_stick = stick.end_point

    angle_flag = 90 - sd.sin(move_wave * 10) * 30
    for x in range(10, 300, 1):
        angle = -move_wave * 20 + x
        point = sd.get_point(x=point_end_stick.x + x, y=point_end_stick.y + sd.sin(angle) * 40 * x / 300)
        draw_flag(point=point, correct_color=sd.cos(angle * 0.5 - 60), angle=angle_flag)

    stick.draw(color=sd.COLOR_DARK_YELLOW, width=15)
    sd.vector(start=point_end_stick, angle=angle_flag, length=160, width=15, color=sd.COLOR_DARK_YELLOW)

    sd.finish_drawing()
    if sd.user_want_exit():
        break
    sd.sleep(0.1)
def angular_to_decart(distance: int, angle: int):
    x = int(distance * sd.cos(angle))
    y = int(distance * sd.sin(angle))
    return x, y
Esempio n. 9
0
 def get_point_from_angle(center, angle, radius):
     x = sd.cos(angle) * radius + center.x
     y = sd.sin(angle) * radius + center.y + 1
     return sd.get_point(x, y)
Esempio n. 10
0
def angular_to_decart(distance, angle):
    x = int(distance * sd.cos(angle))
    y = int(distance * sd.sin(angle))
    return (x, y)