[hamster-applet] rounding area coordinates and dimensions, when doing fillArea in canvas
- From: Toms Baugis <tbaugis src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [hamster-applet] rounding area coordinates and dimensions, when doing fillArea in canvas
- Date: Mon, 16 Nov 2009 23:35:54 +0000 (UTC)
commit 129f2cd2fde32e14b8dbed19de50fb33cb2d5b85
Author: Toms Bauģis <toms baugis gmail com>
Date: Mon Nov 16 23:35:42 2009 +0000
rounding area coordinates and dimensions, when doing fillArea in canvas
hamster/charting.py | 15 ++++++++-------
hamster/edit_activity.py | 7 +++++--
hamster/stats.py | 8 +++++---
3 files changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/hamster/charting.py b/hamster/charting.py
index 2b9f8ea..fa61399 100644
--- a/hamster/charting.py
+++ b/hamster/charting.py
@@ -313,27 +313,28 @@ class BarChart(Chart):
bar_start = 0
base_color = self.bar_base_color or (220, 220, 220)
- bar_x = self.graph_x + bar_width * i + gap
+ bar_x = round(self.graph_x + bar_width * i + gap)
if self.stack_keys:
for j, bar in enumerate(self.bars[i]):
if bar.size > 0:
- bar_size = max_bar_size * bar.size
+ bar_size = round(max_bar_size * bar.size)
bar_start += bar_size
self.draw_bar(bar_x,
self.graph_height - bar_start,
- bar_width - (gap * 2),
+ round(bar_width - (gap * 2)),
bar_size,
self.get_bar_color(j))
else:
- bar_size = max_bar_size * self.bars[i].size
+ bar_size = round(max_bar_size * self.bars[i].size)
bar_start = bar_size
self.draw_bar(bar_x,
self.graph_y + self.graph_height - bar_size,
- bar_width - (gap * 2),
- bar_size, base_color)
+ round(bar_width - (gap * 2)),
+ bar_size,
+ base_color)
#fill with white background (necessary for those dragging cases)
if self.background:
@@ -510,7 +511,7 @@ class HorizontalBarChart(Chart):
bar_size = round(max_bar_size * self.bars[i].size)
bar_start = bar_size
- bar_height = bar_width - (gap * 2)
+ bar_height = round(bar_width - (gap * 2))
self.draw_bar(self.graph_x, bar_y, bar_size, bar_height,
base_color)
diff --git a/hamster/edit_activity.py b/hamster/edit_activity.py
index 6ec860b..14383b9 100644
--- a/hamster/edit_activity.py
+++ b/hamster/edit_activity.py
@@ -268,8 +268,11 @@ class Dayline(graphics.Area):
if self.get_pixel(end_minutes) > 0 and \
self.get_pixel(start_minutes) < self.width:
context.set_source_rgba(0.86, 0.86, 0.86, 0.5)
- context.rectangle(self.get_pixel(start_minutes), graph_y,
- self.get_pixel(end_minutes) - self.get_pixel(start_minutes), graph_height - 1)
+
+ context.rectangle(round(self.get_pixel(start_minutes)),
+ graph_y,
+ round(self.get_pixel(end_minutes) - self.get_pixel(start_minutes)),
+ graph_height - 1)
context.fill()
context.stroke()
diff --git a/hamster/stats.py b/hamster/stats.py
index 375b081..e70efaf 100644
--- a/hamster/stats.py
+++ b/hamster/stats.py
@@ -286,9 +286,11 @@ class TimeLine(graphics.Area):
total_length += fact["delta"]
total_length = total_length.seconds / 60 / 60.0 + total_length.days * 24
total_length = total_length / float(self.max_hours) * self.height - 16
- self.fill_area(ticker_pos * self.x_factor,
- self.height - total_length,
- self.x_factor, total_length,
+
+ self.fill_area(round(ticker_pos * self.x_factor),
+ round(self.height - total_length),
+ round(self.x_factor),
+ round(total_length),
(190,190,190))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]