Java 类org.lwjgl.nanovg.NVGPaint 实例源码
项目:NanoUI
文件:NanoTheme.java
@Override
public void renderImage(long vg, float x, float y, float w, float h, int image, float alpha) {
NVGPaint imgPaint = paintB;
nvgSave(vg);
nvgIntersectScissor(vg, x, y, w, h);
nvgImagePattern(vg, x, y, w, h, 0, image, alpha, imgPaint);
nvgBeginPath(vg);
nvgRect(vg, x, y, w, h);
nvgFillPaint(vg, imgPaint);
nvgFill(vg);
if (Theme.DEBUG) {
nvgStrokeWidth(vg, Theme.DEBUG_STROKE);
nvgStrokeColor(vg, Theme.debugB);
nvgStroke(vg);
}
nvgRestore(vg);
}
项目:NanoUI
文件:NanoTheme.java
@Override
public void renderImage(long vg, float x, float y, int image, float alpha) {
NVGPaint imgPaint = paintB;
int[] iw = new int[1], ih = new int[1];
nvgSave(vg);
nvgImageSize(vg, image, iw, ih);
nvgIntersectScissor(vg, x, y, iw[0], ih[0]);
nvgImagePattern(vg, x, y, iw[0], ih[0], 0, image, alpha, imgPaint);
nvgBeginPath(vg);
nvgRect(vg, x, y, iw[0], iw[0]);
nvgFillPaint(vg, imgPaint);
nvgFill(vg);
if (Theme.DEBUG) {
nvgStrokeWidth(vg, Theme.DEBUG_STROKE);
nvgStrokeColor(vg, Theme.debugB);
nvgStroke(vg);
}
nvgRestore(vg);
}
项目:NanoUI
文件:NanoTheme.java
@Override
public void renderSpinner(long vg, float cx, float cy, float r, float t) {
float a0 = 0.0f + t * 6;
float a1 = NVG_PI + t * 6;
float r0 = r;
float r1 = r * 0.75f;
float ax, ay, bx, by;
NVGPaint paint = paintA;
nvgSave(vg);
nvgBeginPath(vg);
nvgArc(vg, cx, cy, r0, a0, a1, NVG_CW);
nvgArc(vg, cx, cy, r1, a1, a0, NVG_CCW);
nvgClosePath(vg);
ax = cx + (float) Math.cos(a0) * (r0 + r1) * 0.5f;
ay = cy + (float) Math.sin(a0) * (r0 + r1) * 0.5f;
bx = cx + (float) Math.cos(a1) * (r0 + r1) * 0.5f;
by = cy + (float) Math.sin(a1) * (r0 + r1) * 0.5f;
nvgLinearGradient(vg, ax, ay, bx, by, Theme.rgba(0, 0, 0, 0, colorA), Theme.rgba(0, 0, 0, 128, colorB), paint);
nvgFillPaint(vg, paint);
nvgFill(vg);
nvgRestore(vg);
}
项目:CommunityEngine-Java
文件:Node.java
public Node(float x, float y, float width, float height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
color = NVGColor.create();
paint = NVGPaint.create();
}
项目:Mavkit
文件:NanoVGCanvas.java
private NVGPaint unwrap(@Nullable Paint paint) {
if (paint == null) throw new IllegalArgumentException("Cannot use a null paint");
if (!(paint instanceof NanoVGPaint) || !((NanoVGPaint)paint).isOwner(this)) {
throw new IllegalArgumentException("Cannot use a Paint from another Canvas");
}
return ((NanoVGPaint)paint).wrapped;
}
项目:Mavkit
文件:NanoVGCanvas.java
@Override
@Nullable
public Paint createLinearGradient(float startX, float startY, float endX,
float endY, Color start, Color end) {
NVGPaint paint = nvgLinearGradient(ctx, startX, startY, endX, endY, unwrap(start), unwrap(end), NVGPaint.create());
return new NanoVGPaint(paint);
}
项目:Mavkit
文件:NanoVGCanvas.java
@Override
@Nullable
public Paint createBoxGradient(float x, float y, float width, float height,
float radius, float feather, Color inner, Color outer) {
NVGPaint paint = nvgBoxGradient(ctx, x, y, width, height, radius, feather, unwrap(inner), unwrap(outer), NVGPaint.create());
return new NanoVGPaint(paint);
}
项目:Mavkit
文件:NanoVGCanvas.java
@Override
@Nullable
public Paint createRadialGradient(float centerX, float centerY,
float innerRadius, float outerRadius, @NonNull Color inner, @NonNull Color outer) {
NVGPaint paint = nvgRadialGradient(ctx, centerX, centerY, innerRadius, outerRadius, unwrap(inner), unwrap(outer), NVGPaint.create());
return new NanoVGPaint(paint);
}
项目:Mavkit
文件:NanoVGCanvas.java
@Override
@Nullable
public Paint createPattern(float x, float y, float width, float height,
float angle, @NonNull Image image, float alpha) {
NVGPaint paint = NVGPaint.create();
paint = nvgImagePattern(ctx, x, y, width, height, angle, unwrap(image), alpha, paint);
return new NanoVGPaint(paint);
}
项目:Java-GLEngine
文件:Gradient.java
/**
* Sets the current fill paint to this image
*/
public void setAsFillPaint() {
try(MemoryStack stack = MemoryStack.stackPush()) {
NVGPaint c = NVGPaint.mallocStack(stack);
nvgGradient(c);
NanoVG.nvgFillPaint(GUI.gui.nvgCtx, c);
}
}
项目:Java-GLEngine
文件:Gradient.java
/**
* Sets the current stroke paint to this image
*/
public void setAsStrokePaint() {
try(MemoryStack stack = MemoryStack.stackPush()) {
NVGPaint c = NVGPaint.mallocStack(stack);
nvgGradient(c);
NanoVG.nvgStrokePaint(GUI.gui.nvgCtx, c);
}
}
项目:Java-GLEngine
文件:Gradient.java
private void nvgGradient(NVGPaint paint) {
try(MemoryStack stack = MemoryStack.stackPush()) {
NVGColor icolor = NVGColor.mallocStack(stack), ocolor = NVGColor.mallocStack(stack);
inside.convert(icolor);
outside.convert(ocolor);
if(type == 0) {
nvgLinearGradient(gui.nvgCtx, a, b, c, d, icolor, ocolor, paint);
} else if(type == 1) {
nvgBoxGradient(gui.nvgCtx, a, b, c, d, e, f, icolor, ocolor, paint);
} else if(type == 2) {
nvgRadialGradient(gui.nvgCtx, a, b, c, d, icolor, ocolor, paint);
}
}
}
项目:Java-GLEngine
文件:Image.java
/**
* Sets the current fill paint to this image
*/
public void setAsFillPaint() {
try(MemoryStack stack = MemoryStack.stackPush()) {
NVGPaint c = NVGPaint.mallocStack(stack);
c = nvgImagePattern(gui.nvgCtx, x, y, width, height, angle, handle, alpha, c);
NanoVG.nvgFillPaint(GUI.gui.nvgCtx, c);
}
}
项目:Java-GLEngine
文件:Image.java
/**
* Sets the current stroke paint to this image
*/
public void setAsStrokePaint() {
try(MemoryStack stack = MemoryStack.stackPush()) {
NVGPaint c = NVGPaint.mallocStack(stack);
c = nvgImagePattern(gui.nvgCtx, x, y, width, height, angle, handle, alpha, c);
NanoVG.nvgStrokePaint(GUI.gui.nvgCtx, c);
}
}
项目:Mavkit
文件:NanoVGCanvas.java
public NanoVGPaint(NVGPaint paint) {
this.wrapped = paint;
}