DrawResource
final class DrawResource
Package: dev.joid.lib.draw.resource · Module: core · Source: DrawResource.java
Draws resources and GPU textures, tinted by the current color of the render state.
Description
Section titled “Description”Reach it through DrawUtils.RESOURCE.
Positions and sizes are in design pixels, in the coordinates you draw in.
The image is multiplied by the current color of the render state: bind a Color around the call to tint it or fade it.
A drawn resource asks its decoder for the size it covers in screen pixels, so a vector image stays sharp, and turns on mipmaps by itself when it is drawn smaller than its texture with linear filtering. A resource that is still loading draws nothing; a failed resource draws a checkerboard in dev mode and nothing otherwise.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
DrawResource | inst() factory | Returns the shared instance, the one in DrawUtils.RESOURCE. |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
void | drawResource(double x, double y, Resource resource) | Draws the resource at x, y at its own size, Resource.getWidth × Resource.getHeight. |
void | drawResource(double x, double y, double width, double height, Resource resource) | Draws the resource stretched to width × height. |
void | drawResource(double x, double y, double width, double height, double u, double v, double regionWidth, double regionHeight, Resource resource) | Draws a region of the image stretched to width × height: the region starts at u, v and spans regionWidth × regionHeight, in pixels of the source image. |
void | drawTexture(double x, double y, double width, double height, ITexture texture, double u0, double v0, double u1, double v1, TextureFilter filter, BlendState blend) | Draws a raw GPU texture, such as the color texture of a FrameBuffer, stretched to width × height, with the filter and the blending you pass. |
Creation details
Section titled “Creation details”DrawResource inst() factory
Returns the shared instance, the one in DrawUtils.RESOURCE.
Method details
Section titled “Method details”drawResource
Section titled “drawResource”void drawResource(double x, double y, Resource resource)
Draws the resource at x, y at its own size, Resource.getWidth × Resource.getHeight.
void drawResource(double x, double y, double width, double height, Resource resource)
Draws the resource stretched to width × height.
void drawResource(double x, double y, double width, double height, double u, double v, double regionWidth, double regionHeight, Resource resource)
Draws a region of the image stretched to width × height: the region starts at u, v and spans regionWidth × regionHeight, in pixels of the source image.
When the resource has its own region (textureCoords), u and v count from the corner of that region.
drawTexture
Section titled “drawTexture”void drawTexture(double x, double y, double width, double height, ITexture texture, double u0, double v0, double u1, double v1, TextureFilter filter, BlendState blend)
Draws a raw GPU texture, such as the color texture of a FrameBuffer, stretched to width × height, with the filter and the blending you pass.
u0, v0 and u1, v1 are the texture coordinates of the top-left and bottom-right corners, on 1; swap v0 and v1 to flip the image.
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
