Esempio n. 1
0
 def _static_drawables(self):
     """Returns GraphicsObjects that only need to be drawn once."""
     ground = g.Line(g.Point(0, GROUND_Y), g.Point(WIDTH, GROUND_Y))
     target = g.Line(g.Point(WIDTH/2 - 50, TARGET_Y), 
                     g.Point(WIDTH/2 + 50, TARGET_Y))
     target.setOutline("red")
     return ground, target
Esempio n. 2
0
def draw_house():
    house = gr.Rectangle(gr.Point(20, 210), gr.Point(180, 350))
    house.setOutline('gray')
    house.setFill("gray")

    roof = gr.Polygon(gr.Point(20, 210), gr.Point(100, 160), gr.Point(180, 210))
    roof.setFill('black')
    roof.setOutline('black')

    windows = gr.Rectangle(gr.Point(65, 250), gr.Point(135, 310))
    windows.setFill('lightblue')
    windows.setOutline('black')

    line1 = gr.Line(gr.Point(100, 250), gr.Point(100, 310))
    line1.setWidth(1)
    line1.setOutline('black')

    line2 = gr.Line(gr.Point(65, 280), gr.Point(135, 280))
    line2.setWidth(1)
    line2.setOutline('black')

    house.draw(window)
    roof.draw(window)
    windows.draw(window)
    line1.draw(window)
    line2.draw(window)
Esempio n. 3
0
File: tg.py Progetto: VP1147/tg
def grid(m):  # m - Def the distance between 2 lines
    e = 0
    for i in range(0, int((Sx) / (m / Factor)) + 1):
        l = gfx.Line(gfx.Point((e / Factor) + (Sx / 2), 0),
                     gfx.Point((e / Factor) + (Sx / 2), Sy))
        l.setFill(gfx.color_rgb(Color3[0], Color3[1], Color3[2]))
        l.draw(Win)

        l = gfx.Line(gfx.Point((Sx / 2) - (e / Factor), 0),
                     gfx.Point(Sx / 2 - (e / Factor), Sy))
        l.setFill(gfx.color_rgb(Color3[0], Color3[1], Color3[2]))
        l.draw(Win)
        e += m / 2
    e = 0
    for i in range(0, int((Sy) / (m / Factor)) + 1):
        l = gfx.Line(gfx.Point(0, (e / Factor) + (Sy / 2)),
                     gfx.Point(Sx, (e / Factor) + (Sy / 2)))
        l.setFill(gfx.color_rgb(Color3[0], Color3[1], Color3[2]))
        l.draw(Win)

        l = gfx.Line(gfx.Point(0, (Sy / 2) - (e / Factor)),
                     gfx.Point(Sx, (Sy / 2) - (e / Factor)))
        l.setFill(gfx.color_rgb(Color3[0], Color3[1], Color3[2]))
        l.draw(Win)
        e += m / 2
