Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sprite_factory.py
diff options
context:
space:
mode:
authorWalter Bender <walter@walter-laptop.(none)>2010-01-25 16:56:33 (GMT)
committer Walter Bender <walter@walter-laptop.(none)>2010-01-25 16:56:33 (GMT)
commitc223f72fc567756fa317450a3701657bcd1050c0 (patch)
treeb349e8fcfee7979e5d9524d65e90c9e15ce652bd /sprite_factory.py
parent29a05850d56fb53420d1b995bde050ef5a957739 (diff)
toolbar palettes--a beginning
Diffstat (limited to 'sprite_factory.py')
-rwxr-xr-xsprite_factory.py30
1 files changed, 24 insertions, 6 deletions
diff --git a/sprite_factory.py b/sprite_factory.py
index cd15be0..7710429 100755
--- a/sprite_factory.py
+++ b/sprite_factory.py
@@ -236,7 +236,7 @@ class SVG:
svg += self._rect(3, 3, 36, 36)
self._fill, self._stroke = "#008000", "#008000"
svg += self._turtle_body()
- self._fill, self._stroke = "#00a000", "#00a000"
+ self._fill, self._stroke = "#00A000", "#00A000"
svg += self._turtle_shell()
self._fill, self._stroke = "#000000", "#000000"
svg += self._circle(1.25,32.5,8)
@@ -246,6 +246,13 @@ class SVG:
# TODO: Add orientation
return self._header() + svg
+ def palette(self, width, height):
+ self._fill, self._stroke = "#282828", "none"
+ self._width, self._height = width, height
+ svg = self._rect(width, height, 0, 0)
+ svg += self._footer()
+ return self._header() + svg
+
#
# Utility methods
#
@@ -352,7 +359,7 @@ class SVG:
"<svg\n",
" xmlns:svg=\"http://www.w3.org/2000/svg\"\n",
" xmlns=\"http://www.w3.org/2000/svg\"\n",
- " xmlns:xlink=\"http://www.w3.org/1999/xlink\"",
+ " xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n",
" version=\"1.1\"\n",
" width=\"", self._width, "\"\n",
" height=\"", self._height, "\">\n",
@@ -401,20 +408,20 @@ class SVG:
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=\"",
- cx, "\" cy=\"", cy, "\" />")
+ cx, "\" cy=\"", cy, "\" />\n")
def _rect(self, w, h, x, y):
return "%s%s%s%s%s%f%s%f%s%f%s%f%s" % ("<rect style=\"fill:",
self._fill, ";stroke:", self._stroke, ";\" width=\"", w,
- "\" height=\"", h,"\" x=\"", x, "\" y=\"", y, "\" />")
+ "\" height=\"", h,"\" x=\"", x, "\" y=\"", y, "\" />\n")
def _turtle_body(self):
return "%s%s%s%s%s" % ("<path style=\"", self._fill, ";stroke:",
- self._stroke, "\" d=\"M 20,42 C 21,41 23,40 24,40 C 24,39 24,40 26,41 C 28,43 31,43 34,41 C 35,40 35,39 36,40 C 36,40 38,41 39,42 C 41,42 45,43 46,43 C 47,43 46,41 43,39 L 39,36 L 42,34 C 44,30 45,28 43,25 L 41,22 L 46,18 C 48,16 47.5,13.5 47,13 C 46.5,12.5 46,13 45,13 C 44,13 43.5,14 42.5,15 C 39.5,17 40,18 37,17 C 32,16 31.5,15 34.5,12 C 36.5,10 36,7 34,6 C 32,3 28,4 26,6 C 24,8 23,10 25,12 C 28,15 27,16 22,17 C 18,18 19,17 17,15 C 16,14 16,13 15,13 C 14,13 13,13 13,13 C 12,13 11,16 14,18 L 19,22 L 17,25 C 15,28 16,30 18,34 L 20,36 L 16,39 C 13,41 12,43 13,43 C 14,43 18,42 20,42 z M 30,18 C 32,18 36,19 38,20 C 40,22 39.5,25 39.5,28 C 39.5,30 40,32.5 38.5,35 C 37,36.5 36.5,37.5 35,38 C 33.5,38.5 31,39 30,39 C 28,39 26,39 25,38 C 23,37 22.5,37 21.5,35 C 20.5,33 20.5,30 20.5,28 C 20.5,25 20,22 22,20 C 24,19 27,18 30,18 z\" />")
+ self._stroke, "\" d=\"M 20,42 C 21,41 23,40 24,40 C 24,39 24,40 26,41 C 28,43 31,43 34,41 C 35,40 35,39 36,40 C 36,40 38,41 39,42 C 41,42 45,43 46,43 C 47,43 46,41 43,39 L 39,36 L 42,34 C 44,30 45,28 43,25 L 41,22 L 46,18 C 48,16 47.5,13.5 47,13 C 46.5,12.5 46,13 45,13 C 44,13 43.5,14 42.5,15 C 39.5,17 40,18 37,17 C 32,16 31.5,15 34.5,12 C 36.5,10 36,7 34,6 C 32,3 28,4 26,6 C 24,8 23,10 25,12 C 28,15 27,16 22,17 C 18,18 19,17 17,15 C 16,14 16,13 15,13 C 14,13 13,13 13,13 C 12,13 11,16 14,18 L 19,22 L 17,25 C 15,28 16,30 18,34 L 20,36 L 16,39 C 13,41 12,43 13,43 C 14,43 18,42 20,42 z M 30,18 C 32,18 36,19 38,20 C 40,22 39.5,25 39.5,28 C 39.5,30 40,32.5 38.5,35 C 37,36.5 36.5,37.5 35,38 C 33.5,38.5 31,39 30,39 C 28,39 26,39 25,38 C 23,37 22.5,37 21.5,35 C 20.5,33 20.5,30 20.5,28 C 20.5,25 20,22 22,20 C 24,19 27,18 30,18 z\" />\n")
def _turtle_shell(self):
return "%s%s%s%s%s" % ("<path style=\"", self._fill, ";stroke:",
- self._stroke, "\" d=\"M 33,10 C 33,11 31.5,12 30,12 C 28,12 27,11 27,10 C 27,9 28,8 30,8 C 31.5,8 33,9 33,10 z\" />")
+ self._stroke, "\" d=\"M 33,10 C 33,11 31.5,12 30,12 C 28,12 27,11 27,10 C 27,9 28,8 30,8 C 31.5,8 33,9 33,10 z\" />\n")
def _check_min_max(self):
if self._x < self._min_x:
@@ -605,6 +612,14 @@ def close_file(f):
def generator(datapath):
svg0 = SVG()
+ f = open_file(datapath, "palette-test.svg")
+ svg_str = svg0.palette(600,75)
+ f.write(svg_str)
+ close_file(f)
+
+
+ """
+ svg0 = SVG()
f = open_file(datapath, "flow-test.svg")
svg0.set_scale(1)
svg0.expand(20,0)
@@ -615,6 +630,7 @@ def generator(datapath):
svg_str = svg0.basic_flow()
f.write(svg_str)
close_file(f)
+ """
svg1 = SVG()
f = open_file(datapath, "blob-test.svg")
@@ -627,6 +643,7 @@ def generator(datapath):
f.write(svg_str)
close_file(f)
+ """
svg2 = SVG()
f = open_file(datapath, "box-test.svg")
svg2.set_scale(1)
@@ -664,6 +681,7 @@ def generator(datapath):
svg_str = svg5.boolean_not()
f.write(svg_str)
close_file(f)
+ """
def main():
return 0