Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt/tacanvas.py
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2011-02-06 15:16:04 (GMT)
committer Walter Bender <walter@sugarlabs.org>2011-02-06 15:16:04 (GMT)
commitbbb22fcb1cdc756e90a99c619660aaf262208f35 (patch)
tree2f8b2191c6af22e7308e60ebfeac6c1ab39e83dc /TurtleArt/tacanvas.py
parent1ded88e980633a2a9c51d93193bf5951d7848451 (diff)
adding sharing of pixbufs
Diffstat (limited to 'TurtleArt/tacanvas.py')
-rw-r--r--TurtleArt/tacanvas.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/TurtleArt/tacanvas.py b/TurtleArt/tacanvas.py
index ac9e36e..a4dbb64 100644
--- a/TurtleArt/tacanvas.py
+++ b/TurtleArt/tacanvas.py
@@ -24,6 +24,7 @@ import gtk
from math import sin, cos, pi
import pango
import cairo
+import base64
from sprites import Sprite
from tasprite_factory import SVG
@@ -402,7 +403,7 @@ class TurtleGraphics:
round_int(self.gray)]))
self._send_event(event, share)
- def settextcolor(self, c):
+ def settextcolor(self, c): # depreciated
""" Set the text color """
try:
self.tcolor = c
@@ -487,7 +488,7 @@ class TurtleGraphics:
event = "p|%s" % (data_to_string([self._get_my_nick(), bool]))
self._send_event(event, share)
- def draw_pixbuf(self, pixbuf, a, b, x, y, w, h, path):
+ def draw_pixbuf(self, pixbuf, a, b, x, y, w, h, path, share=True):
""" Draw a pixbuf """
w *= self.tw.coord_scale
h *= self.tw.coord_scale
@@ -501,6 +502,21 @@ class TurtleGraphics:
else:
self.tw.svg_string += self.svg.image(x - self.width / 2,
y, w, h, path)
+ if self.tw.sharing():
+ data = pixbuf.get_pixels()
+ height = pixbuf.get_height()
+ width = pixbuf.get_width()
+ stride = pixbuf.get_rowstride()
+ bits_per_sample = pixbuf.get_bits_per_sample()
+ has_alpha = pixbuf.get_has_alpha()
+ colorspace = pixbuf.get_colorspace()
+ event = "P|%s" % (data_to_string([self._get_my_nick(),
+ [round_int(a), round_int(b), round_int(x), round_int(y),
+ round_int(w), round_int(h), path,
+ height, width, stride, bits_per_sample,
+ has_alpha, colorspace,
+ base64.standard_b64encode(str(data))]]))
+ self._send_event(event, share)
def draw_text(self, label, x, y, size, w, share=True):
""" Draw text """
@@ -666,5 +682,5 @@ class TurtleGraphics:
return
if self.tw.sharing():
- print "Sending: %s" % entry
+ # print "Sending: %s" % entry
self.tw.send_event(entry)