Beispiel #1
0
def toes():
    toe0 = GPolygon()
    toe0.add_vertex((420, 555))
    toe0.add_vertex((475, 555))
    toe0.add_vertex((475, 525))
    toe0.filled = True
    toe0.fill_color = 'ivory'
    window.add(toe0)
    toe1 = GPolygon()
    toe1.add_vertex((525, 555))
    toe1.add_vertex((580, 555))
    toe1.add_vertex((580, 525))
    toe1.filled = True
    toe1.fill_color = 'ivory'
    window.add(toe1)
Beispiel #2
0
def picture_wall2():
    wall1 = GPolygon()
    wall1.add_vertex((300, 0))
    wall1.add_vertex((350, 75))
    wall1.add_vertex((440, 100))
    wall1.add_vertex((410, 180))
    wall1.add_vertex((440, 220))
    wall1.add_vertex((460, 280))
    wall1.add_vertex((470, 340))
    wall1.add_vertex((463, 400))
    wall1.add_vertex((473, 430))
    wall1.add_vertex((453, 470))
    wall1.add_vertex((432, 520))
    wall1.add_vertex((420, 550))
    wall1.add_vertex((310, 635))
    wall1.add_vertex((335, 635))
    wall1.add_vertex((443, 550))
    wall1.add_vertex((455, 520))
    wall1.add_vertex((473, 470))
    wall1.add_vertex((495, 430))
    wall1.add_vertex((482, 400))
    wall1.add_vertex((492, 340))
    wall1.add_vertex((480, 280))
    wall1.add_vertex((464, 220))
    wall1.add_vertex((435, 180))
    wall1.add_vertex((450, 100))
    wall1.add_vertex((375, 75))
    wall1.add_vertex((300, 0))
    wall1.filled = True
    wall1.fill_color = 'gray'
    wall1.color = 'gray'
    return wall1
Beispiel #3
0
def sierpinski_triangle(order, length, upper_left_x, upper_left_y):
    """
	:param order:
	:param length:
	:param upper_left_x:
	:param upper_left_y:
	:return:
	"""
    if order == 0:
        return

    else:

        triangle = GPolygon()
        triangle.add_vertex((upper_left_x, upper_left_y))
        triangle.add_vertex((upper_left_x + length, upper_left_y))
        triangle.add_vertex(
            (upper_left_x + length / 2, upper_left_y + (length * 0.886)))
        triangle.filled = True
        triangle.fill_color = 'snow'

        window.add(triangle)

        sierpinski_triangle(order - 1, length / 2, upper_left_x, upper_left_y)

        sierpinski_triangle(order - 1, length / 2, upper_left_x + length / 2,
                            upper_left_y)

        sierpinski_triangle(order - 1, length / 2, upper_left_x + length / 4,
                            upper_left_y + (length * 0.886) / 2)
Beispiel #4
0
def tail():
    tail = GPolygon()
    tail.add_vertex((650, 450))
    tail.add_vertex((650, 500))
    tail.add_vertex((780, 430))
    tail.filled = True
    tail.fill_color = 'green'
    window.add(tail)
Beispiel #5
0
def eyebrow():
    brow = GPolygon()
    brow.add_vertex((540, 50))
    brow.add_vertex((600, 45))
    brow.add_vertex((600, 30))
    brow.filled = True
    brow.fill_color = 'black'
    window.add(brow)
def build_karel1():
    """
    This function builds the first karel
    """
    head = GOval(80, 55, x=190, y=167)
    head.filled = True
    head.color = 'black'
    head.fill_color = 'gray'
    window.add(head)
    r_eye = GRect(13, 13, x=212, y=189)
    r_eye.filled = True
    r_eye.color = 'black'
    r_eye.fill_color = 'blue'
    window.add(r_eye)
    l_eye = GRect(13, 13, x=235, y=189)
    l_eye.filled = True
    l_eye.color = 'black'
    l_eye.fill_color = 'blue'
    window.add(l_eye)
    r_eyeb = GLine(212, 185, 225, 185)
    window.add(r_eyeb)
    l_eyeb = GLine(235, 185, 248, 185)
    window.add(l_eyeb)
    hands = GRect(105, 45, x=177, y=237)
    hands.filled = True
    hands.color = 'black'
    hands.fill_color = 'lime'
    window.add(hands)
    body_1 = GRect(60, 65, x=201, y=223)
    body_1.filled = True
    body_1.color = 'black'
    body_1.fill_color = 'blue'
    window.add(body_1)
    body_2 = GRect(80, 60, x=190, y=230)
    body_2.filled = True
    body_2.color = 'black'
    body_2.fill_color = 'blue'
    window.add(body_2)
    r_foot = GOval(29, 24, x=190, y=290)
    r_foot.filled = True
    r_foot.color = 'black'
    r_foot.fill_color = 'red'
    window.add(r_foot)
    l_foot = GOval(29, 24, x=241, y=290)
    l_foot.filled = True
    l_foot.color = 'black'
    l_foot.fill_color = 'red'
    window.add(l_foot)
    label = GPolygon()
    label.add_vertex((230, 130))
    label.add_vertex((218, 150))
    label.add_vertex((242, 150))
    label.filled = True
    label.fill_color = 'firebrick'
    label.color = 'firebrick'
    window.add(label)
Beispiel #7
0
def nobita_hand():
    hand = GPolygon()
    hand.add_vertex((200, 475))
    hand.add_vertex((310, 555))
    hand.add_vertex((310, 635))
    hand.add_vertex((200, 555))
    hand.filled = True
    hand.fill_color = 'antiquewhite'
    hand.color = 'antiquewhite'
    return hand
Beispiel #8
0
def nobita_handcloth():
    hand_cloth = GPolygon()
    hand_cloth.add_vertex((310, 555))
    hand_cloth.add_vertex((385, 505))
    hand_cloth.add_vertex((385, 585))
    hand_cloth.add_vertex((310, 635))
    hand_cloth.filled = True
    hand_cloth.fill_color = 'yellow'
    hand_cloth.color = 'yellow'
    return hand_cloth
Beispiel #9
0
def heart():
    my_heart = GPolygon()
    my_heart.add_vertex((280, 10))
    my_heart.add_vertex((230, 60))
    my_heart.add_vertex((330, 180))
    my_heart.add_vertex((430, 60))
    my_heart.add_vertex((380, 10))
    my_heart.add_vertex((330, 50))
    my_heart.filled = True
    my_heart.fill_color = 'light pink'
    window.add(my_heart)
Beispiel #10
0
def sierpinski_triangle(order, length, upper_left_x, upper_left_y):
	"""
											line1
											-----------
											 \       /
											  \     /
								line2		   \   /	line3
												\ /
	:param order: int, Controls the order of Sierpinski Triangle
	:param length: int, The length of order 1 Sierpinski Triangle
	:param upper_left_x: int, The upper left x coordinate of order 1 Sierpinski Triangle
	:param upper_left_y: int, The upper left y coordinate of order 1 Sierpinski Triangle
	:return:
	"""
	if order == 0:
		pass
	else:
		# line1 = GLine(upper_left_x, upper_left_y, upper_left_x + length, upper_left_y)
		# line2 = GLine(upper_left_x, upper_left_y, upper_left_x + 0.5*length, upper_left_y + (3**0.5)/2*length)
		# line3 = GLine(upper_left_x + length, upper_left_y, upper_left_x + 0.5*length, upper_left_y + (3**0.5)/2*length)
		# window.add(line1)
		# window.add(line2)
		# window.add(line3)

		# if you want to draw the triangle, you can use it
		# ----------------------------------------------------------------
		triangle = GPolygon()
		triangle.add_vertex((upper_left_x, upper_left_y))
		triangle.add_vertex((upper_left_x + length, upper_left_y))
		triangle.add_vertex((upper_left_x + 0.5*length, upper_left_y + (3**0.5)/2*length))
		# draw it from the line!
		# e.g.
		triangle.filled = True
		if order % 3 == 0:
			triangle.fill_color = 'blue'
		elif order % 3 == 1:
			triangle.fill_color = 'magenta'
		else:
			triangle.fill_color = 'pink'

		window.add(triangle)
		# ----------------------------------------------------------------


		# make the upper left triangle
		sierpinski_triangle(order-1, length/2, upper_left_x, upper_left_y)

		# make the upper right triangle
		sierpinski_triangle(order-1, length/2, upper_left_x + length/2, upper_left_y)

		# make the lower triangle
		sierpinski_triangle(order-1, length/2, upper_left_x + 0.25*length, upper_left_y + (3**0.5)/2*(length/2))
Beispiel #11
0
def back():
    back0 = GPolygon()
    back0.add_vertex((650, 230))
    back0.add_vertex((650, 280))
    back0.add_vertex((700, 255))
    back0.filled = True
    back0.fill_color = 'white'
    window.add(back0)
    back1 = GPolygon()
    back1.add_vertex((650, 280))
    back1.add_vertex((650, 330))
    back1.add_vertex((700, 305))
    back1.filled = True
    back1.fill_color = 'white'
    window.add(back1)
    back2 = GPolygon()
    back2.add_vertex((650, 330))
    back2.add_vertex((650, 380))
    back2.add_vertex((700, 355))
    back2.filled = True
    back2.fill_color = 'white'
    window.add(back2)
Beispiel #12
0
def hand_finger():
    fin0 = GPolygon()
    fin0.add_vertex((420, 300))
    fin0.add_vertex((450, 300))
    fin0.add_vertex((450, 325))
    fin0.filled = True
    fin0.fill_color = 'ivory'
    window.add(fin0)
    fin1 = GPolygon()
    fin1.add_vertex((420, 325))
    fin1.add_vertex((450, 325))
    fin1.add_vertex((450, 350))
    fin1.filled = True
    fin1.fill_color = 'ivory'
    window.add(fin1)
    fin2 = GPolygon()
    fin2.add_vertex((420, 350))
    fin2.add_vertex((450, 350))
    fin2.add_vertex((450, 375))
    fin2.filled = True
    fin2.fill_color = 'ivory'
    window.add(fin2)
Beispiel #13
0
def make_polygon(num, coordinate, color):
    """
    Draw a polygon
    :param num: int, number of vertex
    :param coordinate: list, coordinate of every vertex :[(x1, y1), (x2, y2)...]
    :param color: str, the color want to fill inside
    """
    polygon = GPolygon()
    for i in range(num):
        x = coordinate[i][0] * SIZE
        y = coordinate[i][1] * SIZE
        polygon.add_vertex((x, y))
    window.add(polygon)
    polygon.filled = True
    polygon.fill_color = color
Beispiel #14
0
    def link_point(self, point):
        """
        link the point of pose list and make GObject.
        :param point: Every piece of bird is consist of GPolygon shape, which is make up by these points.
        """
        r = [random.randint(225, 255), random.randint(240, 255), random.randint(255, 255)]
        shape = GPolygon()
        shape.color = 'lightgray'
        shape.filled = True
        shape.fill_color = (r[0], r[1], r[2])
        for j in range(len(point)):
            shape.add_vertex(point[j])
        window.add(shape)
        self.shape_box.append(shape)

        self.eye.filled = True
        self.eye.fill_color = 'navy'
        window.add(self.eye, 370, 210)
Beispiel #15
0
def picture_wall():
    wall1 = GPolygon()
    wall1.add_vertex((0, 0))
    wall1.add_vertex((300, 0))
    wall1.add_vertex((250, 75))
    wall1.add_vertex((180, 100))
    wall1.add_vertex((160, 180))
    wall1.add_vertex((170, 220))
    wall1.add_vertex((140, 280))
    wall1.add_vertex((230, 340))
    wall1.add_vertex((220, 400))
    wall1.add_vertex((200, 440))
    wall1.add_vertex((200, 500))
    wall1.add_vertex((220, 550))
    wall1.add_vertex((310, 635))
    wall1.add_vertex((300, 900))
    wall1.add_vertex((0, 900))
    wall1.filled = True
    wall1.fill_color = 'darkgrey'
    wall1.color = 'grey'
    return wall1
Beispiel #16
0
def picture_wall1():
    wall1 = GPolygon()
    wall1.add_vertex((600, 0))
    wall1.add_vertex((300, 0))
    wall1.add_vertex((350, 75))
    wall1.add_vertex((440, 100))
    wall1.add_vertex((410, 180))
    wall1.add_vertex((440, 220))
    wall1.add_vertex((460, 280))
    wall1.add_vertex((470, 340))
    wall1.add_vertex((463, 400))
    wall1.add_vertex((473, 430))
    wall1.add_vertex((453, 470))
    wall1.add_vertex((432, 520))
    wall1.add_vertex((420, 550))
    wall1.add_vertex((310, 635))
    wall1.add_vertex((300, 900))
    wall1.add_vertex((600, 900))
    wall1.filled = True
    wall1.fill_color = 'darkgrey'
    wall1.color = 'darkgrey'
    return wall1
Beispiel #17
0
def teeth():
    tooth1 = GPolygon()
    tooth1.add_vertex((450, 170))
    tooth1.add_vertex((480, 170))
    tooth1.add_vertex((465, 190))
    tooth1.filled = True
    tooth1.fill_color = 'white'
    window.add(tooth1)
    tooth2 = GPolygon()
    tooth2.add_vertex((480, 170))
    tooth2.add_vertex((510, 170))
    tooth2.add_vertex((495, 190))
    tooth2.filled = True
    tooth2.fill_color = 'white'
    window.add(tooth2)
    tooth3 = GPolygon()
    tooth3.add_vertex((510, 170))
    tooth3.add_vertex((540, 170))
    tooth3.add_vertex((525, 190))
    tooth3.filled = True
    tooth3.fill_color = 'white'
    window.add(tooth3)
    tooth4 = GPolygon()
    tooth4.add_vertex((450, 230))
    tooth4.add_vertex((480, 230))
    tooth4.add_vertex((465, 210))
    tooth4.filled = True
    tooth4.fill_color = 'white'
    window.add(tooth4)
    tooth5 = GPolygon()
    tooth5.add_vertex((480, 230))
    tooth5.add_vertex((510, 230))
    tooth5.add_vertex((495, 210))
    tooth5.filled = True
    tooth5.fill_color = 'white'
    window.add(tooth5)
    tooth6 = GPolygon()
    tooth6.add_vertex((510, 230))
    tooth6.add_vertex((540, 230))
    tooth6.add_vertex((525, 210))
    tooth6.filled = True
    tooth6.fill_color = 'white'
    window.add(tooth6)
