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.
Learn more
Section titled “Learn more”Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
SnapshotImage | frame(ISnapshotBackend backend, int width, int height, Consumer | 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. |
Method details
Section titled “Method details”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.
shader
Section titled “shader”IShader shader(String fragment) static
Returns a shader of that fragment stage, with a vertex stage that applies the projection and the modelview.
assertPixel
Section titled “assertPixel”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.
vertices
Section titled “vertices”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
