From 2a4654370269d406a5edba33c6f818485279bfe8 Mon Sep 17 00:00:00 2001 From: "A.M. Rowsell" Date: Tue, 19 Nov 2024 06:47:00 -0500 Subject: [PATCH] Added theta multiplier feature in GUI --- spirographs.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/spirographs.py b/spirographs.py index 0fc2301..cbe5d20 100644 --- a/spirographs.py +++ b/spirographs.py @@ -24,7 +24,7 @@ class spirographs: self.bigRadius = 12 self.smallRadius = 5 self.distance = 4 - self.rotations = 8 + self.rotations = 2 self.highestTheta = (np.lcm(self.smallRadius, self.bigRadius)/self.bigRadius) * self.rotations * math.pi self.stepSize = self.highestTheta / 4096 # update initial slider positions @@ -107,6 +107,24 @@ class spirographs: return self.distanceAdjustment.set_value(self.distance) + def thetaMultiplier_changed_cb(self, widget): + indexValue = widget.get_active() + if indexValue == 0: + self.rotations = 2 + elif indexValue == 1: + self.rotations = 4 + elif indexValue == 2: + self.rotations = 8 + elif indexValue == 3: + self.rotations = 16 + elif indexValue == 4: # automatic not set up yet + self.rotations = 2 # back to default + self.highestTheta = (np.lcm(int(self.smallRadius + 0.5), int(self.bigRadius + 0.5))/self.bigRadius) * self.rotations * math.pi + self.stepSize = self.highestTheta / 4096 # possibly multiply by number of rotations? + self.recalcPoints() + self.updatePlot() + return + def recalcPoints(self): self.epiX = np.array([self.calcEpiX(i) for i in np.arange(0, self.highestTheta, self.stepSize)]) self.epiY = np.array([self.calcEpiY(i) for i in np.arange(0, self.highestTheta, self.stepSize)])