Beispiel #18
0
def main():
    """
    TODO: use different kinds of rectangles, triangles to create a wolf
    """
    window = GWindow(width=500, height=500, title='wolf')

    head = GPolygon()
    head.add_vertex((225, 100))
    head.add_vertex((275, 100))
    head.add_vertex((250, 225))
    head.filled = True
    head.fill_color = 'thistle'
    window.add(head)

    ear = GPolygon()
    ear.add_vertex((170, 190))
    ear.add_vertex((130, 120))
    ear.add_vertex((100, 200))
    ear.filled = True
    ear.fill_color = 'wheat'
    window.add(ear)

    ear = GPolygon()
    ear.add_vertex((330, 190))
    ear.add_vertex((370, 120))
    ear.add_vertex((400, 200))
    ear.filled = True
    ear.fill_color = 'wheat'
    window.add(ear)

    ear = GPolygon()
    ear.add_vertex((200, 145))
    ear.add_vertex((150, 120))
    ear.add_vertex((100, 100))
    ear.add_vertex((100, 130))
    ear.add_vertex((170, 180))
    ear.filled = True
    ear.fill_color = 'peru'
    window.add(ear)

    ear = GPolygon()
    ear.add_vertex((300, 145))
    ear.add_vertex((350, 120))
    ear.add_vertex((400, 100))
    ear.add_vertex((400, 130))
    ear.add_vertex((330, 180))
    ear.filled = True
    ear.fill_color = 'peru'
    window.add(ear)

    head4 = GPolygon()
    head4.add_vertex((200, 110))
    head4.add_vertex((250, 225))
    head4.add_vertex((210, 225))
    head4.add_vertex((190, 215))
    head4.add_vertex((180, 120))  #ear point
    head4.add_vertex((200, 110))
    head4.filled = True
    head4.fill_color = 'coral'
    window.add(head4)

    head4 = GPolygon()
    head4.add_vertex((320, 110))
    head4.add_vertex((250, 225))
    head4.add_vertex((290, 225))
    head4.add_vertex((310, 215))
    head4.add_vertex((320, 120))
    head4.add_vertex((320, 110))
    head4.filled = True
    head4.fill_color = 'cornsilk'
    window.add(head4)

    ear = GPolygon()
    ear.add_vertex((300, 115))
    ear.add_vertex((400, 70))
    ear.add_vertex((410, 70))
    ear.add_vertex((405, 100))
    ear.add_vertex((330, 150))
    ear.filled = True
    ear.fill_color = 'brown'
    window.add(ear)

    ear = GPolygon()
    ear.add_vertex((200, 115))
    ear.add_vertex((100, 70))
    ear.add_vertex((90, 70))
    ear.add_vertex((95, 100))
    ear.add_vertex((170, 150))
    ear.filled = True
    ear.fill_color = 'brown'
    window.add(ear)

    ear = GPolygon()
    ear.add_vertex((180, 130))
    ear.add_vertex((120, 90))
    ear.add_vertex((125, 120))
    ear.add_vertex((130, 160))
    ear.add_vertex((140, 170))
    ear.add_vertex((170, 200))
    ear.filled = True
    ear.fill_color = 'burlywood'
    window.add(ear)

    ear = GPolygon()
    ear.add_vertex((320, 130))
    ear.add_vertex((380, 90))
    ear.add_vertex((375, 120))
    ear.add_vertex((370, 160))
    ear.add_vertex((360, 170))
    ear.add_vertex((330, 200))
    ear.filled = True
    ear.fill_color = 'burlywood'
    window.add(ear)

    head2 = GPolygon()
    head2.add_vertex((225, 100))
    head2.add_vertex((180, 110))
    head2.add_vertex((250, 225))
    head2.filled = True
    head2.fill_color = 'peru'
    window.add(head2)

    head3 = GPolygon()
    head3.add_vertex((275, 100))
    head3.add_vertex((320, 110))
    head3.add_vertex((250, 225))
    head3.filled = True
    head3.fill_color = 'khaki'
    window.add(head3)

    head5 = GPolygon()
    head5.add_vertex((181, 138))
    head5.add_vertex((170, 140))
    head5.add_vertex((140, 225))
    head5.add_vertex((190, 225))
    head5.add_vertex((190, 225))
    head5.filled = True
    head5.fill_color = 'mistyrose'
    window.add(head5)

    head6 = GPolygon()
    head6.add_vertex((319, 138))
    head6.add_vertex((330, 140))
    head6.add_vertex((360, 225))
    head6.add_vertex((310, 225))
    head6.add_vertex((310, 225))
    head6.filled = True
    head6.fill_color = 'orange'
    window.add(head6)

    eye_left = GPolygon()  # eyes up
    eye_left.add_vertex((190, 205))
    eye_left.add_vertex((170, 225))
    eye_left.add_vertex((225, 225))
    eye_left.filled = True
    eye_left.fill_color = 'black'
    window.add(eye_left)

    eye_left = GPolygon()  # eyes down
    eye_left.add_vertex((190, 225))
    eye_left.add_vertex((200, 235))
    eye_left.add_vertex((225, 225))
    eye_left.filled = True
    eye_left.fill_color = 'black'
    window.add(eye_left)

    eye_right = GPolygon()  # eyes up
    eye_right.add_vertex((310, 205))
    eye_right.add_vertex((330, 225))
    eye_right.add_vertex((275, 225))
    eye_right.filled = True
    eye_right.fill_color = 'black'
    window.add(eye_right)

    eye_right = GPolygon()  # eyes down
    eye_right.add_vertex((310, 225))
    eye_right.add_vertex((300, 235))
    eye_right.add_vertex((275, 225))
    eye_right.filled = True
    eye_right.fill_color = 'black'
    window.add(eye_right)

    head7 = GPolygon()
    head7.add_vertex((250, 225))
    head7.add_vertex((220, 225))
    head7.add_vertex((200, 235))
    head7.add_vertex((220, 330))
    head7.add_vertex((250, 225))
    head7.filled = True
    head7.fill_color = 'purple'
    window.add(head7)

    head8 = GPolygon()
    head8.add_vertex((250, 225))
    head8.add_vertex((280, 225))
    head8.add_vertex((300, 235))
    head8.add_vertex((280, 330))
    head8.add_vertex((250, 225))
    head8.filled = True
    head8.fill_color = 'skyblue'
    window.add(head8)

    head9 = GPolygon()
    head9.add_vertex((250, 225))
    head9.add_vertex((250, 320))
    head9.add_vertex((220, 330))
    head9.filled = True
    head9.fill_color = 'sage'
    window.add(head9)

    head9 = GPolygon()
    head9.add_vertex((250, 225))
    head9.add_vertex((250, 320))
    head9.add_vertex((280, 330))
    head9.filled = True
    head9.fill_color = 'lightpink'
    window.add(head9)

    nose = GPolygon()
    nose.add_vertex((250, 320))
    nose.add_vertex((280, 330))
    nose.add_vertex((270, 345))
    nose.add_vertex((250, 350))
    nose.add_vertex((230, 345))
    nose.add_vertex((220, 330))
    nose.filled = True
    nose.fill_color = 'black'
    window.add(nose)

    cheek = GPolygon()
    cheek.add_vertex((310, 225))
    cheek.add_vertex((330, 225))
    cheek.add_vertex((350, 240))
    cheek.add_vertex((320, 300))
    cheek.filled = True
    cheek.fill_color = 'salmon'
    window.add(cheek)

    cheek = GPolygon()
    cheek.add_vertex((310, 225))
    cheek.add_vertex((320, 300))
    cheek.add_vertex((305, 325))
    cheek.add_vertex((300, 235))
    cheek.filled = True
    cheek.fill_color = 'gold'
    window.add(cheek)

    cheek = GPolygon()
    cheek.add_vertex((190, 225))
    cheek.add_vertex((180, 300))
    cheek.add_vertex((195, 325))
    cheek.add_vertex((200, 235))
    cheek.filled = True
    cheek.fill_color = 'magenta'
    window.add(cheek)

    cheek = GPolygon()
    cheek.add_vertex((190, 225))
    cheek.add_vertex((170, 225))
    cheek.add_vertex((150, 240))
    cheek.add_vertex((180, 300))
    cheek.filled = True
    cheek.fill_color = 'lavenderblush'
    window.add(cheek)

    cheek = GPolygon()
    cheek.add_vertex((300, 235))
    cheek.add_vertex((270, 345))
    cheek.add_vertex((290, 345))
    cheek.filled = True
    cheek.fill_color = 'yellow'
    window.add(cheek)

    cheek = GPolygon()
    cheek.add_vertex((200, 235))
    cheek.add_vertex((230, 345))
    cheek.add_vertex((210, 345))
    cheek.filled = True
    cheek.fill_color = 'yellow'
    window.add(cheek)

    cheek = GPolygon()
    cheek.add_vertex((200, 235))
    cheek.add_vertex((210, 345))
    cheek.add_vertex((200, 370))
    cheek.add_vertex((195, 330))
    cheek.filled = True
    cheek.fill_color = 'brown'
    window.add(cheek)

    cheek = GPolygon()
    cheek.add_vertex((300, 235))
    cheek.add_vertex((290, 345))
    cheek.add_vertex((300, 370))
    cheek.add_vertex((305, 330))
    cheek.filled = True
    cheek.fill_color = 'brown'
    window.add(cheek)

    cheek = GPolygon()
    cheek.add_vertex((300, 235))
    cheek.add_vertex((310, 310))
    cheek.add_vertex((305, 355))
    cheek.add_vertex((300, 330))
    cheek.filled = True
    cheek.fill_color = 'violet'
    window.add(cheek)

    cheek = GPolygon()
    cheek.add_vertex((200, 235))
    cheek.add_vertex((190, 310))
    cheek.add_vertex((195, 355))
    cheek.add_vertex((200, 330))
    cheek.filled = True
    cheek.fill_color = 'aliceblue'
    window.add(cheek)

    cheek = GPolygon()
    cheek.add_vertex((330, 225))
    cheek.add_vertex((325, 200))
    cheek.add_vertex((350, 230))
    cheek.add_vertex((360, 250))
    cheek.filled = True
    cheek.fill_color = 'grey'
    window.add(cheek)

    cheek = GPolygon()
    cheek.add_vertex((325, 200))
    cheek.add_vertex((355, 210))
    cheek.add_vertex((365, 245))
    cheek.add_vertex((350, 230))
    cheek.filled = True
    cheek.fill_color = 'green'
    window.add(cheek)

    cheek = GPolygon()
    cheek.add_vertex((325, 200))
    cheek.add_vertex((350, 195))
    cheek.add_vertex((375, 230))
    cheek.add_vertex((350, 220))
    cheek.filled = True
    cheek.fill_color = 'blue'
    window.add(cheek)

    cheek = GPolygon()
    cheek.add_vertex((170, 225))
    cheek.add_vertex((175, 200))
    cheek.add_vertex((150, 230))
    cheek.add_vertex((140, 250))
    cheek.filled = True
    cheek.fill_color = 'grey'
    window.add(cheek)

    cheek = GPolygon()
    cheek.add_vertex((175, 200))
    cheek.add_vertex((145, 210))
    cheek.add_vertex((135, 245))
    cheek.add_vertex((150, 230))
    cheek.filled = True
    cheek.fill_color = 'green'
    window.add(cheek)

    cheek = GPolygon()
    cheek.add_vertex((175, 200))
    cheek.add_vertex((150, 195))
    cheek.add_vertex((125, 230))
    cheek.add_vertex((150, 220))
    cheek.filled = True
    cheek.fill_color = 'greenyellow'
    window.add(cheek)

    line = GLabel("WOLF", 220, 420)
    line.font = 'courier-25-italic'
    window.add(line)
