Пример #1
0
 def draw(self):
     self.reset()
     if self.model.pos:
         self.draw_circle(self.model.pos, self.model.radius, fill=colors[self.model.color])
         flame = FLAME if not self.model.state else FLAME_OFF
         self.draw_circle(self.model.pos, self.model.radius * 0.8, fill=flame)
         Drawable.draw(self)
Пример #2
0
 def draw (self):
     # Redraw.
     self.reset ()
     # Table.
     self.draw_rectangle ((-22, -22), (3000 + 22, 2100 + 22), fill = BLACK)
     self.draw_rectangle ((0, 0), (3000, 2100), fill = BLACK)
     self.draw_both (self.draw_rectangle, (0, 0), (400, 2100 - 400 - 22), fill = GREEN)
     self.draw_rectangle ((0, 2100 - 400), (400, 2100), fill = RED)
     self.draw_rectangle ((0, 2100 - 400 - 22), (400, 2100 - 400), fill = RED)
     self.draw_rectangle ((3000, 2100 - 400), (3000 - 400, 2100), fill = BLUE)
     self.draw_rectangle ((3000, 2100 - 400 - 22), (3000 - 400, 2100 - 400), fill = BLUE)
     self.draw_rectangle ((1500 - 3 * 350, 0), (1500 + 3 * 350, 2100), fill = BLUE)
     for i in xrange (-3, 3):
         for j in xrange (0, 6):
             if (i + j) % 2:
                 self.draw_rectangle ((1500 + i * 350, j * 350),
                         (1850 + i * 350, 350 + j * 350), fill = RED)
     # Bonus.
     for i, j in ((0, 0), (1, 2), (1, 4)):
         self.draw_circle ((1500 - 175 - i * 350, 175 + j * 350), 50, fill = BLACK)
         self.draw_circle ((1500 + 175 + i * 350, 175 + j * 350), 50, fill = BLACK)
     # Protected zones.
     self.draw_both (self.draw_rectangle, (1500 - 3 * 350, 0), (1500 - 350, 120), fill = BLACK)
     self.draw_both (self.draw_rectangle, (1500 - 3 * 350, 120), (1500 - 3 * 350 + 22, 120 + 130), fill = BLACK)
     self.draw_both (self.draw_rectangle, (1500 - 350, 120), (1500 - 350 - 22, 120 + 130), fill = BLACK)
     self.draw_both (self.draw_rectangle, (1500 - 350, 120 + 130), (1500 - 350 - 20, 350), fill = BLACK)
     self.draw_both (self.draw_rectangle, (1500 - 3 * 350, 350 - 20), (1500 - 350, 350), fill = BLACK)
     # Axes.
     self.draw_line ((0, 200), (0, 0), (200, 0), arrow = 'both')
     # Beacons.
     self.draw_both (self.draw_rectangle, (-22, 2100 + 22), (-22 - 80, 2100 + 22 + 80), fill = BLACK)
     self.draw_both (self.draw_rectangle, (-22, 1050 - 40), (-22 - 80, 1050 + 40), fill = BLACK)
     self.draw_both (self.draw_rectangle, (-22, -80 - 22), (-22 - 80, -22), fill = BLACK)
     # Children.
     Drawable.draw (self)
