org.lwjgl.nanovg.NanoVG.nvgBeginPath()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(11.6k)|赞(0)|评价(0)|浏览(78)

本文整理了Java中org.lwjgl.nanovg.NanoVG.nvgBeginPath()方法的一些代码示例,展示了NanoVG.nvgBeginPath()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NanoVG.nvgBeginPath()方法的具体详情如下:
包路径:org.lwjgl.nanovg.NanoVG
类名称:NanoVG
方法名:nvgBeginPath

NanoVG.nvgBeginPath介绍

[英]Clears the current path and sub-paths.
[中]清除当前路径和子路径。

代码示例

代码示例来源:origin: SpinyOwl/legui

private void renderCaret(long context, Vector4f rect, float nCaretX, NVGColor rgba) {
  nvgLineCap(context, NVG_ROUND);
  nvgLineJoin(context, NVG_ROUND);
  nvgStrokeWidth(context, 1);
  nvgStrokeColor(context, rgba);
  nvgBeginPath(context);
  nvgMoveTo(context, nCaretX, rect.y);
  nvgLineTo(context, nCaretX, rect.y + rect.w);
  nvgStroke(context);
}

代码示例来源:origin: SpinyOwl/legui

private void renderCaret(long context, Vector4f rect, float nCaretX, NVGColor rgba) {
  nvgLineCap(context, NVG_ROUND);
  nvgLineJoin(context, NVG_ROUND);
  nvgStrokeWidth(context, 1);
  nvgStrokeColor(context, rgba);
  nvgBeginPath(context);
  nvgMoveTo(context, nCaretX, rect.y);
  nvgLineTo(context, nCaretX, rect.y + rect.w);
  nvgStroke(context);
}

代码示例来源:origin: SpinyOwl/legui

Vector4f r = (Vector4f) properties.getOrDefault(C_RADIUS, 0);
nvgBeginPath(nanovg);
nvgImagePattern(nanovg, x, y, w, h, 0, imageRef, 1, imagePaint);
nvgRoundedRectVarying(nanovg, x, y, w, h, r.x, r.y, r.z, r.w);

代码示例来源:origin: SpinyOwl/legui

/**
   * Used to render specific Icon.
   *
   * @param image image to render.
   * @param position image position.
   * @param size image size.
   * @param context context.
   * @param nanovg nanoVG context.
   */
  @Override
  protected void renderImage(FBOImage image, Vector2fc position, Vector2fc size, Map<String, Object> properties, Context context, long nanovg) {

    try (NVGPaint imagePaint = NVGPaint.calloc()) {
      NvgLoadableImageReferenceManager manager = (NvgLoadableImageReferenceManager) context.getContextData().get(IMAGE_REFERENCE_MANAGER);

      int imageRef = manager.getImageReference(image, nanovg);
      float x = position.x();
      float y = position.y();
      float w = size.x();
      float h = size.y();
      Vector4f r = (Vector4f) properties.getOrDefault(C_RADIUS, 0);

      nvgBeginPath(nanovg);
      nvgImagePattern(nanovg, x, y, w, h, 0, imageRef, 1, imagePaint);
      nvgRoundedRectVarying(nanovg, x, y, w, h, r.x, r.y, r.z, r.w);
      nvgFillPaint(nanovg, imagePaint);
      nvgFill(nanovg);
    }
  }
}

代码示例来源:origin: lwjglgamedev/lwjglbook

nvgBeginPath(vg);
nvgRect(vg, 0, window.getHeight() - 100, window.getWidth(), 50);
nvgFillColor(vg, rgba(0x23, 0xa1, 0xf1, 200, colour));
nvgBeginPath(vg);
nvgRect(vg, 0, window.getHeight() - 50, window.getWidth(), 10);
nvgFillColor(vg, rgba(0xc1, 0xe3, 0xf9, 200, colour));
nvgBeginPath(vg);
nvgCircle(vg, xcenter, ycenter, radius);
nvgFillColor(vg, rgba(0xc1, 0xe3, 0xf9, 200, colour));

代码示例来源:origin: SpinyOwl/legui

/**
 * Used to render line.
 *
 * @param context nanoVG context.
 * @param color color to render
 * @param x1 left x
 * @param x2 right x
 * @param y2 top y
 * @param y1 bottom y
 * @param width line width
 */
