예제 #1
0
def draw_rectangle(centre_point, radius, color, graphics_window):
    (col, row) = centre_point
    (radius_c, radius_r) = radius
    a = graphics.Rectangle(graphics.Point(col - radius_c, row - radius_r),
                           graphics.Point(col + radius_c, row + radius_r))
    a.setFill(color)
    a.setWidth(0)
    a.draw(graphics_window)
예제 #2
0
def draw_line(point_a, point_b, width, color, graphics_window):
    (col_a, row_a) = point_a
    (col_b, row_b) = point_b
    a = graphics.Line(graphics.Point(col_a, row_a),
                      graphics.Point(col_b, row_b))
    a.setFill(color)
    a.setWidth(width)
    a.draw(graphics_window)
예제 #3
0
def draw_text(text, centre_point, text_size, color, graphics_window):
    (col, row) = centre_point

    for i in range(-2, 3):
        e = []
        e.append(graphics.Text(graphics.Point(col + i, row), text))
        e.append(graphics.Text(graphics.Point(col, row + i), text))
        e.append(graphics.Text(graphics.Point(col + i, row + i), text))
        e.append(graphics.Text(graphics.Point(col + i, row - i), text))
        for ei in e:
            ei.setSize(text_size)
            ei.setStyle("bold")
            ei.setTextColor("white")
            ei.draw(graphics_window)

    a = graphics.Text(graphics.Point(col, row), text)
    a.setSize(text_size)
    a.setStyle("bold")
    a.draw(graphics_window)
예제 #4
0
 def __init__(self, simulator, dimensions, img_size):
     self.simulator = simulator
     self.dimensions = dimensions
     self.tile_size = (int(img_size[0] / dimensions[0]),
                       int(img_size[1] / dimensions[1]))
     self.graphics_window = graphics.GraphWin("Network Simulator",
                                              img_size[0],
                                              img_size[1],
                                              autoflush=False)
     self.img = graphics.Image(graphics.Point(0, 0), img_size[0],
                               img_size[1])
     self.img_count = 0