Browse Source

Add nvgAlpha() and nvgTint() which multiply existing alpha and state instead of resetting it.

shared-context^2
Andrew Belt 3 years ago
parent
commit
ade6e6c060
2 changed files with 16 additions and 0 deletions
  1. +14
    -0
      src/nanovg.c
  2. +2
    -0
      src/nanovg.h

+ 14
- 0
src/nanovg.c View File

@@ -716,6 +716,20 @@ NVGcolor nvgGetGlobalTint(NVGcontext* ctx)
return state->tint;
}

void nvgAlpha(NVGcontext* ctx, float alpha)
{
NVGstate* state = nvg__getState(ctx);
state->tint.a *= alpha;
}

void nvgTint(NVGcontext* ctx, NVGcolor tint)
{
NVGstate* state = nvg__getState(ctx);
int i;
for (i = 0; i < 4; i++)
state->tint.rgba[i] *= tint.rgba[i];
}

void nvgTransform(NVGcontext* ctx, float a, float b, float c, float d, float e, float f)
{
NVGstate* state = nvg__getState(ctx);


+ 2
- 0
src/nanovg.h View File

@@ -273,6 +273,8 @@ void nvgLineJoin(NVGcontext* ctx, int join);
void nvgGlobalAlpha(NVGcontext* ctx, float alpha);
void nvgGlobalTint(NVGcontext* ctx, NVGcolor tint);
NVGcolor nvgGetGlobalTint(NVGcontext* ctx);
void nvgAlpha(NVGcontext* ctx, float alpha);
void nvgTint(NVGcontext* ctx, NVGcolor tint);

//
// Transforms


Loading…
Cancel
Save