private void drawLine(long context, Vector4f color, float x1, float y1, float x2, float y2, float width) {
  try (
      NVGColor colorA = NVGColor.calloc()
  ) {
    NvgColorUtil.fillNvgColorWithRGBA(color, colorA);
    nvgLineCap(context, NVG_ROUND);
    nvgLineJoin(context, NVG_ROUND);
    nvgStrokeWidth(context, width);
    nvgStrokeColor(context, colorA);
    nvgBeginPath(context);
    nvgMoveTo(context, x1, y1);
    nvgLineTo(context, x2, y2);
    nvgStroke(context);
  }
}

代码示例来源:origin: SpinyOwl/legui

/**
 * Used to draw rectangle.
 *
 * @param nvg nanovg context.
 * @param position rectangle position.
 * @param size rectangle size.
 * @param bgColor rectangle background color.
 */
public static void drawRect(long nvg, Vector2fc position, Vector2fc size, Vector4fc bgColor) {
  if (bgColor.w() <= MIN_ALPHA) {
    return;
  }
  try (NVGColor fillColor = NVGColor.calloc()) {
    NvgColorUtil.fillNvgColorWithRGBA(bgColor, fillColor);
    nvgBeginPath(nvg);
    nvgFillColor(nvg, fillColor);
    nvgRect(nvg, position.x(), position.y(), size.x(), size.y());
    nvgFill(nvg);
  }
}

代码示例来源:origin: SpinyOwl/legui

/**
 * Used to draw rectangle.
 *
 * @param nvg nanovg context
 * @param rectangle rectangle size and position.
 * @param bgColor rectangle background color.
 */
public static void drawRect(long nvg, Vector4fc rectangle, Vector4fc bgColor) {
  if (bgColor.w() <= MIN_ALPHA) {
    return;
  }
  try (NVGColor fillColor = NVGColor.calloc()) {
    NvgColorUtil.fillNvgColorWithRGBA(bgColor, fillColor);
    nvgBeginPath(nvg);
    nvgFillColor(nvg, fillColor);
    nvgRect(nvg, rectangle.x(), rectangle.y(), rectangle.z(), rectangle.w());
    nvgFill(nvg);
  }
}

代码示例来源:origin: SpinyOwl/legui

/**
 * 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, float radius) {
  if (bgColor.w() <= MIN_ALPHA) {
    return;
  }
  try (NVGColor fillColor = NVGColor.calloc()) {
    NvgColorUtil.fillNvgColorWithRGBA(bgColor, fillColor);
    nvgBeginPath(nvg);
    nvgFillColor(nvg, fillColor);
    nvgRoundedRect(nvg, rectangle.x(), rectangle.y(), rectangle.z(), rectangle.w(), radius);
    nvgFill(nvg);
  }
}

代码示例来源:origin: SpinyOwl/legui

/**
 * 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, float radius) {
  if (bgColor.w() <= MIN_ALPHA) {
    return;
  }
  try (NVGColor fillColor = NVGColor.calloc()) {
    NvgColorUtil.fillNvgColorWithRGBA(bgColor, fillColor);
    nvgBeginPath(nvg);
    nvgFillColor(nvg, fillColor);
    nvgRoundedRect(nvg, position.x(), position.y(), size.x(), size.y(), radius);
    nvgFill(nvg);
  }
}

代码示例来源:origin: SpinyOwl/legui

public static void dropShadow(long context, float x, float y, float w, float h, float cornerRadius, Vector4f shadowColor) {
  try (
      NVGPaint shadowPaint = NVGPaint.calloc();
      NVGColor colorA = NVGColor.calloc();
      NVGColor colorB = NVGColor.calloc()
  ) {
    NvgColorUtil.fillNvgColorWithRGBA(shadowColor, colorA);
    NvgColorUtil.fillNvgColorWithRGBA(0, 0, 0, 0, colorB);
    nvgBoxGradient(context, x, y + 2, w, h, cornerRadius * 2, 10, colorA, colorB, shadowPaint);
    nvgBeginPath(context);
    nvgRect(context, x - 10, y - 10, w + 20, h + 30);
    nvgRoundedRect(context, x, y, w, h, cornerRadius);
    nvgPathWinding(context, NVG_HOLE);
    nvgFillPaint(context, shadowPaint);
    nvgFill(context);
  }
}

代码示例来源:origin: SpinyOwl/legui

/**
 * 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);
  }
}

代码示例来源:origin: SpinyOwl/legui

/**
 * Used to draw rectangle stroke.
 *
 * @param nvg nanovg context
 * @param rectangle rectangle size and position.
 * @param rectStrokeColor rectangle color.
 * @param strokeWidth stroke width.
 */
