@@ -11,10 +11,12 @@ void ColorLightWidget::addColor(NVGcolor c) { | |||||
void ColorLightWidget::step() { | void ColorLightWidget::step() { | ||||
assert(module); | assert(module); | ||||
assert(module->lights.size() >= lightId + colors.size()); | |||||
color = nvgRGBf(0, 0, 0); | color = nvgRGBf(0, 0, 0); | ||||
for (int i = 0; i < (int)colors.size(); i++) { | for (int i = 0; i < (int)colors.size(); i++) { | ||||
NVGcolor c = colors[i]; | NVGcolor c = colors[i]; | ||||
float brightness = module->lights[lightId + i].getBrightness(); | float brightness = module->lights[lightId + i].getBrightness(); | ||||
brightness = clampf(brightness, 0.0, 1.0); | |||||
color.r += c.r * brightness; | color.r += c.r * brightness; | ||||
color.g += c.g * brightness; | color.g += c.g * brightness; | ||||
color.b += c.b * brightness; | color.b += c.b * brightness; | ||||
@@ -8,6 +8,11 @@ void LightWidget::draw(NVGcontext *vg) { | |||||
float radius = box.size.x / 2.0; | float radius = box.size.x / 2.0; | ||||
float oradius = radius + 20.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 | // Solid | ||||
nvgBeginPath(vg); | nvgBeginPath(vg); | ||||
nvgCircle(vg, radius, radius, radius); | nvgCircle(vg, radius, radius, radius); | ||||
@@ -35,11 +35,11 @@ static float smoothValue; | |||||
float Light::getBrightness() { | float Light::getBrightness() { | ||||
return sqrtf(value); | |||||
return sqrtf(fmaxf(0.0, value)); | |||||
} | } | ||||
void Light::setBrightnessSmooth(float brightness) { | void Light::setBrightnessSmooth(float brightness) { | ||||
value += (brightness * brightness - value) * sampleTime * 60.0; | |||||
value += (brightness * brightness - value) * sampleTime * (60.0 * 3.0); | |||||
} | } | ||||