Exemple #1
0
def draw_figure(point, angle, length, step, side, color=sd.COLOR_YELLOW):
    for line in range(side):
        v = sd.Vector(start_point=point,
                      direction=angle + line * step,
                      length=length)
        v.draw(color=color, width=2)
        point = v.end_point
def branch(point, angle, length):
    if length < 5:
        return
    delta_random = sd.random_number(-14, 14)
    vector = sd.Vector(point, angle, length)
    vector.draw()
    coif_length = sd.random_number(-12, 12)
    coif_length = 75 + coif_length
    next_length = length * float(coif_length / 100)
    branch(vector.end_point, angle - 30 - delta_random, next_length)
    branch(vector.end_point, angle + 30 + delta_random, next_length)
Exemple #3
0
def draw_wall(startPointX=200,
              startPointY=0,
              finishPointX=800,
              finishPointY=500,
              brickWidth=100,
              brickHight=50):

    brickStep = 0

    start_x = startPointX

    finish_y = startPointY

    while finish_y < finishPointY:
        if brickStep % 2 == 0:
            startPointX += brickWidth / 2
            finish_x = finishPointX - brickWidth / 2
        else:
            finish_x = finishPointX
        while startPointX < finish_x:
            startPoint = sd.get_point(startPointX, finish_y)
            endPoint = sd.get_point(startPointX + brickWidth, finish_y + brickHight)
            sd.rectangle(startPoint, endPoint, width=2)
            startPointX += brickWidth
        finish_y += brickHight
        startPointX = start_x
        brickStep += 1

    line_left = sd.Vector(sd.get_point(startPointX, 0), 90, finishPointY, 2)

    line_right = sd.Vector(sd.get_point(finishPointX, 0), 90, finishPointY, 2)

    line_down = sd.Vector(sd.get_point(startPointX, startPointY + 2), 0, finishPointX - startPointX, 2)

    line_left.draw()

    line_right.draw()

    line_down.draw()
Exemple #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)
Exemple #5
0
def draw_tree(start_point=sd.get_point(600, 0),
              angle=90,
              length=130,
              color=sd.COLOR_DARK_GREEN,
              width=3):

    if length < 10:
        return

    if length < 25:
        color = sd.COLOR_GREEN
        width = 1

    vector = sd.Vector(start_point, angle, length, width)
    vector.draw(color)
    draw_tree(vector.end_point, angle - 30, length * 0.75)
    draw_tree(vector.end_point, angle + 30, length * 0.75)