Пример #3
0
 def draw (self):
     # Redraw.
     self.reset ()
     # Table.
     self.draw_rectangle ((-22, -22), (3000 + 22, 2100 + 22), fill = BLACK)
     self.draw_rectangle ((0, -22), (3000, 2100), fill = GREEN)
     self.draw_rectangle ((500, -22), (2500, 0), fill = BLACK)
     self.draw_rectangle ((0, 2100 - 500), (500, 2100), fill = BLUE)
     self.draw_rectangle ((3000 - 500, 2100 - 500), (3000, 2100), fill = YELLOW)
     # Axes.
     self.draw_line ((0, 200), (0, 0), (200, 0), arrow = 'both')
     # Bags.
     self.draw_rectangle ((-20, -22), (500 + 20, -250 - 20), fill = YELLOW)
     self.draw_rectangle ((3000 + 20, -22), (3000 - 500 - 20, -250 - 20), fill = BLUE)
     self.draw_both (self.draw_rectangle, (0, -22), (500, -250), fill = PLEXI)
     # Beacons.
     self.draw_both (self.draw_rectangle, (-22, 2100 + 22), (-22 - 80, 2100 + 22 + 80), fill = BLACK)
     self.draw_both (self.draw_rectangle, (-22, 1050 - 40), (-22 - 80, 1050 + 40), fill = BLACK)
     self.draw_both (self.draw_rectangle, (-22, -80 - 22), (-22 - 80, -22), fill = BLACK)
     # Hill.
     self.draw_rectangle ((750 - 100, 2100), (3000 - 750 + 100, 2100 - 500), fill = WHITE)
     self.draw_both (self.draw_line, (750, 2100), (750, 2100 - 500))
     self.draw_both (self.draw_line, (750 + 500, 2100), (750 + 500, 2100 - 500))
     self.draw_rectangle ((740, 2100 - 500), (3000 - 740, 2100 - 500 - 22), fill = BLACK)
     self.draw_both (self.draw_line, (740 + 500, 2100 - 500), (740 + 500, 2100 - 500 - 22))
     self.draw_both (self.draw_line, (740, 2100 + 22), (740, 2100))
     self.draw_both (self.draw_line, (740 + 500, 2100 + 22), (740 + 500, 2100))
     # Trees.
     for pos in self.model.oranges_pos:
         self.draw_circle ((1500 - pos[0], 2100 - pos[1]), 25)
         self.draw_circle ((1500 + pos[0], 2100 - pos[1]), 25)
     # Children.
     Drawable.draw (self)
Пример #4
0
 def draw (self):
     self.reset ()
     if self.pos:
         self.trans_translate (self.pos)
         self.trans_rotate (self.angle)
         draw_gold_bar (self, self.model)
         Drawable.draw (self)
Пример #5
0
 def draw (self):
     self.reset ()
     if self.pos:
         self.trans_translate (self.pos)
         self.draw_circle ((0, 0), self.model.radius, fill = '#31aa23')
         self.draw_circle ((0, 0), self.model.radius + self.MARGIN,
                 outlinestipple = 'gray25')
         Drawable.draw (self)
Пример #6
0
 def __init__ (self, onto, model):
     Drawable.__init__ (self, onto)
     self.model = model
     for e in model.corns:
         Corn (self, corn_attr[e.black], e)
     for e in model.tomatos:
         Tomato (self, dict (fill = RED), e)
     for e in model.oranges:
         Orange (self, dict (fill = ORANGE), e)
Пример #7
0
 def draw (self):
     self.reset ()
     if self.value is not None:
         self.draw_arc (self.coord, self.l, start = self.start,
                 extent = self.extent, style = 'arc', outline = '#808080')
         a = self.start + self.value * self.extent
         self.draw_line (self.coord, (self.coord[0] + self.l * cos (a),
             self.coord[1] + self.l * sin (a)))
         Drawable.draw (self)
Пример #8
0
 def __init__ (self, onto, model, coord = (0, 0), l = 1, start = 0,
         extent = pi / 2):
     Drawable.__init__ (self, onto)
     self.model = model
     self.coord = coord
     self.l = l
     self.start = start
     self.extent = extent
     self.model.register (self.__notified)
