Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Desenho.py
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2013-01-03 20:28:19 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2013-01-09 11:53:40 (GMT)
commit22503b1403494b973a696e9f2cbf7bc744793ce8 (patch)
treec306160d8852282af1121e3670a4bca445993be6 /Desenho.py
parentbf74b2e49c34c43d222ff43d775321f5c2567a2c (diff)
Improve response in brush tool - OLPC #12405
Now draw only the last part in a polygon, when is open and not filled (the brush case) instead of drawing all the polygon every time. Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
Diffstat (limited to 'Desenho.py')
-rw-r--r--Desenho.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/Desenho.py b/Desenho.py
index 01d5002..04fc602 100644
--- a/Desenho.py
+++ b/Desenho.py
@@ -98,7 +98,8 @@ class Desenho:
self._rainbow_counter = 0
self.points = []
- self._last_points_used = self.points
+ self._last_points_used = []
+ self._last_point_drawn_index = 0
def clear_control_points(self):
self._last_points_used = []
@@ -281,6 +282,7 @@ class Desenho:
widget.drawing_ctx.restore()
self.points = []
+ self._last_point_drawn_index = 0
def _trace(self, widget, coords, last):
widget.desenha = True
@@ -350,9 +352,19 @@ class Desenho:
ctx.set_line_width(widget.tool['line size'])
ctx.stroke()
ctx.restore()
- self._last_points_used.extend(points)
- area = widget.calculate_damaged_area(self._last_points_used)
- widget.queue_draw_area(*area)
+ if fill or closed:
+ self._last_points_used.extend(points)
+ area = widget.calculate_damaged_area(self._last_points_used)
+ widget.queue_draw_area(*area)
+ else:
+ # if is a open line and is not filled (like when using the pencil)
+ # we don't need draw all the poligon, can draw only the part
+ # from the last queue update until now
+ self._last_points_used = points[self._last_point_drawn_index:]
+ if self._last_points_used:
+ area = widget.calculate_damaged_area(self._last_points_used)
+ self._last_point_drawn_index = len(points)
+ widget.queue_draw_area(*area)
def triangle(self, widget, coords, temp, fill):
"""Draw a triangle.
@@ -741,6 +753,9 @@ class Desenho:
else:
# close the polygon
self.points.append((first[0], first[1]))
+ # set the last point index to zero to force draw all
+ # the polygon
+ self._last_point_drawn_index = 0
self._draw_polygon(widget, False, fill, self.points)
widget.desenha = False
widget.last = []