Пример #1
0
def first_screen():
    points = [
        sd.Point(x=230, y=450),
        sd.Point(x=240, y=460),
        sd.Point(x=230, y=470),
        sd.Point(x=240, y=480),
    ]
    sd.polygon(point_list=points)
    points2 = [sd.Point(p.x + 20, p.y + 20) for p in points]
    sd.lines(point_list=points2, color=sd.COLOR_DARK_ORANGE, width=2)
    sd.line(start_point=sd.Point(x=20, y=20),
            end_point=sd.Point(x=40, y=300),
            width=2)
    sd.square(left_bottom=sd.Point(
        400,
        300,
    ), side=100, width=2)
    sd.rectangle(
        left_bottom=sd.Point(x=200, y=200),
        right_top=sd.Point(x=300, y=300),
        color=sd.COLOR_DARK_GREEN,
        width=2,
    )
    sd.rectangle(
        left_bottom=sd.Point(x=400, y=300),
        right_top=sd.Point(x=300, y=400),
        color=sd.COLOR_DARK_GREEN,
        width=2,
    )
    if TAKE_SNAPSHOTS:
        sd.take_snapshot(path=SNAPSHOTS_PATH)
Пример #2
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)
Пример #3
0
def massive_snowfall():
    flakes = [Snowflake() for _ in range(100)]

    while True:
        sd.start_drawing()
        for flake in flakes:
            flake.draw(color=sd.background_color)
        fallen_count = 0
        for flake in flakes:
            if flake.move():
                fallen_count += 1
        for flake in flakes:
            flake.draw(color=sd.COLOR_WHITE)
        for _ in range(fallen_count):
            flakes.append(Snowflake())
        sd.finish_drawing()
        if TAKE_SNAPSHOTS:
            sd.take_snapshot(path=SNAPSHOTS_PATH)
        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
Пример #4
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)
Пример #5
0
                                   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)


limit = 1000

sd.resolution = (1200, 800)
sd.background_color = 'white'
middle = sd.get_point(600, 0)
root_point = sd.get_point(600, 200)
sd.line(middle, root_point, color='black', width=15)
test = sd.get_vector(root_point, 30, 200)

draw_branches(root_point, 90, 100 / 0.8, 10)

sd.pause()
sd.take_snapshot('Tree.png')