Files
        @ 36b0271e7393
    
        
              Branch filter: 
        
    Location: Diana/src/diana/drawer/tikz.py - annotation
        
            
            36b0271e7393
            1.3 KiB
            text/x-python
        
        
    
    more lenient and robust error handling
    | 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 616c96178973 | 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
 |