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)
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)
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
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
def draw_triangle(length, start_x, start_y): """ 功能: :param length: :param start_x: :param start_y: :return: """ triangle = GPolygon() triangle.add_vertex((start_x, start_y)) for edge in range(3): triangle.add_polar_edge(length, -120 * edge) window.add(triangle)
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
def myGArc(width, height, start_ang, sweep_ang, x=0, y=0): rx, ry = width / 2, height / 2 cx, cy = x + rx, y + ry angs = np.linspace(start_ang, sweep_ang, 10000) arc = GPolygon() for ang in angs: arc_x = cx + rx * np.cos(np.deg2rad(ang)) arc_y = cy - ry * np.sin(np.deg2rad(ang)) arc.add_vertex((arc_x, arc_y)) #print(ang) # end_x = cx + rx*np.cos(np.deg2rad(start_ang+sweep_ang)) # end_y = cy - ry*np.sin(np.deg2rad(start_ang+sweep_ang)) return arc
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)
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)
def sierpinski_triangle(order, length, upper_left_x, upper_left_y): """ :param order: decide how many layer of sierpinski triangle :param length: length of triangle's side :param upper_left_x: x coordinate of first triangle's start point :param upper_left_y: y coordinate of first triangle's start point :return: sierpinski triangle of given order """ if order == 0: pass 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 + 0.5 * length, upper_left_y + 0.866 * length)) circle = GOval(math.sqrt(3) * length / 3, math.sqrt(3) * length /3, x=upper_left_x + 0.5 * length - math.sqrt(3) * length /6, y=upper_left_y ) circle.filled = True circle.fill_color ='snow' window.add(circle) window.add(triangle) sierpinski_triangle(order - 1, length/2, upper_left_x, upper_left_y) sierpinski_triangle(order - 1, length/2, upper_left_x + 0.25 * length, upper_left_y + 0.433 * length) sierpinski_triangle(order - 1, length/2, upper_left_x + 0.5 * length, upper_left_y)
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)
def sierpinski_triangle(order, length, upper_left_x, upper_left_y): """ :param order: Level or sierpinski triangle :param length: length of triangle :param upper_left_x: the x start point of triangle :param upper_left_y: the y start point of triangle :return: nothing """ if order == 0: # base case pass else: tri = GPolygon() tri.add_vertex((upper_left_x, upper_left_y)) tri.add_vertex((upper_left_x + length, upper_left_y)) tri.add_vertex( (upper_left_x + length / 2, upper_left_y + length * 0.866)) window.add(tri) sierpinski_triangle(order - 1, length / 2, upper_left_x, upper_left_y) # left top sierpinski_triangle(order - 1, length / 2, upper_left_x + length * 0.5, upper_left_y) # right top sierpinski_triangle(order - 1, length / 2, upper_left_x + length * 0.25, upper_left_y + length * 0.866 * 0.5) # bottom pass
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)
def speak(self): """ This method give one triangle, four round corner and five rectangle to present talk bar, self.words will be the content of speak. """ label = GLabel(self.words, 435, 170) label.font = 'Verdana-20' triangle = GPolygon() triangle.add_vertex((label.x+10, label.y)) triangle.add_vertex((label.x+30, label.y)) triangle.add_vertex((label.x, label.y+30)) rect = GRect(label.width, label.height, x=label.x, y=label.y - label.height) rect_top = GRect(rect.width, 10, x=rect.x, y=rect.y - 10) rect_left = GRect(10, rect.height, x=rect.x - 10, y=rect.y) rect_button = GRect(rect.width, 10, x=rect.x, y=rect.y + rect.height) rect_right = GRect(10, rect.height, x=rect.x + rect.width, y=rect.y) arc_right_top = GArc(40, 40, 0, 90, rect.x - 10 + rect.width, rect.y - 10) arc_left_top = GArc(40, 40, 90, 90, rect.x - 10, rect.y - 10) arc_left_button = GArc(40, 40, 180, 90, rect.x - 10, rect.y - 10 + rect.height) arc_right_button = GArc(40, 40, 270, 90, rect.x - 10 + rect.width, rect.y - 10 + rect.height) self.talk_block = [triangle, rect, rect_top, rect_left, rect_button, rect_right, arc_right_top, arc_left_top, arc_left_button, arc_right_button, label] for i in self.talk_block: i.filled = True i.fill_color = 'crimson' i.color = 'crimson' if i == self.talk_block[-1]: i.color = 'azure' window.add(i) print(label.width, label.height)
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))
def sierpinski_triangle(order, length, upper_left_x, upper_left_y): """ :param order:Controls the order of Sierpinski Triangle :param length:The length of order 1 Sierpinski Triangle :param upper_left_x:The upper left x coordinate of order 1 Sierpinski Triangle :param upper_left_y:The upper left y coordinate of order 1 Sierpinski Triangle :return: """ if order == 0: pass 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.866)) window.add(triangle) # upper-left sierpinski_triangle(order-1, length/2, upper_left_x, upper_left_y) # upper-right sierpinski_triangle(order-1, length/2, upper_left_x+length/2, upper_left_y) # lower-mid sierpinski_triangle(order-1, length/2, upper_left_x+length/4, upper_left_y+(length/2)*0.866)
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
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)
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
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
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)
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)
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)
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)
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)
def peach(): p_face1 = GPolygon() p_face1.add_vertex((750, 155)) p_face1.add_vertex((670, 225)) p_face1.add_vertex((835, 210)) window.add(p_face1) p_face1.color = 'peach' p_face1.fill_color = 'peach' p_face2 = GOval(190, 140) window.add(p_face2, x=665, y=180) p_face2.color = 'peach' p_face2.fill_color = 'peach' p_l_eye = GOval(30, 30) window.add(p_l_eye, x=705, y=215) p_l_eye.filled = True p_l_eye.fill_color = 'darkgray2' p_l_eye2 = GOval(12, 12) window.add(p_l_eye2, x=708, y=220) p_l_eye2.filled = True p_l_eye2.fill_color = 'ivory' p_l_eye3 = GOval(9, 9) window.add(p_l_eye3, x=723, y=224) p_l_eye3.filled = True p_l_eye3.fill_color = 'ivory' p_l_eye4 = GOval(9, 9) window.add(p_l_eye4, x=717, y=232) p_l_eye4.filled = True p_l_eye4.fill_color = 'ivory' p_r_eye = GOval(30, 30) window.add(p_r_eye, x=785, y=215) p_r_eye.filled = True p_r_eye.fill_color = 'darkgray2' p_r_eye2 = GOval(12, 12) window.add(p_r_eye2, x=788, y=220) p_r_eye2.filled = True p_r_eye2.fill_color = 'ivory' p_r_eye3 = GOval(9, 9) window.add(p_r_eye3, x=803, y=224) p_r_eye3.filled = True p_r_eye3.fill_color = 'ivory' p_r_eye4 = GOval(9, 9) window.add(p_r_eye4, x=797, y=232) p_r_eye4.filled = True p_r_eye4.fill_color = 'ivory' p_mouth_1 = GOval(35, 30) window.add(p_mouth_1, x=730, y=260) p_mouth_1.color = 'firebrick' p_mouth_1.filled = True p_mouth_1.fill_color = 'firebrick' p_mouth_2 = GOval(35, 30) window.add(p_mouth_2, x=755, y=260) p_mouth_2.color = 'firebrick' p_mouth_2.filled = True p_mouth_2.fill_color = 'firebrick' p_mouth_3 = GOval(40, 12) window.add(p_mouth_3, x=740, y=280) p_mouth_3.color = 'firebrick' p_mouth_3.filled = True p_mouth_3.fill_color = 'firebrick' p_teeth = GOval(25, 25) window.add(p_teeth, x=747, y=250) p_teeth.color = 'ivory' p_teeth.filled = True p_teeth.fill_color = 'ivory' p_mouth_4 = GOval(40, 15) window.add(p_mouth_4, x=740, y=248) p_mouth_4.color = 'peach' p_mouth_4.filled = True p_mouth_4.fill_color = 'peach' p_l_cheek = GOval(35, 15) window.add(p_l_cheek, x=675, y=250) p_l_cheek.color = 'pink2' p_l_cheek.fill_color = 'pink2' p_r_cheek = GOval(35, 15) window.add(p_r_cheek, x=805, y=250) p_r_cheek.color = 'pink2' p_r_cheek.fill_color = 'pink2' peach_name = GLabel('APEACH') peach_name.font = 'Verdana-30-bold' window.add(peach_name, x=695, y=380)
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)
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 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)