Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAgustin Zubiaga <aguz@sugarlabs.org>2012-09-03 02:25:53 (GMT)
committer Agustin Zubiaga <aguz@sugarlabs.org>2012-09-03 02:25:53 (GMT)
commitbc430de19d30138c0acb2c52339b1888b8dc0173 (patch)
tree55493b91865c8b1c3f8151b7cc61ec23f407085f
parent3ea9371c70fea3f76c59a2b74e38f045995d3d59 (diff)
Use colors like implode
-rwxr-xr-xgame.py32
1 files changed, 18 insertions, 14 deletions
diff --git a/game.py b/game.py
index 0b18676..2bb5da7 100755
--- a/game.py
+++ b/game.py
@@ -32,6 +32,11 @@ SIZE_FACTOR_2 = 3.5 * 200 / BETWEEN_LINE_SPACE
MODE_CIRCLE = 0
MODE_CROSS = 1
+TICTACTOE_COLOR = (1, 1, 1)
+CROSS_COLOR = (0, 0.921568, 0.0627450)
+CIRCLE_COLOR = (1, 0.556862, 0)
+BACKGROUND_COLOR = (0.352941, 0.349019, 0.709803)
+
class Canvas(Gtk.DrawingArea):
@@ -61,15 +66,11 @@ class Canvas(Gtk.DrawingArea):
# White Background
context.rectangle(0, 0, alloc.width, alloc.height)
- context.set_source_rgb(255, 255, 255)
+ context.set_source_rgb(*BACKGROUND_COLOR)
context.fill()
- # Colors
- # FIXME: Use the sugar profile colors
- stroke, fill = (0, 0, 255), (0, 255, 0)
-
# Tic-Tac-Toe
- context.set_source_rgb(*stroke)
+ context.set_source_rgb(*TICTACTOE_COLOR)
context.set_line_width(12)
context.set_line_cap(cairo.LINE_CAP_ROUND)
@@ -115,12 +116,22 @@ class Canvas(Gtk.DrawingArea):
self.squares.extend([(cx1, cy2), (cx2, cy2), (cx3, cy2)])
self.squares.extend([(cx1, cy3), (cx2, cy3), (cx3, cy3)])
- context.set_source_rgb(*fill)
+ # Draw cursor dot
+ if not self.cursor:
+ self.cursor = self.squares[1]
+ cx, cy = self.cursor
+ context.arc(cx, cy, 9, 0, 360)
+ context.fill_preserve()
+ context.stroke()
+
+ # Draw circles and crosses
+ context.set_source_rgb(*CIRCLE_COLOR)
for circle in self.circles:
x, y = circle
context.arc(x, y, SIZE / 2, 0, 360)
context.stroke()
+ context.set_source_rgb(*CROSS_COLOR)
for cross in self.crosses:
x, y = cross
a = SIZE / 2
@@ -131,13 +142,6 @@ class Canvas(Gtk.DrawingArea):
context.line_to(x - a, y + a)
context.stroke()
- # Draw cursor dot
- if self.cursor:
- cx, cy = self.cursor
- context.arc(cx, cy, 9, 0, 360)
- context.fill_preserve()
- context.stroke()
-
def _motion_notify_cb(self, widget, event):
self.cursor = self.get_pos(event.x, event.y)
self.queue_draw()