Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/PascalTriangle.activity/pascaltriangle.py
diff options
context:
space:
mode:
authorPhilip Withnall <philip@tecnocode.co.uk>2013-08-19 04:21:48 (GMT)
committer Philip Withnall <philip@tecnocode.co.uk>2013-08-19 04:21:48 (GMT)
commit6deea88c4e9e83042d5d3ebcadc4197565fabdf1 (patch)
tree8e59a81aceed9f253dd6603051cb8473e33d13c6 /PascalTriangle.activity/pascaltriangle.py
parente18b4a76eeabf2fc2d43f2dd38b1afa52cf514be (diff)
Clean up activity appearance and rendering
Diffstat (limited to 'PascalTriangle.activity/pascaltriangle.py')
-rwxr-xr-xPascalTriangle.activity/pascaltriangle.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/PascalTriangle.activity/pascaltriangle.py b/PascalTriangle.activity/pascaltriangle.py
index b84d0a9..bee5e8b 100755
--- a/PascalTriangle.activity/pascaltriangle.py
+++ b/PascalTriangle.activity/pascaltriangle.py
@@ -264,6 +264,10 @@ class PascalTriangleActivity(activity.Activity):
cell_width = base_width / self._triangle_size
cell_height = 3.0 * (triangle_height / (2 * self._triangle_size + 1))
+ # Set up drawing style.
+ ctx.set_line_width(4)
+ ctx.set_line_join(cairo.LINE_JOIN_ROUND)
+
# Draw the triangle rows from the top down. The row_order is the number
# of cells in the row (increasing from 1 to triangle_size, inclusive).
for row_index in range(self._triangle_size):
@@ -298,16 +302,16 @@ class PascalTriangleActivity(activity.Activity):
def _get_cell_background(self, row_index, column_index):
if (row_index, column_index) == self._current_cell:
- return cairo.SolidPattern(0.0, 0.7, 0.0) # green
+ return cairo.SolidPattern(0.541, 0.886, 0.204) # green
elif self._show_hints and self._current_cell != (-1, -1) and \
(self._current_cell[1] == 0 or \
self._current_cell[1] == self._current_cell[0]) and \
(column_index == 0 or column_index == row_index):
- return cairo.SolidPattern(0.0, 0.0, 0.5) # blue
+ return cairo.SolidPattern(0.447, 0.624, 0.812) # blue
elif self._show_hints and row_index == self._current_cell[0] - 1 and \
(column_index == self._current_cell[1] - 1 or \
column_index == self._current_cell[1]):
- return cairo.SolidPattern(0.5, 0.5, 0.0) # yellow
+ return cairo.SolidPattern(0.988, 0.914, 0.310) # yellow
else:
return cairo.SolidPattern(1.0, 1.0, 1.0) # white
@@ -344,13 +348,16 @@ class PascalTriangleActivity(activity.Activity):
ctx.set_source_rgb(0.4, 0.4, 0.4) # grey
else:
cell_text = self._current_cell_text
- ctx.set_source_rgb(1.0, 0.0, 0.0) # red
+ ctx.set_source_rgb(0.8, 0.0, 0.0) # red
if cell_text != None:
+ # Rule of thumb to scale the font size with the cells.
+ font_size = int(50.0 / (float(self._triangle_size) / 5.0))
+
extents = ctx.text_extents(cell_text)
ctx.move_to(centre[0] - extents[2] / 2.0,
centre[1] + extents[3] / 2.0)
- ctx.set_font_size(50)
+ ctx.set_font_size(font_size)
ctx.show_text(cell_text)