Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2012-07-30 14:52:18 (GMT)
committer Walter Bender <walter.bender@gmail.com>2012-07-30 14:52:18 (GMT)
commit1730609506825c5547bef659016eac6ddfa25d16 (patch)
treee7ffd7d5607903a7451d66ac875c4d0af44df192
parent314bcaee069641a8c0eaf687497022c561a11a60 (diff)
add support for Sugar-color pieces
-rw-r--r--GNUChessActivity.py122
-rw-r--r--chess.py81
-rw-r--r--icons/white-knight-sugar.svg28
-rw-r--r--piece.py136
4 files changed, 330 insertions, 37 deletions
diff --git a/GNUChessActivity.py b/GNUChessActivity.py
index f8d3a02..9024e01 100644
--- a/GNUChessActivity.py
+++ b/GNUChessActivity.py
@@ -80,6 +80,7 @@ class GNUChessActivity(activity.Activity):
else:
self.colors = ['#A0FFA0', '#FF8080']
self.buddy = None
+ self.opponent_colors = None
self.hardware = get_hardware()
self._setup_toolbars()
@@ -106,10 +107,8 @@ class GNUChessActivity(activity.Activity):
self._setup_presence_service()
if self.game_data is not None: # 'saved_game' in self.metadata:
- _logger.debug('>>>>>>>>>>>>>>>>>>>>>> %s' % (str(self.game_data)))
self._restore()
else:
- _logger.debug('>>>>>>>>>>>>>>>>>>>>>> new game')
self._gnuchess.new_game()
self._restoring = False
@@ -132,7 +131,6 @@ class GNUChessActivity(activity.Activity):
def _setup_toolbars(self):
''' Setup the toolbars. '''
-
self.max_participants = 2 # No sharing to begin with
self.edit_toolbar = gtk.Toolbar()
@@ -239,6 +237,31 @@ class GNUChessActivity(activity.Activity):
self.view_toolbar,
tooltip=_("Black's move"))
+ separator_factory(self.view_toolbar, False, True)
+
+ skin_button1 = radio_factory('white-knight',
+ self.view_toolbar,
+ self.do_default_skin_cb,
+ tooltip=_('Default pieces'),
+ group=None)
+
+ skin_button2 = radio_factory('white-knight-sugar',
+ self.view_toolbar,
+ self.do_sugar_skin_cb,
+ tooltip=_('Sugar-style pieces'),
+ group=skin_button1)
+ xocolors = XoColor(self.colors)
+ icon = Icon(icon_name='white-knight-sugar', xo_color=xocolors)
+ icon.show()
+ skin_button2.set_icon_widget(icon)
+
+ self.skin_button3 = radio_factory('view-source',
+ self.view_toolbar,
+ self.do_custom_skin_cb,
+ tooltip=_('Custom pieces'),
+ group=skin_button1)
+ skin_button1.set_active(True)
+
self.play_white_button = radio_factory('white-rook',
self.adjust_toolbar,
self._play_white_cb,
@@ -388,10 +411,86 @@ class GNUChessActivity(activity.Activity):
cb_arg='black_king',
tooltip=_('Black King'))
+
+ def do_default_skin_cb(self, button=None):
+ self._gnuchess.reskin_from_file('black_king',
+ '%s/icons/black-king.svg' % (activity.get_bundle_path()))
+ self._gnuchess.reskin_from_file('black_queen',
+ '%s/icons/black-queen.svg' % (activity.get_bundle_path()))
+ self._gnuchess.reskin_from_file('black_bishop',
+ '%s/icons/black-bishop.svg' % (activity.get_bundle_path()))
+ self._gnuchess.reskin_from_file('black_knight',
+ '%s/icons/black-knight.svg' % (activity.get_bundle_path()))
+ self._gnuchess.reskin_from_file('black_rook',
+ '%s/icons/black-rook.svg' % (activity.get_bundle_path()))
+ self._gnuchess.reskin_from_file('black_pawn',
+ '%s/icons/black-pawn.svg' % (activity.get_bundle_path()))
+ self._gnuchess.reskin_from_file('white_king',
+ '%s/icons/white-king.svg' % (activity.get_bundle_path()))
+ self._gnuchess.reskin_from_file('white_queen',
+ '%s/icons/white-queen.svg' % (activity.get_bundle_path()))
+ self._gnuchess.reskin_from_file('white_bishop',
+ '%s/icons/white-bishop.svg' % (activity.get_bundle_path()))
+ self._gnuchess.reskin_from_file('white_knight',
+ '%s/icons/white-knight.svg' % (activity.get_bundle_path()))
+ self._gnuchess.reskin_from_file('white_rook',
+ '%s/icons/white-rook.svg' % (activity.get_bundle_path()))
+ self._gnuchess.reskin_from_file('white_pawn',
+ '%s/icons/white-pawn.svg' % (activity.get_bundle_path()))
+
+ def _black_peices(self, colors):
+ self._gnuchess.reskin_from_svg('black_king', colors)
+ self._gnuchess.reskin_from_svg('black_queen', colors)
+ self._gnuchess.reskin_from_svg('black_bishop', colors)
+ self._gnuchess.reskin_from_svg('black_knight', colors)
+ self._gnuchess.reskin_from_svg('black_rook', colors)
+ self._gnuchess.reskin_from_svg('black_pawn', colors)
+
+ def _white_peices(self, colors):
+ self._gnuchess.reskin_from_svg('white_king', colors)
+ self._gnuchess.reskin_from_svg('white_queen', colors)
+ self._gnuchess.reskin_from_svg('white_bishop', colors)
+ self._gnuchess.reskin_from_svg('white_knight', colors)
+ self._gnuchess.reskin_from_svg('white_rook', colors)
+ self._gnuchess.reskin_from_svg('white_pawn', colors)
+
+ def do_sugar_skin_cb(self, button=None):
+ colors = self.colors
+ if not self._gnuchess.we_are_sharing:
+ colors[1] = '#000000'
+ self._black_peices(colors)
+ colors[1] = '#ffffff'
+ self._white_peices(colors)
+ else:
+ if self.playing_white:
+ self._white_peices(colors)
+ if self.opponent_colors is not None:
+ colors = self.opponent_colors
+ self._black_peices(colors)
+ else:
+ self._black_peices(colors)
+ if self.opponent_colors is not None:
+ colors = self.opponent_colors
+ self._white_peices(colors)
+
+ def do_custom_skin_cb(self, button=None):
+ for piece in ['white_pawn', 'black_pawn',
+ 'white_rook', 'black_rook',
+ 'white_knight', 'black_knight',
+ 'white_bishop', 'black_bishop',
+ 'white_queen', 'black_queen',
+ 'white_king', 'black_king']:
+ if piece in self.metadata:
+ id = self.metadata[piece]
+ jobject = datastore.get(id)
+ if jobject is not None and jobject.file_path is not None:
+ self._gnuchess.reskin_from_file(piece, jobject.file_path)
+ return
+
def _reskin_cb(self, button, piece):
id, file_path = self._choose_skin()
if file_path is not None:
- self._gnuchess.reskin(piece, file_path)
+ self._gnuchess.reskin_from_file(piece, file_path)
self.metadata[piece] = str(id)
def do_fullscreen_cb(self, button):
@@ -572,17 +671,7 @@ class GNUChessActivity(activity.Activity):
self.playing_robot = False
self.human_button.set_active(True)
self._gnuchess.restore_game(self._parse_move_list(self.game_data))
- for piece in ['white_pawn', 'black_pawn',
- 'white_rook', 'black_rook',
- 'white_knight', 'black_knight',
- 'white_bishop', 'black_bishop',
- 'white_queen', 'black_queen',
- 'white_king', 'black_king']:
- if piece in self.metadata:
- id = self.metadata[piece]
- jobject = datastore.get(id)
- if jobject is not None and jobject.file_path is not None:
- self._gnuchess.reskin(piece, jobject.file_path)
+ self.do_custom_skin_cb()
def _choose_skin(self):
''' Select a skin from the Journal '''
@@ -684,7 +773,6 @@ class GNUChessActivity(activity.Activity):
alert.show()
# Collaboration-related methods
- # TODO: color peices with XO colors
def _setup_presence_service(self):
''' Setup the Presence Service. '''
@@ -826,6 +914,7 @@ params=%r state=%d' % (id, initiator, type, service, params, state))
_logger.debug('received_join %s' % (payload))
if self.initiating:
self.send_new_game()
+ _logger.debug(self.game_data)
if self.game_data is not None:
self.send_restore()
@@ -838,6 +927,7 @@ params=%r state=%d' % (id, initiator, type, service, params, state))
def _receive_colors(self, payload):
_logger.debug('received_colors %s' % (payload))
+ self.opponent_colors = payload
xocolors = XoColor(payload)
icon = Icon(icon_name='human', xo_color=xocolors)
icon.show()
diff --git a/chess.py b/chess.py
index 4b95b44..b3e4b93 100644
--- a/chess.py
+++ b/chess.py
@@ -26,6 +26,8 @@ import logging
_logger = logging.getLogger('gnuchess-activity')
from sprites import Sprites, Sprite
+from piece import svg_header, svg_footer, svg_king, svg_queen, svg_bishop, \
+ svg_knight, svg_rook, svg_pawn
ROBOT_MOVE = 'My move is : '
TOP = 3
@@ -81,7 +83,7 @@ class Gnuchess():
self._width = gtk.gdk.screen_width()
self._height = gtk.gdk.screen_height()
- self._scale = int((self._height - 55) / 10)
+ self.scale = int((self._height - 55) / 10)
self.we_are_sharing = False
self.move_list = []
@@ -1424,13 +1426,13 @@ Black's turn." % (move))
def _xy_to_file_and_rank(self, pos):
''' calculate the board column and row for an xy position '''
- xo = self._width - 8 * self._scale
+ xo = self._width - 8 * self.scale
xo = int(xo / 2)
x = pos[0] - xo
- yo = int(self._scale / 2)
+ yo = int(self.scale / 2)
y = yo
- return ('%s%d' % (FILES[int((pos[0] - xo) / self._scale)],
- 8 - int((pos[1] - yo) / self._scale)))
+ return ('%s%d' % (FILES[int((pos[0] - xo) / self.scale)],
+ 8 - int((pos[1] - yo) / self.scale)))
def _expose_cb(self, win, event):
self.do_expose_event(event)
@@ -1461,16 +1463,16 @@ Black's turn." % (move))
black_bishops = 0
black_queens = 0
w, h = self.white[0].get_dimensions()
- xo = self._width - 8 * self._scale
+ xo = self._width - 8 * self.scale
xo = int(xo / 2)
- yo = int(self._scale / 2)
+ yo = int(self.scale / 2)
for i in range(17): # extra queen
- self.black[i].move((-self._scale, -self._scale))
- self.white[i].move((-self._scale, -self._scale))
+ self.black[i].move((-self.scale, -self.scale))
+ self.white[i].move((-self.scale, -self.scale))
k = 1
for i in range(8):
x = xo
- y = yo + i * self._scale
+ y = yo + i * self.scale
for j in range(8):
piece = board[k]
k += 2
@@ -1542,55 +1544,90 @@ Black's turn." % (move))
self.black[16].set_layer(MID)
elif piece == 'k':
self.black[4].move((x, y))
- x += self._scale
+ x += self.scale
x = xo
- y += self._scale
+ y += self.scale
k += 1
- def reskin(self, piece, file_path):
+ def reskin_from_svg(self, piece, colors):
+ DICT = {'white_pawn': svg_pawn, 'black_pawn': svg_pawn,
+ 'white_rook': svg_rook, 'black_rook': svg_rook,
+ 'white_knight': svg_knight, 'black_knight': svg_knight,
+ 'white_bishop': svg_bishop, 'black_bishop': svg_bishop,
+ 'white_queen': svg_queen, 'black_queen': svg_queen,
+ 'white_king': svg_king, 'black_king': svg_king}
+ pixbuf = svg_str_to_pixbuf(
+ svg_header(colors) + DICT[piece](colors[0]) + svg_footer(),
+ w=self.scale, h=self.scale)
+ self._reskin(piece, pixbuf)
+
+ def reskin_from_file(self, piece, file_path):
+ pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
+ file_path, self.scale, self.scale)
+ self._reskin(piece, pixbuf)
+
+ def _reskin(self, piece, pixbuf):
DICT = {'white_pawn': WP, 'black_pawn': BP,
'white_rook': WR, 'black_rook': BR,
'white_knight': WN, 'black_knight': BN,
'white_bishop': WB, 'black_bishop': BB,
'white_queen': WQ, 'black_queen': BQ,
'white_king': WK, 'black_king': BK}
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
- file_path, self._scale, self._scale)
self.skins[DICT[piece]] = pixbuf
if piece == 'white_pawn':
for i in range(8):
self.white[i + 8].set_image(pixbuf)
+ self.white[i + 8].set_layer(MID)
elif piece == 'black_pawn':
for i in range(8):
self.black[i + 8].set_image(pixbuf)
+ self.black[i + 8].set_layer(MID)
elif piece == 'white_rook':
self.white[0].set_image(pixbuf)
self.white[7].set_image(pixbuf)
+ self.white[0].set_layer(MID)
+ self.white[7].set_layer(MID)
elif piece == 'black_rook':
self.black[0].set_image(pixbuf)
self.black[7].set_image(pixbuf)
+ self.black[0].set_layer(MID)
+ self.black[7].set_layer(MID)
elif piece == 'white_knight':
self.white[1].set_image(pixbuf)
self.white[6].set_image(pixbuf)
+ self.white[1].set_layer(MID)
+ self.white[6].set_layer(MID)
elif piece == 'black_knight':
self.black[1].set_image(pixbuf)
self.black[6].set_image(pixbuf)
+ self.black[1].set_layer(MID)
+ self.black[6].set_layer(MID)
elif piece == 'white_bishop':
self.white[2].set_image(pixbuf)
self.white[5].set_image(pixbuf)
+ self.white[2].set_layer(MID)
+ self.white[5].set_layer(MID)
elif piece == 'black_bishop':
self.black[2].set_image(pixbuf)
self.black[5].set_image(pixbuf)
+ self.black[2].set_layer(MID)
+ self.black[5].set_layer(MID)
elif piece == 'white_queen':
self.white[3].set_image(pixbuf)
self.white[16].set_image(pixbuf)
+ self.white[3].set_layer(MID)
+ self.white[16].set_layer(MID)
elif piece == 'black_queen':
self.black[3].set_image(pixbuf)
self.black[16].set_image(pixbuf)
+ self.black[3].set_layer(MID)
+ self.black[16].set_layer(MID)
elif piece == 'white_king':
self.white[4].set_image(pixbuf)
+ self.white[4].set_layer(MID)
elif piece == 'black_king':
self.black[4].set_image(pixbuf)
+ self.black[4].set_layer(MID)
def _generate_sprites(self, colors):
if 'xo' in self._activity.hardware:
@@ -1610,13 +1647,13 @@ Black's turn." % (move))
self.bg[1].move_relative((int(self._width / 3), 0))
self.bg[2].move_relative((int(2 * self._width / 3), 0))
- w = h = self._scale
+ w = h = self.scale
self._squares.append(self._box(w, h, color='black'))
self._squares.append(self._box(w, h, color='white'))
self._squares.append(self._box(w, h, color=colors[0]))
- xo = self._width - 8 * self._scale
+ xo = self._width - 8 * self.scale
xo = int(xo / 2)
- yo = int(self._scale / 2)
+ yo = int(self.scale / 2)
y = yo
for i in range(8):
x = xo
@@ -1626,8 +1663,8 @@ Black's turn." % (move))
self._squares[black_or_white([i, j])]))
self._board[-1].type = None # '%s%d' % (FILES[j], 8 - i)
self._board[-1].set_layer(BOT)
- x += self._scale
- y += self._scale
+ x += self.scale
+ y += self.scale
self.skins.append(gtk.gdk.pixbuf_new_from_file_at_size(
'%s/icons/white-pawn.svg' % (self._bundle_path), w, h))
@@ -1755,9 +1792,11 @@ Black's turn." % (move))
return '</svg>\n'
-def svg_str_to_pixbuf(svg_string):
+def svg_str_to_pixbuf(svg_string, w=None, h=None):
""" Load pixbuf from SVG string """
pl = gtk.gdk.PixbufLoader('svg')
+ if w is not None:
+ pl.set_size(w, h)
pl.write(svg_string)
pl.close()
pixbuf = pl.get_pixbuf()
diff --git a/icons/white-knight-sugar.svg b/icons/white-knight-sugar.svg
new file mode 100644
index 0000000..1fccca9
--- /dev/null
+++ b/icons/white-knight-sugar.svg
@@ -0,0 +1,28 @@
+<?xml version="1.0" ?>
+<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' [
+ <!ENTITY stroke_color "#000">
+ <!ENTITY fill_color "#eee">
+]>
+<svg height="55px" viewBox="0 0 55 55" width="55px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" stroke-linecap="round" stroke-linejoin="round" stroke-width="3.5" stroke="&stroke_color;" fill="&fill_color;">
+ <g
+ transform="matrix(1.2165491,0,0,0.99238691,-5.9551002,0.27813261)"
+ id="g3783">
+ <g
+ transform="translate(0,2.049694)"
+ id="g2984"
+ style="stroke:none">
+ <path
+ d="m 13.440724,50.700306 0,-3.468899 c 0,0 5.063754,-0.304895 6.717542,-1.158219 4.975737,-2.567387 4.646094,-10.853499 4.646094,-10.853499 l -7.439705,0 7.880585,-14.18671 c -2.076635,2.536817 -3.046328,3.17778 -6.378201,2.538586 -1.396898,1.237102 -2.0977,2.300181 -3.494598,3.537283 l -3.3922,-2.758489 c 0,0 8.204406,-12.235256 9.67669,-13.481023 2.148801,-1.8182 1.472289,-1.604605 3.699373,-1.809071 1.298661,-0.119228 0.02196,-2.889384 2.758991,-4.7605709 l 0.261036,46.4006119 z"
+ id="path2987"
+ style="fill:#ffffff;fill-opacity:1;stroke:none" />
+ <path
+ d="m 43.019759,50.700306 0,-3.468899 c 0,0 -5.063754,-0.304895 -6.717542,-1.158219 C 31.32648,43.505801 31.656123,35.219689 31.656123,35.219689 l 8.050058,-0.08701 -0.65988,-12.620498 C 38.657902,15.083854 33.876641,10.24922 32.550024,9.852512 29.898553,10.265591 31.437562,6.752643 28.258176,4.3867061 L 28.084152,50.700306 z"
+ id="path2987-8"
+ style="fill:&fill_color;;fill-opacity:1;stroke:none" />
+ </g>
+ <path
+ d="m 28.015625,6.34375 0,0.1875 c -2.402227,1.8632619 -1.243572,4.447149 -2.5,4.5625 -2.227084,0.204466 -1.569949,-0.0057 -3.71875,1.8125 -1.472284,1.245767 -9.65625,13.5 -9.65625,13.5 l 3.375,2.75 c 1.396898,-1.237102 2.103102,-2.294148 3.5,-3.53125 3.331873,0.639194 4.298365,-0.02568 6.375,-2.5625 l -7.875,14.1875 7.4375,0 c 0,0 0.350737,8.307613 -4.625,10.875 -1.653788,0.853324 -6.71875,1.15625 -6.71875,1.15625 l 0,3.46875 14.40625,0 0.5,0 14.34375,0 0,-3.46875 c 0,0 -5.064962,-0.302926 -6.71875,-1.15625 -4.975737,-2.567387 -4.625,-10.875 -4.625,-10.875 l 8.03125,-0.0625 -0.65625,-12.625 c -0.388399,-7.428327 -5.173383,-12.259542 -6.5,-12.65625 -2.57631,0.401369 -1.284049,-2.9810068 -4.125,-5.34375 l 0,-0.21875 c -0.04451,0.030426 -0.08259,0.062864 -0.125,0.09375 -0.04073,-0.031939 -0.08265,-0.062237 -0.125,-0.09375 z"
+ id="path2987-4"
+ style="fill:none;stroke:&stroke_color;;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ </g>
+</svg>
diff --git a/piece.py b/piece.py
new file mode 100644
index 0000000..85331dc
--- /dev/null
+++ b/piece.py
@@ -0,0 +1,136 @@
+# -*- coding: utf-8 -*-
+#Copyright (c) 2012 Walter Bender
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# You should have received a copy of the GNU General Public License
+# along with this library; if not, write to the Free Software
+# Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335
+def svg_header(colors):
+ return '<?xml version="1.0" ?>\n\
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"\
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [\n\
+ <!ENTITY stroke_color "%s">\n\
+ <!ENTITY fill_color "%s">\n\
+]>\n\
+<svg height="55px" viewBox="0 0 55 55" width="55px"\n\
+ stroke-linecap="round" stroke-linejoin="round" stroke-width="3.5"\n\
+ stroke="&stroke_color;" fill="&fill_color;">\n' % (colors[0], colors[1])
+
+def svg_king(color):
+ return ' <g\n\
+ transform="matrix(1.2485077,0,0,0.99922675,-6.8339601,0.02333855)"\n\
+ style="stroke-width:2.23826957;stroke-miterlimit:4;stroke-dasharray:none">\n\
+ <g\n\
+ transform="matrix(1,0,0,0.97905135,0,0.06306419)"\n\
+ style="stroke:none">\n\
+ <path\n\
+ d="m 12.658106,53.827716 0,-4.778709 c 0,0 5.063754,-0.304895 6.717542,-1.158219 4.975737,-2.567387 4.646094,-18.853499 4.646094,-18.853499 l -5.439705,0 c -0.839477,-2.324197 5.401947,-2.284496 5.702394,-4.73732 0.701484,-5.726849 -10.250727,-13.947133 -10.250727,-13.947133 0,0 2.295963,-2.1630403 5.649622,-1.5533182 1.484507,0.2698953 3.142244,2.6896822 3.142244,2.6896822 0,0 0.547396,-2.1096036 1.524534,-2.7788088 1.380114,-0.9451903 1.18343,-3.8839179 1.18343,-3.8839179 l -2.015598,0.1262271 0,-1.758755 2.015598,0.023776 0,-1.8895174 2.226832,-0.1559196 0,52.6554316 z"\n\
+ style="fill:%s;fill-opacity:1;stroke:none" />\n\
+ <path\n\
+ d="m 42.341894,53.827712 0,-4.77871 c 0,0 -5.063754,-0.304894 -6.717542,-1.158218 -4.975737,-2.567388 -4.646094,-18.853499 -4.646094,-18.853499 l 5.439705,0 c 0.839477,-2.324197 -5.401947,-2.284496 -5.702394,-4.73732 -0.701484,-5.726849 10.250727,-13.947133 10.250727,-13.947133 0,0 -2.295963,-2.1630405 -5.649622,-1.5533175 -1.484507,0.269895 -3.142244,2.6896815 -3.142244,2.6896815 0,0 -0.547396,-2.1096035 -1.524534,-2.7788085 -1.380114,-0.94519 -1.18343,-3.883918 -1.18343,-3.883918 l 2.015598,0.126227 0,-1.758755 -2.015598,0.02378 0,-1.889517 -2.226832,-0.15592 0,52.6554305 z"\n\
+ style="fill:&fill_color;;fill-opacity:1;stroke:none" />\n\
+ </g>\n\
+ <path\n\
+ d="m 27.34375,1.2319123 0,0.03125 -1.9375,0.125 0,1.84375 -2.03125,-0.03125 0,1.71875 2.03125,-0.125 c 0,0 0.192614,2.8871101 -1.1875,3.8125 -0.977138,0.6551862 -1.53125,2.7187497 -1.53125,2.7187497 0,0 -1.671743,-2.3607584 -3.15625,-2.6249997 -3.353659,-0.5969493 -5.625,1.4999997 -5.625,1.4999997 0,0 10.951484,8.04937 10.25,13.65625 -0.300447,2.40144 -6.558227,2.380742 -5.71875,4.65625 l 5.4375,0 c 0,0 0.350737,15.923896 -4.625,18.4375 -1.653788,0.835448 -6.71875,1.15625 -6.71875,1.15625 l 0,4.65625 14.8125,0 0.28125,0 14.84375,0 0,-4.65625 c 0,0 -5.064962,-0.320802 -6.71875,-1.15625 -4.975737,-2.513605 -4.65625,-18.4375 -4.65625,-18.4375 l 5.4375,0 c 0.839477,-2.275508 -5.387053,-2.25481 -5.6875,-4.65625 -0.701484,-5.60688 10.25,-13.65625 10.25,-13.65625 0,0 -2.302591,-2.0969498 -5.65625,-1.4999997 -1.484507,0.2642411 -3.15625,2.6249997 -3.15625,2.6249997 0,0 -0.522862,-2.0635636 -1.5,-2.7187497 -1.380114,-0.9253895 -1.1875,-3.8125 -1.1875,-3.8125 l 2,0.125 0,-1.71875 -2,0.03125 0,-1.84375 -1.96875,-0.125 0,-0.03125 -0.125,0 -0.15625,0 z"\n\
+ style="fill:none;stroke:&stroke_color;;stroke-width:2.23826957;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />\n\
+ </g>' % (color)
+
+def svg_queen(color):
+ return ' <g\n\
+ transform="matrix(1.2400925,0,0,0.99217787,-6.6025437,0.41261734)"\n\
+ id="g3825"\n\
+ style="stroke-width:2.2538147;stroke-miterlimit:4;stroke-dasharray:none">\n\
+ <g\n\
+ transform="translate(0.1849045,0.0026902)"\n\
+ style="stroke:none">\n\
+ <path\n\
+ d="m 12.248804,52.75 0,-3.468899 c 0,0 5.063754,-0.304895 6.717542,-1.158219 4.975737,-2.567387 4.646094,-22.853499 4.646094,-22.853499 l -5.439705,0 4.722002,-3.500243 -9.270335,-11.18421 c 0,0 2.295963,-2.1630399 5.649622,-1.5533178 1.484507,0.2698953 3.142244,2.6896818 3.142244,2.6896818 0,0 0.547396,-2.1096031 1.524534,-2.7788083 1.380114,-0.9451903 3.499389,-1.5274117 3.499389,-1.5274117 0,0 -2.500849,-0.5555543 -2.47113,-2.1910634 0.03351,-1.8439287 2.47113,-2.354391 2.47113,-2.354391 L 27.44,52.75 z"\n\
+ style="fill:%s;fill-opacity:1;stroke:none" />\n\
+ <path\n\
+ d="m 42.381387,52.75 0,-3.468899 c 0,0 -5.063754,-0.304895 -6.717542,-1.158219 -4.975737,-2.567387 -4.646094,-22.853499 -4.646094,-22.853499 l 5.439705,0 -4.722002,-3.500243 9.270335,-11.18421 c 0,0 -2.295963,-2.1630403 -5.649622,-1.5533178 -1.484507,0.2698947 -3.142244,2.6896818 -3.142244,2.6896818 0,0 -0.547396,-2.1096029 -1.524534,-2.7788086 C 29.309275,7.9972953 27.19,7.415074 27.19,7.415074 c 0,0 2.500849,-0.5555538 2.47113,-2.1910633 C 29.62762,3.3800813 27.19,2.8696196 27.19,2.8696196 L 27.19,52.75 z"\n\
+ style="fill:&fill_color;;fill-opacity:1;stroke:none" />\n\
+ </g>\n\
+ <path\n\
+ d="m 27.375,2.875 0,0.0625 c -0.56504,0.1608461 -2.190825,0.7446427 -2.21875,2.28125 -0.02477,1.3629242 1.640538,1.9585405 2.21875,2.125 l 0,0.0625 c 0,0 0.09747,-0.024378 0.125,-0.03125 0.03182,0.00802 0.125,0.03125 0.125,0.03125 l 0,-0.0625 C 28.176812,7.1880277 29.868878,6.6015825 29.84375,5.21875 29.815825,3.6821422 28.19004,3.098346 27.625,2.9375 l 0,-0.0625 c 0,0 -0.09395,0.023684 -0.125,0.03125 C 27.468946,2.898684 27.375,2.875 27.375,2.875 z m 0.25,4.53125 c 0,0 -0.114761,0.028366 -0.125,0.03125 C 27.4902,7.43474 27.375,7.40625 27.375,7.40625 l 0,0.09375 c -0.366824,0.1062466 -2.013206,0.5904641 -3.25,1.4375 -0.977138,0.669206 -1.53125,2.78125 -1.53125,2.78125 0,0 -1.640493,-2.417605 -3.125,-2.6875 -3.353659,-0.6097222 -5.65625,1.5625 -5.65625,1.5625 l 9.28125,11.1875 -4.71875,3.5 5.4375,0 c 0,0 0.319487,20.276363 -4.65625,22.84375 -1.653788,0.853324 -6.71875,1.15625 -6.71875,1.15625 l 0,3.46875 14.9375,0 0.25,0 14.9375,0 0,-3.46875 c 0,0 -5.064962,-0.302926 -6.71875,-1.15625 -4.975737,-2.567387 -4.625,-22.84375 -4.625,-22.84375 l 5.4375,0 -4.71875,-3.5 9.25,-11.1875 c 0,0 -2.302591,-2.1722226 -5.65625,-1.5625 -1.484507,0.269895 -3.125,2.6875 -3.125,2.6875 0,0 -0.554112,-2.112044 -1.53125,-2.78125 C 29.634926,8.0882181 27.985,7.6041381 27.625,7.5 l 0,-0.09375 z"\n\
+ style="fill:none;stroke:&stroke_color;;stroke-width:2.2538147;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />\n\
+ </g>' % (color)
+
+def svg_bishop(color):
+ return ' <g\n\
+ transform="matrix(1.26334,0,0,0.99082261,-7.24185,0.27159352)"\n\
+ style="stroke-width:2.23450804;stroke-miterlimit:4;stroke-dasharray:none">\n\
+ <g\n\
+ transform="translate(0.4616785,2.0932)"\n\
+ style="stroke:none">\n\
+ <path\n\
+ d="m 12.248804,50.6568 0,-3.468899 c 0,0 5.063754,-0.304895 6.717542,-1.158219 4.975737,-2.567387 4.646094,-20.853499 4.646094,-20.853499 l -5.439705,0 6.402656,-4.099698 C 21.514596,19.079162 20.71868,16.327441 20.737297,14.776585 20.761162,12.788552 21.912462,9.5577976 26.19901,8.2427944 27.429282,7.8653785 25.047978,7.8003211 25.245401,6.0629633 25.380926,4.8703258 26.007324,4.4256454 27.184411,4.3432 l 0,46.3136 z"\n\
+ style="fill:%s;fill-opacity:1;stroke:none" />\n\
+ <path\n\
+ d="m 41.827839,50.6568 0,-3.468899 c 0,0 -5.063754,-0.304895 -6.717542,-1.158219 C 30.13456,43.462295 30.464203,25.176183 30.464203,25.176183 l 5.439705,0 -6.402656,-4.099698 c 3.060795,-1.997323 3.856711,-4.749044 3.838094,-6.2999 -0.02387,-1.988033 -1.175165,-5.2187876 -5.461713,-6.5337906 -1.230272,-0.3774161 1.151032,-0.442473 0.953609,-2.179831 -0.135525,-1.1926381 -0.761923,-1.6373181 -1.93901,-1.7197631 l 0,46.3135997 z"\n\
+ style="fill:&fill_color;;fill-opacity:1;stroke:none" />\n\
+ </g>\n\
+ <path\n\
+ d="m 27.34375,6.4375002 0,0.03125 c -0.97538,0.1388598 -1.533316,0.6056649 -1.65625,1.6875 -0.197423,1.7373577 2.199022,1.8100837 0.96875,2.1874998 -4.286548,1.315004 -5.44488,4.543217 -5.46875,6.53125 -0.01862,1.550856 0.782955,4.283927 3.84375,6.28125 l -6.40625,4.125 5.4375,0 c 0,0 0.350737,18.276363 -4.625,20.84375 -1.653788,0.853324 -6.71875,1.15625 -6.71875,1.15625 l 0,3.46875 14.625,0 0.28125,0 14.65625,0 0,-3.46875 c 0,0 -5.064962,-0.302926 -6.71875,-1.15625 -4.975737,-2.567387 -4.65625,-20.84375 -4.65625,-20.84375 l 5.46875,0 -6.40625,-4.125 c 3.060795,-1.997323 3.831117,-4.730394 3.8125,-6.28125 -0.02387,-1.988033 -1.150952,-5.216247 -5.4375,-6.53125 -1.230272,-0.3774161 1.134923,-0.4501421 0.9375,-2.1874998 -0.123421,-1.0861193 -0.673441,-1.5506904 -1.65625,-1.6875 l 0,-0.03125 c -0.04971,0.00348 -0.07725,0.026447 -0.125,0.03125 -0.05644,-0.00603 -0.09703,-0.027102 -0.15625,-0.03125 z"\n\
+ style="fill:none;stroke:&stroke_color;;stroke-width:2.23450804;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />\n\
+ </g>' % (color)
+
+def svg_knight(color):
+ return ' <g\n\
+ transform="matrix(1.2165491,0,0,0.99238691,-5.9551002,0.27813261)"\n\
+ id="g3783">\n\
+ <g\n\
+ transform="translate(0,2.049694)"\n\
+ style="stroke:none">\n\
+ <path\n\
+ d="m 13.440724,50.700306 0,-3.468899 c 0,0 5.063754,-0.304895 6.717542,-1.158219 4.975737,-2.567387 4.646094,-10.853499 4.646094,-10.853499 l -7.439705,0 7.880585,-14.18671 c -2.076635,2.536817 -3.046328,3.17778 -6.378201,2.538586 -1.396898,1.237102 -2.0977,2.300181 -3.494598,3.537283 l -3.3922,-2.758489 c 0,0 8.204406,-12.235256 9.67669,-13.481023 2.148801,-1.8182 1.472289,-1.604605 3.699373,-1.809071 1.298661,-0.119228 0.02196,-2.889384 2.758991,-4.7605709 l 0.261036,46.4006119 z"\n\
+ style="fill:%s;fill-opacity:1;stroke:none" />\n\
+ <path\n\
+ d="m 43.019759,50.700306 0,-3.468899 c 0,0 -5.063754,-0.304895 -6.717542,-1.158219 C 31.32648,43.505801 31.656123,35.219689 31.656123,35.219689 l 8.050058,-0.08701 -0.65988,-12.620498 C 38.657902,15.083854 33.876641,10.24922 32.550024,9.852512 29.898553,10.265591 31.437562,6.752643 28.258176,4.3867061 L 28.084152,50.700306 z"\n\
+ style="fill:&fill_color;;fill-opacity:1;stroke:none" />\n\
+ </g>\n\
+ <path\n\
+ d="m 28.015625,6.34375 0,0.1875 c -2.402227,1.8632619 -1.243572,4.447149 -2.5,4.5625 -2.227084,0.204466 -1.569949,-0.0057 -3.71875,1.8125 -1.472284,1.245767 -9.65625,13.5 -9.65625,13.5 l 3.375,2.75 c 1.396898,-1.237102 2.103102,-2.294148 3.5,-3.53125 3.331873,0.639194 4.298365,-0.02568 6.375,-2.5625 l -7.875,14.1875 7.4375,0 c 0,0 0.350737,8.307613 -4.625,10.875 -1.653788,0.853324 -6.71875,1.15625 -6.71875,1.15625 l 0,3.46875 14.40625,0 0.5,0 14.34375,0 0,-3.46875 c 0,0 -5.064962,-0.302926 -6.71875,-1.15625 -4.975737,-2.567387 -4.625,-10.875 -4.625,-10.875 l 8.03125,-0.0625 -0.65625,-12.625 c -0.388399,-7.428327 -5.173383,-12.259542 -6.5,-12.65625 -2.57631,0.401369 -1.284049,-2.9810068 -4.125,-5.34375 l 0,-0.21875 c -0.04451,0.030426 -0.08259,0.062864 -0.125,0.09375 -0.04073,-0.031939 -0.08265,-0.062237 -0.125,-0.09375 z"\n\
+ style="fill:none;stroke:&stroke_color;;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />\n\
+ </g>' % (color)
+
+def svg_rook(color):
+ return ' <g\n\
+ transform="matrix(1.2556041,0,0,0.98957446,-7.0291127,5.9926068)"\n\
+ id="g3789"\n\
+ style="stroke-width:2.24279404;stroke-miterlimit:4;stroke-dasharray:none">\n\
+ <g\n\
+ transform="translate(0.25,-5.4906)"\n\
+ style="stroke:none">\n\
+ <path\n\
+ d="m 12.375,52.75 0,-3.468899 c 0,0 4.955557,-0.304895 6.609345,-1.158219 4.975736,-2.567387 4.719281,-20.853499 4.719281,-20.853499 l -4,0 0,-3.240246 -2.828626,0 0,-10.797937 3.171374,0 0,4.142269 4,0 0,-4.142269 3.328626,0 0,39.5188 z"\n\
+ style="fill:%s;fill-opacity:1;stroke:none" />\n\
+ <path\n\
+ d="m 42.125,52.749999 0,-3.468899 c 0,0 -4.955557,-0.304895 -6.609345,-1.158219 -4.975736,-2.567387 -4.719281,-20.853498 -4.719281,-20.853498 l 4,0 0,-3.240246 2.828626,0 0,-10.797936 -3.171374,0 0,4.142268 -4,0 0,-4.142268 -3.328626,0 0,39.518798 z"\n\
+ style="fill:&fill_color;;fill-opacity:1;stroke:none" />\n\
+ </g>\n\
+ <path\n\
+ d="m 17.125,7.75 0,10.78125 2.84375,0 0,3.25 4,0 c 0,0 0.256986,18.276363 -4.71875,20.84375 -1.653788,0.853324 -6.625,1.15625 -6.625,1.15625 l 0,3.46875 14.75,0 0.25,0 14.75,0 0,-3.46875 c 0,0 -4.939962,-0.302926 -6.59375,-1.15625 C 30.805514,40.057613 31.0625,21.78125 31.0625,21.78125 l 4,0 0,-3.25 2.8125,0 0,-10.78125 -3.15625,0 0,4.125 -4,0 0,-4.125 -3.09375,0 -0.25,0 -3.0625,0 0,4.125 -4,0 0,-4.125 -3.1875,0 z"\n\
+ style="fill:none;stroke:&stroke_color;;stroke-width:2.24279404;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />\n\
+ </g>' % (color)
+
+def svg_pawn(color):
+ return ' <g\n\
+ transform="translate(0,2.80808)"\n\
+ style="stroke:none">\n\
+ <path\n\
+ d="m 12.491825,49.94192 13.88066,-7.25995 c 0,0 -11.69178,-1.56637 -11.68897,-11.59766 0.003,-10.03129 11.41501,-12.05425 11.41501,-12.05425 0,0 -5.93421,-1.84586 -5.93581,-7.12297 -0.002,-5.23359 7.21429,-6.84901 7.21429,-6.84901 l 0,44.88384 z"\n\
+ style="fill:%s;fill-opacity:1;stroke:none" />\n\
+ <path\n\
+ d="m 42.508175,49.94192 -13.88066,-7.25995 c 0,0 11.69178,-1.56637 11.68897,-11.59766 -0.003,-10.03129 -11.41501,-12.05425 -11.41501,-12.05425 0,0 5.93421,-1.84586 5.93581,-7.12297 0.002,-5.23359 -7.21429,-6.84901 -7.21429,-6.84901 l 0,44.88384 z"\n\
+ style="fill:&fill_color;;fill-opacity:1;stroke:none" />\n\
+ </g>\n\
+ <path\n\
+ d="m 27.375,7.875 0,0.0625 c -0.710664,0.174133 -6.97064,1.8363323 -6.96875,6.78125 0.0016,5.27711 5.9375,7.125 5.9375,7.125 0,0 -11.40325,1.99996 -11.40625,12.03125 C 14.9347,43.90629 26.625,45.5 26.625,45.5 l -13.875,7.25 14.625,0 0.25,0 14.625,0 -13.875,-7.25 c 0,0 11.69031,-1.59371 11.6875,-11.625 -0.003,-10.03129 -11.40625,-12.03125 -11.40625,-12.03125 0,0 5.9359,-1.84789 5.9375,-7.125 C 34.59564,9.7738323 28.335664,8.111633 27.625,7.9375 l 0,-0.0625 c 0,0 -0.114037,0.03125 -0.125,0.03125 -0.01096,0 -0.125,-0.03125 -0.125,-0.03125 z"\n\
+ style="fill:none;stroke:&stroke_color;;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />' % (color)
+
+def svg_footer():
+ return '</svg>\n'