Beispiel #19
0
def main():
    """

    """
    #左上角,迷因文字第一段
    square1 = GRect(400, 300, x=0, y=0)
    window.add(square1)
    word1 = GLabel('上stanCode前的我', x=40, y=150)
    word1.font = 'Cowrier-30-italic'
    window.add(word1)
    word1_2 = GLabel('code是啥?可以吃嗎?', x=40, y=180)
    word1_2.font = 'Cowrier-20-italic'
    window.add(word1_2)

    #左下角,迷因文字第二段
    square2 = GRect(400, 300, x=0, y=300)
    window.add(square2)
    word2 = GLabel('上stanCode後的我', x=40, y=450)
    word2.font = 'Cowrier-30-italic'
    window.add(word2)
    word2_2 = GLabel('考試都考100分~', x=40, y=480)
    word2_2.font = 'Cowrier-20-italic'
    window.add(word2_2)

    #右上角,迷因圖片第一張
    #背景
    suqare_background1 = GRect(400, 220, x=400, y=0)
    suqare_background1.filled = True
    suqare_background1.fill_color = 'wheat'
    window.add(suqare_background1)
    suqare_background2 = GRect(400, 80, x=400, y=220)
    window.add(suqare_background2)
    suqare_background2.filled = True
    suqare_background2.fill_color = 'gray'

    # 小茶几
    desk6 = GRect(10, 50, x=405, y=210)
    desk6.filled = True
    desk6.fill_color = 'brown'
    window.add(desk6)
    desk7 = GRect(10, 50, x=465, y=210)
    desk7.filled = True
    desk7.fill_color = 'brown'
    window.add(desk7)
    desk1 = GPolygon()
    desk1.add_vertex((500, 230))
    desk1.add_vertex((480, 200))
    desk1.add_vertex((400, 200))
    desk1.add_vertex((420, 230))
    desk1.filled = True
    desk1.fill_color = 'brown'
    window.add(desk1)
    desk2 = GRect(80, 10, x=420, y=230)
    desk2.filled = True
    desk2.fill_color = 'brown'
    window.add(desk2)
    desk3 = GPolygon()
    desk3.add_vertex((420, 230))
    desk3.add_vertex((420, 240))
    desk3.add_vertex((400, 210))
    desk3.add_vertex((400, 200))
    desk3.filled = True
    desk3.fill_color = 'brown'
    window.add(desk3)
    desk4 = GRect(10, 50, x=485, y=240)
    desk4.filled = True
    desk4.fill_color = 'brown'
    window.add(desk4)
    desk5 = GRect(10, 50, x=425, y=240)
    desk5.filled = True
    desk5.fill_color = 'brown'
    window.add(desk5)

    # 檯燈
    lamp = GPolygon()
    lamp.add_vertex((440, 100))
    lamp.add_vertex((460, 100))
    lamp.add_vertex((480, 160))
    lamp.add_vertex((420, 160))
    lamp.filled = True
    lamp.fill_color = 'lightyellow'
    window.add(lamp)
    lamp2 = GRect(10, 20, x=445, y=160)
    lamp2.filled = True
    lamp2.fill_color = 'grey'
    window.add(lamp2)
    lamp3 = GOval(30, 10, x=435, y=180)
    lamp3.filled = True
    lamp3.fill_color = 'lightyellow'
    window.add(lamp3)
    lamp4 = GRect(30, 30, x=435, y=185)
    lamp4.filled = True
    lamp4.fill_color = 'lightyellow'
    window.add(lamp4)

    # 沙發
    sofa1 = GRect(250, 100, x=550, y=100)
    sofa1.filled = True
    sofa1.fill_color = 'darkgray'
    window.add(sofa1)
    sofa2 = GPolygon()
    sofa2.add_vertex((550, 200))
    sofa2.add_vertex((800, 200))
    sofa2.add_vertex((800, 240))
    sofa2.add_vertex((600, 240))
    sofa2.filled = True
    sofa2.fill_color = 'darkgray'
    window.add(sofa2)
    sofa3 = GPolygon()
    sofa3.add_vertex((550, 100))
    sofa3.add_vertex((550, 200))
    sofa3.add_vertex((600, 240))
    sofa3.add_vertex((600, 300))
    sofa3.add_vertex((520, 240))
    sofa3.add_vertex((520, 60))
    sofa3.filled = True
    sofa3.fill_color = 'darkgray'
    window.add(sofa3)
    sofa4 = GPolygon()
    sofa4.add_vertex((550, 100))
    sofa4.add_vertex((520, 60))
    sofa4.add_vertex((800, 60))
    sofa4.add_vertex((800, 100))
    sofa4.filled = True
    sofa4.fill_color = 'darkgray'
    window.add(sofa4)
    sofa5 = GPolygon()
    sofa5.add_vertex((800, 240))
    sofa5.add_vertex((800, 300))
    sofa5.add_vertex((600, 300))
    sofa5.add_vertex((600, 240))
    sofa5.filled = True
    sofa5.fill_color = 'darkgray'
    window.add(sofa5)

    # 右上圖的人
    neck = GRect(20, 10, x=660, y=100)
    neck.filled = True
    neck.fill_color = 'peachpuff'
    window.add(neck)
    face = GOval(40, 60, x=650, y=45)
    face.filled = True
    face.fill_color = 'peachpuff'
    window.add(face)
    left_eye = GLine(660, 65, 670, 60)
    window.add(left_eye)
    right_eye = GLine(685, 65, 675, 60)
    window.add(right_eye)
    mouth = GLine(665, 90, 680, 90)
    window.add(mouth)
    body_1 = GRect(80, 80, x=630, y=110)
    body_1.filled = True
    body_1.fill_color = 'navy'
    window.add(body_1)
    body_2 = GPolygon()
    body_2.add_vertex((630, 110))
    body_2.add_vertex((570, 150))
    body_2.add_vertex((580, 162))
    body_2.add_vertex((630, 130))
    body_2.filled = True
    body_2.fill_color = 'navy'
    window.add(body_2)
    hand_1 = GOval(20, 20, x=560, y=150)
    hand_1.filled = True
    hand_1.fill_color = 'peachpuff'
    window.add(hand_1)
    body_3 = GPolygon()
    body_3.add_vertex((710, 110))
    body_3.add_vertex((780, 133))
    body_3.add_vertex((765, 148))
    body_3.add_vertex((710, 130))
    body_3.filled = True
    body_3.fill_color = 'navy'
    window.add(body_3)
    hand_2 = GOval(20, 20, x=765, y=133)
    hand_2.filled = True
    hand_2.fill_color = 'peachpuff'
    window.add(hand_2)
    leg_2 = GPolygon()
    leg_2.add_vertex((730, 215))
    leg_2.add_vertex((740, 205))
    leg_2.add_vertex((790, 215))
    leg_2.add_vertex((780, 225))
    leg_2.filled = True
    leg_2.fill_color = 'peachpuff'
    window.add(leg_2)
    shoes_2 = GPolygon()
    shoes_2.add_vertex((780, 225))
    shoes_2.add_vertex((790, 200))
    shoes_2.add_vertex((800, 202))
    shoes_2.add_vertex((790, 228))
    shoes_2.filled = True
    shoes_2.fill_color = 'gold'
    window.add(shoes_2)
    body_4 = GPolygon()
    body_4.add_vertex((630, 190))
    body_4.add_vertex((630, 230))
    body_4.add_vertex((670, 230))
    body_4.add_vertex((690, 215))
    body_4.add_vertex((735, 220))
    body_4.add_vertex((760, 200))
    body_4.add_vertex((710, 190))
    body_4.filled = True
    body_4.fill_color = 'cadetblue'
    window.add(body_4)
    leg_1 = GRect(20, 50, x=640, y=230)
    leg_1.filled = True
    leg_1.fill_color = 'peachpuff'
    window.add(leg_1)
    shoes_1 = GOval(33, 10, x=635, y=278)
    shoes_1.filled = True
    shoes_1.fill_color = 'gold'
    window.add(shoes_1)

    # 右下圖的人
    neck2 = GRect(35, 30, x=582, y=495)
    neck2.filled = True
    neck2.fill_color = 'peachpuff'
    window.add(neck2)
    face2 = GOval(100, 150, x=550, y=350)
    face2.filled = True
    face2.fill_color = 'peachpuff'
    window.add(face2)
    hair = GPolygon()
    hair.add_vertex((555, 390))
    hair.add_vertex((555, 330))
    hair.add_vertex((565, 350))
    hair.add_vertex((575, 330))
    hair.add_vertex((585, 350))
    hair.add_vertex((595, 330))
    hair.add_vertex((605, 350))
    hair.add_vertex((615, 330))
    hair.add_vertex((625, 350))
    hair.add_vertex((635, 330))
    hair.add_vertex((645, 390))
    hair.filled = True
    hair.fill_color = 'yellow'
    window.add(hair)
    eye1 = GLine(570, 410, 590, 420)
    window.add(eye1)
    eye1_2 = GLine(590, 420, 570, 430)
    window.add(eye1_2)
    eye2 = GLine(610, 430, 620, 410)
    window.add(eye2)
    eye2_2 = GLine(620, 410, 630, 430)
    window.add(eye2_2)
    mouth2 = GOval(10, 10, x=595, y=470)
    mouth2.filled = True
    window.add(mouth2)
    body1 = GPolygon()
    body1.add_vertex((450, 600))
    body1.add_vertex((500, 550))
    body1.add_vertex((582, 525))
    body1.add_vertex((617, 525))
    body1.add_vertex((700, 550))
    body1.add_vertex((750, 600))
    body1.filled = True
    body1.fill_color = 'lightblue'
    window.add(body1)
    arm = GPolygon()
    arm.add_vertex((750, 600))
    arm.add_vertex((680, 600))
    arm.add_vertex((660, 580))
    arm.add_vertex((660, 550))
    window.add(arm)
    finger5 = GOval(20, 50, x=640, y=480)
    finger5.filled = True
    finger5.fill_color = 'peachpuff'
    window.add(finger5)
    hand1 = GOval(50, 80, x=630, y=520)
    hand1.filled = True
    hand1.fill_color = 'peachpuff'
    window.add(hand1)
    finger1 = GOval(50, 20, x=610, y=520)
    finger1.filled = True
    finger1.fill_color = 'peachpuff'
    window.add(finger1)
    finger2 = GOval(50, 20, x=610, y=540)
    finger2.filled = True
    finger2.fill_color = 'peachpuff'
    window.add(finger2)
    finger3 = GOval(50, 20, x=610, y=560)
    finger3.filled = True
    finger3.fill_color = 'peachpuff'
    window.add(finger3)
    finger4 = GOval(50, 20, x=610, y=580)
    finger4.filled = True
    finger4.fill_color = 'peachpuff'
    window.add(finger4)
Beispiel #20
0
def main():
    """
    lovely Patrick Star !!
    """
    window = GWindow(width=400, height=500)
    body = GPolygon()
    body.add_vertex((150, 150))
    body.add_vertex((250, 150))
    body.add_vertex((275, 350))
    body.add_vertex((125, 350))
    body.filled = True
    body.color = 'pink'
    body.fill_color = 'pink'
    window.add(body)

    head = GOval(100, 100, x=150, y=100)
    head.filled = True
    head.fill_color = 'pink'
    head.color = 'pink'
    window.add(head)

    upleg = GRect(150, 75, x=125, y=350)
    upleg.filled = True
    upleg.color = 'seagreen'
    upleg.fill_color = 'seagreen'
    window.add(upleg)

    lleg = GRect(60, 10, x=125, y=425)
    lleg.filled = True
    lleg.color = 'seagreen'
    lleg.fill_color = 'seagreen'
    window.add(lleg)

    rleg = GRect(60, 10, x=215, y=425)
    rleg.filled = True
    rleg.color = 'seagreen'
    rleg.fill_color = 'seagreen'
    window.add(rleg)

    lfeet = GPolygon()
    lfeet.add_vertex((135, 435))
    lfeet.add_vertex((175, 435))
    lfeet.add_vertex((155, 460))
    lfeet.filled = True
    lfeet.color = 'pink'
    lfeet.fill_color = 'pink'
    window.add(lfeet)

    rfeet = GPolygon()
    rfeet.add_vertex((225, 435))
    rfeet.add_vertex((265, 435))
    rfeet.add_vertex((245, 460))
    rfeet.filled = True
    rfeet.color = 'pink'
    rfeet.fill_color = 'pink'
    window.add(rfeet)

    leyebrow1 = GLine(165, 150, 185, 147)
    leyebrow1.fill = 'black'
    window.add(leyebrow1)
    leyebrow2 = GLine(165, 155, 185, 152)
    leyebrow2.fill = 'black'
    window.add(leyebrow2)
    leyebrow3 = GLine(165, 160, 185, 157)
    leyebrow3.fill = 'black'
    window.add(leyebrow3)

    reyebrow1 = GLine(215, 147, 235, 150)
    reyebrow1.fill = 'black'
    window.add(reyebrow1)
    reyebrow2 = GLine(215, 152, 235, 155)
    reyebrow2.fill = 'black'
    window.add(reyebrow2)
    reyebrow3 = GLine(215, 157, 235, 160)
    reyebrow3.fill = 'black'
    window.add(reyebrow3)

    leye = GOval(35, 75, x=165, y=170)
    leye.filled = True
    leye.fill_color = 'white'
    window.add(leye)

    reye = GOval(35, 75, x=200, y=170)
    reye.filled = True
    reye.fill_color = 'white'
    window.add(reye)

    lcore = GOval(10, 10, x=180, y=205)
    lcore.filled = True
    lcore.fill_color = 'black'
    lcore.color = 'black'
    window.add(lcore)

    rcore = GOval(10, 10, x=210, y=205)
    rcore.filled = True
    rcore.fill_color = 'black'
    rcore.color = 'black'
    window.add(rcore)

    smile = GArc(100, 50, 180, 180, x=150, y=265)
    window.add(smile)

    lhand = GPolygon()
    lhand.add_vertex((75, 250))
    lhand.add_vertex((125, 350))
    lhand.add_vertex((200, 350))
    lhand.filled = True
    lhand.color = 'pink'
    lhand.fill_color = 'pink'
    window.add(lhand)

    rhand = GPolygon()
    rhand.add_vertex((325, 250))
    rhand.add_vertex((275, 350))
    rhand.add_vertex((200, 350))
    rhand.filled = True
    rhand.color = 'pink'
    rhand.fill_color = 'pink'
    window.add(rhand)

    line = GLine(75, 250, 75, 100)
    window.add(line)

    ball = GOval(100, 75, x=35, y=50)
    ball.filled = True
    ball.fill_color = 'red'
    window.add(ball)

    label = GLabel('Stancode_SC101', x=40, y=95)
    label.color = 'white'
    window.add(label)
Beispiel #21
0
def main():
    window = GWindow(width=600, height=500, title='tsum tsum')
    """
    #1 Aliens
    """

    background = GRect(600, 500)
    background.filled = True
    background.fill_color = 'white'
    window.add(background)

    mickey_lear = GOval(150, 150, x=80, y=160)
    mickey_lear.color = 'black'
    mickey_lear.filled = True
    mickey_lear.fill_color = 'limegreen'
    window.add(mickey_lear)

    alien_cover_lear = GOval(150, 150, x=130, y=120)
    alien_cover_lear.color = 'white'
    alien_cover_lear.filled = True
    alien_cover_lear.fill_color = 'white'
    window.add(alien_cover_lear)

    alien_rear = GOval(150, 150, x=350, y=160)
    alien_rear.color = 'black'
    alien_rear.filled = True
    alien_rear.fill_color = 'limegreen'
    window.add(alien_rear)

    alien_cover_rear = GOval(150, 150, x=310, y=120)
    alien_cover_rear.color = 'white'
    alien_cover_rear.filled = True
    alien_cover_rear.fill_color = 'white'
    window.add(alien_cover_rear)

    alien_lhand = GOval(40, 40, x=180, y=380)
    alien_lhand.color = 'black'
    alien_lhand.filled = True
    alien_lhand.fill_color = 'limegreen'
    window.add(alien_lhand)

    alien_rhand = GOval(40, 40, x=380, y=380)
    alien_rhand.color = 'black'
    alien_rhand.filled = True
    alien_rhand.fill_color = 'limegreen'
    window.add(alien_rhand)

    alien_face = GOval(300, 270, x=150, y=150)
    alien_face.color = 'black'
    alien_face.filled = True
    alien_face.fill_color = 'limegreen'
    window.add(alien_face)

    alien_leye = GOval(70, 70, x=190, y=280)
    alien_leye.color = 'black'
    alien_leye.filled = True
    alien_leye.fill_color = 'white'
    window.add(alien_leye)

    alien_meye = GOval(70, 70, x=270, y=240)
    alien_meye.color = 'black'
    alien_meye.filled = True
    alien_meye.fill_color = 'white'
    window.add(alien_meye)

    alien_reye = GOval(70, 70, x=350, y=280)
    alien_reye.color = 'black'
    alien_reye.filled = True
    alien_reye.fill_color = 'white'
    window.add(alien_reye)

    lball = GOval(30, 30, x=220, y=310)
    lball.filled = True
    lball.fill_color = 'black'
    window.add(lball)

    mball = GOval(30, 30, x=290, y=275)
    mball.filled = True
    mball.fill_color = 'black'
    window.add(mball)

    rball = GOval(30, 30, x=360, y=310)
    rball.filled = True
    rball.fill_color = 'black'
    window.add(rball)

    b_triangle = GPolygon()
    b_triangle.add_vertex((290, 200))
    b_triangle.add_vertex((320, 200))
    b_triangle.add_vertex((305, 100))
    b_triangle.color = 'black'
    b_triangle.filled = True
    b_triangle.fill_color = 'limegreen'
    window.add(b_triangle)

    t_headline = GOval(30, 30, x=290, y=100)
    t_headline.color = 'black'
    t_headline.filled = True
    t_headline.fill_color = 'limegreen'
    window.add(t_headline)
