Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tasprite_factory.py
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2010-03-02 19:34:04 (GMT)
committer Walter Bender <walter@sugarlabs.org>2010-03-02 19:34:04 (GMT)
commit9fb8ab4a2edbce70db9446df0d62eb851984ad55 (patch)
treed8e171b5d03e332f055355638199d1e1c2068729 /tasprite_factory.py
parentd965c466848bce04692d66fc7bfc3c28e39890e2 (diff)
fixed SVG bound box error
Diffstat (limited to 'tasprite_factory.py')
-rwxr-xr-xtasprite_factory.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/tasprite_factory.py b/tasprite_factory.py
index df536fb..6bf54fe 100755
--- a/tasprite_factory.py
+++ b/tasprite_factory.py
@@ -646,16 +646,32 @@ class SVG:
"stroke-linecap:round;",
"stroke-opacity:1;\" />\n")
- def text(self, x, y, size, string):
+ def text(self, x, y, size, width, string):
self._x = x
self._y = y
self._check_min_max()
+ self._x = x+width
+ self._y = y-size
+ self._check_min_max()
return " %s%.1f%s%s%s%.1f%s%.1f%s%.1f%s%s%s%s%s" % (
"<text style=\"font-size:", size, "px;fill:", self._stroke,
";font-family:Sans\">\n <tspan x=\"", x, "\" y=\"", y,
"\" style=\"font-size:", size, "px;fill:", self._stroke, "\">",
string, "</tspan>\n </text>\n")
+ def image(self, x, y, w, h, path):
+ self._x = x
+ self._y = y
+ self._check_min_max()
+ self._x = x+w
+ self._y = y+h
+ self._check_min_max()
+ return " %s%.1f%s%.1f%s%.1f%s%.1f%s%s%s" % (
+ "<image x=\"", x, "\" y=\"", y,
+ "\" width=\"", w, "\" height=\"", h,
+ "\" xlink:href=\"", path, "\">\n")
+
+
def _circle(self, r, cx, cy):
return "%s%s%s%s%s%f%s%f%s%f%s" % ("<circle style=\"fill:",
self._fill, ";stroke:", self._stroke, ";\" r=\"", r, "\" cx=\"",
@@ -683,6 +699,7 @@ class SVG:
self._max_y = self._y
def line_to(self, x, y):
+ self._check_min_max()
if self._x == x and self._y == y:
return ""
else:
@@ -698,6 +715,7 @@ class SVG:
return self.line_to(self._x+dx, self._y+dy)
def arc_to(self, x, y, r, a=90, l=0, s=1):
+ self._check_min_max()
if r == 0:
return self.line_to(x, y)
else: