diff --git a/src/drawer/svg.py b/src/drawer/svg.py --- a/src/drawer/svg.py +++ b/src/drawer/svg.py @@ -1,3 +1,6 @@ +from itertools import count + + c=28 padding=15 highNumbers=True @@ -32,21 +35,22 @@ class Svg: self.padding=30 self._index=dict() + self._indexGen=count() def addStone(self,x,y,color): - self._index[(x,y)]=(len(self._index),DiagramPoint(x,y,color)) + self._index[(x,y)]=(next(self._indexGen),DiagramPoint(x,y,color)) def addMove(self,x,y,color,label): if (not self.highNumbers) and isinstance(label,int) and label%100!=0: label%=100 - self._index[(x,y)]=(len(self._index),DiagramPoint(x,y,color,label)) + self._index[(x,y)]=(next(self._indexGen),DiagramPoint(x,y,color,label)) def addLabel(self,x,y,label): - self._index[(x,y)]=(len(self._index),DiagramPoint(x,y,"",label)) + self._index[(x,y)]=(next(self._indexGen),DiagramPoint(x,y,"",label)) def render(self, template): - points = [p for (i,p) in sorted(self._index.values())] + 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 not p.label] moves = [p for p in points if p.color and p.label]