Files
@ 0145cf4869b6
Branch filter:
Location: Diana/src/diana/drawer/tikz.py - annotation
0145cf4869b6
1.3 KiB
text/x-python
SVG slightly better rendering in nomacs
616c96178973 686166c7d5bc 686166c7d5bc 686166c7d5bc 616c96178973 d57d0d4ede15 616c96178973 616c96178973 686166c7d5bc 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 686166c7d5bc 616c96178973 616c96178973 686166c7d5bc 686166c7d5bc 616c96178973 686166c7d5bc 616c96178973 616c96178973 616c96178973 616c96178973 d57d0d4ede15 686166c7d5bc 686166c7d5bc 616c96178973 d57d0d4ede15 686166c7d5bc d57d0d4ede15 d57d0d4ede15 686166c7d5bc 616c96178973 d57d0d4ede15 616c96178973 d57d0d4ede15 616c96178973 | class Tikz:
content = ""
footer = ""
extension = "tex"
high_numbers = 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);
'''
# 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.footer = r'\end{tikzpicture}' '\n'
def __str__(self):
return self.content+self.footer
def draw_stone(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 draw_move(self, x, y, label, color):
fill = "black" if color == "b" else "white"
label_color = "white" if color == "b" else "black"
if (not self.high_numbers) 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, label_color, label)+'\n'
def get_content(self):
return self.content+self.footer
|