def draw(airport, makegatebuilding, coords, numrunways, filenamenum = None):
	win = graphics.GraphWin('airport', 600, 600*(airport.bounds[3] - airport.bounds[1])/(airport.bounds[2] - airport.bounds[0])) # give title and dimensions
	win.setCoords(airport.bounds[0] - 10, airport.bounds[1] - 10, airport.bounds[2] + 10, airport.bounds[3] + 10)

	airportgraphic = graphics.Polygon(map(lambda (x, y): graphics.Point(x,y), airport.exterior.coords))
	airportgraphic.draw(win)

	for i in range(0, numrunways):
		x = coords[i*5 + 0]
		y = coords[i*5 + 1]
		length = coords[i*5 + 2]
		width = coords[i*5 + 3]/100
		angle = coords[i*5 + 4]/1000
		colour = "black"
	
		x1 = x - width * math.sin(angle) / 2 + length * math.cos(angle) / 2
		y1 = y + width * math.cos(angle) / 2 + length * math.sin(angle) / 2
		
		x2 = x + width * math.sin(angle) / 2 - length * math.cos(angle) / 2
		y2 = y - width * math.cos(angle) / 2 - length * math.sin(angle) / 2
		
		x3 = x + width * math.sin(angle) / 2 + length * math.cos(angle) / 2
		y3 = y - width * math.cos(angle) / 2 + length * math.sin(angle) / 2
		
		x4 = x - width * math.sin(angle) / 2 - length * math.cos(angle) / 2
		y4 = y + width * math.cos(angle) / 2 - length * math.sin(angle) / 2
	
		runway1 = graphics.Line(graphics.Point(x1, y1), graphics.Point(x2, y2))
		runway1.setOutline(colour)
		runway1.draw(win)
		runway2 = graphics.Line(graphics.Point(x2, y2), graphics.Point(x3, y3))
		runway2.setOutline(colour)
		runway2.draw(win)
		runway3 = graphics.Line(graphics.Point(x3, y3), graphics.Point(x4, y4))
		runway3.setOutline(colour)
		runway3.draw(win)
		runway4 = graphics.Line(graphics.Point(x4, y4), graphics.Point(x1, y1))
		runway4.setOutline(colour)
		runway4.draw(win)
	
	gatespolygon = makegatebuilding(coords[numrunways*5:])
	
	try:
		gatebuildings = gatespolygon.geoms
	except AttributeError:
		gatebuildings = [gatespolygon]
		
	for gatebuilding in gatebuildings:
		if gatebuilding:
			gatebuildinggraphic = graphics.Polygon(map(lambda (x, y): graphics.Point(x,y), gatebuilding.exterior.coords))
			gatebuildinggraphic.draw(win)
			for interior in gatebuilding.interiors:
				gatebuildinggraphic = graphics.Polygon(map(lambda (x, y): graphics.Point(x,y), interior.coords))
				gatebuildinggraphic.draw(win)

	if filenamenum is not None:
		win.postscript(file="output/step-%05d.ps" % filenamenum, colormode='color')
	else:
		win.getMouse()
	win.close()
Esempio n. 5
0
def fractal_rectangle(
    A,
    B,
    C,
    D,
    deep=10
):  # A,B,C,D - кортежи (пары чисел через запятую) с координатами точек квадрата, deep - глубина рекурсии, в данном случае - 10
    if deep < 1:  # Проверяем сколько осталось нарисовать прямоугольников. Если 0, то выходим из функции.
        return
    gr.Line(gr.Point(*A), gr.Point(*B)).draw(
        window
    )  # *A - функция разворачивания кортежа - использует значения кортежа A[0], A[1], A[2] и т.д.
    gr.Line(gr.Point(*B), gr.Point(*C)).draw(window)
    gr.Line(gr.Point(*C), gr.Point(*D)).draw(window)
    gr.Line(gr.Point(*D), gr.Point(*A)).draw(window)

    # или тоже самое, но короче:
    # for M,N in (A,B), (B,C), (C,D), (D,A):
    #      gr.Line(gr.Point(*M), gr.Point(*N)).draw(window)

    A1 = (A[0] * (1 - alpha) + B[0] * alpha, A[1] * (1 - alpha) + B[1] * alpha
          )  # Вычисляем координаты новых точек
    B1 = (B[0] * (1 - alpha) + C[0] * alpha, B[1] * (1 - alpha) + C[1] * alpha)
    C1 = (C[0] * (1 - alpha) + D[0] * alpha, C[1] * (1 - alpha) + D[1] * alpha)
    D1 = (D[0] * (1 - alpha) + A[0] * alpha, D[1] * (1 - alpha) + A[1] * alpha)

    fractal_rectangle(A1, B1, C1, D1, deep - 1)
Esempio n. 6
0
def die(x,y,window):
  p1 = graphics.Point(x-75,y-75)
  p2 = graphics.Point(x+75,y+75)
  die = graphics.Rectangle(p1,p2)
  die.draw(window)

  pl1 = graphics.Point(x-25,y-125)
  line1 = graphics.Line(p1,pl1)
  line1.draw(window)

  p1l2 = graphics.Point(x+75,y-75)
  p2l2 = graphics.Point(x+125,y-125)
  line2 = graphics.Line(p1l2,p2l2)
  line2.draw(window)

  p1l3 = graphics.Point(x+75,y+75)
  p2l3 = graphics.Point(x+125,y+25)
  line3 = graphics.Line(p1l3,p2l3)
  line3.draw(window)

  p1l4 = graphics.Point(x-25,y-125)
  p2l4 = graphics.Point(x+125,y-125)
  line4 = graphics.Line(p1l4,p2l4)
  line4.draw(window)

  p1l5 = graphics.Point(x+125,y-125)
  p2l5 = graphics.Point(x+125,y+25)
  line5 = graphics.Line(p1l5,p2l5)
  line5.draw(window)