Пример #9
0
    def draw(self):
        # Redraw.
        self.reset()
        # Table.
        self.draw_rectangle((-22, -22), (3000 + 22, 0), fill=YELLOW)
        self.draw_rectangle((0, 0), (3000, 2000), fill=YELLOW)
        self.draw_rectangle((-22, 0), (0, 2000), fill=BLUE)
        self.draw_rectangle((-22, 2000), (1500, 2000 + 22), fill=BLUE)
        self.draw_rectangle((0, 0), (400, 2000), fill=BLUE)
        self.draw_rectangle((3000 + 22, 0), (3000, 2000), fill=RED)
        self.draw_rectangle((3000 + 22, 2000), (1500, 2000 + 22), fill=RED)
        self.draw_rectangle((3000, 0), (3000 - 400, 2000), fill=RED)
        # Start zones.
        self.draw_both(self.draw_rectangle, (0, 0), (400, 100), fill=WHITE)
        self.draw_both(self.draw_rectangle, (0, 0), (390, 90), fill=WHITE)
        self.draw_both(self.draw_rectangle, (0, 400), (400, 800), fill=WHITE)
        self.draw_both(self.draw_rectangle, (0, 1200), (400, 1600), fill=WHITE)
        self.draw_both(self.draw_rectangle, (0, 1900), (400, 2000), fill=WHITE)
        self.draw_both(self.draw_rectangle, (0, 1910), (390, 2000), fill=WHITE)
        # Black lines.
        self.draw_both(self.draw_line, (0, 1400), (460, 1400), fill=BLACK, width=20)
        self.draw_both(self.draw_line, (600, 0), (600, 1260), fill=BLACK, width=20)
        self.draw_both(self.draw_line, (1200, 0), (1200, 300), fill=BLACK, width=20)
        self.draw_line((740, 1300), (2260, 1300), fill=BLACK, width=20)
        self.draw_line((740, 300), (2260, 300), fill=BLACK, width=20)
        self.draw_arc((450, 1250), 150, outline=BLACK, width=20, style="arc", start=0)
        self.draw_arc((3000 - 450, 1250), 150, outline=BLACK, width=20, style="arc", start=pi / 2)
        self.draw_arc((750, 1150), 150, outline=BLACK, width=20, style="arc", start=pi / 2)
        self.draw_arc((3000 - 750, 1150), 150, outline=BLACK, width=20, style="arc", start=0)
        self.draw_arc((750, 450), 150, outline=BLACK, width=20, style="arc", start=pi)
        self.draw_arc((3000 - 750, 450), 150, outline=BLACK, width=20, style="arc", start=-pi / 2)
        # Cake.
        self.draw_arc((1500, 2000), 500, fill=PINK, start=pi, extent=pi)
        self.draw_arc((1500, 2000), 400, start=pi, extent=pi)
        self.draw_arc((1500, 2000), 300, start=pi, extent=pi)
        self.draw_arc((1500, 2000), 200, start=pi, extent=pi, width=5, style="arc")
        self.draw_line((1500, 2000), (1500, 1800), width=5)
        # Gifts.
        def draw_gift(x):
            self.draw_rectangle((x - 374 / 2, -44), (x + 374 / 2, -22), fill=YELLOW)
            self.draw_rectangle((x - 374 / 2, -94), (x - 374 / 2 + 22, -44), fill=YELLOW)
            self.draw_rectangle((x + 374 / 2, -94), (x + 374 / 2 - 22, -44), fill=YELLOW)
            self.draw_rectangle((x - 11, -94), (x + 11, -44), fill=YELLOW)

        draw_gift(600)
        draw_gift(1200)
        draw_gift(1800)
        draw_gift(2400)
        # Axes.
        self.draw_line((0, 200), (0, 0), (200, 0), arrow="both")
        # Beacons.
        self.draw_both(self.draw_rectangle, (-22, 2000 + 22), (-22 - 80, 2000 + 22 + 80), fill=BLACK)
        self.draw_both(self.draw_rectangle, (-22, 1000 - 40), (-22 - 80, 1000 + 40), fill=BLACK)
        self.draw_both(self.draw_rectangle, (-22, -80 - 22), (-22 - 80, -22), fill=BLACK)
        # Children.
        Drawable.draw(self)
Пример #10
0
 def draw (self):
     self.reset ()
     self.trans_scale (0.9/5)
     self.draw_line ((-0.5, 1.5), (-0.5, 0.5), (-2.5, 0.2),
             fill = '#808080')
     self.draw_line ((-2.5, -1.2), (-2.5, -2.3), (2.5, -2.3), (2.5, 0.2),
             (0.5, 0.5), (0.5, 1.5), fill = '#808080')
     for i in (-1.5, -0.5, 0.5, 1.5):
         self.draw_line ((i, -2.3), (i, -2), fill = '#808080')
     Drawable.draw (self)
Пример #11
0
 def __init__ (self, onto, model):
     Drawable.__init__ (self, onto)
     self.model = model
     for e in self.model.coins:
         if e.level <= 2:
             Coin (self, e)
     for e in self.model.gold_bars:
         GoldBar (self, e)
     for e in self.model.coins:
         if e.level > 2:
             Coin (self, e)
