Skip to content

Commit de41fe9

Browse files
committed
Add Circle Modifier
1 parent a7e6a62 commit de41fe9

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

src/MoonLight/Modifiers.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,46 @@
1313

1414
//alphabetically from here
1515

16+
//Takes the x dimension from the layout (1D effect) and turn it into a circle in 2D or a sphere in 3D.
17+
class CircleModifier: public Node {
18+
public:
19+
20+
static const char * name() {return "Circle 💎💡";}
21+
static uint8_t dim() {return _3D;}
22+
static const char * tags() {return "";}
23+
24+
void setup() override {
25+
hasModifier = true;
26+
}
27+
28+
Coord3D originalSize;
29+
30+
void modifyLayout() override {
31+
originalSize = layerV->size;
32+
33+
modifyLight(layerV->size); //modify the virtual size as x, 0, 0
34+
35+
// change the size to be one bigger in each dimension
36+
layerV->size.x++;
37+
layerV->size.y++;
38+
layerV->size.z++;
39+
}
40+
41+
void modifyLight(Coord3D &position) override {
42+
//calculate the distance from the center
43+
int dx = position.x - originalSize.x / 2;
44+
int dy = position.y - originalSize.y / 2;
45+
int dz = position.z - originalSize.z / 2;
46+
47+
// Calculate the distance from the center
48+
float distance = sqrt(dx * dx + dy * dy + dz * dz);
49+
50+
position.x = distance;
51+
position.y = 0;
52+
position.z = 0;
53+
}
54+
};
55+
1656
class MirrorModifier: public Node {
1757
public:
1858

src/MoonLight/ModuleEditor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ class ModuleEditor : public Module
133133
values.add(MirrorModifier::name());
134134
values.add(MultiplyModifier::name());
135135
values.add(PinwheelModifier::name());
136+
values.add(CircleModifier::name());
136137
values.add(AudioSyncMod::name());
137138
//find all the .sc files on FS
138139
File rootFolder = ESPFS.open("/");

src/MoonLight/PhysicalLayer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ PhysicalLayer::PhysicalLayer() {
173173
else if (equal(name, PanelLayout::name())) node = new PanelLayout();
174174
else if (equal(name, RingsLayout::name())) node = new RingsLayout();
175175

176+
else if (equal(name, CircleModifier::name())) node = new CircleModifier();
176177
else if (equal(name, MirrorModifier::name())) node = new MirrorModifier();
177178
else if (equal(name, MultiplyModifier::name())) node = new MultiplyModifier();
178179
else if (equal(name, PinwheelModifier::name())) node = new PinwheelModifier();

0 commit comments

Comments
 (0)