RenderContext2D

class RenderContext2D(val batch: BatchBuilder2D, val agBitmapTextureManager: AgBitmapTextureManager) : Extra

Helper class using BatchBuilder2D that keeps a chain of affine transforms MMatrix, ColorTransform and blendMode and allows to draw images and scissors with that transform.

keepMatrix, keepBlendMode, keepColor and keep block methods allow to do transformations inside its blocks while restoring its initial state at the end of the block.

setMatrix, translate, scale, and rotate allows to control the transform matrix.

rect and imageScale allows to render color quads and images.

blendFactors property allow to specify the blending mode to be used. multiplyColor will set the multiplicative color to be usd when drawing rects and images.

scissor methods allow to specify a scissor rectangle limiting the area where the pixels will be renderer.

Constructors

Link copied to clipboard
constructor(batch: BatchBuilder2D, agBitmapTextureManager: AgBitmapTextureManager)

Properties

Link copied to clipboard
Link copied to clipboard

Blending mode to be used in the renders

Link copied to clipboard
Link copied to clipboard
open override var extra: ExtraType
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
var m: Matrix
Link copied to clipboard
Link copied to clipboard

Multiplicative color to be used in the renders

Link copied to clipboard
var size: Size
Link copied to clipboard

Functions

Link copied to clipboard
fun RenderContext2D.drawText(placements: RichTextDataPlacements, textRangeStart: Int = 0, textRangeEnd: Int = Int.MAX_VALUE)
fun RenderContext2D.drawText(text: String, font: BitmapFont, textSize: Double = 16.0, pos: Point = Point.ZERO, color: RGBA = Colors.WHITE, baseline: Boolean = false, textRangeStart: Int = 0, textRangeEnd: Int = Int.MAX_VALUE)
fun RenderContext2D.drawText(text: RichTextData, pos: Point = Point.ZERO, size: Size = Size(10000, 10000), wordWrap: Boolean = true, includePartialLines: Boolean = false, ellipsis: String? = null, fill: Paint? = null, stroke: Stroke? = null, align: TextAlignment = TextAlignment.TOP_LEFT, includeFirstLineAlways: Boolean = true)
Link copied to clipboard
fun ellipse(center: Point, radius: Size, color: RGBA = this.multiplyColor, filtering: Boolean = this.filtering)
Link copied to clipboard
fun ellipseOutline(center: Point, radius: Size, lineWidth: Double = 1.0, color: RGBA = this.multiplyColor, filtering: Boolean = this.filtering)
Link copied to clipboard
inline fun getTexture(slice: BmpSlice): TextureCoords
Link copied to clipboard
fun imageScale(texture: Texture, pos: Point, scale: Double = 1.0, filtering: Boolean = this.filtering)

Renders a texture with the blendMode at x, y scaling it by scale. The texture colors will be multiplied by multiplyColor. Since it is multiplicative, white won't cause any effect.

fun imageScale(texture: Texture, x: Double, y: Double, scale: Double = 1.0, filtering: Boolean = this.filtering)
fun imageScale(texture: Texture, x: Float, y: Float, scale: Float = 1.0f, filtering: Boolean = this.filtering)
Link copied to clipboard
inline fun <T> keep(crossinline callback: () -> T): T

Executes callback restoring the transform matrix, the blendMode and the multiplyColor at the end

Link copied to clipboard
inline fun <T> keepBlendMode(crossinline callback: () -> T): T

Executes callback restoring the initial blendFactors at the end

Link copied to clipboard
inline fun <T> keepColor(crossinline callback: () -> T): T

Executes callback restoring the initial multiplyColor at the end

Link copied to clipboard
inline fun <T> keepFiltering(crossinline callback: () -> T): T

Executes callback restoring the initial filtering at the end

Link copied to clipboard
inline fun <T> keepMatrix(crossinline callback: () -> T): T

Executes callback restoring the initial transformation MMatrix at the end

Link copied to clipboard
inline fun <T> keepSize(crossinline callback: () -> T): T
Link copied to clipboard
fun RenderContext2D.materialRoundRect(x: Double, y: Double, width: Double, height: Double, color: RGBA = Colors.RED, radius: RectCorners = RectCorners.EMPTY, shadowOffset: Point = Point.ZERO, shadowColor: RGBA = Colors.BLACK, shadowRadius: Double = 0.0, highlightPos: Point = Point.ZERO, highlightRadius: Double = 0.0, highlightColor: RGBA = Colors.WHITE, borderSize: Double = 0.0, borderColor: RGBA = Colors.WHITE)
Link copied to clipboard
fun quadPaddedCustomProgram(x: Float, y: Float, width: Float, height: Float, program: Program, padding: Margin = Margin.ZERO)
Link copied to clipboard
fun rect(rect: Rectangle, color: RGBA = this.multiplyColor, filtering: Boolean = this.filtering, bmp: BmpSlice = Bitmaps.white, program: Program? = null)

Renders a colored rectangle with the multiplyColor with the blendMode at x, y of size widthxheight

Link copied to clipboard
fun rectOutline(rect: Rectangle, border: Float = 1.0f, color: RGBA = this.multiplyColor, filtering: Boolean = this.filtering)

Renders a colored rectangle with the multiplyColor with the blendMode at x, y of size widthxheight

Link copied to clipboard
fun rotate(angle: Angle)

Rotates the current transform matrix by angle

Link copied to clipboard
fun scale(s: Scale)

Scales the current transform matrix by sx and sy

fun scale(scale: Double)
fun scale(sx: Double, sy: Double)
fun scale(sx: Float, sy: Float)

fun scale(scale: Float)

Scales the current transform matrix by scale

Link copied to clipboard
inline fun scissor(scissor: AGScissor, block: () -> Unit)

Temporarily sets the scissor (visible rendering area) to scissor is executed.

inline fun scissor(rect: Rectangle?, block: () -> Unit)

Temporarily sets the scissor (visible rendering area) to rect is executed.

inline fun scissor(x: Double, y: Double, width: Double, height: Double, block: () -> Unit)
inline fun scissor(x: Float, y: Float, width: Float, height: Float, block: () -> Unit)
inline fun scissor(x: Int, y: Int, width: Int, height: Int, block: () -> Unit)

Temporarily sets the scissor (visible rendering area) to x, y, width and height while block is executed.

Link copied to clipboard
fun setMatrix(matrix: Matrix)

Sets the current transform matrix

Link copied to clipboard
fun simplePath(path: VectorPath, color: RGBA = this.multiplyColor, filtering: Boolean = this.filtering)
Link copied to clipboard
fun texturedVertexArray(texturedVertexArray: TexturedVertexArray, filtering: Boolean = this.filtering)
Link copied to clipboard
fun texturedVertexArrayNoTransform(texturedVertexArray: TexturedVertexArray, filtering: Boolean = this.filtering, matrix: Matrix = Matrix.NIL)
Link copied to clipboard

Translates the current transform matrix by dx and dy

fun translate(dx: Double, dy: Double)
fun translate(dx: Float, dy: Float)