From 0ae4572bc4b5c62cf4ac7855a93d9cc89138df4f Mon Sep 17 00:00:00 2001 From: hemmer <915048+hemmer@users.noreply.github.com> Date: Fri, 19 Jul 2024 11:56:20 +0100 Subject: [PATCH] Getting proper LEDs (WIP) --- res/components/cosmos_led_and.svg | 115 ++ res/components/cosmos_led_or.svg | 103 ++ res/components/cosmos_led_xor.svg | 98 ++ res/panels/Cosmos.svg | 2456 +++++++++++++++-------------- src/Cosmos.cpp | 55 +- 5 files changed, 1674 insertions(+), 1153 deletions(-) create mode 100644 res/components/cosmos_led_and.svg create mode 100644 res/components/cosmos_led_or.svg create mode 100644 res/components/cosmos_led_xor.svg diff --git a/res/components/cosmos_led_and.svg b/res/components/cosmos_led_and.svg new file mode 100644 index 0000000..fd46e9d --- /dev/null +++ b/res/components/cosmos_led_and.svg @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/components/cosmos_led_or.svg b/res/components/cosmos_led_or.svg new file mode 100644 index 0000000..0c7b6ae --- /dev/null +++ b/res/components/cosmos_led_or.svg @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/components/cosmos_led_xor.svg b/res/components/cosmos_led_xor.svg new file mode 100644 index 0000000..2635b18 --- /dev/null +++ b/res/components/cosmos_led_xor.svg @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/res/panels/Cosmos.svg b/res/panels/Cosmos.svg index 9573605..6b9a1c8 100644 --- a/res/panels/Cosmos.svg +++ b/res/panels/Cosmos.svg @@ -24,15 +24,15 @@ inkscape:deskcolor="#d1d1d1" inkscape:document-units="mm" showgrid="false" - inkscape:zoom="1.2938725" - inkscape:cx="5.0236789" - inkscape:cy="322.67476" - inkscape:window-width="1390" - inkscape:window-height="1205" - inkscape:window-x="2764" - inkscape:window-y="116" - inkscape:window-maximized="0" - inkscape:current-layer="layer2" /> + inkscape:zoom="3.6596241" + inkscape:cx="94.955108" + inkscape:cy="262.1854" + inkscape:window-width="2560" + inkscape:window-height="1301" + inkscape:window-x="0" + inkscape:window-y="25" + inkscape:window-maximized="1" + inkscape:current-layer="layer1" /> + id="layer3" + inkscape:label="background" + sodipodi:insensitive="true"> + + + + + + + id="g32" + transform="scale(0.33866667)"> + + + + + + + + + + + + + + + + + + + + + + + + + id="path62" /> + id="path64" /> + id="path66" /> + id="path68" /> + + + + - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - + id="ellipse80" /> + + + - - - - - - - - - - - - - + id="path88" + style="fill:#4d4d4d" /> - - - - - - - - - - - - - + id="path90" + style="fill:#4d4d4d" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + id="path92" + style="fill:#4d4d4d" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + id="path94" + style="fill:#4d4d4d" /> + id="path96" + style="fill:#4d4d4d" /> + id="path98" + style="fill:#4d4d4d" /> + id="path100" + style="fill:#4d4d4d" /> + id="path102" + style="fill:#4d4d4d" /> + + + + id="path108" + style="fill:#4d4d4d" /> + id="path110" + style="fill:#4d4d4d" /> + id="path112" + style="fill:#4d4d4d" /> + id="path114" + style="fill:#4d4d4d" /> + id="path116" + style="fill:#4d4d4d" /> + id="path118" + style="fill:#4d4d4d" /> + id="path120" + style="fill:#4d4d4d" /> + id="path122" + style="fill:#4d4d4d" /> + id="path124" + style="fill:#4d4d4d" /> + id="path126" + style="fill:#4d4d4d" /> + id="path128" + style="fill:#4d4d4d" /> + + + + id="path134" + style="fill:#4d4d4d" /> + id="path136" + style="fill:#4d4d4d" /> + id="path138" + style="fill:#4d4d4d" /> + id="path140" + style="fill:#4d4d4d" /> - - - - - - - - - - - - - - - - + - - - - - - - - - - - - + id="path144" + style="fill:#4d4d4d" /> - - - - - - - - - - - - + id="path146" + style="fill:#4d4d4d" /> - - - - - - - - - - - - - - - - - - - - + id="path148" + style="fill:#4d4d4d" /> + + + id="path154" + style="fill:#4d4d4d" /> + + + + id="path160" + style="fill:#4d4d4d" /> + id="path162" + style="fill:#4d4d4d" /> + id="path164" + style="fill:#4d4d4d" /> + id="path166" + style="fill:#4d4d4d" /> + id="path168" + style="fill:#4d4d4d" /> + id="path170" + style="fill:#4d4d4d" /> + id="path172" + style="fill:#4d4d4d" /> - - - - - - - - - - - - + id="path174" + style="fill:#4d4d4d" /> + + + + + + + + + + + + + + id="path200" + style="fill:#4d4d4d" /> + + + + + + id="path210" + style="fill:#4d4d4d" /> + id="path212" + style="fill:#4d4d4d" /> + id="path214" + style="fill:#4d4d4d" /> + id="path216" + style="fill:#4d4d4d" /> + id="path218" + style="fill:#4d4d4d" /> + id="path220" + style="fill:#4d4d4d" /> + id="path222" + style="fill:#4d4d4d" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { + + CosmosLed() { + + } + + void draw(const DrawArgs& args) override {} + void drawLayer(const DrawArgs& args, int layer) override { + if (layer == 1) { + + if (!sw->svg) + return; + + if (module && !module->isBypassed()) { + + for (auto s = sw->svg->handle->shapes; s; s = s->next) { + s->fill.color = ((int)(color.a * 255) << 24) + (((int)(color.b * 255)) << 16) + (((int)(color.g * 255)) << 8) + (int)(color.r * 255); + s->fill.type = NSVG_PAINT_COLOR; + } + + nvgGlobalCompositeBlendFunc(args.vg, NVG_ONE_MINUS_DST_COLOR, NVG_ONE); + svgDraw(args.vg, sw->svg->handle); + drawHalo(args); + } + } + Widget::drawLayer(args, layer); + } +}; + +struct CosmosLedXor : CosmosLed { + CosmosLedXor() { + this->setSvg(Svg::load(asset::plugin(pluginInstance, "res/components/cosmos_led_xor.svg"))); + } +}; + +struct CosmosLedOr : CosmosLed { + CosmosLedOr() { + this->setSvg(Svg::load(asset::plugin(pluginInstance, "res/components/cosmos_led_or.svg"))); + } +}; + + +struct CosmosLedAnd : CosmosLed { + CosmosLedAnd() { + this->setSvg(Svg::load(asset::plugin(pluginInstance, "res/components/cosmos_led_and.svg"))); + } +}; + struct CosmosWidget : ModuleWidget { CosmosWidget(Cosmos* module) { setModule(module); @@ -338,9 +387,9 @@ struct CosmosWidget : ModuleWidget { addOutput(createOutputCentered(mm2px(Vec(17.677, 114.371)), module, Cosmos::XNOR_GATE_OUTPUT)); addOutput(createOutputCentered(mm2px(Vec(52.981, 114.361)), module, Cosmos::XNOR_TRIG_OUTPUT)); - addChild(createLightCentered>(mm2px(Vec(35.331, 29.793)), module, Cosmos::XOR_LIGHT)); - addChild(createLightCentered>(mm2px(Vec(26.279, 39.23)), module, Cosmos::OR_LIGHT)); - addChild(createLightCentered>(mm2px(Vec(44.376, 39.23)), module, Cosmos::AND_LIGHT)); + addChild(createLightCentered(mm2px(Vec(35.331, 29.793)), module, Cosmos::XOR_LIGHT)); + addChild(createLightCentered(mm2px(Vec(26.279, 39.23)), module, Cosmos::OR_LIGHT)); + addChild(createLightCentered(mm2px(Vec(44.376, 39.23)), module, Cosmos::AND_LIGHT)); addChild(createLightCentered>(mm2px(Vec(35.3, 54.892)), module, Cosmos::SUM_LIGHT)); addChild(createLightCentered>(mm2px(Vec(29.372, 59.528)), module, Cosmos::X_LIGHT)); addChild(createLightCentered>(mm2px(Vec(41.292, 59.528)), module, Cosmos::Y_LIGHT));