diff --git a/src/Photron.cpp b/src/Photron.cpp index 950a5f9..6c9aedc 100644 --- a/src/Photron.cpp +++ b/src/Photron.cpp @@ -8,18 +8,24 @@ #define NUM_OF_MARCHING_CIRCLES 5 struct Photron : Module { - enum QuadrantIds { NW, - NE, - SW, - SE }; - enum WaveformIds { LINES, - BLOCKS, - NONE, - NUM_WAVEFORMS }; - enum BackgroundIds { COLOR, - B_AND_W, - BLACK, - NUM_BG }; + enum QuadrantIds { + NW, + NE, + SW, + SE + }; + enum WaveformIds { + LINES, + BLOCKS, + NONE, + NUM_WAVEFORMS + }; + enum BackgroundIds { + COLOR, + B_AND_W, + BLACK, + NUM_BG + }; enum ParamIds { RANDOMIZE_PARAM, RESET_PARAM, @@ -74,7 +80,7 @@ struct Photron : Module { float field[rows][cols]; int blockAlpha[rows][cols]; json_t *patternsRootJ; - int patternIndex = 3; + int patternIndex = 5; bool lockPattern = false; std::vector labels; @@ -510,6 +516,10 @@ struct Photron : Module { } } + void generatePattern(Vec pos, int w, int h) { + generatePattern(pos, w, h, 0.5); + } + void generatePattern(Vec pos, int w, int h, float probability) { int half = static_cast(w / 2); @@ -522,11 +532,9 @@ struct Photron : Module { for (int x = 1; x < w; x += 3) { for (int y = 1; y < h; y += 3) { if (x <= half) { - int r = random::uniform() < probability ? 1 : 0; if (random::uniform() < 0.05) r = 2; - values[x][y] = r; values[x + 1][y] = r; values[x + 1][y + 1] = r; @@ -620,10 +628,10 @@ struct Photron : Module { if (wJ && hJ) { int w = json_integer_value(wJ); int h = json_integer_value(hJ); - generatePattern(getQuadrant(NW), w, h, 0.5); - generatePattern(getQuadrant(NE), w, h, 0.5); - generatePattern(getQuadrant(SW), w, h, 0.5); - generatePattern(getQuadrant(SE), w, h, 0.5); + generatePattern(getQuadrant(NW), w, h); + generatePattern(getQuadrant(NE), w, h); + generatePattern(getQuadrant(SW), w, h); + generatePattern(getQuadrant(SE), w, h); } } else { json_t *wJ = json_object_get(patternsJ, "width"); diff --git a/src/Photron.hpp b/src/Photron.hpp index abf1cb3..3c6a43f 100644 --- a/src/Photron.hpp +++ b/src/Photron.hpp @@ -50,9 +50,9 @@ struct Block { } void distortColor() { - rgb.x = static_cast(rgb.x + randRange(-20, 20)) % 256; - rgb.y = static_cast(rgb.y + randRange(-20, 20)) % 256; - rgb.z = static_cast(rgb.z + randRange(-20, 20)) % 256; + rgb.x = static_cast(rgb.x + randRange(-25, 25)) % 256; + rgb.y = static_cast(rgb.y + randRange(-25, 25)) % 256; + rgb.z = static_cast(rgb.z + randRange(-25, 25)) % 256; isLocked = false; // unlock after user draws } @@ -161,7 +161,7 @@ struct Block { } void update() { - if (!isLocked) { // TODO: locked not working + if (!isLocked) { rgbVel = rgbVel.plus(rgbAcc); rgbVel = rgbVel.limit(maxspeed); rgb = rgb.plus(rgbVel); diff --git a/src/PhotronPanel.cpp b/src/PhotronPanel.cpp index e97cce5..c515fde 100644 --- a/src/PhotronPanel.cpp +++ b/src/PhotronPanel.cpp @@ -751,8 +751,6 @@ struct PhotronPanelWidget : ModuleWidget { menu->addChild(createIndexPtrSubmenuItem("Mode", {"color", "black & white", "solid color", "strip"}, &module->colorMode)); - // menu->addChild(createIndexPtrSubmenuItem("Light pulse", {"Off", "0.1 Hz", "0.2 Hz", "0.25 Hz", "0.33 Hz", "0.4 Hz", "0.5 Hz", "1 Hz"}, &module->pulseHzIndex)); - LightMenuItem *lightPulse = createMenuItem("Light", RIGHT_ARROW); lightPulse->module = module; lightPulse->pulseHz = &module->pulseHz; diff --git a/src/PhotronStrip.cpp b/src/PhotronStrip.cpp index 0d1249d..4bc362b 100644 --- a/src/PhotronStrip.cpp +++ b/src/PhotronStrip.cpp @@ -358,26 +358,15 @@ struct PhotronStripDisplay : Widget { float initY = 0; float dragY = 0; - void onButton(const event::Button &e) override { - if (module == NULL) return; - if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT) { - if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) { - e.consume(this); - module->incrementColorMode(); - } - } - } - - // void onDragStart(const event::DragStart &e) override { - // dragY = APP->scene->rack->getMousePos().y; - // } - - // void onDragMove(const event::DragMove &e) override { - // if (isCClick) { - // float newDragY = APP->scene->rack->getMousePos().y; - // module->hue = (initY + (newDragY - dragY)) / DISPLAY_SIZE_HEIGHT; + // void onButton(const event::Button &e) override { + // if (module == NULL) return; + // if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT) { + // if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) { + // e.consume(this); + // module->incrementColorMode(); + // } // } - // } + // } void drawSingleColor(const DrawArgs &args) { nvgFillColor(args.vg, nvgHSL(module->hue, 1.0, module->getPulsePhase() * 0.5)); @@ -603,8 +592,6 @@ struct PhotronStripWidget : ModuleWidget { display->box.pos = Vec(0.0, 0.0); display->box.size = Vec(DISPLAY_SIZE_WIDTH, DISPLAY_SIZE_HEIGHT); addChild(display); - - } void appendContextMenu(Menu *menu) override {