def expose(self, widget, ctx): context = widget.get_window().cairo_create() rect = self.get_allocation() s = min(rect.width, rect.height) x = (rect.width - s) / 2.0 y = (rect.height - s) / 2.0 Pieces.drawPiece(self.piece, context, x, y, s)
def expose(self, widget, ctx): context = widget.get_window().cairo_create() rect = self.get_allocation() s_min = min(rect.width, rect.height) x_loc = (rect.width - s_min) / 2.0 y_loc = (rect.height - s_min) / 2.0 Pieces.drawPiece(self.piece, context, x_loc, y_loc, s_min, asean=self.asean)
def expose(self, widget, event): context = widget.window.cairo_create() rect = self.get_allocation() s = min(rect.width, rect.height) x = (rect.width-s) / 2.0 y = (rect.height-s) / 2.0 Pieces.drawPiece(self.piece, context, x, y, s)
def draw_position(self, context): context.set_source_rgb(0.5, 0.5, 0.5) self.__drawBoard (context) pieces = self.model.getBoardAtPly(self.shown) context.set_source_rgb(0, 0, 0) for y, row in enumerate(pieces.data): for x, piece in row.items(): if piece is not None: Pieces.drawPiece(piece, context, x*SQUARE, (7-y)*SQUARE, SQUARE)
def _get_active(iconview): model = iconview.get_model() selected = iconview.get_selected_items() if len(selected) == 0: return conf.get("pieceTheme", "Pychess") i = selected[0][0] theme = model[i][1] Pieces.set_piece_theme(theme) return theme
def draw_position(self, context): context.set_source_rgb(0.5, 0.5, 0.5) self.__drawBoard(context) pieces = self.model.getBoardAtPly(self.shown) context.set_source_rgb(0, 0, 0) for y, row in enumerate(pieces.data): for x, piece in row.items(): if piece is not None: Pieces.drawPiece(piece, context, x * SQUARE, (7 - y) * SQUARE, SQUARE)
def _get_active(iconview): model = iconview.get_model() selected = iconview.get_selected_items() if len(selected) == 0: return conf.get("pieceTheme", "pychess") i = selected[0][0] theme = model[i][1] Pieces.set_piece_theme(theme) return theme
def _getActive(iconview): model = iconview.get_model() selected = iconview.get_selected_items() if len(selected) == 0: return conf.get("pieceTheme", "Chessicons") indices = selected[0].get_indices() if indices: idx = indices[0] theme = model[idx][1] Pieces.set_piece_theme(theme) return theme
BISHOP), Piece(BLACK, KNIGHT)), (None, Piece(BLACK, ROOK), Piece(BLACK, QUEEN), Piece(BLACK, KING))) themes = [] pieces = addDataPrefix("pieces") themes += [ d.capitalize() for d in listdir(pieces) if isdir(os.path.join(pieces, d)) ] themes.sort() for theme in themes: pngfile = "%s/%s.png" % (pieces, theme) print('Creating %s' % pngfile) Pieces.set_piece_theme(theme) surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, SQUARE * 4, SQUARE * 4) context = cairo.Context(surface) context.set_source_rgb(0.5, 0.5, 0.5) for x in range(4): for y in range(4): if (x + y) % 2 == 1: context.rectangle(x * SQUARE, y * SQUARE, SQUARE, SQUARE) context.fill() context.rectangle(0, 0, 4 * SQUARE, 4 * SQUARE) context.stroke()
(None, Piece(BLACK, ROOK), Piece(BLACK, QUEEN), Piece(BLACK, KING))) themes = ['Pychess'] pieces = addDataPrefix("pieces") themes += [d.capitalize() for d in listdir(pieces) if isdir(os.path.join(pieces,d)) and d != 'ttf'] ttf = addDataPrefix("pieces/ttf") themes += ['ttf-' + splitext(d)[0].capitalize() for d in listdir(ttf) if splitext(d)[1] == '.ttf'] themes.sort() for theme in themes: pngfile = "%s/%s.png" % (pieces, theme) print('Creating %s' % pngfile) Pieces.set_piece_theme(theme) surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, SQUARE*4, SQUARE*4) context = cairo.Context(surface) context.set_source_rgb(0.5, 0.5, 0.5) for x in range(4): for y in range(4): if (x+y) % 2 == 1: context.rectangle(x*SQUARE, y*SQUARE, SQUARE, SQUARE) context.fill() context.rectangle(0, 0, 4*SQUARE, 4*SQUARE) context.stroke()