|
@@ -31,14 +31,15 @@ static void drawPlug(NVGcontext *vg, math::Vec pos, NVGcolor color) { |
|
|
nvgFill(vg); |
|
|
nvgFill(vg); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static void drawWire(NVGcontext *vg, math::Vec pos1, math::Vec pos2, NVGcolor color, float tension, float opacity) { |
|
|
|
|
|
|
|
|
static void drawWire(NVGcontext *vg, math::Vec pos1, math::Vec pos2, NVGcolor color, float width, float tension, float opacity) { |
|
|
NVGcolor colorShadow = nvgRGBAf(0, 0, 0, 0.10); |
|
|
NVGcolor colorShadow = nvgRGBAf(0, 0, 0, 0.10); |
|
|
NVGcolor colorOutline = nvgLerpRGBA(color, nvgRGBf(0.0, 0.0, 0.0), 0.5); |
|
|
NVGcolor colorOutline = nvgLerpRGBA(color, nvgRGBf(0.0, 0.0, 0.0), 0.5); |
|
|
|
|
|
|
|
|
// Wire |
|
|
// Wire |
|
|
if (opacity > 0.0) { |
|
|
if (opacity > 0.0) { |
|
|
nvgSave(vg); |
|
|
nvgSave(vg); |
|
|
nvgGlobalAlpha(vg, powf(opacity, 1.5)); |
|
|
|
|
|
|
|
|
// This power scaling looks more linear than actual linear scaling |
|
|
|
|
|
nvgGlobalAlpha(vg, std::pow(opacity, 1.5)); |
|
|
|
|
|
|
|
|
float dist = pos1.minus(pos2).norm(); |
|
|
float dist = pos1.minus(pos2).norm(); |
|
|
math::Vec slump; |
|
|
math::Vec slump; |
|
@@ -53,7 +54,7 @@ static void drawWire(NVGcontext *vg, math::Vec pos1, math::Vec pos2, NVGcolor co |
|
|
nvgMoveTo(vg, pos1.x, pos1.y); |
|
|
nvgMoveTo(vg, pos1.x, pos1.y); |
|
|
nvgQuadTo(vg, pos4.x, pos4.y, pos2.x, pos2.y); |
|
|
nvgQuadTo(vg, pos4.x, pos4.y, pos2.x, pos2.y); |
|
|
nvgStrokeColor(vg, colorShadow); |
|
|
nvgStrokeColor(vg, colorShadow); |
|
|
nvgStrokeWidth(vg, 5); |
|
|
|
|
|
|
|
|
nvgStrokeWidth(vg, width); |
|
|
nvgStroke(vg); |
|
|
nvgStroke(vg); |
|
|
|
|
|
|
|
|
// Wire outline |
|
|
// Wire outline |
|
@@ -61,12 +62,12 @@ static void drawWire(NVGcontext *vg, math::Vec pos1, math::Vec pos2, NVGcolor co |
|
|
nvgMoveTo(vg, pos1.x, pos1.y); |
|
|
nvgMoveTo(vg, pos1.x, pos1.y); |
|
|
nvgQuadTo(vg, pos3.x, pos3.y, pos2.x, pos2.y); |
|
|
nvgQuadTo(vg, pos3.x, pos3.y, pos2.x, pos2.y); |
|
|
nvgStrokeColor(vg, colorOutline); |
|
|
nvgStrokeColor(vg, colorOutline); |
|
|
nvgStrokeWidth(vg, 5); |
|
|
|
|
|
|
|
|
nvgStrokeWidth(vg, width); |
|
|
nvgStroke(vg); |
|
|
nvgStroke(vg); |
|
|
|
|
|
|
|
|
// Wire solid |
|
|
// Wire solid |
|
|
nvgStrokeColor(vg, color); |
|
|
nvgStrokeColor(vg, color); |
|
|
nvgStrokeWidth(vg, 3); |
|
|
|
|
|
|
|
|
nvgStrokeWidth(vg, width - 2); |
|
|
nvgStroke(vg); |
|
|
nvgStroke(vg); |
|
|
|
|
|
|
|
|
nvgRestore(vg); |
|
|
nvgRestore(vg); |
|
@@ -178,9 +179,17 @@ void WireWidget::draw(NVGcontext *vg) { |
|
|
opacity = 1.0; |
|
|
opacity = 1.0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
float width = 5; |
|
|
|
|
|
if (wire && wire->outputModule) { |
|
|
|
|
|
Output *output = &wire->outputModule->outputs[wire->outputId]; |
|
|
|
|
|
if (output->numChannels != 1) { |
|
|
|
|
|
width = 8; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
math::Vec outputPos = getOutputPos(); |
|
|
math::Vec outputPos = getOutputPos(); |
|
|
math::Vec inputPos = getInputPos(); |
|
|
math::Vec inputPos = getInputPos(); |
|
|
drawWire(vg, outputPos, inputPos, color, tension, opacity); |
|
|
|
|
|
|
|
|
drawWire(vg, outputPos, inputPos, color, width, tension, opacity); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void WireWidget::drawPlugs(NVGcontext *vg) { |
|
|
void WireWidget::drawPlugs(NVGcontext *vg) { |
|
|