Пример #12
0
 def __init__(self, onto, model):
     Drawable.__init__(self, onto)
     self.model = model
     for e in self.model.candles:
         Candle(self, e)
     for e in self.model.glasses:
         Glass(self, e)
     for e in self.model.plates:
         Plate(self, e)
     Cherries(self, self.model.cherries)
     for e in self.model.gifts:
         Gift(self, e)
Пример #13
0
 def draw(self):
     self.reset()
     if self.distance is None:
         self.draw_line(self.model.pos, self.model.target, fill="blue", arrow="last")
     else:
         inter = (
             self.model.pos[0] + cos(self.model.angle) * self.distance,
             self.model.pos[1] + sin(self.model.angle) * self.distance,
         )
         self.draw_line(self.model.pos, inter, fill="red", arrow="last")
         self.draw_line(inter, self.model.target, fill="blue", arrow="last")
     Drawable.draw(self)
Пример #14
0
 def draw(self):
     self.reset()
     if self.model.pos:
         self.trans_translate(self.model.pos)
         self.trans_rotate(self.model.angle)
         w, h = self.model.dim
         w, h = w / 2, h / 2
         self.draw_rectangle((-w, -h), (w, h), fill=PINK)
         self.draw_rectangle((-w + 22, -h + 22), (w - 22, h - 22), fill=PINK)
         for c in self.model.cherries:
             if c.pos:
                 self.draw_circle(c.pos, c.radius, fill=colors[c.color])
         Drawable.draw(self)
Пример #15
0
 def draw (self):
     self.reset ()
     self.draw_arc ((0, 0), 0.45, start = 7 * pi / 12, extent = 10 * pi / 12,
             style = 'arc', outline = '#808080')
     self.draw_arc ((0, 0), 0.45, start = -5 * pi / 12, extent = 10 * pi / 12,
             style = 'arc', outline = '#808080')
     self.draw_arc ((0, 0), 0.25, start = -7 * pi / 12, extent = 14 * pi / 12,
             style = 'arc', outline = '#808080')
     if self.angle is not None:
         self.trans_scale (0.4)
         self.trans_rotate (-self.angle)
         self.draw_line ((0, 0), (0, 1))
         self.draw_line ((0, 1), (0.3, 1), arrow = 'last', fill = '#808080')
         self.draw_line ((0, 0), (cos (pi / 6), -sin (pi / 6)))
         self.draw_line ((0, 0), (-cos (pi / 6), -sin (pi / 6)))
         Drawable.draw (self)
Пример #16
0
 def __init__ (self, onto, sorter_model):
     Drawable.__init__ (self, onto)
     self.traps = [
             Servo (self, sorter_model.traps[0],
                 (-2.5, -1), 0.8, 0, pi/2),
             Servo (self, sorter_model.traps[1],
                 (-1.5, -0.9), 0.8, 0, pi/2),
             Servo (self, sorter_model.traps[2],
                 (-0.5, -0.8), 0.8, 0, pi/2),
             Servo (self, sorter_model.traps[3],
                 (0.5, -0.8), 0.8, pi, -pi/2),
             Servo (self, sorter_model.traps[4],
                 (1.5, -0.9), 0.8, pi, -pi/2),
             ]
     self.door = Servo (self, sorter_model.door,
             (-2.5, 1.3), 0.8, -pi/6, pi/3),
Пример #17
0
 def __init__ (self, onto, model):
     Drawable.__init__ (self, onto)
     self.model = model
     self.model.register (self.__notified)
     self.door_model = model.elevator_door
     self.door_model.register (self.__door_notified)
Пример #18
0
 def __init__ (self, onto, model):
     Drawable.__init__ (self, onto)
     self.model = model
     self.model.register (self.update)
Пример #19
0
 def __init__ (self, onto, model):
     Drawable.__init__ (self, onto)
     self.model = model
     for p in model.pucks:
         Puck (self, puck_attr[p.color], p)
