Skip to content

Commit

Permalink
Merge pull request #16 from modlfo/master
Browse files Browse the repository at this point in the history
Matches the output of Caudal
  • Loading branch information
jeremywen authored Jan 10, 2018
2 parents 7e556ee + 4f3c884 commit 8cd28f5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/JWModules.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ struct BouncyBallsWidget : ModuleWidget {

struct WavHeadWidget : ModuleWidget {
WavHeadWidget();
void step();
void step() override;
Widget* widgetToMove;
Widget* snowflakesArr[10];
Menu *createContextMenu() override;
Expand All @@ -327,9 +327,9 @@ struct FullScopeWidget : ModuleWidget {
Widget *rightHandle;
TransparentWidget *display;
FullScopeWidget();
void step();
json_t *toJson();
void fromJson(json_t *rootJ);
void step() override;
json_t *toJson() override;
void fromJson(json_t *rootJ) override;
Menu *createContextMenu() override;
};

Expand Down
22 changes: 13 additions & 9 deletions src/ThingThing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,27 @@ struct ThingThingDisplay : Widget {
ballRadius += rescalef(module->inputs[ThingThing::ZOOM_MULT_INPUT].value, -5.0, 5.0, 1.0, 50.0);
}

float x[5];
float y[5];
float angle[5];

for(int i=0; i<5; i++){
angle[i] = i==0 ? 0 : (module->inputs[ThingThing::ANG_INPUT+i].value + angle[i-1]) * module->atten[i];
x[i] = i==0 ? 0 : sinf(rescalef(angle[i], -5, 5, -2*M_PI + M_PI/2.0f, 2*M_PI + M_PI/2.0f)) * zoom;
y[i] = i==0 ? 0 : cosf(rescalef(angle[i], -5, 5, -2*M_PI + M_PI/2.0f, 2*M_PI + M_PI/2.0f)) * zoom;
}

/////////////////////// LINES ///////////////////////
nvgSave(vg);
nvgTranslate(vg, box.size.x * 0.5, box.size.y * 0.5);
for(int i=0; i<5; i++){
float angle = module->inputs[ThingThing::ANG_INPUT+i].value * module->atten[i];
float x = i==0 ? 0 : sinf(rescalef(angle, -5, 5, -2*M_PI, 2*M_PI)) * zoom;
float y = i==0 ? 0 : cosf(rescalef(angle, -5, 5, -2*M_PI, 2*M_PI)) * zoom;
nvgTranslate(vg, x, y);
nvgTranslate(vg, x[i], y[i]);
nvgStrokeColor(vg, nvgRGB(255, 255, 255));
if(i>0){
nvgStrokeWidth(vg, 1);
nvgBeginPath(vg);
nvgMoveTo(vg, 0, 0);
nvgLineTo(vg, -x, -y);
nvgLineTo(vg, -x[i], -y[i]);
nvgStroke(vg);
}
}
Expand All @@ -95,10 +102,7 @@ struct ThingThingDisplay : Widget {
nvgSave(vg);
nvgTranslate(vg, box.size.x * 0.5, box.size.y * 0.5);
for(int i=0; i<5; i++){
float angle = module->inputs[ThingThing::ANG_INPUT+i].value * module->atten[i];
float x = i==0 ? 0 : sinf(rescalef(angle, -5, 5, -2*M_PI, 2*M_PI)) * zoom;
float y = i==0 ? 0 : cosf(rescalef(angle, -5, 5, -2*M_PI, 2*M_PI)) * zoom;
nvgTranslate(vg, x, y);
nvgTranslate(vg, x[i], y[i]);
nvgStrokeColor(vg, module->balls[i].color);
nvgFillColor(vg, module->balls[i].color);
nvgStrokeWidth(vg, 2);
Expand Down

0 comments on commit 8cd28f5

Please sign in to comment.