Exemple #1
0
void vsColoredNodeWire(NVGcontext *ctx, float x0, float y0, float x1, float y1,
                       NVGcolor color0, NVGcolor color1) {
    float length = bnd_fmaxf(fabsf(x1 - x0), fabsf(y1 - y0));
    // how much a noodle curves (0 to 10)
    int noodleCurving = 3;
    float delta = length * (float) noodleCurving / 10.0f;

    nvgBeginPath(ctx);
    nvgMoveTo(ctx, x0, y0);
    nvgBezierTo(ctx,
                x0 + delta, y0,
                x1 - delta, y1,
                x1, y1);
    NVGcolor colorw = nvgRGB(52, 22, 99);
    colorw.a = (color0.a < color1.a) ? color0.a : color1.a;
    nvgStrokeColor(ctx, colorw);
    nvgStrokeWidth(ctx, BND_NODE_WIRE_OUTLINE_WIDTH);
    nvgStroke(ctx);
    nvgStrokePaint(ctx, nvgLinearGradient(ctx,
                                          x0, y0, x1, y1,
                                          color0,
                                          color1));
    nvgStrokeWidth(ctx, BND_NODE_WIRE_WIDTH);
    nvgStroke(ctx);
}
void Slider::draw(NVGcontext* ctx) {
    Vector2f center = mPos.cast<float>() + mSize.cast<float>() * 0.5f;
    Vector2f knobPos(mPos.x() + mValue * mSize.x(), center.y() + 0.5f);
    float kr = (int)(mSize.y()*0.5f);
    NVGpaint bg = nvgBoxGradient(ctx,
        mPos.x(), center.y() - 3 + 1, mSize.x(), 6, 3, 3, Color(0, mEnabled ? 32 : 10), Color(0, mEnabled ? 128 : 210));

    nvgBeginPath(ctx);
    nvgRoundedRect(ctx, mPos.x(), center.y() - 3 + 1, mSize.x(), 6, 2);
    nvgFillPaint(ctx, bg);
    nvgFill(ctx);

    if (mHighlightedRange.second != mHighlightedRange.first) {
        nvgBeginPath(ctx);
        nvgRoundedRect(ctx, mPos.x() + mHighlightedRange.first * mSize.x(), center.y() - 3 + 1, mSize.x() * (mHighlightedRange.second-mHighlightedRange.first), 6, 2);
        nvgFillColor(ctx, mHighlightColor);
        nvgFill(ctx);
    }

    NVGpaint knobShadow = nvgRadialGradient(ctx,
        knobPos.x(), knobPos.y(), kr-3, kr+3, Color(0, 64), mTheme->mTransparent);

    nvgBeginPath(ctx);
    nvgRect(ctx, knobPos.x() - kr - 5, knobPos.y() - kr - 5, kr*2+10, kr*2+10+3);
    nvgCircle(ctx, knobPos.x(), knobPos.y(), kr);
    nvgPathWinding(ctx, NVG_HOLE);
    nvgFillPaint(ctx, knobShadow);
    nvgFill(ctx);

    NVGpaint knob = nvgLinearGradient(ctx,
        mPos.x(), center.y() - kr, mPos.x(), center.y() + kr,
        mTheme->mBorderLight, mTheme->mBorderMedium);
    NVGpaint knobReverse = nvgLinearGradient(ctx,
        mPos.x(), center.y() - kr, mPos.x(), center.y() + kr,
        mTheme->mBorderMedium,
        mTheme->mBorderLight);

    nvgBeginPath(ctx);
    nvgCircle(ctx, knobPos.x(), knobPos.y(), kr);
    nvgStrokeColor(ctx, mTheme->mBorderDark);
    nvgFillPaint(ctx, knob);
    nvgStroke(ctx);
    nvgFill(ctx);
    nvgBeginPath(ctx);
    nvgCircle(ctx, knobPos.x(), knobPos.y(), kr/2);
    nvgFillColor(ctx, Color(150, mEnabled ? 255 : 100));
    nvgStrokePaint(ctx, knobReverse);
    nvgStroke(ctx);
    nvgFill(ctx);
}
Exemple #3
0
    void t2Image::drawInCircle(int x, int y, float radius, int angle /*= 0*/, int alpha /*= 255*/, bool bFill /*= true*/)
    {
        NVGpaint imgPaint = nvgImagePattern(t2GetContext(), x, y, width, height, angle / 255.0f, img, alpha / 255.0f);

        nvgBeginPath(t2GetContext());
        nvgCircle(t2GetContext(), x, y, radius);

        if(bFill)
        {
            nvgFillPaint(t2GetContext(), imgPaint);
            nvgFill(t2GetContext());
        }
        else
        {
            nvgStrokePaint(t2GetContext(), imgPaint);
            nvgStroke(t2GetContext());
        }
    }
Exemple #4
0
void NanoVG::setStrokePaint( NVGpaint paint )
{
    nvgStrokePaint( m_context(), paint );
}
JNIEXPORT void JNICALL Java_org_lwjgl_nanovg_NanoVG_nnvgStrokePaint(JNIEnv *__env, jclass clazz, jlong ctxAddress, jlong paintAddress) {
	NVGcontext *ctx = (NVGcontext *)(intptr_t)ctxAddress;
	NVGpaint *paint = (NVGpaint *)(intptr_t)paintAddress;
	UNUSED_PARAMS(__env, clazz)
	nvgStrokePaint(ctx, *paint);
}
		void NVGRenderer::setStrokePaint(const DrawPaint& paint)
		{
			nvgStrokePaint(m_context, paint.nvg);
		}
void QNanoPainter::setStrokeStyle(const QNanoBrush &brush)
{
    nvgStrokePaint(nvgCtx(), brush.nvgPaint(nvgCtx()));
}
Exemple #8
0
JNIEXPORT void JNICALL Java_firststep_internal_NVG_strokePaint
  (JNIEnv *e, jclass c, jlong ctx, jobject paint)
{
	checkJO(paint,"\nstrokePaint was passed a NULL paint\n");
	nvgStrokePaint((NVGcontext*)ctx, (NVGpaint)*((NVGpaint*)getBuffPtr(e,paint)));
}