Esempio n. 7
0
def bird(x1, y1):
    rightWing = g.Line(g.Point(x1 - 15, y1 - 15), g.Point(x1, y1))
    leftWing = g.Line(g.Point(x1, y1), g.Point(x1 + 15, y1 - 15))
    rightWing.setFill("blue")
    leftWing.setFill("blue")
    rightWing.draw(win)
    leftWing.draw(win)
Esempio n. 8
0
def draw_house():
    walls = gr.Polygon(gr.Point(200, 300), gr.Point(400, 300),
                       gr.Point(400, 450), gr.Point(200, 450))
    walls.setFill('firebrick')
    walls.setOutline('saddlebrown')
    walls.setWidth(2)
    big_window = gr.Rectangle(gr.Point(250, 325), gr.Point(350, 400))
    big_window.setFill('lightcyan')
    big_window.setOutline('saddlebrown')
    big_window.setWidth(2)
    reshetka1 = gr.Line(gr.Point(300, 325), gr.Point(300, 400))
    resetka2 = gr.Line(gr.Point(250, 350), gr.Point(350, 350))
    roof = gr.Polygon(gr.Point(185, 315), gr.Point(300, 150),
                      gr.Point(415, 315))
    roof.setOutline('saddlebrown')
    roof.setWidth(2)
    roof.setFill('peru')
    small_window = gr.Circle(gr.Point(300, 250), 20)
    small_window.setOutline('saddlebrown')
    small_window.setWidth(2)
    small_window.setFill('lightcyan')

    walls.draw(window)
    roof.draw(window)
    big_window.draw(window)
    reshetka1.draw(window)
    resetka2.draw(window)
    small_window.draw(window)
Esempio n. 9
0
def draw_house():
    house_body = gr.Rectangle(gr.Point(200, 220), gr.Point(400, 420))
    house_body.setFill(gr.color_rgb(200, 180, 140))
    house_body.setOutline(gr.color_rgb(160, 140, 100))
    house_body.setWidth(5)
    house_body.draw(window)

    house_roof = gr.Polygon(gr.Point(190, 220), gr.Point(300, 110),
                            gr.Point(410, 220))
    house_roof.setFill(gr.color_rgb(140, 25, 30))
    house_roof.setOutline(gr.color_rgb(100, 5, 10))
    house_roof.setWidth(5)
    house_roof.draw(window)

    house_window = gr.Rectangle(gr.Point(250, 260), gr.Point(350, 360))
    house_window.setFill(gr.color_rgb(132, 205, 255))
    house_window.setWidth(5)
    house_window.draw(window)

    line1 = gr.Line(gr.Point(300, 260), gr.Point(300, 360))
    line2 = gr.Line(gr.Point(250, 310), gr.Point(350, 310))

    line1.setWidth(5)
    line2.setWidth(5)

    line1.draw(window)
    line2.draw(window)
def five_click_stick_figure():
    mouse1 = win.getMouse()
    mouse2 = win.getMouse()
    radius = math.sqrt((mouse1.getX() - mouse2.getX())**2 +
                       (mouse1.getY() - mouse2.getY())**2)
    head = g.Circle(g.Point(mouse1.getX(), mouse1.getY()), radius)
    head.draw(win)

    mouse3 = win.getMouse()
    body = g.Line(g.Point(mouse1.getX(),
                          mouse1.getY() + radius),
                  g.Point(mouse1.getX(), mouse3.getY()))
    body.draw(win)

    symmetry = mouse1.getX()

    mouse4 = win.getMouse()
    arm_distance = (symmetry - mouse4.getX()) * 2
    arms = g.Line(g.Point(mouse4.getX(), mouse4.getY()),
                  g.Point(mouse4.getX() + arm_distance, mouse4.getY()))
    arms.draw(win)

    mouse5 = win.getMouse()
    leg_distance = (symmetry - mouse5.getX()) * 2
    leg_l = g.Line(g.Point(mouse1.getX(), mouse3.getY()),
                   g.Point(mouse5.getX(), mouse5.getY()))
    leg_l.draw(win)
    leg_r = g.Line(g.Point(mouse1.getX(), mouse3.getY()),
                   g.Point(mouse5.getX() + leg_distance, mouse5.getY()))
    leg_r.draw(win)