public static void drawRectStroke(long nvg, Vector4fc rectangle, Vector4fc rectStrokeColor, float strokeWidth) {
  if (rectStrokeColor.w() <= MIN_ALPHA) {
    return;
  }
  try (NVGColor strokeColor = NVGColor.calloc()) {
    NvgColorUtil.fillNvgColorWithRGBA(rectStrokeColor, strokeColor);
    nvgBeginPath(nvg);
    nvgStrokeColor(nvg, strokeColor);
    nvgStrokeWidth(nvg, strokeWidth);
    nvgRect(nvg, rectangle.x(), rectangle.y(), rectangle.z(), rectangle.w());
    nvgStroke(nvg);
  }
}

代码示例来源:origin: SpinyOwl/legui

/**
 * 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 corner radius.
 */
public static void drawRectStroke(long nvg, Vector4fc rectangle, Vector4fc rectStrokeColor, float strokeWidth, float radius) {
  if (rectStrokeColor.w() <= MIN_ALPHA) {
    return;
  }
  try (NVGColor strokeColor = NVGColor.calloc()) {
    NvgColorUtil.fillNvgColorWithRGBA(rectStrokeColor, strokeColor);
    nvgBeginPath(nvg);
    nvgStrokeColor(nvg, strokeColor);
    nvgStrokeWidth(nvg, strokeWidth);
    nvgRoundedRect(nvg, rectangle.x(), rectangle.y(), rectangle.z(), rectangle.w(), radius);
    nvgStroke(nvg);
  }
}

代码示例来源:origin: SpinyOwl/legui

/**
 * 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.
 */
public static void drawRectStroke(long nvg, Vector2fc position, Vector2fc size, Vector4fc rectStrokeColor, float strokeWidth) {
  if (rectStrokeColor.w() <= MIN_ALPHA) {
    return;
  }
  try (NVGColor strokeColor = NVGColor.calloc()) {
    NvgColorUtil.fillNvgColorWithRGBA(rectStrokeColor, strokeColor);
    nvgBeginPath(nvg);
    nvgStrokeColor(nvg, strokeColor);
    nvgStrokeWidth(nvg, strokeWidth);
    nvgRect(nvg, position.x(), position.y(), size.x(), size.y());
    nvgStroke(nvg);
  }
}

代码示例来源:origin: SpinyOwl/legui

/**
 * Used to draw rectangle stroke.
 *
 * @param nvg nanovg context.
 * @param position rectangle position.
 * @param size rectangle size.
 * @param rectStrokeColor rectangle color.
 * @param radius corner radius
 * @param strokeWidth stroke width.
 */
public static void drawRectStroke(long nvg, Vector2fc position, Vector2fc size, Vector4fc rectStrokeColor, float strokeWidth, float radius) {
  if (rectStrokeColor.w() <= MIN_ALPHA) {
    return;
  }
  try (NVGColor strokeColor = NVGColor.calloc()) {
    NvgColorUtil.fillNvgColorWithRGBA(rectStrokeColor, strokeColor);
    nvgBeginPath(nvg);
    nvgStrokeColor(nvg, strokeColor);
    nvgStrokeWidth(nvg, strokeWidth);
    nvgRoundedRect(nvg, position.x(), position.y(), size.x(), size.y(), radius);
    nvgStroke(nvg);
  }
}

代码示例来源:origin: SpinyOwl/legui

/**
 * 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);
  }
}

代码示例来源:origin: SpinyOwl/legui

/**
 * 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);
  }
}

代码示例来源:origin: SpinyOwl/legui

/**
 * 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);
  }
}

代码示例来源:origin: SpinyOwl/legui

try (NVGColor textColor = NVGColor.calloc()) {
  NvgColorUtil.fillNvgColorWithRGBA(fontColor, textColor);
  nvgBeginPath(nvg);
  nvgFillColor(nvg, textColor);
  nnvgText(nvg, textPosition.x, textPosition.y, rowStart, rowEnd);

相关文章