diff --git a/src/nanovg.c b/src/nanovg.c index 5fdbd66..0d00d48 100644 --- a/src/nanovg.c +++ b/src/nanovg.c @@ -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); diff --git a/src/nanovg.h b/src/nanovg.h index b1c4e30..9210f5e 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