Esempio n. 11
0
def draw_caterpillar():
    caterpillar1 = gr.Circle(gr.Point(20, 480), 20)
    caterpillar2 = gr.Circle(gr.Point(60, 480), 20)
    caterpillar3 = gr.Circle(gr.Point(100, 480), 20)
    caterpillar4 = gr.Circle(gr.Point(140, 480), 20)
    caterpillar5 = gr.Circle(gr.Point(180, 480), 20)
    caterpillar = gr.Circle(gr.Point(190, 440), 25)
    caterpillarx1 = gr.Line(gr.Point(190, 415), gr.Point(205, 390))
    caterpillarx2 = gr.Line(gr.Point(190, 415), gr.Point(175, 390))

    caterpillarx1 .setWidth(4)
    caterpillarx2 .setWidth(4)

    caterpillar1.setFill('green')
    caterpillar2.setFill('green')
    caterpillar3.setFill('green')
    caterpillar4.setFill('green')
    caterpillar5.setFill('green')
    caterpillar.setFill('green')
    caterpillarx1 .setFill('black')
    caterpillarx2 .setFill('black')

    caterpillar1.draw(window)
    caterpillar2.draw(window)
    caterpillar3.draw(window)
    caterpillar4.draw(window)
    caterpillar5.draw(window)
    caterpillar.draw(window)
    caterpillarx1 .draw(window)
    caterpillarx2.draw(window)
Esempio n. 12
0
def testBox(width, height, zoom, t_scale):
    win = g.GraphWin('Test', width, height)
    head = g.Circle(g.Point(100, 100), 25)
    head.draw(win)

    # Make the bar to measure the time of the video
    T_SCALE_POS = (width * .1, height * .9)
    NUM_TICKS = 10
    TICK_SEMI_HEIGHT = 5
    t_scale_segs = [
        g.Line(g.Point(T_SCALE_POS[0], T_SCALE_POS[1]),
               g.Point(width - T_SCALE_POS[0], T_SCALE_POS[1]))
    ]
    t_scale_segs += [
        g.Line(
            g.Point(T_SCALE_POS[0] + i * (width * .8 / NUM_TICKS),
                    T_SCALE_POS[1] - TICK_SEMI_HEIGHT),
            g.Point(T_SCALE_POS[0] + i * (width * .8 / NUM_TICKS),
                    T_SCALE_POS[1] + TICK_SEMI_HEIGHT))
        for i in range(NUM_TICKS + 1)
    ]

    for seg in t_scale_segs:
        seg.draw(win)
    #t_scale_segs[0].setWidth(1)
    #t_scale_segs[0].draw(win)

    return win
    def render_update(self, action):
        pt = point_from(self._obs)
        move_to(self._g_obs, self._g_obs.getCenter(), pt)

        goal_pt = point_from(self.ac_goal_pos)
        move_to(self._g_targ, self._g_targ.getCenter(), goal_pt)

        if len(self._g_lines) > 0:
            start_pt = self._g_lines[-1].getP2()
        else:
            start_pt = pt

        self._g_lines.append(gr.Line(start_pt, pt))
        self._g_lines[-1].setFill("red")
        self._g_lines[-1].setWidth(1)
        self._g_lines[-1].draw(self._win)

        # predicted trajectory rendering
        if 'results/trajectory/obs' in action.leaf_keys():
            # clear
            for line in self._curr_trajectory:
                line.undraw()
            self._curr_trajectory = []

            # refill
            idx = action.results.order[0, 0]
            trajectory = action.results.trajectory.obs[0, idx]
            for i in range(trajectory.shape[0] - 1):
                line = gr.Line(point_from(trajectory[i]),
                               point_from(trajectory[i + 1]))
                line.setFill("green")
                line.setWidth(1)
                line.draw(self._win)
                self._curr_trajectory.append(line)
