From 022a832d4d7ea01ea888f47ba7ca1cc1536b74d1 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Thu, 28 Apr 2011 22:10:16 +0200 Subject: host/simu/view/table_eurobot2011: move pawn drawing to function --- host/simu/view/table_eurobot2011.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'host/simu/view/table_eurobot2011.py') diff --git a/host/simu/view/table_eurobot2011.py b/host/simu/view/table_eurobot2011.py index 5e67b9e7..787c9359 100644 --- a/host/simu/view/table_eurobot2011.py +++ b/host/simu/view/table_eurobot2011.py @@ -32,6 +32,18 @@ GREEN = '#268126' BLACK = '#181818' YELLOW = '#cccc00' +def draw_pawn (d, radius, kind): + d.draw_circle ((0, 0), radius, fill = YELLOW) + if kind == 'king': + a = 0.1 * radius + b = 0.5 * radius + d.draw_line ((a, b), (a, a), (b, a), (b, -a), (a, -a), (a, -b), + (-a, -b), (-a, -a), (-b, -a), (-b, a), (-a, a), (-a, b), + (a, b)) + elif kind == 'queen': + d.draw_circle ((0, 0), 0.5 * radius) + d.draw_circle ((0, 0), 0.4 * radius) + class Pawn (Drawable): def __init__ (self, onto, model): @@ -48,17 +60,7 @@ class Pawn (Drawable): self.reset () if self.pos: self.trans_translate (self.pos) - r = self.model.radius - self.draw_circle ((0, 0), r, fill = YELLOW) - if self.model.kind == 'king': - a = 0.1 * r - b = 0.5 * r - self.draw_line ((a, b), (a, a), (b, a), (b, -a), (a, -a), - (a, -b), (-a, -b), (-a, -a), (-b, -a), (-b, a), - (-a, a), (-a, b), (a, b)) - elif self.model.kind == 'queen': - self.draw_circle ((0, 0), 0.5 * r) - self.draw_circle ((0, 0), 0.4 * r) + draw_pawn (self, self.model.radius, self.model.kind) Drawable.draw (self) class Table (Drawable): -- cgit v1.2.3