Пример #20
0
 def draw (self):
     # Redraw.
     self.reset ()
     # Table.
     self.draw_rectangle ((-22, 0), (3000 + 22, 2100 + 22), fill = 'white')
     self.draw_rectangle ((-22, -10), (3000 + 22, 0), fill = PLEXI)
     self.draw_rectangle ((0, 0), (3000, 2100), fill = BLUE)
     self.draw_rectangle ((0, 2100 - 500), (500, 2100), fill = GREEN)
     self.draw_rectangle ((3000 - 500, 2100 - 500), (3000, 2100), fill = RED)
     # Axes.
     self.draw_line ((0, 200), (0, 0), (200, 0), arrow = 'both')
     # Beacons.
     self.draw_rectangle ((-22, 2100 + 22), (-22 - 80, 2100 + 22 + 80), fill = BLACK)
     self.draw_rectangle ((-22, 1050 - 40), (-22 - 80, 1050 + 40), fill = BLACK)
     self.draw_rectangle ((-22, -80 - 10), (-22 - 80, -10), fill = BLACK)
     self.draw_rectangle ((3000 + 22, 2100 + 22), (3000 + 22 + 80, 2100 + 22 + 80), fill = BLACK)
     self.draw_rectangle ((3000 + 22, 1050 - 40), (3000 + 22 + 80, 1050 + 40), fill = BLACK)
     self.draw_rectangle ((3000 + 22, -80 - 10), (3000 + 22 + 80, -10), fill = BLACK)
     # Building areas.
     self.draw_circle ((1500, 1050), 150, fill = BROWN)
     self.draw_rectangle ((1500 - 900, 0), (1500 + 900, 100), fill = BROWN)
     self.draw_rectangle ((1500 - 300, 0), (1500 + 300, 100), fill = BROWN)
     self.draw_rectangle ((1500 - 900 - 22, 0), (1500 - 900, 100), fill = 'white')
     self.draw_rectangle ((1500 + 900 + 22, 0), (1500 + 900, 100), fill = 'white')
     for bx in (-600, 0, +600):
         for dx in (-130 - 65, -65, +65, +130 + 65):
             x = 1500 + bx + dx
             self.draw_rectangle ((x - 7.5, 100), (x + 7.5, 100 + 250), fill = BLACK)
     # Lintel dispensers.
     for x in (1500 - 600, 1500 - 200, 1500 + 200, 1500 + 600):
         self.draw_rectangle ((x - 100, 2100), (x + 100, 2100 + 70 + 22), fill = BLACK)
         if x < 1500:
             color = GREEN
         else:
             color = RED
         self.draw_rectangle ((x - 100, 2100), (x + 100, 2100 + 70), fill = color)
         self.draw_rectangle ((x - 7.5, 2100), (x + 7.5, 2100 - 250), fill = BLACK)
     # Vertical dispensers.
     if self.model.dispensers_card == 1:
         ds = -250
     else:
         ds = +250
     for dpos, dangle, dcolor in (
             ((289, 40), pi / 2, RED),
             ((3000 - 289, 40), pi / 2, GREEN),
             ((40, 1050 + ds), 0, RED),
             ((3000 - 40, 1050 + ds), pi, GREEN),
             ):
         dtm = TransMatrix ()
         dtm.translate (dpos)
         dtm.rotate (dangle)
         if dpos[1] == 40:
             a = 55
         else:
             a = 67
         self.draw_rectangle (dtm.apply ((-a, -25)), dtm.apply ((0, 25)), fill = PLEXI)
         self.draw_rectangle (dtm.apply ((-40, -40)), dtm.apply ((40, 40)), fill = PLEXI)
         self.draw_circle (dtm.apply ((0, 0)), 35, fill = PLEXI, outline = dcolor)
         self.draw_rectangle (dtm.apply ((-40, -40)), dtm.apply ((40, 40)), fill = '')
     # Pucks.
     for m, color in ((-1, GREEN), (1, RED)):
         for x in (400, 650, 900):
             for y in (-125, 75, 275, 475):
                 self.draw_circle ((1500 + m * x, 1050 + y), 35, outline = color)
     # Children.
     Drawable.draw (self)
Пример #21
0
 def __init__ (self, onto, model):
     Drawable.__init__ (self, onto)
     self.model = model
     self.model.register (self.__notified)
     self.__colors = ('red', 'blue', 'green', 'yellow')
