Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt/tasprite_factory.py
diff options
context:
space:
mode:
Diffstat (limited to 'TurtleArt/tasprite_factory.py')
-rwxr-xr-xTurtleArt/tasprite_factory.py134
1 files changed, 61 insertions, 73 deletions
diff --git a/TurtleArt/tasprite_factory.py b/TurtleArt/tasprite_factory.py
index 2b0e922..2c403b6 100755
--- a/TurtleArt/tasprite_factory.py
+++ b/TurtleArt/tasprite_factory.py
@@ -64,12 +64,16 @@ class SVG:
4 * self._stroke_width
self._porch_y = self._innie_y2
self._expand_x = 0
+ self._expand_x2 = 0
self._expand_y = 0
+ self._expand_y2 = 0
+ self._second_clamp = False
self._arm = True
self._else = False
self._draw_innies = True
self._hide = False
self._show = False
+ self._collapsible = False
self._show_x = 0
self._show_y = 0
self._hide_x = 0
@@ -426,76 +430,69 @@ class SVG:
svg = "%s%s%s%s%s%s%s%s" % (" <path d=\"M 27.5 48.3 ",
"C 26.9 48.3 26.4 48.2 25.9 48.2 L 27.2 50.5 L 28.6 48.2 ",
- "C 28.2 48.2 27.9 48.3 27.5 48.3 Z\" stroke_width=\"3.5\" ",
+ "C 28.2 48.2 27.9 48.3 27.5 48.3 Z\" stroke-width=\"3.5\" ",
"fill=\"", self._fill, ";\" stroke=\"", self._stroke,
"\" />\n")
svg += "%s%s%s%s%s%s%s%s%s%s" % (" <path d=\"M 40.2 11.7 ",
"C 38.0 11.7 36.2 13.3 35.8 15.3 ",
"C 37.7 16.7 39.3 18.4 40.5 20.5 ",
"C 42.8 20.4 44.6 18.5 44.6 16.2 ",
- "C 44.6 13.7 42.6 11.7 40.2 11.7 Z\" stroke_width=\"3.5\" ",
+ "C 44.6 13.7 42.6 11.7 40.2 11.7 Z\" stroke-width=\"3.5\" ",
"fill=\"", self._fill, ";\" stroke=\"", self._stroke, "\" />\n")
svg += "%s%s%s%s%s%s%s%s%s%s" % (" <path d=\"M 40.7 39.9 ",
"C 39.5 42.1 37.9 44.0 35.9 45.4 ",
"C 36.4 47.3 38.1 48.7 40.2 48.7 ",
"C 42.6 48.7 44.6 46.7 44.6 44.3 ",
- "C 44.6 42.0 42.9 40.2 40.7 39.9 Z\" stroke_width=\"3.5\" ",
+ "C 44.6 42.0 42.9 40.2 40.7 39.9 Z\" stroke-width=\"3.5\" ",
"fill=\"", self._fill, ";\" stroke=\"", self._stroke, "\" />\n")
svg += "%s%s%s%s%s%s%s%s%s%s" % (" <path d=\"M 14.3 39.9 ",
"C 12.0 40.1 10.2 42.0 10.2 44.3 ",
"C 10.2 46.7 12.2 48.7 14.7 48.7 ",
"C 16.7 48.7 18.5 47.3 18.9 45.4 ",
- "C 17.1 43.9 15.5 42.1 14.3 39.9 Z\" stroke_width=\"3.5\" ",
+ "C 17.1 43.9 15.5 42.1 14.3 39.9 Z\" stroke-width=\"3.5\" ",
"fill=\"", self._fill, ";\" stroke=\"", self._stroke, "\" />\n")
svg += "%s%s%s%s%s%s%s%s%s%s" % (" <path d=\"M 19.0 15.4 ",
"C 18.7 13.3 16.9 11.7 14.7 11.7 ",
"C 12.2 11.7 10.2 13.7 10.2 16.2 ",
"C 10.2 18.5 12.1 20.5 14.5 20.6 ",
- "C 15.7 18.5 17.2 16.8 19.0 15.4 Z\" stroke_width=\"3.5\" ",
- "fill=\"", self._fill, ";\" stroke=\"", self._stroke, "\" />\n")
- svg += "%s%s%s%s%s%s%s%s%s%s%s%s" % (" <path d=\"M 27.5 12.6 ",
- "C 29.4 12.6 31.2 13.0 32.9 13.7 ",
- "C 33.7 12.6 34.1 11.3 34.1 9.9 ",
- "C 34.1 6.2 31.1 3.2 27.4 3.2 ",
- "C 23.7 3.2 20.7 6.2 20.7 9.9 ",
- "C 20.7 11.3 21.2 12.7 22.0 13.7 ",
- "C 23.7 13.0 25.5 12.6 27.5 12.6 Z\" stroke_width=\"3.5\" ",
+ "C 15.7 18.5 17.2 16.8 19.0 15.4 Z\" stroke-width=\"3.5\" ",
"fill=\"", self._fill, ";\" stroke=\"", self._stroke, "\" />\n")
+ svg += '<path d="m 27.497,12.563 c 1.908,0 3.728,0.411 5.418,1.128 C 33.656,12.615 34.847526,11.272713 34.25,10 32.953704,7.2389259 31.1875,2.305074 27.5,2.305074 c -3.6875,0 -5.083333,4.9338519 -6.75,7.694926 -0.73796,1.222538 0.442,2.657 1.206,3.742 1.724,-0.749 3.587,-1.179 5.541,-1.179 z" style="fill:%s;stroke:%s;stroke-width:3.5" />' % (self._fill, self._stroke)
svg += "%s%s%s%s%s%s%s%s%s%s%s%s" % (" <path d=\"M 43.1 30.4 ",
"C 43.1 35.2 41.5 39.7 38.5 43.0 ",
"C 35.6 46.4 31.6 48.3 27.5 48.3 ",
"C 23.4 48.3 19.4 46.4 16.5 43.0 ",
"C 13.5 39.7 11.9 35.2 11.9 30.4 ",
"C 11.9 20.6 18.9 12.6 27.5 12.6 ",
- "C 36.1 12.6 43.1 20.6 43.1 30.4 Z\" stroke_width=\"3.5\" ",
+ "C 36.1 12.6 43.1 20.6 43.1 30.4 Z\" stroke-width=\"3.5\" ",
"fill=\"", self._fill, ";\" stroke=\"", self._stroke, "\" />\n")
svg += "%s%s%s%s%s" % (" <path d=\"M 25.9 33.8 L 24.3 29.1 ",
- "L 27.5 26.5 L 31.1 29.2 L 29.6 33.8 Z\" stroke_width=\"3.5\" ",
+ "L 27.5 26.5 L 31.1 29.2 L 29.6 33.8 Z\" stroke-width=\"3.5\" ",
"fill=\"", self._stroke, ";\" stroke=\"none\" />\n")
svg += "%s%s%s%s%s%s" % (" <path d=\"M 27.5 41.6 ",
"C 23.5 41.4 22.0 39.5 22.0 39.5 L 25.5 35.4 L 30.0 35.5 ",
"L 33.1 39.7 C 33.1 39.7 30.2 41.7 27.5 41.6 Z\" ",
- "stroke_width=\"3.5\" fill=\"", self._stroke,
+ "stroke-width=\"3.5\" fill=\"", self._stroke,
";\" stroke=\"none\" />\n")
svg += "%s%s%s%s%s%s" % (" <path d=\"M 18.5 33.8 ",
"C 17.6 30.9 18.6 27.0 18.6 27.0 L 22.6 29.1 L 24.1 33.8 ",
"L 20.5 38.0 C 20.5 38.0 19.1 36.0 18.4 33.8 Z\" ",
- "stroke_width=\"3.5\" fill=\"", self._stroke,
+ "stroke-width=\"3.5\" fill=\"", self._stroke,
";\" stroke=\"none\" />\n")
svg += "%s%s%s%s%s%s" % (" <path d=\"M 19.5 25.1 ",
"C 19.5 25.1 20.0 23.2 22.5 21.3 ",
"C 24.7 19.7 27.0 19.6 27.0 19.6 L 26.9 24.6 L 23.4 27.3 ",
- "L 19.5 25.1 Z\" stroke_width=\"3.5\" fill=\"", self._stroke,
+ "L 19.5 25.1 Z\" stroke-width=\"3.5\" fill=\"", self._stroke,
";\" stroke=\"none\" />\n")
svg += "%s%s%s%s%s%s" % (" <path d=\"M 32.1 27.8 L 28.6 25.0 ",
"L 29 19.8 C 29 19.8 30.8 19.7 33.0 21.4 ",
"C 35.2 23.2 36.3 26.4 36.3 26.4 L 32.1 27.8 Z\" ",
- "stroke_width=\"3.5\" fill=\"", self._stroke,
+ "stroke-width=\"3.5\" fill=\"", self._stroke,
";\" stroke=\"none\" />\n")
svg += "%s%s%s%s%s%s" % (" <path d=\"M 31.3 34.0 L 32.6 29.6 ",
"L 36.8 28.0 C 36.8 28.0 37.5 30.7 36.8 33.7 ",
"C 36.2 36.0 34.7 38.1 34.7 38.1 L 31.3 34.0 Z\" ",
- "stroke_width=\"3.5\" fill=\"", self._stroke,
+ "stroke-width=\"3.5\" fill=\"", self._stroke,
";\" stroke=\"none\" />\n")
self._width, self._height = 55, 55
svg += self.footer()
@@ -522,9 +519,10 @@ class SVG:
svg += self.footer()
return self.header() + svg
- def sandwich_top(self, innie_flag=True):
- ''' Special block for the top of a collapsible stack; includes
- an 'arm" that extends down the left side of a stack '''
+ def clamp(self):
+ ''' Special block for collapsible stacks; includes an 'arm"
+ that extends down the left side of a stack and a bottom jaw to
+ clamp the blocks. '''
self.reset_min_max()
x = self._stroke_width / 2.0
y = self._stroke_width / 2.0 + self._radius
@@ -534,64 +532,46 @@ class SVG:
self.margins[3] = 0
svg = self.new_path(x, y)
svg += self._corner(1, -1)
- svg += self._rline_to(self._radius + self._stroke_width, 0)
svg += self._do_slot()
+ svg += self._rline_to(self._radius + self._stroke_width, 0)
svg += self._rline_to(self._expand_x, 0)
xx = self._x
svg += self._corner(1, 1)
- if innie_flag:
+ if self._innie[0] is True:
svg += self._do_innie()
+ else:
+ self.margins[2] = \
+ int((self._x - self._stroke_width + 0.5) * self._scale)
+ if self._bool is True:
+ svg += self._do_boolean()
svg += self._corner(-1, 1)
svg += self.line_to(xx, self._y)
svg += self._rline_to(-self._expand_x, 0)
svg += self._do_tab()
- if self._arm:
- svg += self._inverse_corner(-1, 1, 90, 0, 0)
- svg += self._rline_to(0, self._expand_y)
- svg += self._rline_to(-self._radius, 0)
- else:
- svg += self._rline_to(-self._radius - self._stroke_width, 0)
- svg += self._corner(-1, -1)
- svg += self._close_path()
- self.calc_w_h()
- svg += self.style()
- if self._show is True:
- svg += self._show_dot()
- if self._hide is True:
- svg += self._hide_dot()
- svg += self.footer()
- return self.header() + svg
-
- def sandwich_bottom(self):
- ''' Special block for the bottom of a collapsible stack;
- includes a connection to the 'arm" that extends down the left
- side of a stack '''
- self.reset_min_max()
- x = self._stroke_width / 2.0
- y = self._stroke_width / 2.0
- self.margins[0] = int((x + self._stroke_width + 0.5) * self._scale)
- self.margins[1] = int((self._stroke_width + 0.5) * self._scale)
- self.margins[2] = 0
- self.margins[3] = 0
- svg = self.new_path(x, y)
- svg += self._rline_to(self._radius, 0)
+ svg += self._inverse_corner(-1, 1, 90, 0, 0)
svg += self._rline_to(0, self._expand_y)
svg += self._inverse_corner(1, 1, 90, 0, 0)
svg += self._do_slot()
svg += self._rline_to(self._radius, 0)
+ if self._second_clamp:
+ svg += self._corner(-1, 1)
+ svg += self.line_to(xx, self._y)
+ svg += self._rline_to(-self._expand_x, 0)
+ svg += self._do_tab()
+ svg += self._inverse_corner(-1, 1, 90, 0, 0)
+ svg += self._rline_to(0, self._expand_y2)
+ svg += self._inverse_corner(1, 1, 90, 0, 0)
+ svg += self._do_slot()
+ svg += self._rline_to(self._radius, 0)
svg += self._corner(-1, 1)
- svg += self._do_tab()
svg += self._rline_to(-self._radius - self._stroke_width, 0)
+ svg += self._do_tab()
svg += self._corner(-1, -1)
svg += self._close_path()
self.calc_w_h()
svg += self.style()
- self._hide_x = x + self._radius / 2
- self._hide_y = y + self._radius / 2
- if self._hide is True:
+ if self._collapsible:
svg += self._hide_dot()
- if self._show is True:
- svg += self._show_dot()
svg += self.footer()
return self.header() + svg
@@ -635,6 +615,9 @@ class SVG:
def set_show(self, flag=False):
self._show = flag
+ def set_collapsible(self, flag=False):
+ self._collapsible = flag
+
def get_width(self):
return self._width
@@ -656,9 +639,14 @@ class SVG:
def set_orientation(self, orientation=0):
self._orientation = orientation
- def expand(self, w=0, h=0):
+ def second_clamp(self, flag=False):
+ self._second_clamp = flag
+
+ def expand(self, w=0, h=0, w2=0, h2=0):
self._expand_x = w
self._expand_y = h
+ self._expand_x2 = w2
+ self._expand_y2 = h2
def set_stroke_width(self, stroke_width=1.5):
self._stroke_width = stroke_width
@@ -1011,8 +999,8 @@ class SVG:
self._rline_to(0, -self._slot_y))
elif self._cap is True:
return "%s%s" % (
- self._rline_to(self._slot_x / 2.0, -self._slot_y * 2.0),
- self._rline_to(self._slot_x / 2.0, self._slot_y * 2.0))
+ self._rline_to(self._slot_x / 2.0, -self._slot_y * 3.0),
+ self._rline_to(self._slot_x / 2.0, self._slot_y * 3.0))
else:
return self._rline_to(self._slot_x, 0)
@@ -1021,8 +1009,8 @@ class SVG:
return self._rline_to(-self._slot_x, 0)
elif self._tail:
return "%s%s" % (
- self._rline_to(-self._slot_x / 2.0, self._slot_y * 2.0),
- self._rline_to(-self._slot_x / 2.0, -self._slot_y * 2.0))
+ self._rline_to(-self._slot_x / 2.0, self._slot_y * 3.0),
+ self._rline_to(-self._slot_x / 2.0, -self._slot_y * 3.0))
else:
return self._rline_to(-self._slot_x, 0)
@@ -1167,8 +1155,8 @@ class SVG:
x += self._innie_x1 + self._innie_x2
self.margins[0] += self._innie_x1 + self._innie_x2
if self._cap is True:
- y += self._slot_y * 2.0
- self.margins[1] += self._slot_y * 2.0
+ y += self._slot_y * 3.0
+ self.margins[1] += self._slot_y * 3.0
elif self._slot is True:
self.margins[1] += self._slot_y
self.margins[0] *= self._scale
@@ -1190,13 +1178,13 @@ def close_file(f):
def generator(datapath):
svg0 = SVG()
- f = open_file(datapath, "basic.svg")
- svg0.set_innie([True, True])
+ f = open_file(datapath, "clamp.svg")
svg0.set_scale(2)
- svg0.set_tab(True)
- svg0.set_slot(True)
svg0.set_arm(True)
- svg_str = svg0.basic_block()
+ svg0.expand(0, 0, 0, 21)
+ svg0.set_collapsible(True)
+ svg0.set_hide(True)
+ svg_str = svg0.clamp()
f.write(svg_str)
close_file(f)