/** * Used to draw rectangle. * * @param nvg nanovg context * @param rectangle rectangle size and position. * @param bgColor rectangle background color. * @param radius cornder radius */ public static void drawRect(long nvg, Vector4fc rectangle, Vector4fc bgColor, Vector4f radius) { if (radius != null && !radius.equals(ZERO_CORNDERS)) { try (NVGColor fillColor = NVGColor.calloc()) { NvgColorUtil.fillNvgColorWithRGBA(bgColor, fillColor); nvgBeginPath(nvg); nvgFillColor(nvg, fillColor); nvgRoundedRectVarying(nvg, rectangle.x(), rectangle.y(), rectangle.z(), rectangle.w(), radius.x, radius.y, radius.z, radius.w); nvgFill(nvg); } } else { drawRect(nvg, rectangle, bgColor, radius); } }
/** * Used to draw rectangle stroke. * * @param nvg nanovg context * @param rectangle rectangle size and position. * @param rectStrokeColor rectangle color. * @param strokeWidth stroke width. * @param radius radius vector. */ public static void drawRectStroke(long nvg, Vector4fc rectangle, Vector4fc rectStrokeColor, float strokeWidth, Vector4f radius) { if (radius != null && !radius.equals(ZERO_CORNDERS)) { try (NVGColor strokeColor = NVGColor.calloc()) { NvgColorUtil.fillNvgColorWithRGBA(rectStrokeColor, strokeColor); nvgBeginPath(nvg); nvgStrokeColor(nvg, strokeColor); nvgStrokeWidth(nvg, strokeWidth); nvgRoundedRectVarying(nvg, rectangle.x(), rectangle.y(), rectangle.z(), rectangle.w(), radius.x, radius.y, radius.z, radius.w); nvgStroke(nvg); } } else { drawRectStroke(nvg, rectangle, rectStrokeColor, strokeWidth); } }
/** * Used to draw rectangle stroke. * * @param nvg nanovg context. * @param position rectangle position. * @param size rectangle size. * @param rectStrokeColor rectangle color. * @param strokeWidth stroke width. * @param radius radius vector. */ public static void drawRectStroke(long nvg, Vector2fc position, Vector2fc size, Vector4fc rectStrokeColor, float strokeWidth, Vector4f radius) { if (radius != null && !radius.equals(ZERO_CORNDERS)) { try (NVGColor strokeColor = NVGColor.calloc()) { NvgColorUtil.fillNvgColorWithRGBA(rectStrokeColor, strokeColor); nvgBeginPath(nvg); nvgStrokeColor(nvg, strokeColor); nvgStrokeWidth(nvg, strokeWidth); nvgRoundedRectVarying(nvg, position.x(), position.y(), size.x(), size.y(), radius.x, radius.y, radius.z, radius.w); nvgStroke(nvg); } } else { drawRectStroke(nvg, position, size, rectStrokeColor, strokeWidth); } }
/** * Used to draw rectangle. * * @param nvg nanovg context. * @param position rectangle position. * @param size rectangle size. * @param bgColor rectangle background color. * @param radius cornder radius */ public static void drawRect(long nvg, Vector2fc position, Vector2fc size, Vector4fc bgColor, Vector4f radius) { if (radius != null && !radius.equals(ZERO_CORNDERS)) { try (NVGColor fillColor = NVGColor.calloc()) { NvgColorUtil.fillNvgColorWithRGBA(bgColor, fillColor); nvgBeginPath(nvg); nvgFillColor(nvg, fillColor); if (radius.x == radius.y && radius.x == radius.z && radius.x == radius.w) { nvgRoundedRect(nvg, position.x(), position.y(), size.x(), size.y(), radius.x); } else { nvgRoundedRectVarying(nvg, position.x(), position.y(), size.x(), size.y(), radius.x, radius.y, radius.z, radius.w); } nvgFill(nvg); } } else { drawRect(nvg, position, size, bgColor); } }