Beispiel #1
0
def danglingDataSystem():
    srcData = readFile3(logDir + srcSystemDanglingData)
    dstData = readFile3(logDir + dstSystemDanglingData)
    danglingLikes, danglingComments, danglingMessages = getDanglingDataInSrcSystem(
        srcData)
    danglingStatuses, danglingFav = getDanglingDataInDstSystem(dstData)

    x = getPercentageInX()

    data = [
        danglingLikes, danglingComments, danglingMessages, danglingStatuses,
        danglingFav
    ]
    title = [
        'Dangling likes without posts in Diaspora',
        'Dangling comments without posts in Diaspora',
        'Dangling messages without conversations in Diaspora',
        'Dangling statuses without conversations in Mastodon',
        'Dangling favourites without statuses in Mastodon'
    ]
    xs = 'Percentage of migrated users'
    ys = [
        'Num of dangling likes', 'Num of dangling comments',
        'Num of dangling messages', 'Num of dangling statuses',
        'Num of dangling favourites'
    ]
    for i in range(len(data)):
        g.line(x, data[i], xs, ys[i], title[i])
Beispiel #2
0
def heart(a, b):
    line(a, b, a - 20, b - 80)
    penColor(255, 0, 0)
    brushColor(255, 0, 0)
    polygon([(a - 20, b - 80), (a - 7, b - 140), (a - 62, b - 120), (a - 20, b - 80)])
    circle(a - 25, b - 135, 18)
    circle(a - 47, b - 128, 18)
Beispiel #3
0
def apple(x, y, size, mirror):
    """
    apple function draws the apple of the radius r pxls for size = 1
        there are 3 components:
                1) main body
                2) root, represented by a line
                3) leaf, which is obviously a sqrt curve

            The coords of root and leaf are given regarding to r of an main body,
            so all "strange" numbers in the further functions are also just a calibrate number for beauty's purposes
            (._.)

            mirror is for drawing mirrored images
    """
    # apple body
    penColor(245, 84, 84)
    penSize(0)
    brushColor(245, 84, 84)
    circle(x, y, 25 * size)
    # root
    penColor("black")
    penSize(2 * size)
    line(x, y - size * 20, x + size * 12.5 * mirror, y - size * 42.5)
    # leaf
    brushColor(100, 225, 100)
    penSize(size)
    polygon(curve(x + size * 2.5 * mirror, y - size * 27.5, size, mirror))
def dragon(n, x0, y0, x1, y1, q):
    if n == 0:
        graph.line(x0, y0, x1, y1)
    else:
        alf1 = alf * q
        _x = math.cos(alf1) * ((x1 - x0) * math.cos(alf1) - (y1 - y0) * math.sin(alf1)) + x0
        _y = math.cos(alf1) * ((x1 - x0) * math.sin(alf1) + (y1 - y0) * math.cos(alf1)) + y0
        dragon(n - 1, x0, y0, _x, _y, 1)
        dragon(n - 1, _x, _y, x1, y1, -1)
Beispiel #5
0
def gradient(R=225, G=0, B=0):
    i = 0
    global k
    penSize(1)
    R = R / (300 * k)
    G = G / (300 * k)
    B = B / (300 * k)
    print(R, G, B)
    while i < 300 * k:
        penColor(int(R * i) + 20, int(G * i) + 20, int(B * i) + 20)
        line(0, i, 200 * k, i)
        i += 1
Beispiel #6
0
def horns(x, y, size, color="red"):
    """
    note: it is possible to change the cf alien's ball (horn balls)
    """
    penSize(0.5 * size)
    line(x + 1.6 * size, y - 3 * size, x + 2.2 * size, y - 4 * size)
    line(x - 1.6 * size, y - 3 * size, x - 2.2 * size, y - 4 * size)

    brushColor(color)
    penSize(0.15 * size)
    circle(x + 2.3 * size, y - 4.1 * size, 0.3 * size)
    circle(x - 2.3 * size, y - 4.1 * size, 0.3 * size)
def bird(scale: float = 1., angle: float = 0.):
    """Draw a scaled and turned instance of a bird"""
    pts = turn(scale_reflect(bird_pts(), scale, False), angle)
    lines = []
    for i in range(len(pts) - 1):
        lines.append(line(*pts[i], *pts[i + 1]))
        lines.append(point(*pts[1]))
    return lines
