diff --git a/src/lattice.py b/src/lattice.py index 2f06706..06b08d8 100644 --- a/src/lattice.py +++ b/src/lattice.py @@ -34,5 +34,5 @@ class Square_lattice(Lattice): # draw def draw(self,painter): - painter.draw_grid(Point(0,0),self.spacing) + painter.draw_grid(Point(self.spacing/2,self.spacing/2),self.spacing) diff --git a/src/painter.py b/src/painter.py index 8a9fd02..45445d2 100644 --- a/src/painter.py +++ b/src/painter.py @@ -22,8 +22,7 @@ class Painter(Widget): self.particles=[] # underlying lattice - #self.lattice=None - self.lattice=Square_lattice() + self.lattice=None # particle under mouse self.undermouse=None @@ -96,17 +95,30 @@ class Painter(Widget): # height offset due to status bar and command prompt height_offset=self.app.status_bar.height+self.app.command_prompt.height # vertical lines - # offest wrt 0 - offset=(pos.x-0.5)%mesh - for i in range(math.floor((self.width/Square_element.size-offset)/mesh)+1): + # lines right of pos + xx=pos.x+mesh/2 + while self.pos_tocoord_x(xx)0: Color(1,1,1) - Line(points=(0,(i*mesh+offset)*Square_element.size+height_offset,self.width,(i*mesh+offset)*Square_element.size+height_offset)) + Line(points=(self.pos_tocoord_x(xx),height_offset,self.pos_tocoord_x(xx),self.height+height_offset)) + xx-=mesh + # lines above pos + yy=pos.y+mesh/2 + while self.pos_tocoord_y(yy)0: + Color(1,1,1) + Line(points=(0,self.pos_tocoord_y(yy),self.width,self.pos_tocoord_y(yy))) + yy-=mesh # respond to keyboard