Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    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 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)
Ejemplo n.º 7
0
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()

    context.set_source_rgb(0, 0, 0)
    for y, row in enumerate(PIECES):
        for x, piece in enumerate(row):
            if piece is not None:
                Pieces.drawPiece(piece, context, x * SQUARE, (3 - y) * SQUARE,
                                 SQUARE)

    surface.write_to_png(pngfile)
Ejemplo n.º 8
0
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()

    context.set_source_rgb(0, 0, 0)
    for y, row in enumerate(PIECES):
        for x, piece in enumerate(row):
            if piece is not None:
                Pieces.drawPiece(piece, context, x*SQUARE, (3-y)*SQUARE, SQUARE)

    surface.write_to_png(pngfile)