diff --git a/src/nanovg.c b/src/nanovg.c index bb0f038..e2402ee 100644 --- a/src/nanovg.c +++ b/src/nanovg.c @@ -736,6 +736,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); diff --git a/src/nanovg.h b/src/nanovg.h index 8e50926..9a8c1f4 100644 --- a/src/nanovg.h +++ b/src/nanovg.h @@ -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