Beispiel #22
0
def main():
    """
    TODO:
    1.create the left side of my drawing
    2.create the right side of my drawing
    3.create the label
    """
    window = GWindow(512, 238, title="Life of π")
    # white hair
    white_hair = GRect(512, 238)
    white_hair.filled = True
    white_hair.fill_color = "moccasin"
    white_hair.color = "moccasin"
    window.add(white_hair)
    # 1.create the left side of my drawing
    # left side:
    # brown_hair,black_stripe_1~8,lower_eyelid,gold_eye,pupil,small_light,big_light,eyelid_white,eyelid_black.nose
    # brown hair
    brown_hair = GPolygon()
    brown_hair.add_vertex((0, 0))  # 1
    brown_hair.add_vertex((41, 0))
    brown_hair.add_vertex((64, 50))
    brown_hair.add_vertex((47, 84))
    brown_hair.add_vertex((60, 126))  # 5
    brown_hair.add_vertex((77, 158))
    brown_hair.add_vertex((123, 187))
    brown_hair.add_vertex((146, 212))
    brown_hair.add_vertex((183, 166))
    brown_hair.add_vertex((169, 135))  # 10
    brown_hair.add_vertex((191, 92))
    brown_hair.add_vertex((189, 41))
    brown_hair.add_vertex((162, 0))
    brown_hair.add_vertex((256, 0))
    brown_hair.add_vertex((256, 238))  # 15
    brown_hair.add_vertex((82, 238))
    brown_hair.add_vertex((40, 197))
    brown_hair.add_vertex((0, 197))  # 18
    brown_hair.filled = True
    brown_hair.fill_color = "darkorange"
    brown_hair.color = "darkorange"
    window.add(brown_hair)
    # black stripe
    # 1
    black_stripe_1 = GPolygon()
    black_stripe_1.add_vertex((0, 0))  # 1
    black_stripe_1.add_vertex((70, 0))
    black_stripe_1.add_vertex((59, 39))
    black_stripe_1.add_vertex((70, 52))
    black_stripe_1.add_vertex((59, 58))  # 5
    black_stripe_1.add_vertex((59, 80))  # 6
    black_stripe_1.add_vertex((63, 100))
    black_stripe_1.add_vertex((51, 110))
    black_stripe_1.add_vertex((28, 150))
    black_stripe_1.add_vertex((31, 103))  # 10
    black_stripe_1.add_vertex((41, 77))  # 11
    black_stripe_1.add_vertex((42, 52))
    black_stripe_1.add_vertex((20, 66))
    black_stripe_1.add_vertex((19, 107))
    black_stripe_1.add_vertex((0, 150))  # 15
    black_stripe_1.add_vertex((0, 57))
    black_stripe_1.add_vertex((32, 23))
    black_stripe_1.filled = True
    black_stripe_1.color = "black"
    window.add(black_stripe_1)
    # 2
    black_stripe_2 = GPolygon()
    black_stripe_2.add_vertex((30, 152))  # 1
    black_stripe_2.add_vertex((58, 208))
    black_stripe_2.add_vertex((83, 216))
    black_stripe_2.add_vertex((115, 208))
    black_stripe_2.add_vertex((79, 235))  # 5
    black_stripe_2.add_vertex((47, 226))  # 6
    black_stripe_2.filled = True
    black_stripe_2.color = "black"
    window.add(black_stripe_2)
    # 3
    black_stripe_3 = GPolygon()
    black_stripe_3.add_vertex((57, 165))  # 1
    black_stripe_3.add_vertex((73, 190))
    black_stripe_3.add_vertex((121, 188))
    black_stripe_3.add_vertex((85, 166))
    black_stripe_3.add_vertex((89, 178))  # 5
    black_stripe_3.filled = True
    black_stripe_3.color = "black"
    window.add(black_stripe_3)
    # 4
    black_stripe_4 = GPolygon()
    black_stripe_4.add_vertex((85, 167))  # 1
    black_stripe_4.add_vertex((60, 120))
    black_stripe_4.add_vertex((58, 146))
    black_stripe_4.filled = True
    black_stripe_4.color = "black"
    window.add(black_stripe_4)
    # 5
    black_stripe_5 = GPolygon()
    black_stripe_5.add_vertex((62, 100))  # 1
    black_stripe_5.add_vertex((102, 101))
    black_stripe_5.add_vertex((133, 112))
    black_stripe_5.add_vertex((153, 131))
    black_stripe_5.add_vertex((162, 148))  # 5
    black_stripe_5.add_vertex((170, 190))  # 6
    black_stripe_5.add_vertex((149, 212))
    black_stripe_5.add_vertex((141, 178))
    black_stripe_5.add_vertex((121, 176))
    black_stripe_5.add_vertex((101, 164))  # 10
    black_stripe_5.add_vertex((88, 146))  # 11
    black_stripe_5.add_vertex((82, 118))
    black_stripe_5.add_vertex((61, 123))
    black_stripe_5.filled = True
    black_stripe_5.color = "black"
    window.add(black_stripe_5)
    # 6
    black_stripe_6 = GPolygon()
    black_stripe_6.add_vertex((192, 0))  # 1
    black_stripe_6.add_vertex((211, 5))
    black_stripe_6.add_vertex((180, 29))
    black_stripe_6.add_vertex((162, 33))
    black_stripe_6.add_vertex((160, 55))  # 5
    black_stripe_6.add_vertex((145, 61))  # 6
    black_stripe_6.add_vertex((133, 44))
    black_stripe_6.add_vertex((124, 62))
    black_stripe_6.add_vertex((154, 120))
    black_stripe_6.add_vertex((119, 100))  # 10
    black_stripe_6.add_vertex((99, 80))  # 11
    black_stripe_6.add_vertex((71, 67))
    black_stripe_6.add_vertex((92, 65))
    black_stripe_6.add_vertex((99, 47))
    black_stripe_6.add_vertex((104, 50))  # 15
    black_stripe_6.add_vertex((99, 65))  # 16
    black_stripe_6.add_vertex((127, 91))
    black_stripe_6.add_vertex((110, 62))
    black_stripe_6.add_vertex((121, 45))
    black_stripe_6.add_vertex((120, 31))  # 20
    black_stripe_6.add_vertex((130, 18))
    black_stripe_6.add_vertex((162, 19))  # 22
    black_stripe_6.filled = True
    black_stripe_6.color = "black"
    window.add(black_stripe_6)
    # 7
    black_stripe_7 = GPolygon()
    black_stripe_7.add_vertex((256, 0))  # 1
    black_stripe_7.add_vertex((231, 20))
    black_stripe_7.add_vertex((223, 8))
    black_stripe_7.add_vertex((192, 38))
    black_stripe_7.add_vertex((181, 65))  # 5
    black_stripe_7.add_vertex((190, 96))  # 6
    black_stripe_7.add_vertex((180, 126))
    black_stripe_7.add_vertex((191, 124))
    black_stripe_7.add_vertex((195, 102))
    black_stripe_7.add_vertex((211, 89))  # 10
    black_stripe_7.add_vertex((203, 81))  # 11
    black_stripe_7.add_vertex((199, 52))
    black_stripe_7.add_vertex((200, 43))
    black_stripe_7.add_vertex((222, 31))
    black_stripe_7.add_vertex((231, 56))  # 15
    black_stripe_7.add_vertex((225, 76))  # 16
    black_stripe_7.add_vertex((215, 89))
    black_stripe_7.add_vertex((226, 94))
    black_stripe_7.add_vertex((241, 68))
    black_stripe_7.add_vertex((250, 47))  # 20
    black_stripe_7.add_vertex((252, 81))
    black_stripe_7.add_vertex((234, 112))
    black_stripe_7.add_vertex((256, 123))  # 23
    black_stripe_7.filled = True
    black_stripe_7.color = "black"
    window.add(black_stripe_7)
    # 8
    black_stripe_8 = GPolygon()
    black_stripe_8.add_vertex((193, 126))  # 1
    black_stripe_8.add_vertex((189, 144))
    black_stripe_8.add_vertex((216, 121))
    black_stripe_8.add_vertex((225, 99))
    black_stripe_8.add_vertex((208, 117))  # 5
    black_stripe_8.filled = True
    black_stripe_8.color = "black"
    window.add(black_stripe_8)
    # lower-eyelid
    lower_eyelid = GPolygon()
    lower_eyelid.add_vertex((78, 107))  # 1
    lower_eyelid.add_vertex((84, 110))
    lower_eyelid.add_vertex((96, 150))
    lower_eyelid.add_vertex((114, 162))
    lower_eyelid.add_vertex((138, 164))  # 5
    lower_eyelid.add_vertex((154, 168))
    lower_eyelid.add_vertex((160, 150))
    lower_eyelid.add_vertex((159, 187))
    lower_eyelid.add_vertex((137, 167))
    lower_eyelid.add_vertex((114, 165))  # 10
    lower_eyelid.add_vertex((94, 153))
    lower_eyelid.add_vertex((82, 111))
    lower_eyelid.filled = True
    lower_eyelid.color = "thistle"
    lower_eyelid.fill_color = "thistle"
    window.add(lower_eyelid)
    # eye
    # eye-gold_eye
    gold_eye = GOval(52, 50, x=94, y=103)
    gold_eye.filled = True
    gold_eye.color = "gold"
    gold_eye.fill_color = "gold"
    window.add(gold_eye)
    # eye-pupil
    pupil = GOval(13, 12, x=113, y=122)
    pupil.filled = True
    pupil.fill_color = "black"
    window.add(pupil)
    # eye-small_light
    small_light = GOval(4, 4, x=124, y=124)
    small_light.filled = True
    small_light.color = "white"
    small_light.fill_color = "white"
    window.add(small_light)
    # eye-big_light
    big_light = GOval(10, 11, x=104, y=118)
    big_light.filled = True
    big_light.color = "white"
    big_light.fill_color = "white"
    window.add(big_light)
    # eyelid
    # eyelid_white
    eyelid_white = GPolygon()
    eyelid_white.add_vertex((105, 97))
    eyelid_white.add_vertex((133, 101))
    eyelid_white.add_vertex((155, 117))
    eyelid_white.add_vertex((154, 142))
    eyelid_white.add_vertex((126, 115))
    eyelid_white.add_vertex((93, 107))
    eyelid_white.filled = True
    eyelid_white.fill_color = "burlywood"
    eyelid_white.color = "burlywood"
    window.add(eyelid_white)
    # eyelid_black
    eyelid_black = GPolygon()
    eyelid_black.add_vertex((91, 100))
    eyelid_black.add_vertex((129, 108))
    eyelid_black.add_vertex((157, 132))
    eyelid_black.add_vertex((156, 147))
    eyelid_black.add_vertex((126, 120))
    eyelid_black.add_vertex((91, 111))
    eyelid_black.add_vertex((87, 104))
    eyelid_black.filled = True
    eyelid_black.fill_color = "black"
    window.add(eyelid_black)
    # nose
    nose = GPolygon()
    nose.add_vertex((256, 170))
    nose.add_vertex((256, 238))
    nose.add_vertex((163, 238))
    nose.filled = True
    nose.fill_color = "chocolate"
    nose.color = "chocolate"
    window.add(nose)
    # 2.create the right side of my drawing
    # right side:
    # brown_hair,black_stripe_1~8,lower_eyelid,gold_eye,pupil,small_light,big_light,eyelid_white,eyelid_black,nose
    # brown hair
    brown_hair = GPolygon()
    brown_hair.add_vertex((window.width-1-0, 0))  # 1
    brown_hair.add_vertex((window.width-1-41, 0))
    brown_hair.add_vertex((window.width-1-64, 50))
    brown_hair.add_vertex((window.width-1-47, 84))
    brown_hair.add_vertex((window.width-1-60, 126))  # 5
    brown_hair.add_vertex((window.width-1-77, 158))
    brown_hair.add_vertex((window.width-1-123, 187))
    brown_hair.add_vertex((window.width-1-146, 212))
    brown_hair.add_vertex((window.width-1-183, 166))
    brown_hair.add_vertex((window.width-1-169, 135))  # 10
    brown_hair.add_vertex((window.width-1-191, 92))
    brown_hair.add_vertex((window.width-1-189, 41))
    brown_hair.add_vertex((window.width-1-162, 0))
    brown_hair.add_vertex((window.width-1-256, 0))
    brown_hair.add_vertex((window.width-1-256, 238))  # 15
    brown_hair.add_vertex((window.width-1-82, 238))
    brown_hair.add_vertex((window.width-1-40, 197))
    brown_hair.add_vertex((window.width-1-0, 197))  # 18
    brown_hair.filled = True
    brown_hair.fill_color = "darkorange"
    brown_hair.color = "darkorange"
    window.add(brown_hair)
    # black stripe
    # 1
    black_stripe_1 = GPolygon()
    black_stripe_1.add_vertex((window.width-1-0, 0))  # 1
    black_stripe_1.add_vertex((window.width-1-70, 0))
    black_stripe_1.add_vertex((window.width-1-59, 39))
    black_stripe_1.add_vertex((window.width-1-70, 52))
    black_stripe_1.add_vertex((window.width-1-59, 58))  # 5
    black_stripe_1.add_vertex((window.width-1-59, 80))  # 6
    black_stripe_1.add_vertex((window.width-1-63, 100))
    black_stripe_1.add_vertex((window.width-1-51, 110))
    black_stripe_1.add_vertex((window.width-1-28, 150))
    black_stripe_1.add_vertex((window.width-1-31, 103))  # 10
    black_stripe_1.add_vertex((window.width-1-41, 77))  # 11
    black_stripe_1.add_vertex((window.width-1-42, 52))
    black_stripe_1.add_vertex((window.width-1-20, 66))
    black_stripe_1.add_vertex((window.width-1-19, 107))
    black_stripe_1.add_vertex((window.width-1-0, 150))  # 15
    black_stripe_1.add_vertex((window.width-1-0, 57))
    black_stripe_1.add_vertex((window.width-1-32, 23))
    black_stripe_1.filled = True
    black_stripe_1.color = "black"
    window.add(black_stripe_1)
    # 2
    black_stripe_2 = GPolygon()
    black_stripe_2.add_vertex((window.width-1-30, 152))  # 1
    black_stripe_2.add_vertex((window.width-1-58, 208))
    black_stripe_2.add_vertex((window.width-1-83, 216))
    black_stripe_2.add_vertex((window.width-1-115, 208))
    black_stripe_2.add_vertex((window.width-1-79, 235))  # 5
    black_stripe_2.add_vertex((window.width-1-47, 226))  # 6
    black_stripe_2.filled = True
    black_stripe_2.color = "black"
    window.add(black_stripe_2)
    # 3
    black_stripe_3 = GPolygon()
    black_stripe_3.add_vertex((window.width-1-57, 165))  # 1
    black_stripe_3.add_vertex((window.width-1-73, 190))
    black_stripe_3.add_vertex((window.width-1-121, 188))
    black_stripe_3.add_vertex((window.width-1-85, 166))
    black_stripe_3.add_vertex((window.width-1-89, 178))  # 5
    black_stripe_3.filled = True
    black_stripe_3.color = "black"
    window.add(black_stripe_3)
    # 4
    black_stripe_4 = GPolygon()
    black_stripe_4.add_vertex((window.width-1-85, 167))  # 1
    black_stripe_4.add_vertex((window.width-1-60, 120))
    black_stripe_4.add_vertex((window.width-1-58, 146))
    black_stripe_4.filled = True
    black_stripe_4.color = "black"
    window.add(black_stripe_4)
    # 5
    black_stripe_5 = GPolygon()
    black_stripe_5.add_vertex((window.width-1-62, 100))  # 1
    black_stripe_5.add_vertex((window.width-1-102, 101))
    black_stripe_5.add_vertex((window.width-1-133, 112))
    black_stripe_5.add_vertex((window.width-1-153, 131))
    black_stripe_5.add_vertex((window.width-1-162, 148))  # 5
    black_stripe_5.add_vertex((window.width-1-170, 190))  # 6
    black_stripe_5.add_vertex((window.width-1-149, 212))
    black_stripe_5.add_vertex((window.width-1-141, 178))
    black_stripe_5.add_vertex((window.width-1-121, 176))
    black_stripe_5.add_vertex((window.width-1-101, 164))  # 10
    black_stripe_5.add_vertex((window.width-1-88, 146))  # 11
    black_stripe_5.add_vertex((window.width-1-82, 118))
    black_stripe_5.add_vertex((window.width-1-61, 123))
    black_stripe_5.filled = True
    black_stripe_5.color = "black"
    window.add(black_stripe_5)
    # 6
    black_stripe_6 = GPolygon()
    black_stripe_6.add_vertex((window.width-1-192, 0))  # 1
    black_stripe_6.add_vertex((window.width-1-211, 5))
    black_stripe_6.add_vertex((window.width-1-180, 29))
    black_stripe_6.add_vertex((window.width-1-162, 33))
    black_stripe_6.add_vertex((window.width-1-160, 55))  # 5
    black_stripe_6.add_vertex((window.width-1-145, 61))  # 6
    black_stripe_6.add_vertex((window.width-1-133, 44))
    black_stripe_6.add_vertex((window.width-1-124, 62))
    black_stripe_6.add_vertex((window.width-1-154, 120))
    black_stripe_6.add_vertex((window.width-1-119, 100))  # 10
    black_stripe_6.add_vertex((window.width-1-99, 80))  # 11
    black_stripe_6.add_vertex((window.width-1-71, 67))
    black_stripe_6.add_vertex((window.width-1-92, 65))
    black_stripe_6.add_vertex((window.width-1-99, 47))
    black_stripe_6.add_vertex((window.width-1-104, 50))  # 15
    black_stripe_6.add_vertex((window.width-1-99, 65))  # 16
    black_stripe_6.add_vertex((window.width-1-127, 91))
    black_stripe_6.add_vertex((window.width-1-110, 62))
    black_stripe_6.add_vertex((window.width-1-121, 45))
    black_stripe_6.add_vertex((window.width-1-120, 31))  # 20
    black_stripe_6.add_vertex((window.width-1-130, 18))
    black_stripe_6.add_vertex((window.width-1-162, 19))  # 22
    black_stripe_6.filled = True
    black_stripe_6.color = "black"
    window.add(black_stripe_6)
    # 7
    black_stripe_7 = GPolygon()
    black_stripe_7.add_vertex((window.width-1-256, 0))  # 1
    black_stripe_7.add_vertex((window.width-1-231, 20))
    black_stripe_7.add_vertex((window.width-1-223, 8))
    black_stripe_7.add_vertex((window.width-1-192, 38))
    black_stripe_7.add_vertex((window.width-1-181, 65))  # 5
    black_stripe_7.add_vertex((window.width-1-190, 96))  # 6
    black_stripe_7.add_vertex((window.width-1-180, 126))
    black_stripe_7.add_vertex((window.width-1-191, 124))
    black_stripe_7.add_vertex((window.width-1-195, 102))
    black_stripe_7.add_vertex((window.width-1-211, 89))  # 10
    black_stripe_7.add_vertex((window.width-1-203, 81))  # 11
    black_stripe_7.add_vertex((window.width-1-199, 52))
    black_stripe_7.add_vertex((window.width-1-200, 43))
    black_stripe_7.add_vertex((window.width-1-222, 31))
    black_stripe_7.add_vertex((window.width-1-231, 56))  # 15
    black_stripe_7.add_vertex((window.width-1-225, 76))  # 16
    black_stripe_7.add_vertex((window.width-1-215, 89))
    black_stripe_7.add_vertex((window.width-1-226, 94))
    black_stripe_7.add_vertex((window.width-1-241, 68))
    black_stripe_7.add_vertex((window.width-1-250, 47))  # 20
    black_stripe_7.add_vertex((window.width-1-252, 81))
    black_stripe_7.add_vertex((window.width-1-234, 112))
    black_stripe_7.add_vertex((window.width-1-256, 123))  # 23
    black_stripe_7.filled = True
    black_stripe_7.color = "black"
    window.add(black_stripe_7)
    # 8
    black_stripe_8 = GPolygon()
    black_stripe_8.add_vertex((window.width-1-193, 126))  # 1
    black_stripe_8.add_vertex((window.width-1-189, 144))
    black_stripe_8.add_vertex((window.width-1-216, 121))
    black_stripe_8.add_vertex((window.width-1-225, 99))
    black_stripe_8.add_vertex((window.width-1-208, 117))  # 5
    black_stripe_8.filled = True
    black_stripe_8.color = "black"
    window.add(black_stripe_8)
    # lower-eyelid
    lower_eyelid = GPolygon()
    lower_eyelid.add_vertex((window.width-1-78, 107))  # 1
    lower_eyelid.add_vertex((window.width-1-84, 110))
    lower_eyelid.add_vertex((window.width-1-96, 150))
    lower_eyelid.add_vertex((window.width-1-114, 162))
    lower_eyelid.add_vertex((window.width-1-138, 164))  # 5
    lower_eyelid.add_vertex((window.width-1-154, 168))
    lower_eyelid.add_vertex((window.width-1-160, 150))
    lower_eyelid.add_vertex((window.width-1-159, 187))
    lower_eyelid.add_vertex((window.width-1-137, 167))
    lower_eyelid.add_vertex((window.width-1-114, 165))  # 10
    lower_eyelid.add_vertex((window.width-1-94, 153))
    lower_eyelid.add_vertex((window.width-1-82, 111))
    lower_eyelid.filled = True
    lower_eyelid.color = "thistle"
    lower_eyelid.fill_color = "thistle"
    window.add(lower_eyelid)
    # eye
    # eye-gold_eye
    gold_eye = GOval(52, 50, x=270+94, y=103)
    gold_eye.filled = True
    gold_eye.color = "gold"
    gold_eye.fill_color = "gold"
    window.add(gold_eye)
    # eye-pupil
    pupil = GOval(13, 12, x=270+113, y=122)
    pupil.filled = True
    pupil.fill_color = "black"
    window.add(pupil)
    # eye-small_light
    small_light = GOval(4, 4, x=255+124, y=124)
    small_light.filled = True
    small_light.color = "white"
    small_light.fill_color = "white"
    window.add(small_light)
    # eye-big_light
    big_light = GOval(10, 11, x=290+104, y=118)
    big_light.filled = True
    big_light.color = "white"
    big_light.fill_color = "white"
    window.add(big_light)
    # eyelid
    # eyelid_white
    eyelid_white = GPolygon()
    eyelid_white.add_vertex((window.width-1-105, 97))
    eyelid_white.add_vertex((window.width-1-133, 101))
    eyelid_white.add_vertex((window.width-1-155, 117))
    eyelid_white.add_vertex((window.width-1-154, 142))
    eyelid_white.add_vertex((window.width-1-126, 115))
    eyelid_white.add_vertex((window.width-1-93, 107))
    eyelid_white.filled = True
    eyelid_white.fill_color = "burlywood"
    eyelid_white.color = "burlywood"
    window.add(eyelid_white)
    # eyelid_black
    eyelid_black = GPolygon()
    eyelid_black.add_vertex((window.width-1-91, 100))
    eyelid_black.add_vertex((window.width-1-129, 108))
    eyelid_black.add_vertex((window.width-1-157, 132))
    eyelid_black.add_vertex((window.width-1-156, 147))
    eyelid_black.add_vertex((window.width-1-126, 120))
    eyelid_black.add_vertex((window.width-1-91, 111))
    eyelid_black.add_vertex((window.width-1-87, 104))
    eyelid_black.filled = True
    eyelid_black.fill_color = "black"
    window.add(eyelid_black)
    # nose
    nose = GPolygon()
    nose.add_vertex((window.width-1-256, 170))
    nose.add_vertex((window.width-1-256, 238))
    nose.add_vertex((window.width-1-163, 238))
    nose.filled = True
    nose.fill_color = "chocolate"
    nose.color = "chocolate"
    window.add(nose)
    # 3.create the label
    # label
    label = GLabel("Life", x=210, y=50)
    label.font = "Courier-30-bold"
    label.color = "white"
    window.add(label)
    label = GLabel("of", x=235, y=95)
    label.font = "Courier-25-bold"
    label.color = "white"
    window.add(label)
    label = GLabel("π", x=228, y=180)
    label.font = "Courier-70-bold"
    label.color = "white"
    window.add(label)
