13 const qreal VuoRendererColors::minAlpha = 0.35;
15 const int VuoRendererColors::subtleHighlightingLighteningFactor = 140;
16 const int VuoRendererColors::activityFadeDuration = 400;
18 bool VuoRendererColors::_isDark =
false;
32 this->tintColor = tintColor;
33 this->selectionType = selectionType;
34 this->isHovered = isHovered;
35 this->highlightType = highlightType;
36 this->isMissingImplementation = isMissingImplementation;
39 qint64 timeNow = QDateTime::currentMSecsSinceEpoch();
41 this->currentFadePercentage = ((timeOfLastActivity == VuoRendererItem::notTrackingActivity)? 0 :
42 ((timeOfLastActivity == VuoRendererItem::activityInProgress)? 0 :
43 fmin(1, (timeNow - timeOfLastActivity)/(1.0*activityFadeDuration))));
82 return QColor::fromHslF(0, 0, _isDark ? .19 : 1, 1);
91 return applyHighlighting(baseColor());
116 return Qt::transparent;
134 if (isMissingImplementation)
137 return applyHighlighting(baseColor().darker(_isDark ? 160 : 130));
145 QColor c = applyHighlighting(QColor::fromHslF(0, 0, 1, 1), .2);
146 if (isMissingImplementation)
147 c.setAlphaF(_isDark ? .5 : 1);
156 QColor c = applyHighlighting(QColor::fromHslF(0, 0, 1, .6));
157 if (isMissingImplementation)
158 c.setAlphaF(_isDark ? .5 : 1);
183 qreal adjustedAlpha = (1. - currentFadePercentage) * getCurrentAlpha();
185 c.setAlphaF(c.alphaF() * adjustedAlpha);
210 qreal adjustedAlpha = (1. - currentFadePercentage) * getCurrentAlpha();
212 c.setAlphaF(c.alphaF() * adjustedAlpha);
230 return Qt::transparent;
232 return applyHighlighting(QColor::fromHslF(0, 0, .2,
258 return QColor::fromRgb(220, 50, 47, 160);
272 QColor frameColor = (_isDark? darkColor :
nodeFill());
273 frameColor.setAlpha(_isDark? 0.5*frameColor.alpha() : 0.82*frameColor.alpha());
286 float darkenFactor = .8;
288 c.setRedF (c.redF() * (1-darkenFactor) + b.redF() * darkenFactor);
289 c.setGreenF(c.greenF() * (1-darkenFactor) + b.greenF() * darkenFactor);
290 c.setBlueF (c.blueF() * (1-darkenFactor) + b.blueF() * darkenFactor);
294 int lightenFactor = 113;
295 if (tintColor == VuoNode::TintYellow)
297 else if (tintColor == VuoNode::TintCyan
298 || tintColor == VuoNode::TintGreen
299 || tintColor == VuoNode::TintLime)
301 c = c.lighter(lightenFactor);
305 c.getHsv(&h, &s, &v, &a);
306 return (QColor::fromHsv(h, (_isDark? s*4/3 : s/3), v, a));
314 QColor c = applyHighlighting(QColor::fromHslF(0, 0, 1, .8));
325 return _isDark ?
"#1d6ae5" :
"#74acec";
332 QColor VuoRendererColors::lerpColor(QColor v0, QColor v1,
float t)
335 v0.getRgbF(&r0,&g0,&b0,&a);
338 v1.getRgbF(&r1,&g1,&b1);
340 return QColor::fromRgbF(
341 fmin(r0 + (r1 - r0)*t, 1.),
342 fmin(g0 + (g1 - g0)*t, 1.),
343 fmin(b0 + (b1 - b0)*t, 1.),
348 QColor VuoRendererColors::baseColor(
bool useTintColor)
351 || tintColor == VuoNode::TintNone )
return QColor::fromHslF( 0./360., 0, getNodeFillLightness(), 1);
352 else if (tintColor == VuoNode::TintYellow )
return QColor::fromHslF( 57./360., 1, .49, 1);
353 else if (tintColor == VuoNode::TintTangerine)
return QColor::fromHslF( 41./360., 1, .67, 1);
354 else if (tintColor == VuoNode::TintOrange )
return QColor::fromHslF( 19./360., 1, .73, 1);
355 else if (tintColor == VuoNode::TintMagenta )
return QColor::fromHslF(323./360., 1, .78, 1);
356 else if (tintColor == VuoNode::TintViolet )
return QColor::fromHslF(275./360., 1, .81, 1);
357 else if (tintColor == VuoNode::TintBlue )
return QColor::fromHslF(213./360., 1, .77, 1);
358 else if (tintColor == VuoNode::TintCyan )
return QColor::fromHslF(165./360., 1, .68, 1);
359 else if (tintColor == VuoNode::TintGreen )
return QColor::fromHslF( 99./360., 1, .70, 1);
360 elsereturn QColor::fromHslF( 70./360., 1, .48, 1);
363 QColor VuoRendererColors::applyHighlighting(QColor baseColor, qreal selectionIntensity)
365 qreal alpha = baseColor.alphaF() * getCurrentAlpha();
371 if (selectionType != VuoRendererColors::noSelection)
372 baseColor = lerpColor(baseColor,
selection(), selectionIntensity);
387 alpha *= _isDark ? .1 : .2;
389 if (tintColor != VuoNode::TintNone)
392 baseColor = baseColor.lighter(100. + (_isDark ? 10. : -6.) * highlight);
394 baseColor.setAlphaF(alpha);
405 return QDateTime::currentMSecsSinceEpoch();
415 return QDateTime::currentMSecsSinceEpoch();
424 qint64 timeNow = QDateTime::currentMSecsSinceEpoch();
427 return virtualFiredEventOrigin;
437 return QDateTime::currentMSecsSinceEpoch();
445 qreal VuoRendererColors::getCurrentAlpha(
void)
447 return 1 - currentFadePercentage * (1 - minAlpha);
453 qreal VuoRendererColors::getNodeFillLightness(
void)
455 return _isDark ? .62 : .83;
465 return isInput ? VuoNode::TintBlue : VuoNode::TintLime;