diff --git a/src/diana/drawer/tikz.py b/src/diana/drawer/tikz.py --- a/src/diana/drawer/tikz.py +++ b/src/diana/drawer/tikz.py @@ -1,38 +1,39 @@ class Tikz: - content="" - footer="" - extension="tex" + content = "" + footer = "" + extension = "tex" - highNumbers=True + highNumbers = True def __init__(self): - self.content=r'''\begin{tikzpicture} + 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 + # stars 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.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' + 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 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 + 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 - 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' + 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