Beispiel #8
0
def draw_an_umbrella(umbrella_base_x, umbrella_base_y,
                     umbrella_stick_length, umbrella_stick_width,
                     umbrella_triangle_base, umbrella_triangle_height):
    g.penSize(umbrella_stick_width)
    umbrella_color = '#c56200'
    g.penColor(umbrella_color)

    fi = math.pi / 180 * 20
    for _ in range(umbrella_stick_length // 2):
        dx_umbrella = math.sin(fi) * 2
        dy = math.cos(fi) * 2
        g.line(umbrella_base_x, umbrella_base_y,
               umbrella_base_x + dx_umbrella, umbrella_base_y - dy)  # umbrella_triangle_left_angle_y)
        umbrella_base_x += dx_umbrella
        umbrella_base_y -= dy
        fi += math.pi / 180 * 0.5

    umbrella_triangle_right_angle_x = umbrella_base_x + umbrella_triangle_base * math.cos(fi) / 2
    umbrella_triangle_left_angle_y = umbrella_base_y - umbrella_triangle_base * math.sin(fi) / 2

    umbrella_triangle_left_angle_x = umbrella_base_x - umbrella_triangle_base * math.cos(fi) / 2
    umbrella_triangle_right_angle_y = umbrella_base_y + umbrella_triangle_base * math.sin(fi) / 2

    umbrella_top_angle_x = umbrella_base_x + umbrella_triangle_height * math.sin(fi)
    umbrella_top_angle_y = umbrella_base_y - umbrella_triangle_height * math.cos(fi)

    g.penSize(pen_width_1)
    g.penColor('black')

    g.brushColor('#f66347')
    g.polygon([(umbrella_triangle_left_angle_x, umbrella_triangle_left_angle_y),
               (umbrella_triangle_right_angle_x, umbrella_triangle_right_angle_y),
               (umbrella_top_angle_x, umbrella_top_angle_y)])

    number_of_needle = 6
    needle_base_point_x = umbrella_triangle_left_angle_x
    needle_base_point_y = umbrella_triangle_left_angle_y
    step_needle_x = umbrella_triangle_base / 7 * math.cos(fi)
    step_needle_y = umbrella_triangle_base / 7 * math.sin(fi)
    for _ in range(number_of_needle):
        needle_base_point_x += step_needle_x
        needle_base_point_y += step_needle_y

        g.line(umbrella_top_angle_x, umbrella_top_angle_y,
               needle_base_point_x, needle_base_point_y)
Beispiel #9
0
def cat_head(x0, y0, size, direction, color):
    """Drawing cat head with eyes and nose - all variables sam as for body."""
    x1 = x0 - direction * size
    y1 = y0
    head_size = size / 3

    oval(x1 - direction * head_size * sin(pi / 4),
         y1 + head_size * cos(pi / 4) / 1.5, size / 4, 3, pi / 2)
    graph.circle(x1, y1, head_size)

    if color == 'brown':
        graph.brushColor(135, 170, 0)
    else:
        graph.brushColor(40, 215, 255)
    graph.circle(x1 - head_size / 2, y1, head_size / 4)
    graph.circle(x1 + head_size / 2, y1, head_size / 4)

    graph.brushColor(0, 0, 0)
    oval(x1 - head_size / 2 + head_size / 10, y1,
         head_size / 4 - head_size / 30, 4, pi / 2)
    oval(x1 + head_size / 2 + head_size / 10, y1,
         head_size / 4 - head_size / 30, 4, pi / 2)

    graph.penColor(250, 250, 250)
    graph.brushColor(250, 250, 250)
    oval(x1 - head_size / 2 - head_size / 14, y1 - head_size / 12,
         head_size / 4 - head_size / 9, 4, pi / 4)
    oval(x1 + head_size / 2 - head_size / 14, y1 - head_size / 12,
         head_size / 4 - head_size / 9, 4, pi / 4)

    graph.penColor(0, 0, 0)
    graph.brushColor(225, 170, 135)
    nose = [(x1 + head_size / 15, y1 + head_size / 3),
            (x1 - head_size / 15, y1 + head_size / 3),
            (x1, y1 + head_size / 3 + head_size / 10)]
    graph.polygon(nose)

    graph.line(x1, y1 + head_size / 3 + head_size / 10, x1, y1 + head_size / 2)
    sector(x1 - head_size / 8, y1 + head_size / 2, head_size / 8, 0,
           pi / 2 + pi / 6, 1)
    sector(x1 + head_size / 8, y1 + head_size / 2, head_size / 8,
           pi / 2 - pi / 6, pi, 1)

    cat_ears(x1, y1, head_size, color)
    cat_mustache(x1, y1, head_size)
Beispiel #10
0
def cat(x0, y0, size):
    """Body"""
    graph.brushColor("#C87137")
    ellipse(x0, y0, 250 * size, 115 * size, 0, size)

    """Head"""
    graph.brushColor("#C87137")
    ellipse(x0 - 230 * size, y0 - 20 * size,
            80, 80, 0, size)

    """Nose"""
    graph.polygon([(x0 - 220 * size, y0 + 10 * size),
                   (x0 - 240 * size, y0 + 10 * size),
                   (x0 - 230 * size, y0 + 20 * size)])
    graph.penSize(2)
    graph.penColor("black")
    graph.line(x0 - 230 * size, y0 + 20 * size,
               x0 - 230 * size, y0 + 40 * size)
    graph.polyline(
        [(x0 - 230 * size, y0 + 40 * size),
         (x0 - 229 * size, y0 + 41 * size),
         (x0 - 229 * size, y0 + 42 * size),
         (x0 - 228 * size, y0 + 41 * size),
         (x0 - 227 * size, y0 + 42 * size),
         (x0 - 220 * size, y0 + 42 * size),
         (x0 - 217 * size, y0 + 40 * size),
         (x0 - 214 * size, y0 + 37 * size),
         (x0 - 214 * size, y0 + 33 * size)])
    graph.polyline(
        [(x0 - 230 * size, y0 + 40 * size),
         (x0 - 231 * size, y0 + 41 * size),
         (x0 - 231 * size, y0 + 42 * size),
         (x0 - 232 * size, y0 + 41 * size),
         (x0 - 233 * size, y0 + 42 * size),
         (x0 - 240 * size, y0 + 42 * size),
         (x0 - 243 * size, y0 + 40 * size),
         (x0 - 246 * size, y0 + 37 * size),
         (x0 - 246 * size, y0 + 33 * size)])
Beispiel #11
0
def timeVsSize(stencilConnection,
               stencilCursor,
               destApp,
               startTime=None,
               endTime=None):
    if startTime == None or endTime == None:
        migrationIDs = pd.getAllMigrationIDs(stencilConnection, stencilCursor)
    else:
        migrationIDs = pd.getMigrationIDsBetweenTimestamps(
            stencilConnection, stencilCursor, startTime, endTime)
    time = []
    size = []
    for migrationID in migrationIDs:
        print migrationID
        l = pd.getLengthOfMigration(migrationID, stencilCursor)
        if l == None:
            continue
        else:
            time.append(l)
            size.append(
                pd.getMigratedDataSize(destApp, migrationID, stencilCursor))
    _log("timeVsSize", [time, size])
    g.line(size, time, "Migration Size (KB)", "Migration Time (s)",
           "Migration Time Vs Migration Size")
Beispiel #12
0
def draw_an_umbrella(umbrella_base_x, umbrella_base_y, umbrella_stick_length,
                     umbrella_stick_width, umbrella_triangle_base,
                     umbrella_triangle_height):

    umbrella_triangle_left_angle_x = umbrella_base_x - umbrella_triangle_base / 2
    umbrella_triangle_left_angle_y = umbrella_base_y - umbrella_stick_length

    umbrella_triangle_right_angle_x = umbrella_triangle_left_angle_x + umbrella_triangle_base
    umbrella_triangle_right_angle_y = umbrella_triangle_left_angle_y

    umbrella_top_angle_x = umbrella_base_x
    umbrella_top_angle_y = umbrella_triangle_left_angle_y - umbrella_triangle_height

    g.penSize(umbrella_stick_width)
    umbrella_color = '#c56200'
    g.penColor(umbrella_color)
    g.line(umbrella_base_x, umbrella_base_y, umbrella_base_x,
           umbrella_triangle_left_angle_y)

    g.penSize(pen_width_1)
    g.penColor('black')

    g.brushColor('#f66347')
    g.polygon([
        (umbrella_triangle_left_angle_x, umbrella_triangle_left_angle_y),
        (umbrella_triangle_right_angle_x, umbrella_triangle_right_angle_y),
        (umbrella_top_angle_x, umbrella_top_angle_y)
    ])

    number_of_needle = 6
    needle_base_point_x = umbrella_triangle_left_angle_x
    step_needle = umbrella_triangle_base / 7
    for i in range(number_of_needle):
        needle_base_point_x += step_needle
        g.line(umbrella_top_angle_x, umbrella_top_angle_y, needle_base_point_x,
               umbrella_triangle_left_angle_y)
Beispiel #13
0
def grabla(x1, y1, x2, y2):
    n = 5
    a = int(((x2 - x1)**2)**0.5 // (x2 - x1))
    penSize(15)
    colour = random.randint(-1, 1)
    penColor(112 + colour // 3, 66, 65)
    brushColor(112 + colour // 3, 66, 65)
    penSize(1)
    for i in range(x1, x2, a):
        n += random.random() * ((-1)**i)
        if n > 9:
            n -= 1
        elif n < 3:
            n += 1

        yy1 = (y2 - y1) * (i - x1) / (x2 - x1) + y1
        colour += random.randint(-5, 4)
        penColor(112 + colour, 66, 65)
        brushColor(112 + colour, 66, 65)
        circle(i, yy1, n)

    tan = (yy1 - y1) / (x2 - x1)

    alpha = 3.14 / 2 + math.atan(tan)

    bx = int(50 * math.sin(alpha))
    by = int(50 * math.cos(alpha))
    penSize(10)
    penColor(53, 50, 51)
    line(x2 + bx, yy1 + by, x2 - bx, yy1 - by)
    for i in range(x2 - bx, x2 + bx, 7):
        penSize(3)
        y = yy1 + by + by * (i - x2 - bx) / bx
        penSize(5)
        penColor(53, 50, 51)
        line(i, y, i, y - 18)
        penSize(2)
        penColor(66, 63, 64)
        line(i - 2, y, i - 2, y - 17)
Beispiel #14
0
umbrella_triangle_base = 138 
umbrella_triangle_height = 33

umbrella_triangle_left_angle_x = umbrella_base_x - umbrella_triangle_base / 2 
umbrella_triangle_left_angle_y = umbrella_base_y - umbrella_stick_length

umbrella_triangle_right_angle_x = umbrella_triangle_left_angle_x + umbrella_triangle_base
umbrella_triangle_right_angle_y = umbrella_triangle_left_angle_y

umbrella_top_angle_x = umbrella_base_x
umbrella_top_angle_y = umbrella_triangle_left_angle_y - umbrella_triangle_height

g.penSize(umbrella_stick_width)
umbrella_color = '#c56200'
g.penColor(umbrella_color)
g.line(umbrella_base_x, umbrella_base_y, 
       umbrella_base_x, umbrella_triangle_left_angle_y)

g.penSize(pen_width_1)
g.penColor('black')

g.brushColor('#f66347')
g.polygon([(umbrella_triangle_left_angle_x, umbrella_triangle_left_angle_y),
           (umbrella_triangle_right_angle_x, umbrella_triangle_right_angle_y),
           (umbrella_top_angle_x, umbrella_top_angle_y)])

number_of_needle = 6
needle_base_point_x = umbrella_triangle_left_angle_x
step_needle = umbrella_triangle_base / 7
for i in range(number_of_needle):
    needle_base_point_x += step_needle
    g.line(umbrella_top_angle_x, umbrella_top_angle_y, 
Beispiel #15
0
def umbrella(x, y, s):
    graph.penColor('#e38219')
    graph.brushColor('#e38219')
    d_stolbik = 0.01 * d * s
    h_stolbik = 0.43 * h * s
    d_zont = 3 / 24 * d * s
    h_zont = 3 / 49 * h * s
    graph.rectangle(x, y, x + d_stolbik, y + h_stolbik)
    graph.penColor('#f45151')
    graph.brushColor('#f45151')
    graph.polygon([(x, y), (x - d_zont, y + h_zont), (x, y + h_zont), (x, y)])
    graph.rectangle(x, y, x + d_stolbik, y + h_zont)
    graph.polygon([(x + d_stolbik, y), (x + d_stolbik + d_zont, y + h_zont),
                   (x + d_stolbik, y + h_zont), (x + d_stolbik, y)])
    graph.penColor('#000000')
    graph.line(x, y, x - 0.1 * d_zont, y + h_zont)
    graph.line(x, y, x - 0.4 * d_zont, y + h_zont)
    graph.line(x, y, x - 0.7 * d_zont, y + h_zont)
    graph.line(x + d_stolbik, y, x + d_stolbik + 0.1 * d_zont, y + h_zont)
    graph.line(x + d_stolbik, y, x + d_stolbik + 0.4 * d_zont, y + h_zont)
    graph.line(x + d_stolbik, y, x + d_stolbik + 0.7 * d_zont, y + h_zont)
Beispiel #16
0
def draw_a_ship(ship_bow_x, ship_size):
    ship_bow_y = sea_upper_left_point_y + ship_size * (225 -
                                                       sea_upper_left_point_y)

    ship_keel_x = ship_bow_x - ship_size * 65
    ship_keel_y = ship_bow_y + ship_size * 28

    ship_stern_top_x = ship_bow_x - ship_size * 209
    ship_stern_top_y = ship_bow_y

    ship_stern_bottom_x = ship_stern_top_x
    ship_stern_bottom_y = ship_keel_y

    ship_color = '#df6f0d'
    g.penColor(ship_color)
    g.brushColor(ship_color)
    ship_stern_radius = ship_stern_bottom_y - ship_stern_top_y

    points_of_ship = [(ship_stern_bottom_x, ship_stern_bottom_y),
                      (ship_keel_x, ship_keel_y), (ship_bow_x, ship_bow_y),
                      (ship_stern_top_x - ship_stern_radius, ship_stern_top_y)]

    points_of_ship += points_of_stern(ship_stern_top_x, ship_stern_top_y,
                                      ship_stern_radius)
    object_1 = g.polygon(points_of_ship)

    g.penColor(sea_color)
    g.penSize(pen_width_1)
    object_2 = g.line(ship_stern_top_x, ship_stern_top_y, ship_stern_bottom_x,
                      ship_stern_bottom_y)
    object_3 = g.line(ship_keel_x, ship_bow_y, ship_keel_x, ship_keel_y)

    ship_porthole_center_x = ship_bow_x - ship_size * 50
    ship_porthole_center_y = ship_bow_y + ship_size * 11
    ship_porthole_radius = ship_size * 7
    porthole_pen_width = ship_size * 3.25
    g.penSize(porthole_pen_width)
    g.penColor('black')
    portole_color = 'white'
    g.brushColor(portole_color)
    object_4 = g.circle(ship_porthole_center_x, ship_porthole_center_y,
                        ship_porthole_radius)

    mast_base_x = ship_bow_x - ship_size * 150
    mast_base_y = ship_bow_y
    mast_hight = ship_size * 96
    mast_width = ship_size * 6

    g.penSize(mast_width)
    mast_color = 'black'
    g.penColor(mast_color)
    object_5 = g.line(mast_base_x, mast_base_y, mast_base_x,
                      mast_base_y - mast_hight)

    sail_top_mount_x = mast_base_x
    sail_top_mount_y = mast_base_y - mast_hight
    sail_bottom_mount_x = mast_base_x
    sail_bottom_mount_y = mast_base_y
    sail_left_edge_x = ship_bow_x - ship_size * 134
    sail_left_edge_y = (sail_top_mount_y + sail_bottom_mount_y) / 2
    sail_right_edge_x = ship_bow_x - ship_size * 96
    sail_right_edge_y = sail_left_edge_y

    g.penSize(pen_width_1)
    g.penColor('black')
    sail_color = '#c9c094'
    g.brushColor(sail_color)
    object_6 = g.polygon([(sail_top_mount_x, sail_top_mount_y),
                          (sail_left_edge_x, sail_left_edge_y),
                          (sail_right_edge_x, sail_right_edge_y)])
    object_7 = g.polygon([(sail_bottom_mount_x, sail_bottom_mount_y),
                          (sail_left_edge_x, sail_left_edge_y),
                          (sail_right_edge_x, sail_right_edge_y)])

    return [
        object_1, object_2, object_3, object_4, object_5, object_6, object_7
    ]
brushColor('white')

circle(140, 165, 35)
circle(260, 165, 35)

# that thing inside eyes
brushColor(175, 133, 133)

circle(140, 165, 8)
circle(260, 165, 8)

# eyebrows
penColor(119, 78, 78)
penSize(15)

line(110, 135, 170, 140)
line(230, 145, 290, 125)

# mouth/moustache or how do u wanna call it
# by crossing over each other circles
x = 140
y = 260
n = 5
brushColor(119, 78, 78)

for i in range(7):
    circle(x, y, n)
    x += 8
    y -= 5**(i**0.2)
    n += 2
Beispiel #18
0
center = 10  # половина центральной части платформы

width = 800  # Размер экрана
height = 600  # Размер экрана
radius = 10  # Радиус шарика
FrameSize = 6
graph.windowSize(width + 50, height + 50)  # размер окна
graph.canvasSize(width, height)  # размер холста
graph.canvasPos(0, 0)  # позиция холста

objects = ControllerClass('position.txt', width, height, FrameSize,
                          radius)  # объект контроллера

graph.penColor('black')  # цвет рамки
graph.penSize(FrameSize)  # ширина рамки
graph.line(5, 5, 5, height)  # левая сторона рамки
graph.line(5, 5, width, 5)  # верхняя сторона рамки
graph.line(width, 5, width, height)  # правая сторона рамки


def mov(event):
    objects.brusochek.mov(width, event.keycode)


def update():

    for dot in objects.dots:

        if objects.brusochek.p != 0:

            dot.circleInWindow()
Beispiel #19
0
elips(794 * 900 / 1123 * 0.15, 900 * 0.49, 794 * 900 / 1123 * 0.35, 3)
elips(2, 900 * 0.7, 794 * 900 / 1123 * 0.3, 0.3)
graph.penSize(5)
graph.polyline([(794 * 900 / 1123 * 0.3 + 5, 900 * 0.65),
                (794 * 900 / 1123 * 0.37, 900 * 0.565),
                (794 * 900 / 1123 * 0.8, 900 * 0.3)])
graph.penSize(1)
graph.elips(794 * 900 / 1123 * 0.25, 900 * 0.595, 794 * 900 / 1123 * 0.4, 4)
graph.elips(794 * 900 / 1123 * 0.15, 900 * 0.84, 794 * 900 / 1123 * 0.4, 1.7)
graph.elips(794 * 900 / 1123 * 0.32, 900 * 0.9, 794 * 900 / 1123 * 0.5, 6)
graph.circle(794 * 900 / 1123 * 0.18, 900 * 0.46, 10)
graph.brushColor(77, 77, 77)
elips(794 * 900 / 1123 * 0.55, 900 * 0.79, 794 * 900 / 1123 * 0.9, 10)
graph.brushColor(22, 80, 68)
elips(794 * 900 / 1123 * 0.6, 900 * 0.8, 794 * 900 / 1123 * 0.85, 10)
graph.line(794 * 900 / 1123 * 0.8, 900 * 0.3, 794 * 900 / 1123 * 0.8,
           900 * 0.8)
graph.brushColor("black")
graph.circle(794 * 900 / 1123 * 0.235, 900 * 0.5 - 25, 5)
graph.circle(794 * 900 / 1123 * 0.35, 900 * 0.5 - 15, 5)
graph.penSize(2)
graph.polyline([(794 * 900 / 1123 * 0.235, 900 * 0.5 + 10),
                (794 * 900 / 1123 * 0.332, 900 * 0.5 + 10),
                (794 * 900 / 1123 * 0.336, 900 * 0.5 + 6),
                (794 * 900 / 1123 * 0.337, 900 * 0.5 + 3)])
graph.brushColor("grey")
graph.penSize(1)
graph.polygon([(794 * 900 / 1123 * 0.53, 900 * 0.9),
               (794 * 900 / 1123 * 0.54, 900 * 0.94),
               (794 * 900 / 1123 * 0.6, 900 * 0.895)])
graph.brushColor("red")
graph.polygon([(794 * 900 / 1123 * 0.68, 900 * 0.88),
Beispiel #20
0
# coding: utf-8
"""
Использование графического модуля graph.py.
GR_HATCH - штриховка
  (C) К. Поляков, 2017
  e-mail: [email protected]
  web: http://kpolyakov.spb.ru
"""
from graph import rectangle, line, run

x1 = 100; y1 = 100
x2 = 300; y2 = 200
N = 10
rectangle (x1, y1, x2, y2)
h = (x2 - x1) / (N + 1)
x = x1 + h
for i in range(N):
  line(x, y1, x, y2)
  x += h

run()
Beispiel #21
0
    ellipse(14, 10, a + 47, b - 70)
    penColor(255, 0, 0)
    brushColor(255, 0, 0)
    ellipse(14, 12, a + 32, b - 95)
    penColor(255, 255, 255)
    brushColor(255, 255, 255)
    ellipse(15, 12, a + 49, b - 88)


brushColor(80, 230, 230)
rectangle(0, 0, 1000, 250)
brushColor(0, 128, 85)


brushColor(80, 230, 230)
rectangle(0, 0, 1000, 250)
brushColor(0, 128, 85)

rectangle(0, 250, 1000, 600)
man(200, 200)
woman(360, 200)
mirorwoman(600, 200)
man(772, 200)
heart(110, 340)
ice_cream(852, 340)
penColor(0, 0, 0)
line(480, 265, 520, 180)
ice_cream(520, 180)

run()
Beispiel #22
0
def bird(x, y, color):
    graph.penColor(color)
    graph.line(x, y, x + 20, y)
    graph.line((x + 20), y, (x + 37), y + 10)
Beispiel #23
0
def woman(a, b):
    penColor(233, 99, 233)
    brushColor(233, 99, 233)
    polygon([(a, b + 30), (a + 75, b + 220), (a - 75, b + 220), (a, b + 30)])
    penColor(229, 194, 152)
    brushColor(229, 194, 152)
    circle(a, b, 45)
    penColor(0, 0, 0)
    # отрисовывает ноги : первые две строки - правую, а вторые две строки - левую;
    line(a + 20, b + 220, a + 20, b + 330)
    line(a + 20, b + 330, a + 40, b + 330)
    line(a - 20, b + 220, a - 20, b + 330)
    line(a - 20, b + 330, a - 40, b + 330)
    # отрисовывает руки : первая строка - правую, а вторая строка - левую;
    line(a + 12, b + 60, a + 50, b + 100)
    line(a + 50, b + 100, a + 120, b + 65)
    line(a - 12, b + 60, a - 82, b + 140)
Beispiel #24
0
def cat(x0, y0, size, d, color):

    graph.penColor(0, 0, 0)
    graph.penSize(0.05)
    # Body
    if color == 'brown':
        graph.brushColor(200, 115, 55)
    else:
        graph.brushColor(110, 95, 85)
    oval(x0 + d * 1.2 * size, y0 + size / 6, size * 2 / 3, 5, d * pi / 6)
    oval(x0, y0, size, 2, 0)
    oval(x0 + d * 0.8 * size, y0 + size / 4, size / 4, 1, 0)
    oval(x0 - d * 0.8 * size, y0 + size / 3, size / 4, 2, 0)
    oval(x0 + d * (0.8 * size + size / 5), y0 + size / 4 + size / 3, size / 4,
         3, pi / 2)

    # Head
    x1 = x0 - d * size
    y1 = y0
    head = size / 3

    oval(x1 - d * head * sin(pi / 4), y1 + head * cos(pi / 4) / 1.5, size / 4,
         3, pi / 2)
    graph.circle(x1, y1, head)

    if color == 'brown':
        graph.brushColor(135, 170, 0)
    else:
        graph.brushColor(40, 215, 255)
    graph.circle(x1 - head / 2, y1, head / 4)
    graph.circle(x1 + head / 2, y1, head / 4)

    graph.brushColor(0, 0, 0)
    oval(x1 - head / 2 + head / 10, y1, head / 4 - head / 30, 4, pi / 2)
    oval(x1 + head / 2 + head / 10, y1, head / 4 - head / 30, 4, pi / 2)

    graph.penColor(250, 250, 250)
    graph.brushColor(250, 250, 250)
    oval(x1 - head / 2 - head / 14, y1 - head / 12, head / 4 - head / 9, 4,
         pi / 4)
    oval(x1 + head / 2 - head / 14, y1 - head / 12, head / 4 - head / 9, 4,
         pi / 4)

    graph.penColor(0, 0, 0)
    graph.brushColor(225, 170, 135)
    nose = [(x1 + head / 15, y1 + head / 3), (x1 - head / 15, y1 + head / 3),
            (x1, y1 + head / 3 + head / 10)]
    graph.polygon(nose)

    graph.line(x1, y1 + head / 3 + head / 10, x1, y1 + head / 2)
    sector(x1 - head / 8, y1 + head / 2, head / 8, 0, pi / 2 + pi / 6, 1, 0)
    sector(x1 + head / 8, y1 + head / 2, head / 8, pi / 2 - pi / 6, pi, 1, 0)

    # Ears
    indent = head / 10
    x2 = x1 + head * 0.9 * sin(pi / 12)
    y2 = y1 - head * 0.9 * cos(pi / 12)
    x3 = x1 + head * 0.9 * sin(pi / 3 - pi / 12)
    y3 = y1 - head * 0.9 * cos(pi / 3 - pi / 12)
    x4 = x3 + head / 10
    y4 = y3 - head / 2

    ear = [(x2, y2), (x3, y3), (x4, y4)]
    if color == 'brown':
        graph.brushColor(200, 115, 55)
    else:
        graph.brushColor(110, 95, 85)
    graph.polygon(ear)

    ear = [(x2 + indent, y2), (x3 - indent / 2, y3 - indent / 2),
           (x4 - indent / 2, y4 + indent / 2)]
    graph.brushColor(225, 170, 135)
    graph.polygon(ear)

    x2 = x1 - head * 0.9 * sin(pi / 12)
    y2 = y1 - head * 0.9 * cos(pi / 12)
    x3 = x1 - head * 0.9 * sin(pi / 3 - pi / 12)
    y3 = y1 - head * 0.9 * cos(pi / 3 - pi / 12)
    x4 = x3 - head / 10
    y4 = y3 - head / 2

    ear = [(x2, y2), (x3, y3), (x4, y4)]
    if color == 'brown':
        graph.brushColor(200, 115, 55)
    else:
        graph.brushColor(110, 95, 85)
    graph.polygon(ear)
    ear = [(x2 - indent, y2), (x3 + indent / 2, y3 - indent / 2),
           (x4 + indent / 2, y4 + indent / 2)]
    graph.brushColor(225, 170, 135)
    graph.polygon(ear)

    # Mustache

    k = 1
    ymin = 0
    ymax = 1000
    h = 0.02
    mult = 0.4

    for i in range(-1, 2):
        x0 = x1 - head / 8 + k / 2
        y0 = y1 + head / 2 + i * indent / 2

        mult *= 1.5
        y = ymin

        points = []
        while y < ymax:
            x = -(mult**2) * y * y
            xe = x0 + k * x
            ye = y0 - k * y
            if x >= -head and x <= 0:
                points.append((xe, ye))
            y += h
        graph.polyline(points)
        points.clear()

    mult = 0.4

    for i in range(-1, 2):
        x0 = x1 + head / 8 + k / 2
        y0 = y1 + head / 2 + i * indent / 2

        mult *= 1.5
        y = ymin

        points = []
        while y < ymax:
            x = (mult**2) * y * y
            xe = x0 + k * x
            ye = y0 - k * y
            if head >= x >= 0:
                points.append((xe, ye))
            y += h
        graph.polyline(points)
        points.clear()
def line_sr(x1: int, y1: int, x2: int, y2: int, scale: float, reflect: bool):
    """Draw a scaled and reflected instance of a line"""
    return line(400 - x1 * scale, y1 * scale, 400 - x2 * scale, y2 * scale) if reflect \
        else line(x1 * scale, y1 * scale, x2 * scale, y2 * scale)
Beispiel #26
0
def draw_a_ship(ship_bow_x, ship_size):
    ship_bow_y = sea_upper_left_point_y + ship_size * (
        225 - sea_upper_left_point_y)  #221

    ship_keel_x = ship_bow_x - ship_size * 65
    ship_keel_y = ship_bow_y + ship_size * 28

    ship_stern_top_x = ship_bow_x - ship_size * 209
    ship_stern_top_y = ship_bow_y

    ship_stern_bottom_x = ship_stern_top_x
    ship_stern_bottom_y = ship_keel_y

    ship_color = '#df6f0d'
    g.penColor(ship_color)
    g.brushColor(ship_color)
    g.polygon([(ship_bow_x, ship_bow_y), (ship_keel_x, ship_keel_y),
               (ship_stern_bottom_x, ship_stern_bottom_y),
               (ship_stern_top_x, ship_stern_top_y)])

    ship_stern_radius = ship_stern_bottom_y - ship_stern_top_y
    g.circle(ship_stern_top_x, ship_stern_top_y, ship_stern_radius)

    fill_1_top_left_point_x = ship_stern_top_x - ship_stern_radius
    fill_1_top_left_point_y = sea_upper_left_point_y
    fill_1_bottom_right_point_x = ship_stern_top_x + ship_stern_radius
    fill_1_bottom_right_point_y = ship_stern_top_y - 1
    g.penColor(sea_color)
    g.brushColor(sea_color)
    g.rectangle(fill_1_top_left_point_x, fill_1_top_left_point_y,
                fill_1_bottom_right_point_x, fill_1_bottom_right_point_y)

    fill_2_top_left_point_x = ship_stern_top_x - ship_stern_radius
    fill_2_top_left_point_y = ship_stern_top_y - ship_stern_radius
    fill_2_bottom_right_point_x = ship_stern_top_x + ship_stern_radius
    fill_2_bottom_right_point_y = sea_upper_left_point_y - 1
    g.penColor(sky_color)
    g.brushColor(sky_color)
    g.rectangle(fill_2_top_left_point_x, fill_2_top_left_point_y,
                fill_2_bottom_right_point_x, fill_2_bottom_right_point_y)

    g.penColor(sea_color)
    g.penSize(pen_width_1)
    g.line(ship_stern_top_x, ship_stern_top_y, ship_stern_bottom_x,
           ship_stern_bottom_y)
    g.line(ship_keel_x, ship_bow_y, ship_keel_x, ship_keel_y)

    ship_porthole_center_x = ship_bow_x - ship_size * 50
    ship_porthole_center_y = ship_bow_y + ship_size * 11
    ship_porthole_radius = ship_size * 7
    porthole_pen_width = ship_size * 3.25
    g.penSize(porthole_pen_width)
    g.penColor('black')
    portole_color = 'white'
    g.brushColor(portole_color)
    g.circle(ship_porthole_center_x, ship_porthole_center_y,
             ship_porthole_radius)

    mast_base_x = ship_bow_x - ship_size * 150
    mast_base_y = ship_bow_y
    mast_hight = ship_size * 96
    mast_width = ship_size * 6

    g.penSize(mast_width)
    mast_color = 'black'
    g.penColor(mast_color)
    g.line(mast_base_x, mast_base_y, mast_base_x, mast_base_y - mast_hight)

    sail_top_mount_x = mast_base_x
    sail_top_mount_y = mast_base_y - mast_hight
    sail_bottom_mount_x = mast_base_x
    sail_bottom_mount_y = mast_base_y
    sail_left_edge_x = ship_bow_x - ship_size * 134
    sail_left_edge_y = (sail_top_mount_y + sail_bottom_mount_y) / 2
    sail_right_edge_x = ship_bow_x - ship_size * 96
    sail_right_edge_y = sail_left_edge_y

    g.penSize(pen_width_1)
    g.penColor('black')
    sail_color = '#c9c094'
    g.brushColor(sail_color)
    g.polygon([(sail_top_mount_x, sail_top_mount_y),
               (sail_left_edge_x, sail_left_edge_y),
               (sail_right_edge_x, sail_right_edge_y)])
    g.polygon([(sail_bottom_mount_x, sail_bottom_mount_y),
               (sail_left_edge_x, sail_left_edge_y),
               (sail_right_edge_x, sail_right_edge_y)])
Beispiel #27
0
graph.brushColor(0, 0, 0)
MyLib.oval(x1 - head / 2 + head/10, y1, head / 4 - head / 30, 4, pi / 2)
MyLib.oval(x1 + head / 2 + head/10, y1, head / 4 - head / 30, 4, pi / 2)

graph.penColor(250, 250, 250)
graph.brushColor(250, 250, 250)
MyLib.oval(x1 - head / 2 - head/14, y1 - head / 12, head / 4 - head / 9, 4, pi / 4)
MyLib.oval(x1 + head / 2 - head/14, y1 - head / 12, head / 4 - head / 9, 4, pi / 4)

graph.penColor(0, 0, 0)
graph.brushColor(225, 170, 135)
nose = [(x1 + head / 15, y1 + head / 3), (x1 - head / 15, y1 + head / 3), (x1, y1 + head / 3 + head / 10)]
graph.polygon(nose)

graph.line(x1, y1 + head / 3 + head / 10, x1, y1 + head / 2)
MyLib.sector(x1 - head / 8, y1 + head / 2, head / 8, 0, pi / 2 + pi / 6, 1, 0)
MyLib.sector(x1 + head / 8, y1 + head / 2, head / 8, pi /2 - pi / 6, pi, 1, 0)

# Ears
indent = head / 10
x2 = x1 + head * 0.9 * sin(pi / 12)
y2 = y1 - head * 0.9 * cos(pi / 12)
x3 = x1 + head * 0.9 * sin(pi / 3 - pi / 12)
y3 = y1 - head * 0.9 * cos(pi / 3 - pi / 12)
x4 = x3 + head / 10
y4 = y3 - head / 2


ear = [(x2, y2), (x3, y3), (x4, y4)]
if d == 1:
Beispiel #28
0
def man(a, b):
    penColor(133, 133, 133)
    brushColor(133, 133, 133)
    ellipse(50, 95, a, b + 120)
    penColor(229, 194, 152)
    brushColor(229, 194, 152)
    circle(a, b, 45)
    penColor(0, 0, 0)
    # отрисовывает руки : первая строка - правую, а вторая строка - левую;
    line(a + 40, b + 60, a + 80, b + 140)
    line(a - 40, b + 60, a - 90, b + 140)

    # отрисовывает ноги : первые две строки - правую, а вторые две строки - левую;
    line(a + 25, b + 200, a + 45, b + 330)
    line(a + 45, b + 330, a + 65, b + 330)
    line(a - 25, b + 200, a - 65, b + 330)
    line(a - 65, b + 330, a - 100, b + 330)
Beispiel #29
0
def letters(f: object, s: object, t: object) -> object:
    g.penColor(f, s, t)

    # py

    g.line(10 / z, 130 / z, 10 / z, 30 / z)
    g.line(10 / z, 30 / z, 50 / z, 30 / z)
    g.line(50 / z, 30 / z, 50 / z, 80 / z)
    g.line(50 / z, 80 / z, 10 / z, 80 / z)
    g.line(105 / z, 105 / z, 75 / z, 30 / z)
    g.line(105 / z, 105 / z, 135 / z, 30 / z)
    g.line(105 / z, 105 / z, 105 / z, 145 / z)

    # th

    g.line(145 / z, 30 / z, 200 / z, 30 / z)
    g.line(175 / z, 30 / z, 175 / z, 130 / z)
    g.line(220 / z, 30 / z, 220 / z, 130 / z)
    g.line(220 / z, 80 / z, 270 / z, 80 / z)
    g.line(270 / z, 30 / z, 270 / z, 130 / z)

    # on

    g.line(295 / z, 30 / z, 295 / z, 130 / z)
    g.line(295 / z, 130 / z, 340 / z, 130 / z)
    g.line(340 / z, 130 / z, 340 / z, 30 / z)
    g.line(340 / z, 30 / z, 295 / z, 30 / z)
    g.line(360 / z, 130 / z, 360 / z, 30 / z)
    g.line(360 / z, 30 / z, 410 / z, 130 / z)
    g.line(410 / z, 130 / z, 410 / z, 30 / z)

    # is

    g.line(525 / z, 20 / z, 525 / z, 25 / z)
    g.line(525 / z, 30 / z, 525 / z, 130 / z)
    g.line(620 / z, 30 / z, 570 / z, 30 / z)
    g.line(570 / z, 30 / z, 570 / z, 80 / z)
    g.line(570 / z, 80 / z, 620 / z, 80 / z)
    g.line(620 / z, 80 / z, 620 / z, 130 / z)
    g.line(620 / z, 130 / z, 570 / z, 130 / z)

    # am

    g.line(710 / z, 130 / z, 735 / z, 30 / z)
    g.line(735 / z, 30 / z, 760 / z, 130 / z)
    g.line(722.5 / z, 80 / z, 757.5 / z, 80 / z)
    g.line(780 / z, 130 / z, 780 / z, 30 / z)
    g.line(780 / z, 30 / z, 805 / z, 80 / z)
    g.line(805 / z, 80 / z, 830 / z, 30 / z)
    g.line(830 / z, 30 / z, 830 / z, 130 / z)

    # az

    g.line(850 / z, 130 / z, 875 / z, 30 / z)
    g.line(875 / z, 30 / z, 900 / z, 130 / z)
    g.line(862.5 / z, 80 / z, 887.5 / z, 80 / z)
    g.line(920 / z, 30 / z, 970 / z, 30 / z)
    g.line(970 / z, 30 / z, 920 / z, 130 / z)
    g.line(920 / z, 130 / z, 970 / z, 130 / z)

    # ing

    g.line(1015 / z, 20 / z, 1015 / z, 25 / z)
    g.line(1015 / z, 30 / z, 1015 / z, 130 / z)
    g.line(1060 / z, 130 / z, 1060 / z, 30 / z)
    g.line(1060 / z, 30 / z, 1110 / z, 130 / z)
    g.line(1110 / z, 130 / z, 1110 / z, 30 / z)
    g.line(1180 / z, 30 / z, 1130 / z, 30 / z)
    g.line(1130 / z, 30 / z, 1130 / z, 130 / z)
    g.line(1130 / z, 130 / z, 1180 / z, 130 / z)
    g.line(1180 / z, 130 / z, 1180 / z, 80 / z)
    g.line(1180 / z, 80 / z, 1153 / z, 80 / z)