|
|
@@ -74,7 +74,7 @@ struct NVGstate { |
|
|
|
float miterLimit; |
|
|
|
int lineJoin; |
|
|
|
int lineCap; |
|
|
|
float alpha; |
|
|
|
NVGcolor tint; |
|
|
|
float xform[6]; |
|
|
|
NVGscissor scissor; |
|
|
|
float fontSize; |
|
|
@@ -651,7 +651,7 @@ void nvgReset(NVGcontext* ctx) |
|
|
|
state->miterLimit = 10.0f; |
|
|
|
state->lineCap = NVG_BUTT; |
|
|
|
state->lineJoin = NVG_MITER; |
|
|
|
state->alpha = 1.0f; |
|
|
|
state->tint = nvgRGBAf(1, 1, 1, 1); |
|
|
|
nvgTransformIdentity(state->xform); |
|
|
|
|
|
|
|
state->scissor.extent[0] = -1.0f; |
|
|
@@ -697,9 +697,34 @@ void nvgLineJoin(NVGcontext* ctx, int join) |
|
|
|
} |
|
|
|
|
|
|
|
void nvgGlobalAlpha(NVGcontext* ctx, float alpha) |
|
|
|
{ |
|
|
|
nvgGlobalTint(ctx, nvgRGBAf(1, 1, 1, alpha)); |
|
|
|
} |
|
|
|
|
|
|
|
void nvgGlobalTint(NVGcontext* ctx, NVGcolor tint) |
|
|
|
{ |
|
|
|
NVGstate* state = nvg__getState(ctx); |
|
|
|
state->tint = tint; |
|
|
|
} |
|
|
|
|
|
|
|
NVGcolor nvgGetGlobalTint(NVGcontext* ctx) |
|
|
|
{ |
|
|
|
NVGstate* state = nvg__getState(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); |
|
|
|
state->alpha = alpha; |
|
|
|
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) |
|
|
@@ -2234,9 +2259,11 @@ void nvgFill(NVGcontext* ctx) |
|
|
|
else |
|
|
|
nvg__expandFill(ctx, 0.0f, NVG_MITER, 2.4f); |
|
|
|
|
|
|
|
// Apply global alpha |
|
|
|
fillPaint.innerColor.a *= state->alpha; |
|
|
|
fillPaint.outerColor.a *= state->alpha; |
|
|
|
// Apply global tint |
|
|
|
for (i = 0; i < 4; i++) { |
|
|
|
fillPaint.innerColor.rgba[i] *= state->tint.rgba[i]; |
|
|
|
fillPaint.outerColor.rgba[i] *= state->tint.rgba[i]; |
|
|
|
} |
|
|
|
|
|
|
|
ctx->params.renderFill(ctx->params.userPtr, &fillPaint, state->compositeOperation, &state->scissor, ctx->fringeWidth, |
|
|
|
ctx->cache->bounds, ctx->cache->paths, ctx->cache->npaths); |
|
|
@@ -2269,9 +2296,11 @@ void nvgStroke(NVGcontext* ctx) |
|
|
|
strokeWidth = ctx->fringeWidth; |
|
|
|
} |
|
|
|
|
|
|
|
// Apply global alpha |
|
|
|
strokePaint.innerColor.a *= state->alpha; |
|
|
|
strokePaint.outerColor.a *= state->alpha; |
|
|
|
// Apply global tint |
|
|
|
for (i = 0; i < 4; i++) { |
|
|
|
strokePaint.innerColor.rgba[i] *= state->tint.rgba[i]; |
|
|
|
strokePaint.outerColor.rgba[i] *= state->tint.rgba[i]; |
|
|
|
} |
|
|
|
|
|
|
|
nvg__flattenPaths(ctx); |
|
|
|
|
|
|
@@ -2438,15 +2467,18 @@ static int nvg__allocTextAtlas(NVGcontext* ctx) |
|
|
|
|
|
|
|
static void nvg__renderText(NVGcontext* ctx, NVGvertex* verts, int nverts) |
|
|
|
{ |
|
|
|
int i; |
|
|
|
NVGstate* state = nvg__getState(ctx); |
|
|
|
NVGpaint paint = state->fill; |
|
|
|
|
|
|
|
// Render triangles. |
|
|
|
paint.image = ctx->fontImages[ctx->fontImageIdx]; |
|
|
|
|
|
|
|
// Apply global alpha |
|
|
|
paint.innerColor.a *= state->alpha; |
|
|
|
paint.outerColor.a *= state->alpha; |
|
|
|
// Apply global tint |
|
|
|
for (i = 0; i < 4; i++) { |
|
|
|
paint.innerColor.rgba[i] *= state->tint.rgba[i]; |
|
|
|
paint.outerColor.rgba[i] *= state->tint.rgba[i]; |
|
|
|
} |
|
|
|
|
|
|
|
ctx->params.renderTriangles(ctx->params.userPtr, &paint, state->compositeOperation, &state->scissor, verts, nverts, ctx->fringeWidth); |
|
|
|
|
|
|
|