MCPcopy Create free account
hub / github.com/VCVRack/Rack / step

Method step

src/app/ModuleLightWidget.cpp:107–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105
106
107void ModuleLightWidget::step() {
108 std::vector<float> brightnesses(baseColors.size());
109
110 int lastLightId = firstLightId + (int) baseColors.size();
111 if (module) {
112 if (module->isBypassed()) {
113 // Leave lights off
114 }
115 else if (0 <= firstLightId && lastLightId <= (int) module->lights.size()) {
116 for (size_t i = 0; i < baseColors.size(); i++) {
117 float b = module->lights[firstLightId + i].getBrightness();
118 if (!std::isfinite(b))
119 b = 0.f;
120 b = math::clamp(b, 0.f, 1.f);
121 // Because LEDs are nonlinear, this seems to look more natural.
122 b = std::sqrt(b);
123 brightnesses[i] = b;
124 }
125 }
126 }
127 else {
128 // Turn all lights on
129 for (size_t i = 0; i < baseColors.size(); i++) {
130 brightnesses[i] = 1.f;
131 }
132 }
133
134 setBrightnesses(brightnesses);
135
136 MultiLightWidget::step();
137}
138
139
140void ModuleLightWidget::onHover(const HoverEvent& e) {

Callers

nothing calls this directly

Calls 6

sqrtFunction · 0.85
stepFunction · 0.85
isBypassedMethod · 0.80
clampFunction · 0.50
sizeMethod · 0.45
getBrightnessMethod · 0.45

Tested by

no test coverage detected