Пример #22
0
 def draw (self):
     # Redraw.
     self.reset ()
     # Table.
     self.draw_rectangle ((-22, -22), (3000 + 22, 2000 + 22), fill = BLUE)
     self.draw_rectangle ((0, 0), (3000, 2000), fill = BLUE)
     #  Start zones.
     self.draw_rectangle ((0, 2000 - 500), (500, 2000), fill = PURPLE)
     self.draw_rectangle ((3000, 2000 - 500), (3000 - 500, 2000), fill = RED)
     #  Black lines.
     pup = 2000 - 500 + 50
     self.draw_both (self.draw_polygon, (500, pup), (650, pup), (650, 0), (630, 0),
             (630, pup - 20), (500, pup - 20), fill = BLACK, outline = 'black')
     #  Ships.
     ba = 0.04995839
     self.draw_both (self.draw_polygon, (0, 2000 - 500), (400, 2000 - 500), (325, 0), (0, 0),
             fill = BROWN, outline = 'black')
     self.draw_both (self.draw_rectangle, (0, 2000 - 500), (400, 2000 - 500 - 18), fill = BROWN)
     cba = 750 * math.cos (ba)
     sba = 750 * math.sin (ba)
     self.draw_both (self.draw_polygon, (325, 0), (325 + sba, cba), (325 + sba + 18, cba), (325 + 18, 0),
             fill = BROWN, outline = 'black')
     self.draw_both (self.draw_rectangle, (-22, -22), (340, 610 - 22), fill = TRANS)
     self.draw_both (self.draw_rectangle, (-4, -4), (340 - 18, 610 - 22 - 18), fill = TRANS)
     #  Peanut island.
     self.draw_both (self.draw_circle, (1500 - 400, 1000), r = 300, fill = YELLOW)
     self.draw_rectangle ((1500 - 400 + 141, 1000 + 265), (1500 + 400 - 141, 1000 - 265), fill = YELLOW, outline = '')
     self.draw_arc ((1500, 1000 + 750), 550, start = pi + 1, extent = pi - 2, fill = BLUE, outline = '')
     self.draw_arc ((1500, 1000 + 750), 550, start = pi + 1.08083, extent = pi - 2 * 1.08083, style = 'arc')
     self.draw_arc ((1500, 1000 - 750), 550, start = 1, extent = pi - 2, fill = BLUE, outline = '')
     self.draw_arc ((1500, 1000 - 750), 550, start = 1.08083, extent = pi - 2 * 1.08083, style = 'arc')
     self.draw_both (self.draw_circle, (1500 - 400, 1000), r = 200, fill = GREEN)
     self.draw_circle ((1500, 1000), r = 75, fill = GREEN)
     self.draw_both (self.draw_rectangle, (1500 - 400 - 125, 1000 - 125), (1500 - 400 + 125, 1000 + 125), fill = BROWN)
     #  Map island.
     self.draw_arc ((1500, 2000), 400, start = pi, extent = pi, fill = YELLOW)
     self.draw_arc ((1500, 2000), 300, start = pi, extent = pi, fill = GREEN)
     #  Map.
     self.draw_rectangle ((1500 - 200 - 22, 2000 + 148), (1500 + 200 + 22, 2000 + 140), fill = BLUE)
     self.draw_rectangle ((1500 - 200, 2000 + 140), (1500 + 200, 2000 - 8), fill = BLUE)
     self.draw_both (self.draw_rectangle, (1500 - 200 - 22, 2000 + 140), (1500 - 200, 2000 + 125), fill = BLUE)
     self.draw_both (self.draw_rectangle, (1500 - 200 - 22, 2000 + 125), (1500 - 200, 2000 - 23), fill = BLUE)
     self.draw_rectangle ((1500 - 22, 2000 + 140), (1500 + 22, 2000 + 125), fill = BLUE)
     self.draw_rectangle ((1500 - 22, 2000 + 125), (1500 + 22, 2000 + 115), fill = BLUE)
     self.draw_rectangle ((1500 - 22, 2000 + 2), (1500 + 22, 2000 - 13), fill = BLUE)
     self.draw_rectangle ((1500 - 22, 2000 - 13), (1500 + 22, 2000 - 23), fill = BLUE)
     # Bottles.
     def draw_bottle (x, color):
         self.draw_rectangle ((x - 100, 0), (x + 100, -44), fill = color)
         self.draw_rectangle ((x - 100, -44), (x + 100, -66), fill = color)
         self.draw_rectangle ((x - 11, 44), (x + 11, 0), fill = color)
         self.draw_rectangle ((x - 50, 22), (x + 100, -44), fill = color)
         self.draw_polygon ((x - 50, 22), (x - 80, 0), (x - 100, 0), (x - 100, -22), (x - 80, -22), (x - 50, -44),
                 fill = color, outline = 'black')
     draw_bottle (640, PURPLE)
     draw_bottle (640 + 477, RED)
     draw_bottle (3000 - 640, RED)
     draw_bottle (3000 - 640 - 477, PURPLE)
     # Axes.
     self.draw_line ((0, 200), (0, 0), (200, 0), arrow = 'both')
     # Beacons.
     self.draw_both (self.draw_rectangle, (-22, 2000 + 22), (-22 - 80, 2000 + 22 + 80), fill = BLACK)
     self.draw_both (self.draw_rectangle, (-22, 1000 - 40), (-22 - 80, 1000 + 40), fill = BLACK)
     self.draw_both (self.draw_rectangle, (-22, -80 - 22), (-22 - 80, -22), fill = BLACK)
     # Children.
     Drawable.draw (self)