Beispiel #23
0
def main():
    """
    Create a window and lots of objects from GObject.
    Add those objects to the window to make the drawing.
    """

    window = GWindow(width=600, height=470, title='little my')

    r = GRect(600, 470, x=0, y=0)
    r.filled = True
    r.color = '#1C3747'
    r.fill_color = '#1C3747'
    window.add(r)

    wood1 = GRect(25, 300, x=360, y=170)
    wood1.filled = True
    wood1.color = '#C29950'
    wood1.fill_color = '#C29950'
    window.add(wood1)

    wood3 = GRect(280, 190, x=230, y=10)
    wood3.filled = True
    wood3.color = '#8F4629'
    wood3.fill_color = '#8F4629'
    window.add(wood3)

    wood2 = GRect(240, 150, x=250, y=30)
    wood2.filled = True
    wood2.color = '#C29950'
    wood2.fill_color = '#C29950'
    window.add(wood2)

    grass = GOval(50, 140, x=-10, y=400)
    grass.filled = True
    grass.color = '#405F3E'
    grass.fill_color = '#405F3E'
    window.add(grass)

    grass = GOval(60, 140, x=10, y=420)
    grass.filled = True
    grass.color = '#5D7160'
    grass.fill_color = '#5D7160'
    window.add(grass)

    grass = GOval(90, 160, x=40, y=420)
    grass.filled = True
    grass.color = '#61806B'
    grass.fill_color = '#61806B'
    window.add(grass)

    grass = GOval(100, 140, x=80, y=430)
    grass.filled = True
    grass.color = '#435646'
    grass.fill_color = '#435646'
    window.add(grass)

    grass = GOval(180, 100, x=90, y=430)
    grass.filled = True
    grass.color = '#435646'
    grass.fill_color = '#435646'
    window.add(grass)

    grass = GOval(100, 150, x=200, y=410)
    grass.filled = True
    grass.color = '#405F3E'
    grass.fill_color = '#405F3E'
    window.add(grass)

    grass = GOval(110, 180, x=230, y=420)
    grass.filled = True
    grass.color = '#435646'
    grass.fill_color = '#435646'
    window.add(grass)

    l_shoe = GPolygon()
    l_shoe.add_vertex((170, 370))
    l_shoe.add_vertex((190, 445))
    l_shoe.add_vertex((190, 445))
    l_shoe.add_vertex((200, 445))
    l_shoe.add_vertex((210, 445))
    l_shoe.add_vertex((220, 440))
    l_shoe.add_vertex((230, 455))
    l_shoe.add_vertex((220, 465))
    l_shoe.add_vertex((200, 465))
    l_shoe.add_vertex((185, 460))
    l_shoe.add_vertex((180, 465))
    l_shoe.add_vertex((168, 465))
    l_shoe.add_vertex((155, 370))
    l_shoe.filled = True
    l_shoe.fill_color = 'black'
    window.add(l_shoe)

    r_shoe = GPolygon()
    r_shoe.add_vertex((130, 370))
    r_shoe.add_vertex((110, 445))
    r_shoe.add_vertex((110, 445))
    r_shoe.add_vertex((100, 445))
    r_shoe.add_vertex((90, 445))
    r_shoe.add_vertex((80, 440))
    r_shoe.add_vertex((70, 455))
    r_shoe.add_vertex((85, 465))
    r_shoe.add_vertex((100, 465))
    r_shoe.add_vertex((115, 460))
    r_shoe.add_vertex((120, 465))
    r_shoe.add_vertex((132, 465))
    r_shoe.add_vertex((145, 370))
    r_shoe.filled = True
    r_shoe.fill_color = 'black'
    window.add(r_shoe)

    dress = GPolygon()
    dress.add_vertex((108, 218))
    dress.add_vertex((96, 250))
    dress.add_vertex((45, 260))
    dress.add_vertex((43, 275))
    dress.add_vertex((71, 330))
    dress.add_vertex((30, 390))
    dress.add_vertex((90, 410))
    dress.add_vertex((135, 415))
    dress.add_vertex((166, 420))
    dress.add_vertex((200, 415))
    dress.add_vertex((270, 390))
    dress.add_vertex((205, 265))
    dress.add_vertex((355, 265))
    dress.add_vertex((355, 250))
    dress.add_vertex((205, 250))
    dress.add_vertex((193, 218))
    dress.filled = True
    dress.fill_color = '#B5272D'
    window.add(dress)

    l_hand = GPolygon()
    l_hand.add_vertex((90, 268))
    l_hand.add_vertex((60, 275))
    l_hand.add_vertex((80, 310))
    l_hand.filled = True
    l_hand.fill_color = '#1C3747'
    window.add(l_hand)

    l_tie = GPolygon()
    l_tie.add_vertex((150, 238))
    l_tie.add_vertex((105, 220))
    l_tie.add_vertex((105, 255))
    l_tie.filled = True
    l_tie.fill_color = '#D17989'
    window.add(l_tie)

    r_tie = GPolygon()
    r_tie.add_vertex((150, 238))
    r_tie.add_vertex((195, 220))
    r_tie.add_vertex((195, 255))
    r_tie.filled = True
    r_tie.fill_color = '#D17989'
    window.add(r_tie)

    tie = GOval(20, 26, x=140, y=225)
    tie.filled = True
    tie.fill_color = '#D17989'
    window.add(tie)

    l_ear = GOval(40, 40, x=60, y=150)
    l_ear.filled = True
    l_ear.fill_color = '#FFF1E2'
    window.add(l_ear)

    r_ear = GOval(40, 40, x=200, y=150)
    r_ear.filled = True
    r_ear.fill_color = '#FFF1E2'
    window.add(r_ear)

    face = GOval(160, 140, x=70, y=90)
    face.filled = True
    face.fill_color = '#FFF1E2'
    window.add(face)

    l_eye = GArc(40, 90, -10, -180, x=90, y=140)
    l_eye.filled = True
    l_eye.fill_color = 'white'
    window.add(l_eye)

    l_eye_b = GArc(20, 60, -10, -178, x=100, y=148)
    l_eye_b.filled = True
    l_eye_b.fill_color = '#4A8165'
    window.add(l_eye_b)

    r_eye = GArc(40, 90, 10, -180, x=170, y=140)
    r_eye.filled = True
    r_eye.fill_color = 'white'
    window.add(r_eye)

    r_eye_b = GArc(20, 60, 10, -178, x=180, y=148)
    r_eye_b.filled = True
    r_eye_b.fill_color = '#4A8165'
    window.add(r_eye_b)

    nose1 = GLine(146, 160, 148, 173)
    nose1.color = 'black'
    window.add(nose1)

    nose2 = GLine(156, 160, 154, 173)
    nose2.color = 'black'
    window.add(nose2)

    nose3 = GLine(149, 175, 140, 199)
    nose3.color = 'black'
    window.add(nose3)

    nose4 = GLine(162, 199, 153, 175)
    nose4.color = 'black'
    window.add(nose4)

    nose5 = GLine(140, 199, 162, 199)
    nose5.color = 'black'
    window.add(nose5)

    mouth = GArc(100, 80, -30, -120, x=110, y=190)
    mouth.color = 'black'
    window.add(mouth)

    h_tail1 = GOval(50, 100, x=125, y=30)
    h_tail1.filled = True
    h_tail1.fill_color = '#F39401'
    h_tail1.color = '#F39401'
    window.add(h_tail1)

    h_tail1_line1 = GArc(160, 110, 120, 100, x=135, y=30)
    h_tail1_line1.color = 'black'
    window.add(h_tail1_line1)

    h_tail1_line2 = GArc(160, 110, 120, 100, x=142, y=30)
    h_tail1_line2.color = 'black'
    window.add(h_tail1_line2)

    h_tail1_line3 = GArc(160, 110, 60, -100, x=120, y=30)
    h_tail1_line3.color = 'black'
    window.add(h_tail1_line3)

    h_tail1_line4 = GArc(160, 110, 60, -100, x=127, y=30)
    h_tail1_line4.color = 'black'
    window.add(h_tail1_line4)

    h_tail1_line5 = GLine(150, 50, 150, 86)
    h_tail1_line5.color = 'black'
    window.add(h_tail1_line5)

    hair = GArc(160, 240, 0, 180, x=70, y=90)
    hair.filled = True
    hair.fill_color = '#F39401'
    hair.color = '#F39401'
    window.add(hair)

    hairline1 = GArc(800, 230, 115, 69, x=80, y=90)
    hairline1.color = 'black'
    window.add(hairline1)

    hairline2 = GArc(820, 230, 120, 66, x=95, y=89)
    hairline2.fill = 'black'
    window.add(hairline2)

    hairline3 = GArc(840, 240, 130, 58, x=110, y=88)
    hairline3.fill = 'black'
    window.add(hairline3)

    hairline4 = GArc(860, 240, 135, 56, x=125, y=87)
    hairline4.fill = 'black'
    window.add(hairline4)

    hairline5 = GArc(920, 250, 140, 53, x=135, y=85)
    hairline5.fill = 'black'
    window.add(hairline5)

    hairline6 = GLine(150, 110, 153, 150)
    hairline6.fill = 'black'
    window.add(hairline6)

    hairline7 = GArc(300, 400, 90, -75, x=80, y=96)
    hairline7.fill = 'black'
    window.add(hairline7)

    hairline8 = GArc(300, 425, 85, -70, x=75, y=93)
    hairline8.fill = 'black'
    window.add(hairline8)

    hairline9 = GArc(320, 475, 70, -55, x=90, y=90)
    hairline9.fill = 'black'
    window.add(hairline9)

    hairline10 = GArc(280, 500, 65, -50, x=100, y=90)
    hairline10.fill = 'black'
    window.add(hairline10)

    hairline11 = GArc(280, 530, 60, -45, x=100, y=90)
    hairline11.fill = 'black'
    window.add(hairline11)

    l_hand = GArc(50, 50, 40, -180, x=43, y=298)
    l_hand.filled = True
    l_hand.fill_color = 'black'
    window.add(l_hand)

    r_hand = GOval(40, 40, x=350, y=235)
    r_hand.filled = True
    r_hand.fill_color = 'black'
    window.add(r_hand)

    label = GLabel('Python!', x=263, y=140)
    label.font = 'Verdana-38-italic-bold'
    label.color = 'white'
    window.add(label)

    grass = GOval(120, 180, x=260, y=430)
    grass.filled = True
    grass.color = '#435646'
    grass.fill_color = '#5D7160'
    window.add(grass)

    grass = GOval(120, 180, x=330, y=450)
    grass.filled = True
    grass.color = '#405F3E'
    grass.fill_color = '#405F3E'
    window.add(grass)

    grass = GOval(120, 180, x=370, y=430)
    grass.filled = True
    grass.color = '#435646'
    grass.fill_color = '#435646'
    window.add(grass)

    grass = GOval(120, 150, x=430, y=420)
    grass.filled = True
    grass.color = '#4F5939'
    grass.fill_color = '#4F5939'
    window.add(grass)

    grass = GOval(80, 180, x=470, y=410)
    grass.filled = True
    grass.color = '#405F3E'
    grass.fill_color = '#405F3E'
    window.add(grass)

    grass = GOval(120, 150, x=500, y=440)
    grass.filled = True
    grass.color = '#435646'
    grass.fill_color = '#435646'
    window.add(grass)

    hatti = GRect(50, 170, x=420, y=300)
    hatti.filled = True
    hatti.color = '#DADADA'
    hatti.fill_color = '#DADADA'
    window.add(hatti)

    hatti_h = GOval(50, 50, x=420, y=275)
    hatti_h.filled = True
    hatti_h.color = '#DADADA'
    hatti_h.fill_color = '#DADADA'
    window.add(hatti_h)

    hatti_e = GOval(25, 25, x=420, y=300)
    hatti_e.filled = True
    hatti_e.color = 'black'
    hatti_e.fill_color = 'white'
    window.add(hatti_e)

    hatti_ee = GOval(25, 25, x=445, y=300)
    hatti_ee.filled = True
    hatti_ee.color = 'black'
    hatti_ee.fill_color = 'white'
    window.add(hatti_ee)

    hatti_b = GOval(10, 10, x=452.5, y=307.5)
    hatti_b.filled = True
    hatti_b.color = 'black'
    hatti_b.fill_color = 'black'
    window.add(hatti_b)

    hatti_bb = GOval(10, 10, x=427.5, y=307.5)
    hatti_bb.filled = True
    hatti_bb.color = 'black'
    hatti_bb.fill_color = 'black'
    window.add(hatti_bb)

    hatti = GRect(50, 210, x=480, y=260)
    hatti.filled = True
    hatti.color = '#DADADA'
    hatti.fill_color = '#DADADA'
    window.add(hatti)

    hatti_h = GOval(50, 50, x=480, y=235)
    hatti_h.filled = True
    hatti_h.color = '#DADADA'
    hatti_h.fill_color = '#DADADA'
    window.add(hatti_h)

    hatti_e = GOval(25, 25, x=480, y=260)
    hatti_e.filled = True
    hatti_e.color = 'black'
    hatti_e.fill_color = 'white'
    window.add(hatti_e)

    hatti_ee = GOval(25, 25, x=505, y=260)
    hatti_ee.filled = True
    hatti_ee.color = 'black'
    hatti_ee.fill_color = 'white'
    window.add(hatti_ee)

    hatti_b = GOval(10, 10, x=512.5, y=267.5)
    hatti_b.filled = True
    hatti_b.color = 'black'
    hatti_b.fill_color = 'black'
    window.add(hatti_b)

    hatti_bb = GOval(10, 10, x=487.5, y=267.5)
    hatti_bb.filled = True
    hatti_bb.color = 'black'
    hatti_bb.fill_color = 'black'
    window.add(hatti_bb)

    hatti = GRect(50, 150, x=520, y=320)
    hatti.filled = True
    hatti.fill_color = '#DADADA'
    window.add(hatti)

    hatti_h = GOval(50, 50, x=520, y=295)
    hatti_h.filled = True
    hatti_h.fill_color = '#DADADA'
    window.add(hatti_h)

    r = GRect(48, 25, x=521, y=321)
    r.filled = True
    r.color = '#DADADA'
    r.fill_color = '#DADADA'
    window.add(r)

    hatti_e = GOval(25, 25, x=520, y=320)
    hatti_e.filled = True
    hatti_e.color = 'black'
    hatti_e.fill_color = 'white'
    window.add(hatti_e)

    hatti_ee = GOval(25, 25, x=545, y=320)
    hatti_ee.filled = True
    hatti_ee.color = 'black'
    hatti_ee.fill_color = 'white'
    window.add(hatti_ee)

    hatti_b = GOval(10, 10, x=552.5, y=327.5)
    hatti_b.filled = True
    hatti_b.color = 'black'
    hatti_b.fill_color = 'black'
    window.add(hatti_b)

    hatti_bb = GOval(10, 10, x=527.5, y=327.5)
    hatti_bb.filled = True
    hatti_bb.color = 'black'
    hatti_bb.fill_color = 'black'
    window.add(hatti_bb)

    hatti = GRect(50, 150, x=450, y=380)
    hatti.filled = True
    hatti.fill_color = '#DADADA'
    window.add(hatti)

    hatti_h = GOval(50, 50, x=450, y=355)
    hatti_h.filled = True
    hatti_h.fill_color = '#DADADA'
    window.add(hatti_h)

    r = GRect(48, 25, x=451, y=380)
    r.filled = True
    r.color = '#DADADA'
    r.fill_color = '#DADADA'
    window.add(r)

    hatti_e = GOval(25, 25, x=450, y=380)
    hatti_e.filled = True
    hatti_e.color = 'black'
    hatti_e.fill_color = 'white'
    window.add(hatti_e)

    hatti_ee = GOval(25, 25, x=475, y=380)
    hatti_ee.filled = True
    hatti_ee.color = 'black'
    hatti_ee.fill_color = 'white'
    window.add(hatti_ee)

    hatti_b = GOval(10, 10, x=457.5, y=387.5)
    hatti_b.filled = True
    hatti_b.color = 'black'
    hatti_b.fill_color = 'black'
    window.add(hatti_b)

    hatti_bb = GOval(10, 10, x=482.5, y=387.5)
    hatti_bb.filled = True
    hatti_bb.color = 'black'
    hatti_bb.fill_color = 'black'
    window.add(hatti_bb)