Esempio n. 14
0
def ptMoneyMap():
    MainWin = graphics.GraphWin("MoneyMap", 800, 700)
    MoneyList = GetMoneyList(100, 0.1, 18)
    line = graphics.Line(graphics.Point(80, 20), graphics.Point(80, 600))
    line.draw(MainWin)
    for y in range(600, 30, -20):
        kline = graphics.Line(graphics.Point(80, y), graphics.Point(88, y))
        kline.draw(MainWin)
        txt = graphics.Text(graphics.Point(60, y), str(600 - y))
        txt.draw(MainWin)

    x = 100
    YearNum = 0
    for CurrentMoney in MoneyList:
        StartPoint = graphics.Point(x, 600 - CurrentMoney)
        x += 15
        YearTxt = graphics.Text(graphics.Point(x, 610), str(YearNum) + "年")
        YearNum += 1
        YearTxt.draw(MainWin)
        x += 15
        EndPoint = graphics.Point(x, 600)

        cRectangle = graphics.Rectangle(StartPoint, EndPoint)
        cRectangle.setFill("green")

        cRectangle.draw(MainWin)

        x += 5
    for i in range(10):
        pt = MainWin.getMouse()
        print("clicked x:", pt.getX(), ",y:", pt.getY())
Esempio n. 15
0
 def drawBoard(self):
     # window object
     self.win_ = graph.GraphWin("Board",\
         (self.board_edge_[1] - self.board_edge_[0]) * 1.25,\
         (self.board_edge_[3]- self.board_edge_[2]) * 1.25)
     # set color of background of window
     self.win_.setBackground(graph.color_rgb(240, 250, 15))
     # x,y-coordinates of grids
     self.x_pos_ = np.linspace(self.board_edge_[0], self.board_edge_[1],
                               self.n_col_)
     self.y_pos_ = np.linspace(self.board_edge_[2], self.board_edge_[3],
                               self.n_row_)
     # draw grid of chessboard
     for x in self.x_pos_:
         p1 = graph.Point(x, self.board_edge_[2])
         p2 = graph.Point(x, self.board_edge_[3])
         line = graph.Line(p1, p2)
         # set edge bold
         if x == self.board_edge_[0] or x == self.board_edge_[1]:
             line.setWidth(2.5)
         line.draw(self.win_)
     for y in self.y_pos_:
         p1 = graph.Point(self.board_edge_[0], y)
         p2 = graph.Point(self.board_edge_[1], y)
         line = graph.Line(p1, p2)
         # set edge bold
         if y == self.board_edge_[2] or y == self.board_edge_[3]:
             line.setWidth(2.5)
         line.draw(self.win_)
Esempio n. 16
0
File: tg.py Progetto: VP1147/tg
def axis(x, y):
    l1 = gfx.Line(gfx.Point(x / 2, 0), gfx.Point(x / 2, x))
    l1.setFill(gfx.color_rgb(Color2[0], Color2[1], Color2[2]))
    l1.draw(Win)

    l2 = gfx.Line(gfx.Point(x, y / 2), gfx.Point(1, y / 2))
    l2.setFill(gfx.color_rgb(Color2[0], Color2[1], Color2[2]))
    l2.draw(Win)
Esempio n. 17
0
def fractal_rectangle(A, B, C, D, deep=10):
    if deep < 1:
        return

    gr.Line(gr.Point(*A), gr.Point(*B)).draw(window)
    gr.Line(gr.Point(*B), gr.Point(*C)).draw(window)
    gr.Line(gr.Point(*C), gr.Point(*D)).draw(window)
    gr.Line(gr.Point(*D), gr.Point(*A)).draw(window)
Esempio n. 18
0
def draw_icecream(win):

    line1 = gr.Line(gr.Point(270, 600), gr.Point(220, 650))
    line2 = gr.Line(gr.Point(220, 650), gr.Point(250, 670))
    line3 = gr.Line(gr.Point(250, 670), gr.Point(270, 600))

    line1.draw(win)
    line2.draw(win)
    line3.draw(win)
Esempio n. 19
0
def brow(x, y):
    eyebrow1 = gr.Line(gr.Point(x - 15, y - 30), gr.Point(x - 40, y - 37))
    eyebrow2 = gr.Line(gr.Point(x + 10, y - 40), gr.Point(x + 40, y - 50))
    eyebrow1.setWidth(10)
    eyebrow2.setWidth(10)
    eyebrow1.setOutline('black')
    eyebrow2.setOutline('black')
    eyebrow1.draw(window)
    eyebrow2.draw(window)
