From 1cd4e0fdc6baeeb8eef346f40c02cf4c381821c4 Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Thu, 22 Feb 2024 17:08:42 -0500 Subject: [PATCH] Fix lattice_points for disk --- src/element.py | 2 +- src/painter.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/element.py b/src/element.py index 87b4211..38dd650 100644 --- a/src/element.py +++ b/src/element.py @@ -290,7 +290,7 @@ class Element_circle(Element): dx=math.floor(0.5*self.size/lattice.spacing) for i in range(-dx,dx+1): for j in range(-dx,dx+1): - if i*i+j*j<=2*dx*dx: + if lattice.spacing*lattice.spacing*(i*i+j*j)<=self.size*self.size/4: out.append(Point(self.pos.x+i*lattice.spacing,self.pos.y+j*lattice.spacing)) return out diff --git a/src/painter.py b/src/painter.py index 264165e..9701023 100644 --- a/src/painter.py +++ b/src/painter.py @@ -212,7 +212,7 @@ class Painter(Widget): if count==0: return Color(color[0],color[1],color[2],1-count*0.1) - Rectangle(pos=(self.pos_tocoord_x(x-0.5),self.pos_tocoord_y(y-0.5)),size=(self.base_size,self.base_size)) + Rectangle(pos=(self.pos_tocoord_x(x-0.5*self.lattice.spacing),self.pos_tocoord_y(y-0.5*self.lattice.spacing)),size=(self.base_size*self.lattice.spacing,self.base_size*self.lattice.spacing))