Browse Source

Tweak LightWidget rendering

tags/v0.5.0
Andrew Belt 7 years ago
parent
commit
bd9b237c43
3 changed files with 9 additions and 2 deletions
  1. +2
    -0
      src/app/ColorLightWidget.cpp
  2. +5
    -0
      src/app/LightWidget.cpp
  3. +2
    -2
      src/engine.cpp

+ 2
- 0
src/app/ColorLightWidget.cpp View File

@@ -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;


+ 5
- 0
src/app/LightWidget.cpp View File

@@ -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);


+ 2
- 2
src/engine.cpp View File

@@ -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);
}




Loading…
Cancel
Save