From 2e7100c17b8887386936d9d1187e0796b0415d1f Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Fri, 27 Oct 2017 12:10:53 -0400 Subject: [PATCH 1/2] Reverted light sizes in components.hpp, updated README --- README.md | 4 +++- include/components.hpp | 21 +++++++++++++++++---- src/app/ColorLightWidget.cpp | 1 + 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7c6e567c..2f77abe1 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ However, please search before posting to avoid duplicates, and limit to one issu You may vote on feature requests by using the Thumbs Up/Down reaction on the first post. +I rarely accept Pull Requests, so please notify me in advance to plan your contribution before writing code. + ## Setting up your development environment Rack's dependencies (GLEW, glfw, etc) do not need to be installed on your system, since specific versions are compiled locally during the build process. However, you need proper tools to build these dependencies. @@ -63,7 +65,7 @@ Run Rack. Be sure to check out and build the version of Rack you wish to build your plugins against. -Clone your favorite plugin in the `plugins/` directory. e.g.: +You must clone the plugin in Rack's `plugins/` directory, e.g. cd plugins git clone https://github.com/VCVRack/Fundamental.git diff --git a/include/components.hpp b/include/components.hpp index 5b1f4e1c..5eba281b 100644 --- a/include/components.hpp +++ b/include/components.hpp @@ -434,6 +434,19 @@ struct GreenLight : ColorLightWidget { } }; +struct YellowLight : ColorLightWidget { + YellowLight() { + addColor(COLOR_YELLOW); + } +}; + +struct BlueLight : ColorLightWidget { + BlueLight() { + addColor(COLOR_BLUE); + } +}; + +/** Reads two adjacent lightIds, so `lightId` and `lightId + 1` must be defined */ struct GreenRedLight : ColorLightWidget { GreenRedLight() { addColor(COLOR_GREEN); @@ -446,7 +459,7 @@ struct GreenRedLight : ColorLightWidget { template struct LargeLight : BASE { LargeLight() { - this->box.size = Vec(15, 15); + this->box.size = Vec(20, 20); } }; @@ -454,7 +467,7 @@ struct LargeLight : BASE { template struct MediumLight : BASE { MediumLight() { - this->box.size = Vec(9, 9); + this->box.size = Vec(12, 12); } }; @@ -462,7 +475,7 @@ struct MediumLight : BASE { template struct SmallLight : BASE { SmallLight() { - this->box.size = Vec(6, 6); + this->box.size = Vec(8, 8); } }; @@ -470,7 +483,7 @@ struct SmallLight : BASE { template struct TinyLight : BASE { TinyLight() { - this->box.size = Vec(3, 3); + this->box.size = Vec(5, 5); } }; diff --git a/src/app/ColorLightWidget.cpp b/src/app/ColorLightWidget.cpp index c7dcd094..0d16a48d 100644 --- a/src/app/ColorLightWidget.cpp +++ b/src/app/ColorLightWidget.cpp @@ -10,6 +10,7 @@ void ColorLightWidget::addColor(NVGcolor c) { } void ColorLightWidget::step() { + assert(module); color = nvgRGBf(0, 0, 0); for (int i = 0; i < (int)colors.size(); i++) { NVGcolor c = colors[i]; From bd9b237c4344e2d71e8083a63d6bd6d45c19e215 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Fri, 27 Oct 2017 12:51:32 -0400 Subject: [PATCH 2/2] Tweak LightWidget rendering --- src/app/ColorLightWidget.cpp | 2 ++ src/app/LightWidget.cpp | 5 +++++ src/engine.cpp | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/ColorLightWidget.cpp b/src/app/ColorLightWidget.cpp index 0d16a48d..125373b2 100644 --- a/src/app/ColorLightWidget.cpp +++ b/src/app/ColorLightWidget.cpp @@ -11,10 +11,12 @@ void ColorLightWidget::addColor(NVGcolor c) { void ColorLightWidget::step() { assert(module); + assert(module->lights.size() >= lightId + colors.size()); color = nvgRGBf(0, 0, 0); for (int i = 0; i < (int)colors.size(); i++) { NVGcolor c = colors[i]; float brightness = module->lights[lightId + i].getBrightness(); + brightness = clampf(brightness, 0.0, 1.0); color.r += c.r * brightness; color.g += c.g * brightness; color.b += c.b * brightness; diff --git a/src/app/LightWidget.cpp b/src/app/LightWidget.cpp index 1a27bb95..02acac06 100644 --- a/src/app/LightWidget.cpp +++ b/src/app/LightWidget.cpp @@ -8,6 +8,11 @@ void LightWidget::draw(NVGcontext *vg) { float radius = box.size.x / 2.0; float oradius = radius + 20.0; + color.r = clampf(color.r, 0.0, 1.0); + color.g = clampf(color.g, 0.0, 1.0); + color.b = clampf(color.b, 0.0, 1.0); + color.a = clampf(color.a, 0.0, 1.0); + // Solid nvgBeginPath(vg); nvgCircle(vg, radius, radius, radius); diff --git a/src/engine.cpp b/src/engine.cpp index bf903cda..c4a8009a 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -35,11 +35,11 @@ static float smoothValue; float Light::getBrightness() { - return sqrtf(value); + return sqrtf(fmaxf(0.0, value)); } void Light::setBrightnessSmooth(float brightness) { - value += (brightness * brightness - value) * sampleTime * 60.0; + value += (brightness * brightness - value) * sampleTime * (60.0 * 3.0); }