Exemplo n.º 1
0
void drawLines(struct NVGcontext* vg, float x, float y, float w, float h, float t)
{
	int i, j;
	float pad = 5.0f, s = w/9.0f - pad*2;
	float pts[4*2], fx, fy;
	int joins[3] = {NVG_MITER, NVG_ROUND, NVG_BEVEL};
	int caps[3] = {NVG_BUTT, NVG_ROUND, NVG_SQUARE};
	NVG_NOTUSED(h);

	nvgSave(vg);
	pts[0] = -s*0.25f + cosf(t*0.3f) * s*0.5f;
	pts[1] = sinf(t*0.3f) * s*0.5f;
	pts[2] = -s*0.25f;
	pts[3] = 0;
	pts[4] = s*0.25f;
	pts[5] = 0;
	pts[6] = s*0.25f + cosf(-t*0.3f) * s*0.5f;
	pts[7] = sinf(-t*0.3f) * s*0.5f;

	for (i = 0; i < 3; i++)
	{
		for (j = 0; j < 3; j++)
		{
			fx = x + s*0.5f + (i*3+j)/9.0f*w + pad;
			fy = y - s*0.5f + pad;

			nvgLineCap(vg, caps[i]);
			nvgLineJoin(vg, joins[j]);

			nvgStrokeWidth(vg, s*0.3f);
			nvgStrokeColor(vg, nvgRGBA(0,0,0,160) );
			nvgBeginPath(vg);
			nvgMoveTo(vg, fx+pts[0], fy+pts[1]);
			nvgLineTo(vg, fx+pts[2], fy+pts[3]);
			nvgLineTo(vg, fx+pts[4], fy+pts[5]);
			nvgLineTo(vg, fx+pts[6], fy+pts[7]);
			nvgStroke(vg);

			nvgLineCap(vg, NVG_BUTT);
			nvgLineJoin(vg, NVG_BEVEL);

			nvgStrokeWidth(vg, 1.0f);
			nvgStrokeColor(vg, nvgRGBA(0,192,255,255) );
			nvgBeginPath(vg);
			nvgMoveTo(vg, fx+pts[0], fy+pts[1]);
			nvgLineTo(vg, fx+pts[2], fy+pts[3]);
			nvgLineTo(vg, fx+pts[4], fy+pts[5]);
			nvgLineTo(vg, fx+pts[6], fy+pts[7]);
			nvgStroke(vg);
		}
	}

	nvgRestore(vg);
}
Exemplo n.º 2
0
void drawCaps(struct NVGcontext* vg, float x, float y, float width)
{
	int i;
	int caps[3] = {NVG_BUTT, NVG_ROUND, NVG_SQUARE};
	float lineWidth = 8.0f;

	nvgSave(vg);

	nvgBeginPath(vg);
	nvgRect(vg, x-lineWidth/2, y, width+lineWidth, 40);
	nvgFillColor(vg, nvgRGBA(255,255,255,32));
	nvgFill(vg);

	nvgBeginPath(vg);
	nvgRect(vg, x, y, width, 40);
	nvgFillColor(vg, nvgRGBA(255,255,255,32));
	nvgFill(vg);

	nvgStrokeWidth(vg, lineWidth);
	for (i = 0; i < 3; i++) {
		nvgLineCap(vg, caps[i]);
		nvgStrokeColor(vg, nvgRGBA(0,0,0,255));
		nvgBeginPath(vg);
		nvgMoveTo(vg, x, y + i*10 + 5);
		nvgLineTo(vg, x+width, y + i*10 + 5);
		nvgStroke(vg);
	}

	nvgRestore(vg);
}
Exemplo n.º 3
0
void VectorRenderer::preDraw(lmscalar a, lmscalar b, lmscalar c, lmscalar d, lmscalar e, lmscalar f) {
	LOOM_PROFILE_SCOPE(vectorPreDraw);

	nvgSave(nvg);
	nvgTransform(nvg, (float) a, (float) b, (float) c, (float) d, (float) e, (float) f);
	
	nvgLineCap(nvg, NVG_BUTT);
	nvgLineJoin(nvg, NVG_ROUND);

	currentTextFormat = VectorTextFormat::defaultFormat;
	currentTextFormatAlpha = 1;
	currentTextFormatApplied = false;
}
Exemplo n.º 4
0
void NanoVG::setLineCap( int cap )
{
    nvgLineCap( m_context(), cap );
}
JNIEXPORT void JNICALL Java_org_lwjgl_nanovg_NanoVG_nnvgLineCap(JNIEnv *__env, jclass clazz, jlong ctxAddress, jint cap) {
	NVGcontext *ctx = (NVGcontext *)(intptr_t)ctxAddress;
	UNUSED_PARAMS(__env, clazz)
	nvgLineCap(ctx, cap);
}
Exemplo n.º 6
0
void QNanoPainter::setLineCap(LineCap cap)
{
    nvgLineCap(nvgCtx(), cap);
}
void Application::drawDebugUI() {
    NVGcontext* nvg = context->nvgContext;
    nvgBeginFrame(nvg, context->getScreenWidth(), context->getScreenHeight(),1.0f);
    nvgResetScissor(nvg);
    rootRegion.drawDebug(context.get());
    Region* onTop = context->getOnTopRegion();
    if (onTop != nullptr) {
        onTop->drawDebug(context.get());
    }
    float cr = context->theme.CORNER_RADIUS;
    if (context->getViewport().contains(context->cursorPosition)) {
        nvgFontSize(nvg, 15);
        nvgFontFaceId(nvg, context->getFontHandle(FontType::Bold));

        /*
        int alignment = 0;
        if (context->cursorPosition.x < context->width() * 0.5f) {
        	alignment = NVG_ALIGN_LEFT;
        } else {
        	alignment = NVG_ALIGN_RIGHT;
        }
        if (context->cursorPosition.y < context->height() * 0.5f) {
        	alignment |= NVG_ALIGN_TOP;
        } else {
        	alignment |= NVG_ALIGN_BOTTOM;
        }
        std::string txt = MakeString() << std::setprecision(4) << " "
        		<< context->cursorPosition;
        nvgTextAlign(nvg, alignment);
        nvgFillColor(nvg, Color(0, 0, 0, 128));
        if (context->hasFocus) {
        	drawText(nvg, context->cursorPosition, txt, FontStyle::Outline,
        			Color(255), Color(64, 64, 64));
        }
        */
        nvgTextAlign(nvg, NVG_ALIGN_TOP);
        float yoffset = 5;
        std::string txt = context->hasFocus ? "Window Has Focus" : "Window Lost Focus";
        drawText(nvg, 5, yoffset, txt.c_str(), FontStyle::Outline, Color(255),
                 Color(64, 64, 64));
        yoffset += 16;
        if (context->mouseOverRegion != nullptr) {
            txt = MakeString() << "Mouse Over ["
                  << context->mouseOverRegion->name << "] "
                  << context->cursorPosition;
            drawText(nvg, 5, yoffset, txt.c_str(), FontStyle::Outline,
                     Color(255), Color(64, 64, 64));
            yoffset += 16;
        }
        if (context->mouseDownRegion != nullptr) {
            txt = MakeString() << "Mouse Down ["
                  << context->mouseDownRegion->name << "] "
                  << context->cursorDownPosition;
            drawText(nvg, 5, yoffset, txt.c_str(), FontStyle::Outline,
                     Color(255), Color(64, 64, 64));
            yoffset += 16;
        }
        if (context->mouseFocusRegion != nullptr) {
            txt = MakeString() << "Mouse Focus ["
                  << context->mouseFocusRegion->name << "]";
            drawText(nvg, 5, yoffset, txt.c_str(), FontStyle::Outline,
                     Color(255), Color(64, 64, 64));
            yoffset += 16;
        }
        if (context->onTopRegion != nullptr) {
            txt =
                MakeString() << "On Top [" << context->onTopRegion->name
                << ": "
                << (context->onTopRegion->isVisible() ?
                    "Visible" : "Hidden") << "]";
            drawText(nvg, 5, yoffset, txt.c_str(), FontStyle::Outline,
                     Color(255), Color(64, 64, 64));
            yoffset += 16;
        }
        if (context->leftMouseButton) {
            txt = "Left Mouse Button Down";
            drawText(nvg, 5, yoffset, txt.c_str(), FontStyle::Outline,
                     Color(255), Color(64, 64, 64));
            yoffset += 16;
        }
        if (context->rightMouseButton) {
            txt = "Right Mouse Button Down";
            drawText(nvg, 5, yoffset, txt.c_str(), FontStyle::Outline,
                     Color(255), Color(64, 64, 64));
            yoffset += 16;
        }
        if (context->hasFocus) {
            nvgBeginPath(nvg);
            nvgLineCap(nvg, NVG_ROUND);
            nvgStrokeWidth(nvg, 2.0f);
            nvgStrokeColor(nvg, Color(255, 255, 255, 255));
            nvgMoveTo(nvg, context->cursorPosition.x - cr,
                      context->cursorPosition.y);
            nvgLineTo(nvg, context->cursorPosition.x + cr,
                      context->cursorPosition.y);
            nvgMoveTo(nvg, context->cursorPosition.x,
                      context->cursorPosition.y - cr);
            nvgLineTo(nvg, context->cursorPosition.x,
                      context->cursorPosition.y + cr);

            nvgStroke(nvg);
            nvgBeginPath(nvg);
            nvgFillColor(nvg, Color(255, 255, 255, 255));
            nvgCircle(nvg, context->cursorPosition.x, context->cursorPosition.y,
                      3.0f);
            nvgFill(nvg);

            nvgBeginPath(nvg);
            nvgFillColor(nvg, Color(255, 64, 32, 255));
            nvgCircle(nvg, context->cursorPosition.x, context->cursorPosition.y,
                      1.5f);
            nvgFill(nvg);
        }
    }
    nvgEndFrame(nvg);
}
Exemplo n.º 8
0
JNIEXPORT void JNICALL Java_firststep_internal_NVG_lineCap
  (JNIEnv *e, jclass c, jlong ctx, jint cap)
{
	nvgLineCap((NVGcontext*)ctx, cap);
}
Exemplo n.º 9
0
void VectorRenderer::lineCaps(VectorLineCaps::Enum caps) {
	nvgLineCap(nvg, caps);
}