Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Quiñones <manuq@laptop.org>2012-03-27 03:52:08 (GMT)
committer Manuel Quiñones <manuq@laptop.org>2012-03-27 03:52:08 (GMT)
commit264f4db5a1618b6ab6017c9d1c71e66dffc6f54a (patch)
treec5e6ff4e804d59e44deadf3398b505988ba1c3f3
parent86c79634de63ae10314b4540a51f667d35111030 (diff)
Share brush settings
Signed-off-by: Manuel Quiñones <manuq@laptop.org>
-rw-r--r--drawing.py14
-rw-r--r--paintwithme.py8
2 files changed, 12 insertions, 10 deletions
diff --git a/drawing.py b/drawing.py
index 749efc6..f4c9294 100644
--- a/drawing.py
+++ b/drawing.py
@@ -94,10 +94,10 @@ class Drawing(gtk.DrawingArea):
height = self._drawing_canvas.get_height()
return width, height
- def remote_stroke(self, stroke_points):
+ def remote_stroke(self, stroke_points, settings):
"""Draw stroke from other player."""
context = cairo.Context(self._drawing_canvas)
- self._set_stroke_context(context)
+ self._set_stroke_context(context, settings)
self._paint_stroke(context, stroke_points)
self.queue_draw()
@@ -126,10 +126,12 @@ class Drawing(gtk.DrawingArea):
if self.we_are_sharing:
self._parent.send_new_drawing()
- def _set_stroke_context(self, context):
+ def _set_stroke_context(self, context, settings=None):
"""Set the settings of our brush to the Cairo context."""
- context.set_source_rgba(*self._settings['stroke color'])
- context.set_line_width(self._settings['stroke width'])
+ if settings is None:
+ settings = self._settings
+ context.set_source_rgba(*settings['stroke color'])
+ context.set_line_width(settings['stroke width'])
def _paint_stroke(self, context, stroke_points):
"""Draw lines from the list of points to the Cairo context"""
@@ -154,7 +156,7 @@ class Drawing(gtk.DrawingArea):
self._paint_stroke(context, self._stroke_points)
if self.we_are_sharing:
- self._parent.send_stroke(self._stroke_points)
+ self._parent.send_stroke(self._stroke_points, self._settings)
# Clean the list of points:
if continue_stroke:
diff --git a/paintwithme.py b/paintwithme.py
index d07f8cf..a0033ed 100644
--- a/paintwithme.py
+++ b/paintwithme.py
@@ -192,14 +192,14 @@ params=%r state=%d' % (id, initiator, type, service, params, state))
width, height = json_load(payload)
self._drawing.setup(width, height)
- def send_stroke(self, stroke_points):
+ def send_stroke(self, stroke_points, settings):
"""Send a new stroke to all the players."""
- self.send_event('p|%s' % (json_dump(stroke_points)))
+ self.send_event('p|%s' % (json_dump((stroke_points, settings))))
def _receive_stroke(self, payload):
"""When a stroke is finished, everyone should show it."""
- stroke_points = json_load(payload)
- self._drawing.remote_stroke(stroke_points)
+ stroke_points, settings = json_load(payload)
+ self._drawing.remote_stroke(stroke_points, settings)
def send_event(self, entry):
""" Send event through the tube. """