示例#1
0
    def draw(self):
        w, h = self.width, self.height
        g = Game.getgame()
        try:
            n = len(g.deck.cards)
        except AttributeError:
            return

        glColor3f(*[i / 255.0 for i in Colors.blue.light])
        glRectf(0, 0, w, h)
        glColor3f(*[i / 255.0 for i in Colors.blue.heavy])
        glRectf(0, h, w, 0)

        glColor3f(1, 1, 1)
        try:
            nums = L('thb-num')
            seq = str(n)
            ox = (w - len(seq) * 14) // 2
            oy = (h - nums[0].height) // 2
            with nums[0].owner:
                for i, ch in enumerate(seq):
                    n = ord(ch) - ord('0')
                    # x, y = w - 34 + ox + i*14, 68
                    nums[n].blit_nobind(ox + i * 14, oy)

        except AttributeError:
            pass
示例#2
0
    def draw(self):
        glPushMatrix()

        glTranslatef(self.xoffset, self.yoffset, self.zoffset)

        def color(i):
            if i % self.graduations_major == 0:
                glColor4f(*self.color_grads_major)
            elif i % (self.graduations_major / 2) == 0:
                glColor4f(*self.color_grads_interm)
            else:
                if self.light: return False
                glColor4f(*self.color_grads_minor)
            return True

        # draw the grid
        glBegin(GL_LINES)
        for i in range(0, int(math.ceil(self.width + 1))):
            if color(i):
                glVertex3f(float(i), 0.0, 0.0)
                glVertex3f(float(i), self.depth, 0.0)

        for i in range(0, int(math.ceil(self.depth + 1))):
            if color(i):
                glVertex3f(0, float(i), 0.0)
                glVertex3f(self.width, float(i), 0.0)
        glEnd()

        # draw fill
        glColor4f(*self.color_fill)
        glRectf(0.0, 0.0, float(self.width), float(self.depth))

        glPopMatrix()
示例#3
0
    def render_road(self):
        gl.glBegin(gl.GL_QUADS)
        gl.glColor4f(0.4, 0.8, 0.4, 1.0)
        gl.glVertex3f(-PLAYFIELD, +PLAYFIELD, 0)
        gl.glVertex3f(+PLAYFIELD, +PLAYFIELD, 0)
        gl.glVertex3f(+PLAYFIELD, -PLAYFIELD, 0)
        gl.glVertex3f(-PLAYFIELD, -PLAYFIELD, 0)
        gl.glColor4f(0.4, 0.9, 0.4, 1.0)
        k = PLAYFIELD / 20.0
        for x in range(-20, 20, 2):
            for y in range(-20, 20, 2):
                gl.glVertex3f(k * x + k, k * y + 0, 0)
                gl.glVertex3f(k * x + 0, k * y + 0, 0)
                gl.glVertex3f(k * x + 0, k * y + k, 0)
                gl.glVertex3f(k * x + k, k * y + k, 0)
        for poly, color in self.road_poly:
            gl.glColor4f(color[0], color[1], color[2], 1)
            for p in poly:
                gl.glVertex3f(p[0], p[1], 0)

        gl.glEnd()

        if self.highlight_loc is not None:
            gl.glColor4f(1, 0, 0, 1)
            gl.glRectf(self.highlight_loc[0], self.highlight_loc[1],
                       self.highlight_loc[0] + 3, self.highlight_loc[1] + 3)
示例#4
0
    def draw(self):
        w, h = self.width, self.height
        g = Game.getgame()
        try:
            n = len(g.deck.cards)
        except AttributeError:
            return

        glColor3f(*[i/255.0 for i in Colors.blue.light])
        glRectf(0, 0, w, h)
        glColor3f(*[i/255.0 for i in Colors.blue.heavy])
        glRectf(0, h, w, 0)

        glColor3f(1, 1, 1)
        try:
            nums = gres.num
            seq = str(n)
            ox = (w - len(seq)*14)//2
            oy = (h - nums[0].height)//2
            with nums[0].owner:
                for i, ch in enumerate(seq):
                    n = ord(ch) - ord('0')
                    # x, y = w - 34 + ox + i*14, 68
                    nums[n].blit_nobind(ox + i*14, oy)

        except AttributeError:
            pass
示例#5
0
 def draw_pixel(self, x, y):
     x_scaled = (x + 1) * pixel_size
     y_scaled = self.height - (y) * pixel_size
     glRectf(
         x_scaled - pixel_size, y_scaled,
         x_scaled, y_scaled - pixel_size
     )
示例#6
0
    def draw(self):
        glPushMatrix()

        glTranslatef(self.xoffset, self.yoffset, self.zoffset)

        def color(i):
            if i % self.graduations_major == 0:
                glColor4f(*self.color_grads_major)
            elif i % (self.graduations_major / 2) == 0:
                glColor4f(*self.color_grads_interm)
            else:
                if self.light: return False
                glColor4f(*self.color_grads_minor)
            return True

        # draw the grid
        glBegin(GL_LINES)
        for i in range(0, int(math.ceil(self.width + 1))):
            if color(i):
                glVertex3f(float(i), 0.0, 0.0)
                glVertex3f(float(i), self.depth, 0.0)

        for i in range(0, int(math.ceil(self.depth + 1))):
            if color(i):
                glVertex3f(0, float(i), 0.0)
                glVertex3f(self.width, float(i), 0.0)
        glEnd()

        # draw fill
        glColor4f(*self.color_fill)
        glRectf(0.0, 0.0, float(self.width), float(self.depth))

        glPopMatrix()
