ckb-next  v0.2.8 at branch master
ckb-next driver for corsair devices
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
kblight.cpp File Reference
#include <cmath>
#include <QDateTime>
#include <QSet>
#include "kblight.h"
#include "kbmode.h"
+ Include dependency graph for kblight.cpp:

Go to the source code of this file.

Functions

static float sToL (float srgb)
 
static float lToS (float linear)
 
QRgb monoRgb (float r, float g, float b)
 

Variables

static int _shareDimming = -1
 
static QSet< KbLight * > activeLights
 

Function Documentation

static float lToS ( float  linear)
static

Definition at line 277 of file kblight.cpp.

Referenced by KbLight::frameUpdate(), and monoRgb().

277  {
278  if(linear <= 0.0031308f)
279  return 12.92f * linear * 255.f;
280  return (1.055f * pow(linear, 1.f / 2.4f) - 0.055f) * 255.f;
281 }

+ Here is the caller graph for this function:

QRgb monoRgb ( float  r,
float  g,
float  b 
)

Definition at line 284 of file kblight.cpp.

References lToS(), and sToL().

Referenced by KbLight::base(), KbLight::frameUpdate(), and KeyWidget::paintEvent().

284  {
285  // It's important to use a linear colorspace for this, otherwise the colors will appear inconsistent
286  // Note that although we could use linear space for alpha blending or the animation blending functions, we don't.
287  // The reason for this is that photo manipulation programs don't do it either, so even though the result would technically be more correct,
288  // it would look wrong to most people.
289  r = sToL(r);
290  g = sToL(g);
291  b = sToL(b);
292  int value = round(lToS((r + g + b) / 3.f));
293  return qRgb(value, value, value);
294 }
static float sToL(float srgb)
Definition: kblight.cpp:270
static float lToS(float linear)
Definition: kblight.cpp:277

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static float sToL ( float  srgb)
static

Definition at line 270 of file kblight.cpp.

Referenced by KbLight::frameUpdate(), and monoRgb().

270  {
271  srgb /= 255.f;
272  if(srgb <= 0.04045f)
273  return srgb / 12.92f;
274  return pow((srgb + 0.055f) / 1.055f, 2.4f);
275 }

+ Here is the caller graph for this function:

Variable Documentation

int _shareDimming = -1
static

Definition at line 7 of file kblight.cpp.

Referenced by KbLight::dimming(), KbLight::open(), and KbLight::shareDimming().

QSet<KbLight*> activeLights
static

Definition at line 8 of file kblight.cpp.

Referenced by KbLight::close(), KbLight::open(), KbLight::shareDimming(), and KbLight::~KbLight().