From 94d2541eba3258ff1a65690a86dfbca85d0aeea8 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Tue, 02 Mar 2010 22:42:36 +0000 Subject: adding image support to SVG export --- diff --git a/tacanvas.py b/tacanvas.py index b26d729..054f309 100644 --- a/tacanvas.py +++ b/tacanvas.py @@ -300,11 +300,13 @@ class TurtleGraphics: def setpen(self,bool): self.pendown = bool - def draw_pixbuf(self,pixbuf,a,b,x,y,w,h): + def draw_pixbuf(self, pixbuf, a, b, x, y, w, h, path): w *= self.tw.coord_scale h *= self.tw.coord_scale self.canvas.images[0].draw_pixbuf(self.gc, pixbuf, a, b, x, y) - self.invalt(x,y,w,h) + self.invalt(x, y, w, h) + if self.tw.saving_svg: + self.tw.svg_string += self.svg.image(x-self.width/2, y, w, h, path) def draw_text(self, label, x, y, size, w): w *= self.tw.coord_scale diff --git a/talogo.py b/talogo.py index f1691f3..6a49706 100644 --- a/talogo.py +++ b/talogo.py @@ -412,6 +412,7 @@ class LogoCode: self.trace = 0 self.gplay = None self.ag = None + self.filepath = None # Scale factors for depreciated portfolio blocks self.title_height = int((self.tw.canvas.height/20)*self.tw.scale) @@ -1096,6 +1097,7 @@ class LogoCode: pass elif media[6:] is not "None": pixbuf = None + self.filepath = None if self.tw.running_sugar: try: dsobject = datastore.get(media[6:]) @@ -1103,15 +1105,18 @@ class LogoCode: play_movie_from_file(self, dsobject.file_path, int(x), int(y), int(w), int(h)) else: + self.filepath = dsobject.file_path pixbuf = get_pixbuf_from_journal(dsobject, int(w), int(h)) dsobject.destroy() except: # Maybe it is a pathname instead. try: + self.filepath = media[6:0] pixbuf = gtk.gdk.pixbuf_new_from_file_at_size( media[6:], int(w), int(h)) except: + self.filepath = None self.tw.showlabel('nojournal', media[6:]) print "Couldn't open Journal object %s" % (media[6:]) else: @@ -1120,14 +1125,17 @@ class LogoCode: play_movie_from_file(self, media[6:], int(x), int(y), int(w), int(h)) else: + self.filepath = media[6:] pixbuf = gtk.gdk.pixbuf_new_from_file_at_size( media[6:], int(w), int(h)) except: + self.filepath = None self.tw.showlabel('nofile', media[6:]) print "Couldn't open media object %s" % (media[6:]) if pixbuf is not None: self.tw.canvas.draw_pixbuf(pixbuf, 0, 0, int(x), int(y), - int(w), int(h)) + int(w), int(h), + self.filepath) def show_description(self, media, x, y, w, h): if media == "" or media[6:] == "": diff --git a/tasprite_factory.py b/tasprite_factory.py index 6bf54fe..97b1426 100755 --- a/tasprite_factory.py +++ b/tasprite_factory.py @@ -669,7 +669,7 @@ class SVG: return " %s%.1f%s%.1f%s%.1f%s%.1f%s%s%s" % ( "\n") + "\" xlink:href=\"file://", path, "\"/>\n") def _circle(self, r, cx, cy): -- cgit v0.9.1