Пример #23
0
 def draw (self):
     self.reset ()
     if self.pos:
         self.trans_translate (self.pos)
         self.draw_circle ((0, 0), self.model.radius, **self.attr)
         Drawable.draw (self)
Пример #24
0
 def draw (self):
     # Redraw.
     self.reset ()
     # Table.
     self.draw_rectangle ((-22, -22 - 80), (3000 / 2, 2100 + 22), fill = '#ff1f1f')
     self.draw_rectangle ((3000 / 2, -22 - 80), (3000 + 22, 2100 + 22), fill = '#201fff')
     self.draw_rectangle ((0, 0), (3000, 2100), fill = '#a49d8b')
     self.draw_rectangle ((0, -22 - 80), (3000, -22), fill = '#a49d8b')
     self.draw_rectangle ((0, 2100 - 500), (500, 2100), fill = '#201fff')
     self.draw_rectangle ((3000 - 500, 2100 - 500), (3000, 2100), fill = '#ff1f1f')
     self.draw_line ((3000 / 2, -22 - 80), (3000 / 2, 2100 + 22))
     # Axes.
     self.draw_line ((0, 200), (0, 0), (200, 0), arrow = 'both')
     # Beacons and baskets.
     self.draw_rectangle ((-22, 2100), (-22 - 80, 2100 + 80), fill = '#5b5b5d')
     self.draw_rectangle ((-22, 1050 - 40), (-22 - 80, 1050 + 40), fill = '#5b5b5d')
     self.draw_rectangle ((-22, 500), (-22 - 80, 500 + 80), fill = '#5b5b5d')
     self.draw_rectangle ((-22, -80), (-22 - 80, 0), fill = '#5b5b5d')
     self.draw_rectangle ((-22, 0), (-22 - 80, 500), fill = '#5b5b5d')
     self.draw_rectangle ((-22 - 80 - 250, 0), (-22 - 80, 500), fill = '#6d6dad', stipple = 'gray75')
     self.draw_rectangle ((3000 + 22, 2100), (3000 + 22 + 80, 2100 + 80), fill = '#5b5b5d')
     self.draw_rectangle ((3000 + 22, 1050 - 40), (3000 + 22 + 80, 1050 + 40), fill = '#5b5b5d')
     self.draw_rectangle ((3000 + 22, 500), (3000 + 22 + 80, 500 + 80), fill = '#5b5b5d')
     self.draw_rectangle ((3000 + 22, -80), (3000 + 22 + 80, 0), fill = '#5b5b5d')
     self.draw_rectangle ((3000 + 22, 0), (3000 + 22 + 80, 500), fill = '#5b5b5d')
     self.draw_rectangle ((3000 + 22 + 80 + 250, 0), (3000 + 22 + 80, 500), fill = '#6d6dad', stipple = 'gray75')
     # Vertical dispensers.
     self.draw_rectangle ((-22, 2100 - 750 - 85 / 2), (0, 2100 - 750 + 85 / 2), fill = '#5b5b5b')
     self.draw_circle ((40, 2100 - 750), 40)
     self.draw_rectangle ((700 - 85 / 2, 2100), (700 + 85 / 2, 2100 + 22), fill = '#5b5b5b')
     self.draw_circle ((700, 2100 - 40), 40)
     self.draw_rectangle ((3000 + 22, 2100 - 750 - 85 / 2), (3000, 2100 - 750 + 85 / 2), fill = '#5b5b5b')
     self.draw_circle ((3000 - 40, 2100 - 750), 40)
     self.draw_rectangle ((3000 - 700 + 85 / 2, 2100), (3000 - 700 - 85 / 2, 2100 + 22), fill = '#5b5b5b')
     self.draw_circle ((3000 - 700, 2100 - 40), 40)
     # Horizontal dispenser.
     self.draw_rectangle ((3000 / 2 - 924 / 2, 2100 + 22), (3000 / 2 + 924 / 2, 2100 + 22 + 80 + 22), fill = '#5b5b5b')
     self.draw_rectangle ((3000 / 2 - 924 / 2 + 22, 2100 + 22), (3000 / 2 + 924 / 2 - 22, 2100 + 22 + 80), fill = '#5b5b5b')
     self.draw_rectangle ((3000 / 2 - 880 / 2 - 35 - 60, 2100), (3000 / 2 - 880 / 2 - 35, 2100 + 44), fill = '#5b5b5b')
     self.draw_rectangle ((3000 / 2 + 880 / 2 + 35 + 60, 2100), (3000 / 2 + 880 / 2 + 35, 2100 + 44), fill = '#5b5b5b')
     # Balls.
     balls = [ (800, 200, 'rb'), (800, 400, 'RB'), (800, 600, 'ww'),
             (1300, 200, 'rb'), (1300, 400, 'rb'), (1300, 600, 'ww'),
             (520, 800, 'WW'), (700, 40, 'RB'), (40, 750, 'WW'),
             (450, 1120, 'ww'), (750, 1070, 'ww'), (1050, 1020, 'ww'),
             (1500 - 72 / 2, -22 - 80 / 2, 'BR'),
             (1500 - 72 / 2 - 1 * 73, -22 - 80 / 2, 'RB'),
             (1500 - 72 / 2 - 2 * 73, -22 - 80 / 2, 'BR'),
             (1500 - 72 / 2 - 3 * 73, -22 - 80 / 2, 'RB'),
             (1500 - 72 / 2 - 4 * 73, -22 - 80 / 2, 'BR'),
             (1500 - 72 / 2 - 5 * 73, -22 - 80 / 2, 'RB'),
             (1500, 1000, 'W'),
             ]
     balls_config = { 'r': { 'outline': '#bf4141' }, 'R': { 'fill': '#bf4141' },
             'b': { 'outline': '#4241bf' }, 'B': { 'fill': '#4241bf' },
             'w': { 'outline': '#bfbfbf' }, 'W': { 'fill': '#bfbfbf' } }
     for b in balls:
         self.draw_circle ((3000 - b[0], 2100 - b[1]), 72 / 2,
                 **balls_config[b[2][0]])
         if len (b[2]) > 1:
             self.draw_circle ((b[0], 2100 - b[1]), 72 / 2,
                     **balls_config[b[2][1]])
     Drawable.draw (self)
Пример #25
0
 def __init__ (self, onto):
     Drawable.__init__ (self, onto)
     self.table = Table ()
     self.a = (0, 0)
     self.b = (10, 10)
     self.result = None
Пример #26
0
 def draw(self):
     self.reset()
     if self.model.pos:
         self.draw_circle(self.model.pos, self.model.radius, fill=BLACK, outline=TRANS)
         Drawable.draw(self)
Пример #27
0
 def draw (self):
     self.reset ()
     if self.pos:
         self.trans_translate (self.pos)
         draw_pawn (self, self.model)
         Drawable.draw (self)
Пример #28
0
 def __init__ (self, onto, model):
     Drawable.__init__ (self, onto)
     self.model = model
     self.rays = [ ]
     for r in model.rays:
         self.rays.append (DistanceSensor (onto, r))
Пример #29
0
 def __init__ (self, onto, model):
     Drawable.__init__ (self, onto)
     self.model = model
     self.model.register (self.__notified)
Пример #30
0
 def __init__ (self, onto, table_model):
     Drawable.__init__ (self, onto)