Esempio n. 20
0
def drawGrid(win):
    for i in range(0, WIDTH, 20):
        ln = g.Line(g.Point(i, 0), g.Point(i, HEIGHT))
        ln.setOutline(g.color_rgb(200, 200, 255))
        ln.draw(win)
    for i in range(0, HEIGHT, 20):
        ln = g.Line(g.Point(0, i), g.Point(WIDTH, i))
        ln.setOutline(g.color_rgb(200, 200, 255))
        ln.draw(win)
Esempio n. 21
0
def background():
    sky = gr.Line(gr.Point(0, 125), gr.Point(500, 125))
    sky.setWidth(250)
    sky.setFill('Blue')
    sky.draw(window)
    grass = gr.Line(gr.Point(0, 375), gr.Point(500, 375))
    grass.setWidth(250)
    grass.setFill('Green')
    grass.draw(window)
Esempio n. 22
0
def wind_line():
    '''решетки окна'''
    wind_line1 = gr.Line(gr.Point(w / 3, h / 2 - 40),
                         gr.Point(w / 3, h / 2 + 40))
    wind_line2 = gr.Line(gr.Point(w / 3 - 40, h / 2),
                         gr.Point(w / 3 + 40, h / 2))
    wind_line1.setWidth(5)
    wind_line2.setWidth(5)
    wind_line1.draw(window)
    wind_line2.draw(window)
Esempio n. 23
0
def buildRoof():
    leftRoofA = houseTL
    leftRoofB = g.Point(250, 100)
    leftRoof = g.Line(leftRoofA, leftRoofB)
    leftRoof.draw(win)

    rightRoofA = leftRoofB
    rightRoofB = g.Point(450, 150)
    rightRoof = g.Line(rightRoofA, rightRoofB)
    rightRoof.draw(win)
Esempio n. 24
0
def draw_sun_eyebrows():
    eyebrow1 = gr.Line(gr.Point(210, 242), gr.Point(245, 262))
    eyebrow2 = gr.Line(gr.Point(255, 265), gr.Point(290, 245))
    eyebrow1.setWidth(10)
    eyebrow2.setWidth(10)
    eyebrow1.setOutline('black')
    eyebrow2.setOutline('black')

    eyebrow1.draw(window)
    eyebrow2.draw(window)
Esempio n. 25
0
def createGameBackground():
    win = gr.GraphWin("Flappy Mule", 400, 600)
    win.setBackground('steelblue1')

    #Here I will draw Miller Library, the backdrop for my game
    base = gr.Rectangle(gr.Point(10, 600), gr.Point(390, 500))
    left_rect = gr.Rectangle(gr.Point(10, 600), gr.Point(90, 500))
    right_rect = gr.Rectangle(gr.Point(310, 600), gr.Point(390, 500))
    right_tri = gr.Polygon(gr.Point(300, 500), gr.Point(400, 500),
                           gr.Point(350, 450))
    left_tri = gr.Polygon(gr.Point(0, 500), gr.Point(100, 500),
                          gr.Point(50, 450))
    mid_rect = gr.Rectangle(gr.Point(110, 600), gr.Point(290, 425))
    mid_tri = gr.Polygon(gr.Point(120, 500), gr.Point(280, 500),
                         gr.Point(200, 450))
    pillar1 = gr.Rectangle(gr.Point(120, 580), gr.Point(130, 500))
    pillar2 = gr.Rectangle(gr.Point(150, 580), gr.Point(160, 500))
    pillar3 = gr.Rectangle(gr.Point(180, 580), gr.Point(190, 500))
    pillar4 = gr.Rectangle(gr.Point(210, 580), gr.Point(220, 500))
    pillar5 = gr.Rectangle(gr.Point(240, 580), gr.Point(250, 500))
    pillar6 = gr.Rectangle(gr.Point(270, 580), gr.Point(280, 500))
    stair_rect = gr.Rectangle(gr.Point(110, 600), gr.Point(290, 580))
    mid_rect2 = gr.Rectangle(gr.Point(170, 425), gr.Point(230, 375))
    mid_rect3 = gr.Rectangle(gr.Point(180, 375), gr.Point(220, 325))
    mid_rect4 = gr.Rectangle(gr.Point(185, 325), gr.Point(215, 275))
    mid_rect5 = gr.Rectangle(gr.Point(190, 275), gr.Point(210, 240))
    clock = gr.Circle(gr.Point(200, 350), 10)
    pointer = gr.Polygon(gr.Point(190, 240), gr.Point(210, 240),
                         gr.Point(200, 175))
    dot_top = gr.Circle(gr.Point(200, 172), 5)
    vert_line = gr.Line(gr.Point(200, 167.5), gr.Point(200, 157.5))
    hor_line = gr.Line(gr.Point(195, 162.5), gr.Point(205, 162.5))
    topper = gr.Polygon(gr.Point(205, 157.5), gr.Point(195, 157.5),
                        gr.Point(197, 152.5), gr.Point(200, 152.5),
                        gr.Point(200, 155), gr.Point(205, 155))

    sun = gr.Circle(gr.Point(50, 50), 50)
    sun.setFill('yellow')
    sun.setOutline('yellow')

    grass = gr.Rectangle(gr.Point(0, 600), gr.Point(400, 595))
    grass.setFill('green')
    grass.setOutline('green')

    objects = [
        base, right_rect, left_rect, right_tri, left_tri, mid_rect, mid_tri,
        pillar1, pillar2, pillar3, pillar4, pillar5, pillar6, stair_rect,
        mid_rect2, mid_rect3, mid_rect4, mid_rect5, clock, pointer, dot_top,
        vert_line, hor_line, topper, sun, grass
    ]

    for item in objects:
        item.draw(win)

    return win
