Skip to content

ContractDraw

final class ContractDraw
Package: dev.joid.test.contract · Module: tool-testkit · Source: ContractDraw.java

The helpers of the contract suites, for contract tests of your own: a frame around a drawing, quads and vertices, a shader from a fragment stage, a pixel assertion.

ReturnsSignatureSummary
SnapshotImageframe(ISnapshotBackend backend, int width, int height, Consumer draw) staticBegins a frame, clears it to opaque black, runs the drawing, ends the frame, then returns the capture of that size and presents.
voidreset(int width, int height) staticResets the modelview, an orthographic projection of that size from the top-left corner, and a render state with that viewport, normal blending and no depth writes.
IShadershader(String fragment) staticReturns a shader of that fragment stage, with a vertex stage that applies the projection and the modelview.
voidassertPixel(SnapshotImage image, int x, int y, int expected) staticFails with both colors in hexadecimal when the pixel at that position is not that ARGB color.
VertexBufferquad(float x, float y, float width, float height, float z, boolean texture, int color, boolean normal, float start, float end) staticReturns two triangles of that rectangle at that depth, with texture coordinates from start to end, and an ARGB vertex color when it is not 0.
VertexBuffervertices(float[][] points, float z, boolean texture, int color, boolean normal) staticReturns a vertex buffer of those points, each {x, y, u, v}, at that depth, with the texture coordinates, the color and the normal flags of the buffer.

SnapshotImage frame(ISnapshotBackend backend, int width, int height, Consumer<IRenderBridge> draw) static

Begins a frame, clears it to opaque black, runs the drawing, ends the frame, then returns the capture of that size and presents.

void reset(int width, int height) static

Resets the modelview, an orthographic projection of that size from the top-left corner, and a render state with that viewport, normal blending and no depth writes.

IShader shader(String fragment) static

Returns a shader of that fragment stage, with a vertex stage that applies the projection and the modelview.

void assertPixel(SnapshotImage image, int x, int y, int expected) static

Fails with both colors in hexadecimal when the pixel at that position is not that ARGB color.

VertexBuffer quad(float x, float y, float width, float height, float z, boolean texture, int color, boolean normal, float start, float end) static

Returns two triangles of that rectangle at that depth, with texture coordinates from start to end, and an ARGB vertex color when it is not 0.

VertexBuffer vertices(float[][] points, float z, boolean texture, int color, boolean normal) static

Returns a vertex buffer of those points, each {x, y, u, v}, at that depth, with the texture coordinates, the color and the normal flags of the buffer.


fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses

Report a problem with this page