示例#7
0
 def draw(self):
     if not self.should_draw: return
     glColor3f(1, 1, 1)
     self.texture.blit(0, 100)
     glColor4f(1, 1, 1, 0.65)
     glRectf(0, 0, self.width, 100)
     self.lbls.draw()
     self.draw_subcontrols()
示例#8
0
 def draw(self):
     if not self.should_draw: return
     glColor3f(1, 1, 1)
     self.texture.blit(0, 100)
     glColor4f(1, 1, 1, 0.65)
     glRectf(0, 0, self.width, 100)
     self.lbls.draw()
     self.draw_subcontrols()
示例#9
0
 def draw_ui(self):
     if DropDownMenu._submenu_count >= self.level:
         gl.glColor4f(1, 1, 1, 0.5)
         gl.glRectf(self.x, self.y, self.x + self.width, self.y - self.height)
         gl.glColor4f(0, 0, 0, 0.5)
         gl.glRectf(self.x + 1, self.y - 1, self.x + self.width - 1, self.y - self.height + 1)
         super(DropDownMenu, self).draw()
     for sm in self.submenus.values():
         sm.draw()
示例#10
0
文件: conway.py 项目: eordano/random
 def on_draw(self):
     self.clear()
     for x, y in ((a, b) for b in self.y for a in self.x):
         if self.grid[y][x] == 1:
             win_x_unit = 500/self.x_size
             win_y_unit = 500/self.y_size
             glColor3f(1, 1, 1)
             x1 = win_x_unit * x
             x2 = win_x_unit * (x + 1)
             y1 = win_y_unit * y
             y2 = win_y_unit * (y + 1)
             glRectf(x1, y1, x2, y2)
示例#11
0
文件: tilemap.py 项目: kearnh/4xgame
    def draw_ui(self):
        if self.show:
            gl.glColor4f(1, 1, 0, 0.6)
            gl.glRectf(self.x, self.y, self.x+self.parent.dx,
                    self.y+self.parent.dy)

        # FIXME temporary
        gl.glColor4f(0, 0, 0, 1)
        gl.glRectf(2, 2, 120, 40)

        self.pos_label.begin_update()
        self.pos_label.text = "%d : %d" % (self.x+self.parent.x,
                self.y+self.parent.y)
        self.pos_label.end_update()
        self.pos_label.draw()

        self.context_label.begin_update()
        self.context_label.text = 'bg: %s, fg: %s' %                          \
            (self.parent.get_tile(self.x+self.parent.x, self.y+self.parent.y, \
            fg=False), self.parent.get_tile(self.x+self.parent.x,             \
            self.y+self.parent.y, fg=True))
        self.context_label.end_update()
        self.context_label.draw()
示例#12
0
 def draw(self):
     Layer.draw(self)
     game = State.model()
     world = game.world
     
     cell_width = self.width / world.columns
     cell_height = self.height / world.rows
     
     depth = 0
     
     x = self.x
     for col in xrange(world.columns):
         y = self.y
         for row in xrange(world.rows):
             floor = world.get_floor(col, row, depth)
             
             color = (1.0, 1.0, 1.0)
             
             if game.current_floor_coords == (col, row, depth):
                 color = (0.7, 0.7, 1.0)
             
             if floor is None:
                 opacity = 0
             elif floor.known:
                 opacity = 0.5
             elif floor.explored:
                 opacity = 1.0
             else:
                 opacity = 0
             
             if opacity > 0:
                 self.set_color(*color, opacity=opacity)
                 
                 gl.glRectf(x, y, x + cell_width, y + cell_height)
             
             y += cell_height
         x += cell_width
示例#13
0
 def draw(self):
     glColor3f(1, 1, 1)
     self.backdrop.blit(0, 0)
     glColor4f(0, 0, 0, .5)
     glRectf(0, 0, 1000, 138)
     glColor3f(0.1922, 0.2706, 0.3882)
     glRectf(0, 138, 1000, 140)
     glColor3f(1, 1, 1)
     self.draw_subcontrols()
     fa = self.flash_alpha
     if fa:
         glColor4f(1, 1, 1, fa)
         glRectf(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT)
示例#14
0
 def draw(self):
     glColor3f(1, 1, 1)
     self.backdrop.blit(0, 0)
     glColor4f(0, 0, 0, .5)
     glRectf(0, 0, 1000, 138)
     glColor3f(0.1922, 0.2706, 0.3882)
     glRectf(0, 138, 1000, 140)
     glColor3f(1, 1, 1)
     self.draw_subcontrols()
     fa = self.flash_alpha
     if fa:
         glColor4f(1, 1, 1, fa)
         glRectf(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT)
示例#15
0
 def draw(self):
     glColor3f(1, 1, 1)
     self.texture.blit(0, 80)
     glColor4f(1, 1, 1, 0.65)
     glRectf(0, 0, self.width, self.ta_height)
     self.draw_subcontrols()
示例#16
0
 def draw(self):
     glColor3f(1, 1, 1)
     self.texture.blit(0, 0)
     glColor4f(1, 1, 1, 0.65)
     glRectf(0, 0, self.width, self.ta_height)
     self.draw_subcontrols()
示例#17
0
文件: sandbox.py 项目: rj79/pysandbox
 def fill_rect(self, *args):
     x, y, w, h = self._decode_xywh(*args)
     glColor4f(*self._fill_color)
     glRectf(x, y, x + w, y + h)