Beispiel #24
0
def main():
    """
    it shows the animation of a guinea pig with zentangle pattern, and a label will show on the top of window
    """
    #background

    background = GRect(600, 600)
    background.filled = True
    window.add(background)


    #zentangle

    for i in range(0,600,30):
        line = GLine(i,0,600,600)
        window.add(line)
        line.color = 'white'
        pause(10)

    for j in range(0,600,30):
        line = GLine(600,j,0,600)
        window.add(line)
        line.color = 'wheat'
        pause(10)

    for k in range(0, 600, 30):
        line = GLine(600-k, 600, 0, 0)
        window.add(line)
        line.color = 'whitesmoke'
        pause(10)

    for l in range(0, 600, 30):
        line = GLine(0, 600-l, 600, 0)
        window.add(line)
        line.color = 'grey'
        pause(10)



    for m in range(0,300, 10):
        circle = GOval(m, m, x=random.randrange(0, window.width), y=random.randrange(0, window.width))
        window.add(circle)
        circle.color = 'red'
        pause(10)

    for n in range(0, 200, 40):
        circle = GOval(n, n, x=random.randrange(0, window.width), y=random.randrange(0, window.width))
        window.add(circle)
        circle.color = 'orange'
        pause(10)

    for o in range(100,300, 35):
        circle = GOval(o, o, x=random.randrange(0, window.width), y=random.randrange(0, window.width))
        window.add(circle)
        circle.color = 'yellow'
        pause(10)

    for p in range(50,200, 25):
        circle = GOval(p, p, x=random.randrange(0, window.width), y=random.randrange(0, window.width))
        window.add(circle)
        circle.color = 'lime'
        pause(10)

    for q in range(0,100, 15):
        circle = GOval(q, q, x=random.randrange(0, window.width), y=random.randrange(0, window.width))
        window.add(circle)
        circle.color = 'lightblue'
        pause(10)

    for r in range(300, 500, 30):
        circle = GOval(r, r, x=random.randrange(0, window.width), y=random.randrange(0, window.width))
        window.add(circle)
        circle.color = 'navy'
        pause(10)

    for s in range(0, 400, 50):
        circle = GOval(s, s, x=random.randrange(0, window.width), y=random.randrange(0, window.width))
        window.add(circle)
        circle.color = 'purple'
        pause(10)


    #face
    face = GPolygon()
    face.add_vertex((255, 250))
    face.add_vertex((345, 250))
    face.add_vertex((355, 340))
    face.add_vertex((245, 340))

    forehead = GPolygon()
    forehead.add_vertex((270, 255))
    forehead.add_vertex((330, 255))
    forehead.add_vertex((335, 275))
    forehead.add_vertex((265, 275))

    l_chin = GPolygon()
    l_chin = GPolygon()
    l_chin.add_vertex((250, 310))
    l_chin.add_vertex((300, 305))
    l_chin.add_vertex((300, 340))
    l_chin.add_vertex((247, 340))

    r_chin = GPolygon()
    r_chin = GPolygon()
    r_chin.add_vertex((300, 305))
    r_chin.add_vertex((350, 310))
    r_chin.add_vertex((353, 340))
    r_chin.add_vertex((300, 340))

    nose = GOval(18, 35, x=292, y=290)

    l_eye = GOval(15, 17, x=280, y=285)
    r_eye = GOval(15, 17, x=310, y=285)

    l_foot = GOval(20, 30, x=233, y=315)
    r_foot = GOval(20, 30, x=348, y=315)

    l_ear = GOval(25, 15, x=230, y=265)
    r_ear = GOval(25, 15, x=345, y=265)

    mouse1 = GLine(300, 340, 300, 333)
    mouse2 = GLine(300, 333, 293, 323)
    mouse3 = GLine(300, 333, 307, 323)

    window.add(l_foot)
    l_foot.filled = True
    l_foot.fill_color = 'lightsalmon'
    l_foot.color = 'lightsalmon'

    window.add(r_foot)
    r_foot.filled = True
    r_foot.fill_color = 'lightsalmon'
    r_foot.color = 'lightsalmon'

    window.add(face)
    face.filled = True
    face.fill_color = 'goldenrod'
    face.color = 'goldenrod'

    window.add(forehead)
    forehead.filled = True
    forehead.fill_color = 'lightyellow'
    forehead.color = 'peachpuff'

    window.add(l_chin)
    l_chin.filled = True
    l_chin.fill_color = 'wheat'
    l_chin.color = 'wheat'

    window.add(r_chin)
    r_chin.filled = True
    r_chin.fill_color = 'wheat'
    r_chin.color = 'wheat'

    window.add(nose)
    nose.filled = True
    nose.fill_color = 'wheat'
    nose.color = 'wheat'

    window.add(mouse1)
    mouse1.color = 'brown'
    window.add(mouse2)
    mouse2.color = 'brown'
    window.add(mouse3)
    mouse3.color = 'brown'

    window.add(l_eye)
    l_eye.filled = True
    window.add(r_eye)
    r_eye.filled = True

    window.add(l_ear)
    l_ear.filled = True
    l_ear.fill_color = 'brown'
    l_ear.color = 'brown'
    window.add(r_ear)
    r_ear.filled = True
    r_ear.fill_color = 'brown'
    r_ear.color = 'brown'


    # words
    label = GLabel('Python is just like Zentangle - impossible to have the same works')
    label.font = 'Courier-10-italic'
    words_frame = GRect(530, 40, x=(window.width - label.width - 10) / 2, y=18)
    label.color = 'navy'

    window.add(words_frame)
    words_frame.filled = True
    words_frame.fill_color = 'lemonchiffon'
    words_frame.color = 'gold'
    window.add(label, x=(window.width - label.width) / 2, y=50)

    vx = 1
    while True:
        label.move(vx, 0)
        words_frame.move(vx, 0)
        if words_frame.x <= 0 or words_frame.x + words_frame.width >= window.width:
            vx = -vx
        pause(DELAY)
