Configurable line color
authorW. Trevor King <wking@drexel.edu>
Sun, 28 Mar 2010 00:18:02 +0000 (20:18 -0400)
committerW. Trevor King <wking@drexel.edu>
Sun, 28 Mar 2010 00:18:02 +0000 (20:18 -0400)
pyrisk/graphics.py

index 6ca4aa22142f47732babe16ee80021c7c9364bc7..f171e0d24b8078c04bd7cc1f99479e63e8fe6e4f 100644 (file)
@@ -331,13 +331,14 @@ class WorldRenderer (object):
             self.template_lib = TEMPLATE_LIBRARY
         self.buf = buf
         self.line_width = line_width
+        self.line_color = 'black'
         self.dpcm = dpcm
     def render(self, world):
         template = self.template_lib.get(world.name)
         if template == None:
             template = self._auto_template(world)
-        return self.render_template(template)
-    def render_template(self, template):
+        return self.render_template(world, template)
+    def render_template(self, world, template):
         region_pos,width,height = self._locate(template)
         lines = [
             '<?xml version="1.0" standalone="no"?>',
@@ -353,8 +354,8 @@ class WorldRenderer (object):
         for r in template.regions:
             lines.extend([
                     '<!-- %s -->' % r.name,
-                    '<polygon fill="red" stroke="blue" stroke-width="%d"'
-                    % self.line_width,
+                    '<polygon fill="red" stroke="%s" stroke-width="%d"'
+                    % (self.line_color, self.line_width),
                     '         points="%s" />'
                     % ' '.join(['%d,%d' % ((region_pos[id(r)]+p)
                                            *(1,-1) # svg y value increases down
@@ -366,8 +367,8 @@ class WorldRenderer (object):
                     continue
                 drawn_rts[id(rt)] = rt
                 lines.extend([
-                        '<polyline stroke="black" stroke-width="%d"'
-                        % self.line_width,
+                        '<polyline stroke="%s" stroke-width="%d"'
+                        % (self.line_color, self.line_width),
                         '         points="%s" />'
                         % ' '.join(['%d,%d' % ((region_pos[id(r)]+rt_start+p)
                                            *(1,-1) # svg y value increases down