Esempio n. 26
0
def patch_six(window):
    for i in range(11):
        p1 = g.Point(50 + (i * 50), 50)
        p2 = g.Point(600 - p1.getX(), 600 - p1.getY())
        line = g.Line(p1, p2)
        line.draw(window)
    for i in range(11):
        p1 = g.Point(50, 50 + (i * 50))
        p2 = g.Point(600 - p1.getX(), 600 - p1.getY())
        line = g.Line(p1, p2)
        line.draw(window)
def draw_stick_figure():
    head = g.Circle(g.Point(100, 60), 20)
    head.draw(win)
    body = g.Line(g.Point(100, 80), g.Point(100, 120))
    body.draw(win)
    arms = g.Line(g.Point(70, 100), g.Point(130, 100))
    arms.draw(win)
    leg_l = g.Line(g.Point(100, 120), g.Point(120, 170))
    leg_l.draw(win)
    leg_r = g.Line(g.Point(100, 120), g.Point(80, 170))
    leg_r.draw(win)
    def lines(self):

        lines = []
        for i in range(self.size):
            vertLine = graphics.Line(graphics.Point(30 * i, 0), graphics.Point(30 * i, 420))
            lines.append(vertLine)
        for i in range(self.size):
            horizLine = graphics.Line(graphics.Point(0, 30 * i), graphics.Point(420, 30 * i))
            lines.append(horizLine)
        for item in lines:
            item.draw(self.win)
Esempio n. 29
0
def legs():
    leg2 = gr.Line(gr.Point(120, 230), gr.Point(120, 290))
    leg2.setWidth(40)
    leg2.setOutline('brown')

    leg1 = gr.Line(gr.Point(200, 230), gr.Point(200, 290))
    leg1.setWidth(40)
    leg1.setOutline('brown')

    leg1.draw(window)
    leg2.draw(window)
Esempio n. 30
0
def factorial_rect(A, B, C, D, deep=10, alpha=0.2):
    if deep == 0:
        return
    gr.Line(gr.Point(*A), gr.Point(*B)).draw(window)
    gr.Line(gr.Point(*B), gr.Point(*C)).draw(window)
    gr.Line(gr.Point(*C), gr.Point(*D)).draw(window)
    gr.Line(gr.Point(*D), gr.Point(*A)).draw(window)
    A1 = ((1 - alpha) * A[0] + alpha * B[0], (1 - alpha) * A[1] + alpha * B[1])
    B1 = ((1 - alpha) * B[0] + alpha * C[0], (1 - alpha) * B[1] + alpha * C[1])
    C1 = ((1 - alpha) * C[0] + alpha * D[0], (1 - alpha) * C[1] + alpha * D[1])
    D1 = ((1 - alpha) * D[0] + alpha * A[0], (1 - alpha) * D[1] + alpha * A[1])
    factorial_rect(A1, B1, C1, D1, deep - 1)