Beispiel #25
0
def main():
    """
    TODO:
    """
    window = GWindow(width=550, height=550, title='Pikachu')
    ball = GOval(550, 550)
    ball.filled = True
    ball.fill_color = 'red'
    window.add(ball, 0, 0)
    ball2 = GRect(550, 275)
    ball2.filled = True
    ball2.fill_color = 'white'
    window.add(ball2, 0, 275)
    ball3 = GOval(550, 550)
    window.add(ball3)
    ball4 = GRect(550, 50)
    ball4.filled = True
    ball4.fill_color = 'black'
    window.add(ball4, 0, 250)
    tail = GRect(40, 20)
    tail.filled = True
    tail.fill_color = 'gold'
    tail.color = 'gold'
    window.add(tail, 350, 325)
    tail2 = GRect(20, 60)
    tail2.filled = True
    tail2.fill_color = 'gold'
    tail2.color = 'gold'
    window.add(tail2, 370, 280)
    tail = GRect(40, 20)
    tail.filled = True
    tail.fill_color = 'gold'
    tail.color = 'gold'
    window.add(tail, 370, 280)
    tail = GRect(30, 50)
    tail.filled = True
    tail.fill_color = 'gold'
    tail.color = 'gold'
    window.add(tail, 390, 260)
    tail = GRect(100, 50)
    tail.filled = True
    tail.fill_color = 'gold'
    tail.color = 'gold'
    window.add(tail, 390, 230)
    body = GRect(130, 180)
    body.filled = True
    body.fill_color = 'gold'
    window.add(body, 212, 200)
    body2 = GRect(100, 100)
    body2.filled = True
    body2.fill_color = 'gold'
    body2.color = 'gold'
    window.add(body2, 220, 287)
    body3 = GPolygon()
    body3.add_vertex((214, 220))
    body3.add_vertex((193, 330))
    body3.add_vertex((220, 330))
    body3.filled = True
    body3.fill_color = 'gold'
    body3.color = 'gold'
    window.add(body3)
    body3 = GPolygon()
    body3.add_vertex((340, 220))
    body3.add_vertex((343, 330))
    body3.add_vertex((358, 330))
    body3.filled = True
    body3.fill_color = 'gold'
    body3.color = 'gold'
    window.add(body3)
    l_leg = GOval(100, 90)
    l_leg.filled = True
    l_leg.fill_color = 'gold'
    l_leg.color = 'gold'
    window.add(l_leg, 190, 300)
    r_leg = GOval(100, 90)
    r_leg.filled = True
    r_leg.fill_color = 'gold'
    r_leg.color = 'gold'
    window.add(r_leg, 260, 300)
    body2 = GRect(100, 100)
    body2.filled = True
    body2.fill_color = 'gold'
    body2.color = 'gold'
    window.add(body2, 220, 287)
    body3 = GPolygon()
    body3.add_vertex((214, 220))
    body3.add_vertex((193, 330))
    body3.add_vertex((220, 330))
    body3.filled = True
    body3.fill_color = 'gold'
    body3.color = 'gold'
    window.add(body3)
    body4 = GPolygon()
    body4.add_vertex((340, 220))
    body4.add_vertex((343, 330))
    body4.add_vertex((358, 330))
    body4.filled = True
    body4.fill_color = 'gold'
    body4.color = 'gold'
    window.add(body4)
    l_leg = GOval(100, 90)
    l_leg.filled = True
    l_leg.fill_color = 'gold'
    l_leg.color = 'gold'
    window.add(l_leg, 190, 300)
    l_hand = GOval(40, 125)
    l_hand.filled = True
    l_hand.fill_color = 'gold'
    window.add(l_hand, 200, 225)
    l_leg2 = GOval(20, 60)
    l_leg2.filled = True
    l_leg2.fill_color = 'gold'
    window.add(l_leg2, 210, 340)
    l_leg3 = GLine(217, 340, 217, 360)
    window.add(l_leg3)
    l_leg4 = GLine(222, 340, 222, 360)
    window.add(l_leg4)
    r_leg = GOval(100, 90)
    r_leg.filled = True
    r_leg.fill_color = 'gold'
    r_leg.color = 'gold'
    window.add(r_leg, 260, 300)
    r_hand = GOval(40, 125)
    r_hand.filled = True
    r_hand.fill_color = 'gold'
    window.add(r_hand, 310, 225)
    r_leg2 = GOval(20, 60)
    r_leg2.filled = True
    r_leg2.fill_color = 'gold'
    window.add(r_leg2, 320, 340)
    r_leg3 = GLine(327, 340, 327, 360)
    window.add(r_leg3)
    r_leg4 = GLine(332, 340, 332, 360)
    window.add(r_leg4)
    l_ear = GOval(100, 30)
    l_ear.filled = True
    l_ear.fill_color = 'gold'
    window.add(l_ear, 135, 110)
    l_ear2 = GPolygon()
    l_ear2.add_vertex((120, 125))
    l_ear2.add_vertex((145, 115))
    l_ear2.add_vertex((145, 135))
    l_ear2.filled = True
    l_ear2.fill_color = 'black'
    window.add(l_ear2)
    r_ear = GOval(30, 100)
    r_ear.filled = True
    r_ear.fill_color = 'gold'
    window.add(r_ear, 300, 25)
    r_ear2 = GPolygon()
    r_ear2.add_vertex((315, 10))
    r_ear2.add_vertex((305, 35))
    r_ear2.add_vertex((325, 35))
    r_ear2.filled = True
    r_ear2.fill_color = 'black'
    window.add(r_ear2)
    face4 = GOval(152, 156)
    face4.filled = True
    face4.fill_color = 'gold'
    window.add(face4, 199, 100)
    face2 = GOval(90, 100)
    face2.filled = True
    face2.fill_color = 'gold'
    window.add(face2, 195, 140)
    face3 = GOval(90, 100)
    face3.filled = True
    face3.fill_color = 'gold'
    window.add(face3, 265, 140)
    face = GOval(150, 155)
    face.filled = True
    face.fill_color = 'gold'
    face.color = 'gold'
    window.add(face, 200, 100)
    l_eye = GOval(30, 30)
    l_eye.filled = True
    l_eye.fill_color = 'black'
    window.add(l_eye, 225, 150)
    l_eye2 = GOval(15, 15)
    l_eye2.filled = True
    l_eye2.fill_color = 'white'
    window.add(l_eye2, 235, 150)
    r_eye = GOval(30, 30)
    r_eye.filled = True
    r_eye.fill_color = 'black'
    window.add(r_eye, 295, 150)
    r_eye2 = GOval(15, 15)
    r_eye2.filled = True
    r_eye2.fill_color = 'white'
    window.add(r_eye2, 298, 153)
    nose = GOval(5, 5)
    nose.filled = True
    nose.fill_color = 'black'
    window.add(nose, 270, 190)
    l_face = GOval(33, 33)
    l_face.filled = True
    l_face.fill_color = 'tomato'
    window.add(l_face, 200, 190)
    l_face = GOval(33, 33)
    l_face.filled = True
    l_face.fill_color = 'tomato'
    window.add(l_face, 320, 190)
    mouth = GPolygon()
    mouth.add_vertex((260, 205))
    mouth.add_vertex((285, 205))
    mouth.add_vertex((272, 240))
    mouth.filled = True
    mouth.fill_color = 'darkred'
    window.add(mouth)
Beispiel #26
0
def main():
    """
    Mike Wazowski is one of my fav characters in Monsters, Inc.
    because he is sooo cute and optimistic!
    """
    window = GWindow(width=800, height=800, title='Mike Wazowski sticker')

    # Mike's body
    body = GOval(400, 400, x=200, y=200)
    body.filled = True
    body.fill_color = "darkseagreen"
    body.color = "darkseagreen"
    window.add(body)

    # Mike's eyes
    white_eye = GOval(175, 175, x=320, y=250)
    white_eye.filled = True
    white_eye.fill_color = "white"
    white_eye.color = "white"
    window.add(white_eye)

    black_eye = GOval(100, 100, x=350, y=270)
    black_eye.filled = True
    window.add(black_eye)

    small_white_eye = GOval(25, 25, x=375, y=280)
    small_white_eye.filled = True
    small_white_eye.fill_color = "white"
    small_white_eye.color = "white"
    window.add(small_white_eye)
    # Mike's mouth
    mouth = GOval(200, 100, x=300, y=450)
    mouth.filled = True
    window.add(mouth)
    # Mike's teethes
    teeth_1 = GPolygon()
    teeth_1.add_vertex((330, 462))
    teeth_1.add_vertex((360, 454))
    teeth_1.add_vertex((355, 480))
    teeth_1.filled = True
    teeth_1.fill_color = "white"
    teeth_1.color = "white"
    window.add(teeth_1)

    teeth_2 = GPolygon()
    teeth_2.add_vertex((360, 454))
    teeth_2.add_vertex((390, 450))
    teeth_2.add_vertex((377, 480))
    teeth_2.filled = True
    teeth_2.fill_color = "white"
    teeth_2.color = "white"
    window.add(teeth_2)

    teeth_3 = GPolygon()
    teeth_3.add_vertex((390, 450))
    teeth_3.add_vertex((420, 450))
    teeth_3.add_vertex((410, 480))
    teeth_3.filled = True
    teeth_3.fill_color = "white"
    teeth_3.color = "white"
    window.add(teeth_3)

    teeth_4 = GPolygon()
    teeth_4.add_vertex((420, 450))
    teeth_4.add_vertex((450, 455))
    teeth_4.add_vertex((430, 480))
    teeth_4.filled = True
    teeth_4.fill_color = "white"
    teeth_4.color = "white"
    window.add(teeth_4)

    teeth_5 = GPolygon()
    teeth_5.add_vertex((450, 455))
    teeth_5.add_vertex((477, 465.5))
    teeth_5.add_vertex((460, 488))
    teeth_5.filled = True
    teeth_5.fill_color = "white"
    teeth_5.color = "white"
    window.add(teeth_5)

    teeth_6 = GPolygon()
    teeth_6.add_vertex((360, 548))
    teeth_6.add_vertex((390, 550))
    teeth_6.add_vertex((375, 530))
    teeth_6.filled = True
    teeth_6.fill_color = "white"
    teeth_6.color = "white"
    window.add(teeth_6)

    teeth_7 = GPolygon()
    teeth_7.add_vertex((390, 550))
    teeth_7.add_vertex((420, 550))
    teeth_7.add_vertex((405, 530))
    teeth_7.filled = True
    teeth_7.fill_color = "white"
    teeth_7.color = "white"
    window.add(teeth_7)

    teeth_8 = GPolygon()
    teeth_8.add_vertex((420, 550))
    teeth_8.add_vertex((450, 546))
    teeth_8.add_vertex((435, 530))
    teeth_8.filled = True
    teeth_8.fill_color = "white"
    teeth_8.color = "white"
    window.add(teeth_8)
    # Mike's legs
    left_leg = GPolygon()
    left_leg.add_vertex((340, 570))
    left_leg.add_vertex((345, 700))
    left_leg.add_vertex((360, 700))
    left_leg.add_vertex((365, 590))
    left_leg.filled = True
    left_leg.fill_color = "darkseagreen"
    left_leg.color = "darkseagreen"
    window.add(left_leg)

    right_leg = GPolygon()
    right_leg.add_vertex((460, 590))
    right_leg.add_vertex((465, 700))
    right_leg.add_vertex((480, 700))
    right_leg.add_vertex((485, 570))
    right_leg.filled = True
    right_leg.fill_color = "darkseagreen"
    right_leg.color = "darkseagreen"
    window.add(right_leg)

    left_sole = GPolygon()
    left_sole.add_vertex((310, 700))
    left_sole.add_vertex((360, 700))
    left_sole.add_vertex((310, 720))
    left_sole.filled = True
    left_sole.fill_color = "darkseagreen"
    left_sole.color = "darkseagreen"
    window.add(left_sole)

    right_sole = GPolygon()
    right_sole.add_vertex((465, 700))
    right_sole.add_vertex((515, 700))
    right_sole.add_vertex((515, 720))
    right_sole.filled = True
    right_sole.fill_color = "darkseagreen"
    right_sole.color = "darkseagreen"
    window.add(right_sole)

    left_toe_1 = GPolygon()
    left_toe_1.add_vertex((310, 700))
    left_toe_1.add_vertex((310, 706))
    left_toe_1.add_vertex((300, 703))
    left_toe_1.filled = True
    window.add(left_toe_1)

    left_toe_2 = GPolygon()
    left_toe_2.add_vertex((310, 706))
    left_toe_2.add_vertex((310, 713))
    left_toe_2.add_vertex((300, 710))
    left_toe_2.filled = True
    window.add(left_toe_2)

    left_toe_3 = GPolygon()
    left_toe_3.add_vertex((310, 713))
    left_toe_3.add_vertex((310, 720))
    left_toe_3.add_vertex((300, 715))
    left_toe_3.filled = True
    window.add(left_toe_3)

    right_toe_1 = GPolygon()
    right_toe_1.add_vertex((515, 700))
    right_toe_1.add_vertex((515, 706))
    right_toe_1.add_vertex((525, 703))
    right_toe_1.filled = True
    window.add(right_toe_1)

    right_toe_2 = GPolygon()
    right_toe_2.add_vertex((515, 706))
    right_toe_2.add_vertex((515, 713))
    right_toe_2.add_vertex((525, 710))
    right_toe_2.filled = True
    window.add(right_toe_2)

    right_toe_3 = GPolygon()
    right_toe_3.add_vertex((515, 713))
    right_toe_3.add_vertex((515, 720))
    right_toe_3.add_vertex((525, 715))
    right_toe_3.filled = True
    window.add(right_toe_3)
    # Mike's hands
    left_arm = GPolygon()
    left_arm.add_vertex((200, 400))
    left_arm.add_vertex((160, 510))
    left_arm.add_vertex((163, 520))
    left_arm.add_vertex((210, 445))
    left_arm.filled = True
    left_arm.fill_color = "darkseagreen"
    left_arm.color = "darkseagreen"
    window.add(left_arm)

    right_arm = GPolygon()
    right_arm.add_vertex((600, 400))
    right_arm.add_vertex((595, 445))
    right_arm.add_vertex((637, 520))
    right_arm.add_vertex((640, 510))
    right_arm.filled = True
    right_arm.fill_color = "darkseagreen"
    right_arm.color = "darkseagreen"
    window.add(right_arm)

    left_hand = GOval(30, 30, x=150, y=498)
    left_hand.filled = True
    left_hand.fill_color = "darkseagreen"
    left_hand.color = "darkseagreen"
    window.add(left_hand)

    right_hand = GOval(30, 30, x=632, y=507)
    right_hand.filled = True
    right_hand.fill_color = "darkseagreen"
    right_hand.color = "darkseagreen"
    window.add(right_hand)
    # Mike's ears
    left_ear = GPolygon()
    left_ear.add_vertex((300, 230))
    left_ear.add_vertex((320, 230))
    left_ear.add_vertex((310, 190))
    left_ear.filled = True
    left_ear.fill_color = "darkseagreen"
    left_ear.color = "darkseagreen"
    window.add(left_ear)

    right_ear = GPolygon()
    right_ear.add_vertex((475, 230))
    right_ear.add_vertex((495, 230))
    right_ear.add_vertex((485, 190))
    right_ear.filled = True
    right_ear.fill_color = "darkseagreen"
    right_ear.color = "darkseagreen"
    window.add(right_ear)
    # texts
    label = GLabel("Uhhhh...", x=270, y=145)
    label.font = "Comic Sans MS-70-bold"
    label.color = "black"
    window.add(label)
