org.lwjgl.nanovg.NSVGShape Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lwjgl-nanovg Show documentation
Show all versions of lwjgl-nanovg Show documentation
A small antialiased vector graphics rendering library for OpenGL. Also includes NanoSVG, a simple SVG parser.
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.nanovg;
import javax.annotation.*;
import java.nio.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.MemoryUtil.*;
/**
* Member documentation
*
*
* - {@code id} – optional 'id' attr of the shape or its group
* - {@code fill} – fill paint
* - {@code stroke} – stroke paint
* - {@code opacity} – opacity of the shape
* - {@code strokeWidth} – stroke width (scaled)
* - {@code strokeDashOffset} – stroke dash offset (scaled)
* - {@code strokeDashArray} – stroke dash array (scaled)
* - {@code strokeDashCount} – number of dash values in dash array
* - {@code strokeLineJoin} – stroke join type
* - {@code strokeLineCap} – stroke cap type
* - {@code miterLimit} – miter limit
* - {@code fillRule} – fill rule, see NSVGfillRule
* - {@code flags} – logical or of NSVG_FLAGS_* flags
* - {@code bounds} – tight bounding box of the shape {@code [minx,miny,maxx,maxy]}
* - {@code paths} – linked list of paths in the image
* - {@code next} – pointer to next shape, or {@code NULL} if last element
*
*
* Layout
*
*
* struct NSVGshape {
* char id[64];
* {@link NSVGPaint NSVGpaint} fill;
* {@link NSVGPaint NSVGpaint} stroke;
* float opacity;
* float strokeWidth;
* float strokeDashOffset;
* float strokeDashArray[8];
* char strokeDashCount;
* char strokeLineJoin;
* char strokeLineCap;
* float miterLimit;
* char fillRule;
* unsigned char flags;
* float bounds[4];
* {@link NSVGPath NSVGpath} * paths;
* {@link NSVGShape NSVGshape} * next;
* }
*/
@NativeType("struct NSVGshape")
public class NSVGShape extends Struct {
/** The struct size in bytes. */
public static final int SIZEOF;
public static final int ALIGNOF;
/** The struct member offsets. */
public static final int
ID,
FILL,
STROKE,
OPACITY,
STROKEWIDTH,
STROKEDASHOFFSET,
STROKEDASHARRAY,
STROKEDASHCOUNT,
STROKELINEJOIN,
STROKELINECAP,
MITERLIMIT,
FILLRULE,
FLAGS,
BOUNDS,
PATHS,
NEXT;
static {
Layout layout = __struct(
__array(1, 64),
__member(NSVGPaint.SIZEOF, NSVGPaint.ALIGNOF),
__member(NSVGPaint.SIZEOF, NSVGPaint.ALIGNOF),
__member(4),
__member(4),
__member(4),
__array(4, 8),
__member(1),
__member(1),
__member(1),
__member(4),
__member(1),
__member(1),
__array(4, 4),
__member(POINTER_SIZE),
__member(POINTER_SIZE)
);
SIZEOF = layout.getSize();
ALIGNOF = layout.getAlignment();
ID = layout.offsetof(0);
FILL = layout.offsetof(1);
STROKE = layout.offsetof(2);
OPACITY = layout.offsetof(3);
STROKEWIDTH = layout.offsetof(4);
STROKEDASHOFFSET = layout.offsetof(5);
STROKEDASHARRAY = layout.offsetof(6);
STROKEDASHCOUNT = layout.offsetof(7);
STROKELINEJOIN = layout.offsetof(8);
STROKELINECAP = layout.offsetof(9);
MITERLIMIT = layout.offsetof(10);
FILLRULE = layout.offsetof(11);
FLAGS = layout.offsetof(12);
BOUNDS = layout.offsetof(13);
PATHS = layout.offsetof(14);
NEXT = layout.offsetof(15);
}
NSVGShape(long address, @Nullable ByteBuffer container) {
super(address, container);
}
/**
* Creates a {@link NSVGShape} instance at the current position of the specified {@link ByteBuffer} container. Changes to the buffer's content will be
* visible to the struct instance and vice versa.
*
* The created instance holds a strong reference to the container object.
*/
public NSVGShape(ByteBuffer container) {
this(memAddress(container), __checkContainer(container, SIZEOF));
}
@Override
public int sizeof() { return SIZEOF; }
/** Returns a {@link ByteBuffer} view of the {@code id} field. */
@NativeType("char[64]")
public ByteBuffer id() { return nid(address()); }
/** Returns the value at the specified index of the {@code id} field. */
@NativeType("char")
public byte id(int index) { return nid(address(), index); }
/** Returns a {@link NSVGPaint} view of the {@code fill} field. */
@NativeType("NSVGpaint")
public NSVGPaint fill() { return nfill(address()); }
/** Returns a {@link NSVGPaint} view of the {@code stroke} field. */
@NativeType("NSVGpaint")
public NSVGPaint stroke() { return nstroke(address()); }
/** Returns the value of the {@code opacity} field. */
public float opacity() { return nopacity(address()); }
/** Returns the value of the {@code strokeWidth} field. */
public float strokeWidth() { return nstrokeWidth(address()); }
/** Returns the value of the {@code strokeDashOffset} field. */
public float strokeDashOffset() { return nstrokeDashOffset(address()); }
/** Returns a {@link FloatBuffer} view of the {@code strokeDashArray} field. */
@NativeType("float[8]")
public FloatBuffer strokeDashArray() { return nstrokeDashArray(address()); }
/** Returns the value at the specified index of the {@code strokeDashArray} field. */
public float strokeDashArray(int index) { return nstrokeDashArray(address(), index); }
/** Returns the value of the {@code strokeDashCount} field. */
@NativeType("char")
public byte strokeDashCount() { return nstrokeDashCount(address()); }
/** Returns the value of the {@code strokeLineJoin} field. */
@NativeType("char")
public byte strokeLineJoin() { return nstrokeLineJoin(address()); }
/** Returns the value of the {@code strokeLineCap} field. */
@NativeType("char")
public byte strokeLineCap() { return nstrokeLineCap(address()); }
/** Returns the value of the {@code miterLimit} field. */
public float miterLimit() { return nmiterLimit(address()); }
/** Returns the value of the {@code fillRule} field. */
@NativeType("char")
public byte fillRule() { return nfillRule(address()); }
/** Returns the value of the {@code flags} field. */
@NativeType("unsigned char")
public byte flags() { return nflags(address()); }
/** Returns a {@link FloatBuffer} view of the {@code bounds} field. */
@NativeType("float[4]")
public FloatBuffer bounds() { return nbounds(address()); }
/** Returns the value at the specified index of the {@code bounds} field. */
public float bounds(int index) { return nbounds(address(), index); }
/** Returns a {@link NSVGPath} view of the struct pointed to by the {@code paths} field. */
@NativeType("NSVGpath *")
public NSVGPath paths() { return npaths(address()); }
/** Returns a {@link NSVGShape} view of the struct pointed to by the {@code next} field. */
@NativeType("NSVGshape *")
public NSVGShape next() { return nnext(address()); }
// -----------------------------------
/** Returns a new {@link NSVGShape} instance for the specified memory address. */
public static NSVGShape create(long address) {
return new NSVGShape(address, null);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static NSVGShape createSafe(long address) {
return address == NULL ? null : create(address);
}
/**
* Create a {@link NSVGShape.Buffer} instance at the specified memory.
*
* @param address the memory address
* @param capacity the buffer capacity
*/
public static NSVGShape.Buffer create(long address, int capacity) {
return new Buffer(address, capacity);
}
/** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static NSVGShape.Buffer createSafe(long address, int capacity) {
return address == NULL ? null : create(address, capacity);
}
// -----------------------------------
/** Unsafe version of {@link #id}. */
public static ByteBuffer nid(long struct) { return memByteBuffer(struct + NSVGShape.ID, 64); }
/** Unsafe version of {@link #id(int) id}. */
public static byte nid(long struct, int index) {
if (CHECKS) { check(index, 64); }
return memGetByte(struct + NSVGShape.ID + index * 1);
}
/** Unsafe version of {@link #fill}. */
public static NSVGPaint nfill(long struct) { return NSVGPaint.create(struct + NSVGShape.FILL); }
/** Unsafe version of {@link #stroke}. */
public static NSVGPaint nstroke(long struct) { return NSVGPaint.create(struct + NSVGShape.STROKE); }
/** Unsafe version of {@link #opacity}. */
public static float nopacity(long struct) { return memGetFloat(struct + NSVGShape.OPACITY); }
/** Unsafe version of {@link #strokeWidth}. */
public static float nstrokeWidth(long struct) { return memGetFloat(struct + NSVGShape.STROKEWIDTH); }
/** Unsafe version of {@link #strokeDashOffset}. */
public static float nstrokeDashOffset(long struct) { return memGetFloat(struct + NSVGShape.STROKEDASHOFFSET); }
/** Unsafe version of {@link #strokeDashArray}. */
public static FloatBuffer nstrokeDashArray(long struct) { return memFloatBuffer(struct + NSVGShape.STROKEDASHARRAY, 8); }
/** Unsafe version of {@link #strokeDashArray(int) strokeDashArray}. */
public static float nstrokeDashArray(long struct, int index) {
if (CHECKS) { check(index, 8); }
return memGetFloat(struct + NSVGShape.STROKEDASHARRAY + index * 4);
}
/** Unsafe version of {@link #strokeDashCount}. */
public static byte nstrokeDashCount(long struct) { return memGetByte(struct + NSVGShape.STROKEDASHCOUNT); }
/** Unsafe version of {@link #strokeLineJoin}. */
public static byte nstrokeLineJoin(long struct) { return memGetByte(struct + NSVGShape.STROKELINEJOIN); }
/** Unsafe version of {@link #strokeLineCap}. */
public static byte nstrokeLineCap(long struct) { return memGetByte(struct + NSVGShape.STROKELINECAP); }
/** Unsafe version of {@link #miterLimit}. */
public static float nmiterLimit(long struct) { return memGetFloat(struct + NSVGShape.MITERLIMIT); }
/** Unsafe version of {@link #fillRule}. */
public static byte nfillRule(long struct) { return memGetByte(struct + NSVGShape.FILLRULE); }
/** Unsafe version of {@link #flags}. */
public static byte nflags(long struct) { return memGetByte(struct + NSVGShape.FLAGS); }
/** Unsafe version of {@link #bounds}. */
public static FloatBuffer nbounds(long struct) { return memFloatBuffer(struct + NSVGShape.BOUNDS, 4); }
/** Unsafe version of {@link #bounds(int) bounds}. */
public static float nbounds(long struct, int index) {
if (CHECKS) { check(index, 4); }
return memGetFloat(struct + NSVGShape.BOUNDS + index * 4);
}
/** Unsafe version of {@link #paths}. */
public static NSVGPath npaths(long struct) { return NSVGPath.create(memGetAddress(struct + NSVGShape.PATHS)); }
/** Unsafe version of {@link #next}. */
public static NSVGShape nnext(long struct) { return NSVGShape.create(memGetAddress(struct + NSVGShape.NEXT)); }
// -----------------------------------
/** An array of {@link NSVGShape} structs. */
public static class Buffer extends StructBuffer {
/**
* Creates a new {@link NSVGShape.Buffer} instance backed by the specified container.
*
* Changes to the container's content will be visible to the struct buffer instance and vice versa. The two buffers' position, limit, and mark values
* will be independent. The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided
* by {@link NSVGShape#SIZEOF}, and its mark will be undefined.
*
* The created buffer instance holds a strong reference to the container object.
*/
public Buffer(ByteBuffer container) {
super(container, container.remaining() / SIZEOF);
}
public Buffer(long address, int cap) {
super(address, null, -1, 0, cap, cap);
}
Buffer(long address, @Nullable ByteBuffer container, int mark, int pos, int lim, int cap) {
super(address, container, mark, pos, lim, cap);
}
@Override
protected Buffer self() {
return this;
}
@Override
protected Buffer newBufferInstance(long address, @Nullable ByteBuffer container, int mark, int pos, int lim, int cap) {
return new Buffer(address, container, mark, pos, lim, cap);
}
@Override
protected NSVGShape newInstance(long address) {
return new NSVGShape(address, container);
}
@Override
public int sizeof() {
return SIZEOF;
}
/** Returns a {@link ByteBuffer} view of the {@code id} field. */
@NativeType("char[64]")
public ByteBuffer id() { return NSVGShape.nid(address()); }
/** Returns the value at the specified index of the {@code id} field. */
@NativeType("char")
public byte id(int index) { return NSVGShape.nid(address(), index); }
/** Returns a {@link NSVGPaint} view of the {@code fill} field. */
@NativeType("NSVGpaint")
public NSVGPaint fill() { return NSVGShape.nfill(address()); }
/** Returns a {@link NSVGPaint} view of the {@code stroke} field. */
@NativeType("NSVGpaint")
public NSVGPaint stroke() { return NSVGShape.nstroke(address()); }
/** Returns the value of the {@code opacity} field. */
public float opacity() { return NSVGShape.nopacity(address()); }
/** Returns the value of the {@code strokeWidth} field. */
public float strokeWidth() { return NSVGShape.nstrokeWidth(address()); }
/** Returns the value of the {@code strokeDashOffset} field. */
public float strokeDashOffset() { return NSVGShape.nstrokeDashOffset(address()); }
/** Returns a {@link FloatBuffer} view of the {@code strokeDashArray} field. */
@NativeType("float[8]")
public FloatBuffer strokeDashArray() { return NSVGShape.nstrokeDashArray(address()); }
/** Returns the value at the specified index of the {@code strokeDashArray} field. */
public float strokeDashArray(int index) { return NSVGShape.nstrokeDashArray(address(), index); }
/** Returns the value of the {@code strokeDashCount} field. */
@NativeType("char")
public byte strokeDashCount() { return NSVGShape.nstrokeDashCount(address()); }
/** Returns the value of the {@code strokeLineJoin} field. */
@NativeType("char")
public byte strokeLineJoin() { return NSVGShape.nstrokeLineJoin(address()); }
/** Returns the value of the {@code strokeLineCap} field. */
@NativeType("char")
public byte strokeLineCap() { return NSVGShape.nstrokeLineCap(address()); }
/** Returns the value of the {@code miterLimit} field. */
public float miterLimit() { return NSVGShape.nmiterLimit(address()); }
/** Returns the value of the {@code fillRule} field. */
@NativeType("char")
public byte fillRule() { return NSVGShape.nfillRule(address()); }
/** Returns the value of the {@code flags} field. */
@NativeType("unsigned char")
public byte flags() { return NSVGShape.nflags(address()); }
/** Returns a {@link FloatBuffer} view of the {@code bounds} field. */
@NativeType("float[4]")
public FloatBuffer bounds() { return NSVGShape.nbounds(address()); }
/** Returns the value at the specified index of the {@code bounds} field. */
public float bounds(int index) { return NSVGShape.nbounds(address(), index); }
/** Returns a {@link NSVGPath} view of the struct pointed to by the {@code paths} field. */
@NativeType("NSVGpath *")
public NSVGPath paths() { return NSVGShape.npaths(address()); }
/** Returns a {@link NSVGShape} view of the struct pointed to by the {@code next} field. */
@NativeType("NSVGshape *")
public NSVGShape next() { return NSVGShape.nnext(address()); }
}
}