git @ Cat's Eye Technologies ALPACA / fdb7060
Don't have a background element, just insert all default elements. Chris Pressey 7 years ago
2 changed file(s) with 5 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
2222 --generations 30
2323
2424 Create a kinoje config file `life.yaml` like:
25
25
2626 duration: 3.0
2727 fps: 10.0
2828 width: 20
106106
107107 def to_svg(self, min_x, min_y, max_x, max_y, stylesheet=None):
108108 if stylesheet is None:
109 stylesheet = 'rect { fill: black } .SVGBackground { fill: white }'
109 stylesheet = 'rect { fill: white } .{} { fill: black }'.format(self.default)
110110 rects = []
111111 y = min_y
112112 while y is not None and y <= max_y:
113113 x = min_x
114114 while x <= max_x:
115115 state = self.get(x, y)
116 if state != self.default:
117 rects.append(
118 '<rect class="{}" x="{}" y="{}" width="1" height="1" />'.format(state, x, y)
119 )
116 rects.append(
117 '<rect class="{}" x="{}" y="{}" width="1" height="1" />'.format(state, x, y)
118 )
120119 x += 1
121120 y += 1
122121 return """\
126125 <style type="text/css">
127126 {}
128127 </style>
129 <rect class="SVGBackground" width="100%" height="100%" />
130128 {}
131129 </svg>""".format(min_x, min_y, max_x, max_y, stylesheet, '\n '.join(rects))