def build_labels():
    """
    This function creates the texts on the canvas
    """
    l_title = GLabel('Which one is Karel?')
    l_title.font = 'Courier-25'
    l_title.color = 'black'
    window.add(l_title, x=260, y=60)
    l_num = GLabel('19')
    l_num.font = 'Courier-50'
    l_num.color = 'whitesmoke'
    window.add(l_num, x=37, y=242)
    l_skip = GLabel('skip')
    l_skip.font = 'Courier-20'
    l_skip.color = 'whitesmoke'
    window.add(l_skip, x=726, y=152)
    l_ans1 = GLabel('Answers')
    l_ans1.font = 'Courier-20-italic'
    l_ans1.color = 'black'
    window.add(l_ans1, x=698, y=270)
    l_ans2 = GLabel('0')
    l_ans2.font = 'Courier-50-italic'
    l_ans2.color = 'black'
    window.add(l_ans2, x=722, y=252)
    l_game_pin = GLabel('Game PIN: SC101')
    l_game_pin.font = 'Courier-20'
    l_game_pin.color = 'black'
    window.add(l_game_pin, x=20, y=540)
    l_1 = GPolygon()
    l_1.add_vertex((210, 360))
    l_1.add_vertex((197, 380))
    l_1.add_vertex((221, 380))
    l_1.filled = True
    l_1.color = 'whitesmoke'
    l_1.fill_color= 'whitesmoke'
    window.add(l_1)
    l_2_1 = GPolygon()
    l_2_1.add_vertex((210+380, 359))
    l_2_1.add_vertex((198+380, 370))
    l_2_1.add_vertex((221+380, 370))
    l_2_1.filled = True
    l_2_1.fill_color = 'whitesmoke'
    l_2_1.color = 'whitesmoke'
    window.add(l_2_1)
    l_2_2 = GPolygon()
    l_2_2.add_vertex((210+380, 381))
    l_2_2.add_vertex((198+380, 370))
    l_2_2.add_vertex((221+380, 370))
    l_2_2.filled = True
    l_2_2.fill_color = 'whitesmoke'
    l_2_2.color = 'whitesmoke'
    window.add(l_2_2)
    l_3 = GOval(23, 23, x=198, y=450)
    l_3.filled = True
    l_3.fill_color = 'whitesmoke'
    l_3.color = 'whitesmoke'
    window.add(l_3)
    l_4 = GRect(20, 20, x=583, y=450)
    l_4.filled = True
    l_4.fill_color = 'whitesmoke'
    l_4.color = 'whitesmoke'
    window.add(l_4)
Beispiel #28
0
def main():
    """
    TODO:
    This figure uses campy module to demonstrate personality.
    A lot of faiths hold by people, just like the shape of circles or triangles,
    while eventually others can only see the polygon.
    """
    window=GWindow(600,600)

    # color of background
    rect=GRect(800,800)
    rect.filled=True
    rect.fill_color='lightgrey'
    window.add(rect)

    # polygon, circle ,rect and triangle with different colors
    polygon1=GPolygon()
    polygon1.add_vertex((550, 590))
    polygon1.add_vertex((570, 360))
    polygon1.add_vertex((100, 60))
    polygon1.filled=True
    polygon1.fill_color='greenyellow'
    window.add(polygon1)

    rect1=GRect(335,335,x=135,y=150)
    rect1.filled=True
    rect1.fill_color='sage'
    rect2=GRect(370,370,x=120,y=135)
    rect2.filled=True
    rect2.fill_color='magenta'
    rect3=GRect(400,400,x=105,y=120)
    rect3.filled=True
    rect3.fill_color='purple'
    rect4=GRect(440,440,x=85,y=100)
    rect4.filled=True
    rect4.fill_color='peachpuff'
    window.add(rect4)
    window.add(rect3)
    window.add(rect2)
    window.add(rect1)

    circle5=GOval(265,265,x=170,y=185)
    circle5.filled=True
    circle5.fill_color='lightsage'
    circle6=GOval(285,285,x=160,y=175)
    circle6.filled=True
    circle6.fill_color='tan'
    circle7=GOval(305,305,x=150,y=165)
    circle7.filled=True
    circle7.fill_color='midnightblue'
    circle8=GOval(325,325,x=140,y=155)
    circle8.filled=True
    circle8.fill_color='powderblue'
    window.add(circle8)
    window.add(circle7)
    window.add(circle6)
    window.add(circle5)

    triangle1=GPolygon()
    triangle1.add_vertex((300,230))
    triangle1.add_vertex((225,340))
    triangle1.add_vertex((375,340))
    triangle2=GPolygon()
    triangle2.add_vertex((300,215))
    triangle2.add_vertex((210,350))
    triangle2.add_vertex((390,350))
    triangle1.filled=True
    triangle1.fill_color='pink'
    triangle2.filled=True
    triangle2.fill_color='lightgrey'
    triangle3=GPolygon()
    triangle3.add_vertex((300,200))
    triangle3.add_vertex((195,360))
    triangle3.add_vertex((405,360))
    triangle4=GPolygon()
    triangle4.add_vertex((300,185))
    triangle4.add_vertex((180,370))
    triangle4.add_vertex((420,370))
    triangle3.filled=True
    triangle3.fill_color='linen'
    triangle4.filled=True
    triangle4.fill_color='yellow'
    window.add(triangle4)
    window.add(triangle3)
    window.add(triangle2)
    window.add(triangle1)

    circle1=GOval(20,20,x=290,y=290)
    circle1.filled=True
    circle1.fill_color='aquamarine'
    circle2=GOval(40,40,x=280,y=280)
    circle2.filled=True
    circle2.fill_color='aqua'
    circle3=GOval(60,60,x=270,y=270)
    circle3.filled=True
    circle3.fill_color='darkblue'
    circle4=GOval(80,80,x=260,y=260)
    circle4.filled=True
    circle4.fill_color='blueviolet'
    window.add(circle4)
    window.add(circle3)
    window.add(circle2)
    window.add(circle1)

    polygon=GPolygon()
    polygon.add_vertex((100, 60))
    polygon.add_vertex((50,100))
    polygon.add_vertex((40,180))
    polygon.add_vertex((20,400))
    polygon.add_vertex((30,550))
    polygon.add_vertex((180,580))
    polygon.add_vertex((400, 550))
    polygon.add_vertex((550, 590))
    polygon.filled=True
    polygon.fill_color='salmon'
    window.add(polygon)

    # logo
    sc101=GLabel('SC101-2020.Nov')
    sc101.font='Courier-15-bold-italic'
    window.add(sc101,0,window.height-sc101.height+20)
Beispiel #29
0
def main():
    """
    TODO:
    """
    window = GWindow(width=1200, height=600)
    body = GRect(200, 300, x=200, y=150)
    head = GOval(200, 200, x=200, y=50)
    eye = GOval(170, 120, x=250, y=130)
    left_foot = GRect(80, 100, x=200, y=450)
    right_foot = GRect(80, 100, x=320, y=450)
    back = GPolygon()
    back.add_vertex((200, 200))
    back.add_vertex((130, 220))
    back.add_vertex((130, 400))
    back.add_vertex((200, 400))
    handle_1 = GRect(40, 100, x=500, y=250)
    handle_2 = GRect(80, 40, x=420, y=280)
    knife = GPolygon()
    knife.add_vertex((540, 280))
    knife.add_vertex((570, 260))
    knife.add_vertex((590, 275))
    knife.add_vertex((610, 265))
    knife.add_vertex((640, 315))
    knife.add_vertex((540, 315))

    head.filled = True
    body.filled = True
    eye.filled = True
    back.filled = True
    handle_1.filled = True
    left_foot.filled = True
    right_foot.filled = True
    handle_2.filled = True
    knife.filled = True

    head.fill_color = 'red'
    body.fill_color = 'red'
    eye.fill_color = 'skyblue'
    left_foot.fill_color = 'red'
    right_foot.fill_color = 'red'
    back.fill_color = 'red'
    handle_1.fill_color = 'black'
    handle_2.fill_color = 'black'
    knife.fill_color = 'grey'

    head.color = 'red'
    body.color = 'red'
    left_foot.color = 'red'
    right_foot.color = 'red'

    window.add(body)
    window.add(head)
    window.add(eye)
    window.add(left_foot)
    window.add(right_foot)
    window.add(back)
    window.add(handle_1)
    window.add(handle_2)
    window.add(knife)

    body2 = GRect(200, 300, x=750, y=150)
    head2 = GOval(200, 200, x=750, y=50)
    eye2 = GOval(170, 120, x=730, y=130)
    left_foot2 = GRect(80, 100, x=750, y=450)
    right_foot2 = GRect(80, 100, x=870, y=450)
    back2 = GPolygon()
    back2.add_vertex((950, 200))
    back2.add_vertex((1020, 220))
    back2.add_vertex((1020, 400))
    back2.add_vertex((950, 400))

    knife2 = GPolygon()
    knife2.add_vertex((700, 200))
    knife2.add_vertex((680, 180))
    knife2.add_vertex((650, 200))
    knife2.add_vertex((650, 400))
    knife2.add_vertex((700, 400))

    head2.filled = True
    body2.filled = True
    eye2.filled = True
    back2.filled = True
    left_foot2.filled = True
    right_foot2.filled = True

    knife2.filled = True

    head2.fill_color = 'purple'
    body2.fill_color = 'purple'
    eye2.fill_color = 'skyblue'
    left_foot2.fill_color = 'purple'
    right_foot2.fill_color = 'purple'
    back2.fill_color = 'purple'
    knife2.fill_color = 'brown'

    head2.color = 'purple'
    body2.color = 'purple'
    left_foot2.color = 'purple'
    right_foot2.color = 'purple'
    knife2.color = 'brown'

    window.add(body2)
    window.add(head2)
    window.add(eye2)
    window.add(left_foot2)
    window.add(right_foot2)
    window.add(back2)

    label = GLabel('Among Us', x=450, y=500)
    label.font = 'Courier-50-italic'
    window.add(label)

    window.add(knife2)
def build_karel2():
    """
    This function builds the second karel
    """
    add = 1
    head = GOval(80, 55, x=190+120*add, y=167)
    head.filled = True
    head.color = 'black'
    head.fill_color = 'gray'
    window.add(head)
    r_eye = GRect(13, 13, x=212+120*add, y=189)
    r_eye.filled = True
    r_eye.color = 'black'
    r_eye.fill_color = 'blue'
    window.add(r_eye)
    l_eye = GRect(13, 13, x=235+120*add, y=189)
    l_eye.filled = True
    l_eye.color = 'black'
    l_eye.fill_color = 'blue'
    window.add(l_eye)
    mouth = GPolygon()
    mouth.filled = True
    mouth.fill_color = 'red'
    mouth.color = 'black'
    mouth.add_vertex((350, 205))
    mouth.add_vertex((353, 211))
    mouth.add_vertex((347, 211))
    window.add(mouth)
    hands = GRect(105, 45, x=177+120*add, y=237)
    hands.filled = True
    hands.color = 'black'
    hands.fill_color = 'lime'
    window.add(hands)
    body_1 = GRect(60, 65, x=201+120*add, y=223)
    body_1.filled = True
    body_1.color = 'black'
    body_1.fill_color = 'blue'
    window.add(body_1)
    body_2 = GRect(80, 60, x=190+120*add, y=230)
    body_2.filled = True
    body_2.color = 'black'
    body_2.fill_color = 'blue'
    window.add(body_2)
    r_foot = GOval(29, 24, x=190+120*add, y=290)
    r_foot.filled = True
    r_foot.color = 'black'
    r_foot.fill_color = 'red'
    window.add(r_foot)
    l_foot = GOval(29, 24, x=241+120*add, y=290)
    l_foot.filled = True
    l_foot.color = 'black'
    l_foot.fill_color = 'red'
    window.add(l_foot)
    label1 = GPolygon()
    label1.add_vertex((230+120*add, 128))
    label1.add_vertex((218+120*add, 140))
    label1.add_vertex((242+120*add, 140))
    label1.filled = True
    label1.fill_color = 'steelblue'
    label1.color = 'steelblue'
    window.add(label1)
    label2 = GPolygon()
    label2.add_vertex((230 + 120 * add, 152))
    label2.add_vertex((218 + 120 * add, 140))
    label2.add_vertex((242 + 120 * add, 140))
    label2.filled = True
    label2.fill_color = 'steelblue'
    label2.color = 'steelblue'
    window.add(label2)