Skip to content

Commit 8c5041d

Browse files
committed
Merge remote-tracking branch 'Brandon502/main'
2 parents 443ff76 + b599d7c commit 8c5041d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/MoonLight/Modifiers.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ class PinwheelModifier: public Node {
133133
bool reverse = false;
134134
uint8_t symmetry = 1;
135135
uint8_t zTwist = 0;
136+
float petalWidth = 6.0;
136137

137138
void setup() override {
138139
hasModifier = true;
@@ -155,13 +156,19 @@ class PinwheelModifier: public Node {
155156
// layerV->size.y = 1;
156157
// layerV->size.z = 1;
157158
// }
159+
if (petals < 1) petals = 1; // Ensure at least one petal
160+
const int FACTORS[23] = {360, 180, 120, 90, 72, 60, 45, 40, 36, 30, 24, 20, 18, 15, 12, 10, 9, 8, 6, 5, 4, 3, 2}; // Factors of 360
161+
int factor;
162+
if (symmetry > 23) factor = 2; // Default to 2 if symmetry is greater than 23
163+
else if (symmetry > 0) factor = FACTORS[symmetry - 1]; // Convert symmetry to a factor of 360
164+
else factor = 360; // Default to 360 if symmetry is <= 0
165+
petalWidth = factor / float(petals);
166+
158167
ESP_LOGD(TAG, "Pinwheel %d %d %d", layerV->size.x, layerV->size.y, layerV->size.z);
159168
}
160169

161170
void modifyPosition(Coord3D &position) override {
162171
// Coord3D mapped;
163-
// factors of 360
164-
const int FACTORS[24] = {360, 180, 120, 90, 72, 60, 45, 40, 36, 30, 24, 20, 18, 15, 12, 10, 9, 8, 6, 5, 4, 3, 2};
165172
// UI Variables
166173

167174
const int dx = position.x - layerV->middle.x;
@@ -172,7 +179,6 @@ class PinwheelModifier: public Node {
172179
if (swirlVal < 0) angle = 360 - angle; // Reverse Swirl
173180

174181
int value = angle + swirlFactor + (zTwist * position.z);
175-
float petalWidth = symmetry / float(petals);
176182
value /= petalWidth;
177183
value %= petals;
178184

0 commit comments

Comments
 (0)