Changeset - fdd10bc51cf8
[Not reviewed]
default
0 3 0
Laman - 6 years ago 2019-05-29 16:34:11

optional background color
3 files changed with 8 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/diana/drawer/svg.py
Show inline comments
 
@@ -30,20 +30,22 @@ class Svg(Base):
 
		self.boardSize=480
 
		self.padding=30
 

	
 
	def render(self, templateName):
 
	def render(self,templateName,bgcolor=""):
 
		points = [p for (i,p) in sorted(self._index.values(), key=lambda x: x[0])]
 

	
 
		stones = [p for p in points if p.color and p.label==""]
 
		moves = [p for p in points if p.color and p.label]
 
		labels = [p for p in points if not p.color and p.label]
 

	
 
		params = {"boardSize":self.boardSize, "padding":self.padding, "stones":stones, "moves":moves, "labels":labels, "adjustFont":adjustFont}
 
		params = {
 
			"boardSize":self.boardSize, "padding":self.padding, "stones":stones, "moves":moves,
 
			"labels":labels, "adjustFont":adjustFont, "bgcolor":bgcolor}
 

	
 
		return self._env.get_template(templateName).render(params)
 

	
 
	def save(self,filename,template="templ.svg"):
 
	def save(self,filename,template="templ.svg",bgcolor=""):
 
		file=open(filename+".svg",'w')
 
		file.write(self.render(template))
 
		file.write(self.render(template,bgcolor))
 
		file.close()
 

	
 
		super().save(filename)
src/diana/templ/templ-pleb.svg
Show inline comments
 
{% extends "templ.svg" %}
 

	
 
{% block style %}
 
rect{fill:white;stroke:black;stroke-width:1px}
 
rect{fill:{{bgcolor or "white"}};stroke:black;stroke-width:1px}
 
text{font-family:"DejaVu Sans";text-anchor:middle;}
 
line{stroke:black;stroke-width:0.7px}
 
circle{stroke:black}
src/diana/templ/templ.svg
Show inline comments
 
@@ -15,7 +15,7 @@
 
	<defs>
 
		<style type="text/css"><![CDATA[
 
		{% block style %}
 
			rect{fill:white;stroke:black;stroke-width:1px}
 
			rect{fill:{{bgcolor or "white"}};stroke:black;stroke-width:1px}
 
			text{font-family:"DejaVu Sans";text-anchor:middle}
 
			line{stroke:black;stroke-width:0.7px}
 
			circle{stroke:black}
0 comments (0 inline, 0 general)