Browse Source

Add color::lerp().

tags/v2.3.0
Andrew Belt 1 year ago
parent
commit
6f12a83d67
2 changed files with 9 additions and 0 deletions
  1. +2
    -0
      include/color.hpp
  2. +7
    -0
      src/color.cpp

+ 2
- 0
include/color.hpp View File

@@ -34,6 +34,8 @@ NVGcolor plus(NVGcolor a, NVGcolor b);
/** Multiplies color components elementwise. */
NVGcolor mult(NVGcolor a, NVGcolor b);
NVGcolor mult(NVGcolor a, float x);
/** Interpolates RGBA color values. */
NVGcolor lerp(NVGcolor a, NVGcolor b, float t);
/** Screen blending with alpha compositing */
NVGcolor screen(NVGcolor a, NVGcolor b);
/** Multiplies alpha value. */


+ 7
- 0
src/color.cpp View File

@@ -44,6 +44,13 @@ NVGcolor mult(NVGcolor a, float x) {
return a;
}

NVGcolor lerp(NVGcolor a, NVGcolor b, float t) {
NVGcolor c;
for (int i = 0; i < 4; i++)
c.rgba[i] = a.rgba[i] * (1 - t) + b.rgba[i] * t;
return c;
}

/** Screen blending with alpha compositing */
NVGcolor screen(NVGcolor a, NVGcolor b) {
if (a.a == 0.f)


Loading…
Cancel
Save