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 house_background(): night_sky = GRect(WINDOW_WIDTH, WINDOW_HEIGHT) obj_fill_color_add(night_sky, "darkgrey") house_obj = [None] * 3 # room floor house_obj[0] = GPolygon() polygon_helper(house_obj[0], "oldlace", (300, 750), (1500, 750), (1500, 900), ( 0, 900)) # left wall house_obj[1] = GPolygon() polygon_helper(house_obj[1], "oldlace", ( 0, -20), ( 300, 50), ( 300, 750), ( 0, 900)) # ceiling house_obj[2] = GPolygon() polygon_helper(house_obj[2], "oldlace", ( 0, -20), (1500, 0), (1500, 50), (300, 50))
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 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: 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 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 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 batman(): #batman legs left_leg = GRect(40, 100, x = 280, y = 775) obj_fill_color_add(left_leg, "gray") left_shoe = GPolygon() polygon_helper(left_shoe, "dimgrey", (280, 840), (280, 880), (330, 880), (320, 840)) right_leg = GRect(40, 100, x = 360, y = 775) obj_fill_color_add(right_leg, "gray") right_shoe = GPolygon() polygon_helper(right_shoe, "dimgrey", (360, 840), (360, 880), (410, 880), (400, 840)) #batman head bat_ear1 = GPolygon() polygon_helper(bat_ear1, "gray", (275, 450), (325, 450), (300, 375)) head = GOval(180, 220, x = 260, y = 400) obj_fill_color_add(head, "gray") bat_ear2 = GPolygon() polygon_helper(bat_ear2, "gray", (360, 450), (410, 450), (385, 375)) #batman appearance face = GArc(275, 330, 0, -90, 300, 450) obj_fill_color_add(face, "bisque") eye = GRect(30, 10, x = 400, y = 475) obj_fill_color_add(eye, "white") mouth = GLine(405, 575, 425, 575) obj_fill_color_add(mouth, "black") #batman body left_arm = GPolygon() polygon_helper(left_arm, "gray", (275, 600), (210, 650), (275, 720), (300, 720), (250, 655), (340, 600)) right_arm = GPolygon() polygon_helper(right_arm, "gray", (355, 600), (415, 650), (385, 720), (405, 720), (455, 650), (405, 600)) cape = GPolygon() polygon_helper(cape, "dimgrey", (280, 580), (250, 800), (450, 800), (380, 580))
def rescue_light(): #color database light_color = ["dimgrey", "lightgrey", "gainsboro", "whitesmoke"] light_beam = GPolygon() light_beam.color = "darkgrey" polygon_helper(light_beam, "darkgrey", (920, 350), (1300, 650), (1255, 250)) bat_icon_background = GOval(385, 300, x = 870, y = 100) bat_icon_background.color = "darkgrey" obj_fill_color_add(bat_icon_background, "darkgrey") # gradually brighten the beam pause(1000) for s in light_color: light_beam.color = s light_beam.fill_color = s bat_icon_background.color = s bat_icon_background.fill_color = s pause(800) #batman icon in light bat_icon = GImage("batman.jpeg") window.add(bat_icon, bat_icon_background.x + 60, bat_icon_background.y + 45)
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 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 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 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 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: 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(): """ 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)