diff --git a/src/diana.py b/src/diana.py
--- a/src/diana.py
+++ b/src/diana.py
@@ -5,6 +5,9 @@ import sys
import go
import sgf
+from drawer.svg import Svg
+from drawer.tikz import Tikz
+
if len(sys.argv)>1:
files=sys.argv[1:]
else:
@@ -14,126 +17,15 @@ movesPerDiagram=75
minMovesPerDiagram=10
t=sys.stdout
-c=28
-padding=15
-highNumbers=True
-
-class Svg:
- content=""
- footer=""
- extension="svg"
-
- padding=15
- gridSize=28
- highNumbers=True
-
- def __init__(self):
- self.content='''
-\n"
-
- grid=' \n'
-
- # okraje desky
- for i in (0,18):
- self.content+=' \n'.format(self.padding, 18*self.gridSize+self.padding, self.gridSize*i+self.padding, self.gridSize*i+self.padding)
- self.content+=' \n'.format(self.gridSize*i+self.padding, self.gridSize*i+self.padding, self.padding, 18*self.gridSize+self.padding)
-
- # mřížka
- for i in range(1,18):
- self.content+=grid.format(padding, 18*c+padding, c*i+padding, c*i+padding)
- self.content+=grid.format(c*i+padding, c*i+padding, padding, 18*c+padding)
-
- # hvězdy
- for i in range(3):
- for j in range(3):
- self.content+=' \n'.format(padding+3*c+6*i*c, padding+3*c+6*j*c, 2)
-
- def __str__(self):
- return self.content+self.footer
-
- def drawStone(self,x,y,color):
- self.content+=' \n'.format(padding+x*c, padding+y*c, c/2-1, color)
-
- def getFontSize(self,text):
- if len(text)<2: return round(0.7*c)
- elif len(text)<3: return round(0.55*c)
- else: return round(0.4*c)
-
- def writeLabel(self,x,y,label,color):
- label=str(label)
- fontSize=self.getFontSize(label)
- self.content+=' {4}\n'.format(padding+x*c, padding+y*c+0.35*fontSize, color, fontSize, label)
-
- def drawMove(self,x,y,label,color):
- labelColor="w" if color=="b" else "b"
-
- if (not self.highNumbers) and isinstance(label,int) and label%100!=0: label=label%100 # dost neobratná logika
-
- self.drawStone(x,y,color)
- self.writeLabel(x,y,label,labelColor)
-
- def getContent(self):
- return self.content+self.footer
-
-
-class Tikz:
- content=""
- footer=""
- extension="tex"
-
- highNumbers=True
-
- def __init__(self):
- self.content=r'''\begin{tikzpicture}
- \draw[step=\boardSquare,gray,very thin] (0,0) grid (18\boardSquare,18\boardSquare);
- \draw (0,0) rectangle (18\boardSquare,18\boardSquare);
-
- '''
-
- # hvězdy
- for i in range(3):
- for j in range(3):
- self.content+=r''' \filldraw[fill=black] ({0}\boardSquare,{1}\boardSquare) circle[radius=0.04];'''.format(6*i+3, 6*j+3)+'\n'
- self.content+='\n'
-
- self.footer=r'\end{tikzpicture}' '\n'
-
- def __str__(self):
- return self.content+self.footer
-
- def drawStone(self,x,y,color):
- fill="black" if color=="b" else "white"
- self.content+=r' \filldraw[draw=black,fill={0}] ({1}\boardSquare,{2}\boardSquare) circle[radius=0.5\boardSquare];'.format(fill,x,18-y)+'\n'
-
- def drawMove(self,x,y,label,color):
- fill="black" if color=="b" else "white"
- labelColor="white" if color=="b" else "black"
- if (not self.highNumbers) and isinstance(label,int) and label%100!=0: label=label%100 # dost neobratná logika
-
- self.content+=r' \filldraw[draw=black,fill={0}] ({1}\boardSquare,{2}\boardSquare) circle[radius=0.5\boardSquare] node[color={3}]{{{4}}};'.format(fill,x,18-y,labelColor,label)+'\n'
-
- def getContent(self):
- return self.content+self.footer
def processFile(fileName):
shortName="".join(re.split(r'[/\\]',fileName)[-1].split('.')[:-1])
- game= go.Go()
+ game=go.Go()
global t
- record= sgf.Sgf(open(fileName, 'r', encoding="utf-8").read())
+ record=sgf.Sgf(open(fileName, 'r', encoding="utf-8").read())
moves=record.getMoves()
localBoard=dict()
diff --git a/src/drawer/__init__.py b/src/drawer/__init__.py
new file mode 100644
diff --git a/src/drawer/svg.py b/src/drawer/svg.py
new file mode 100644
--- /dev/null
+++ b/src/drawer/svg.py
@@ -0,0 +1,72 @@
+c=28
+padding=15
+highNumbers=True
+
+
+class Svg:
+ content=""
+ footer=""
+ extension="svg"
+
+ padding=15
+ gridSize=28
+ highNumbers=True
+
+ def __init__(self):
+ self.content='''
+\n"
+
+ grid=' \n'
+
+ # okraje desky
+ for i in (0,18):
+ self.content+=' \n'.format(self.padding, 18*self.gridSize+self.padding, self.gridSize*i+self.padding, self.gridSize*i+self.padding)
+ self.content+=' \n'.format(self.gridSize*i+self.padding, self.gridSize*i+self.padding, self.padding, 18*self.gridSize+self.padding)
+
+ # mřížka
+ for i in range(1,18):
+ self.content+=grid.format(self.padding, 18*self.gridSize+self.padding, c*i+self.padding, c*i+self.padding)
+ self.content+=grid.format(c*i+self.padding, c*i+self.padding, self.padding, 18*c+self.padding)
+
+ # hvězdy
+ for i in range(3):
+ for j in range(3):
+ self.content+=' \n'.format(padding+3*c+6*i*c, padding+3*c+6*j*c, 2)
+
+ def __str__(self):
+ return self.content+self.footer
+
+ def drawStone(self,x,y,color):
+ self.content+=' \n'.format(padding+x*c, padding+y*c, c/2-1, color)
+
+ def getFontSize(self,text):
+ if len(text)<2: return round(0.7*c)
+ elif len(text)<3: return round(0.55*c)
+ else: return round(0.4*c)
+
+ def writeLabel(self,x,y,label,color):
+ label=str(label)
+ fontSize=self.getFontSize(label)
+ self.content+=' {4}\n'.format(padding+x*c, padding+y*c+0.35*fontSize, color, fontSize, label)
+
+ def drawMove(self,x,y,label,color):
+ labelColor="w" if color=="b" else "b"
+
+ if (not self.highNumbers) and isinstance(label,int) and label%100!=0: label=label%100 # dost neobratná logika
+
+ self.drawStone(x,y,color)
+ self.writeLabel(x,y,label,labelColor)
+
+ def getContent(self):
+ return self.content+self.footer
diff --git a/src/drawer/tikz.py b/src/drawer/tikz.py
new file mode 100644
--- /dev/null
+++ b/src/drawer/tikz.py
@@ -0,0 +1,38 @@
+class Tikz:
+ content=""
+ footer=""
+ extension="tex"
+
+ highNumbers=True
+
+ def __init__(self):
+ self.content=r'''\begin{tikzpicture}
+ \draw[step=\boardSquare,gray,very thin] (0,0) grid (18\boardSquare,18\boardSquare);
+ \draw (0,0) rectangle (18\boardSquare,18\boardSquare);
+
+ '''
+
+ # hvězdy
+ for i in range(3):
+ for j in range(3):
+ self.content+=r''' \filldraw[fill=black] ({0}\boardSquare,{1}\boardSquare) circle[radius=0.04];'''.format(6*i+3, 6*j+3)+'\n'
+ self.content+='\n'
+
+ self.footer=r'\end{tikzpicture}' '\n'
+
+ def __str__(self):
+ return self.content+self.footer
+
+ def drawStone(self,x,y,color):
+ fill="black" if color=="b" else "white"
+ self.content+=r' \filldraw[draw=black,fill={0}] ({1}\boardSquare,{2}\boardSquare) circle[radius=0.5\boardSquare];'.format(fill,x,18-y)+'\n'
+
+ def drawMove(self,x,y,label,color):
+ fill="black" if color=="b" else "white"
+ labelColor="white" if color=="b" else "black"
+ if (not self.highNumbers) and isinstance(label,int) and label%100!=0: label=label%100 # dost neobratná logika
+
+ self.content+=r' \filldraw[draw=black,fill={0}] ({1}\boardSquare,{2}\boardSquare) circle[radius=0.5\boardSquare] node[color={3}]{{{4}}};'.format(fill,x,18-y,labelColor,label)+'\n'
+
+ def getContent(self):
+ return self.content+self.footer