Canvas

object Canvas

The canvas management object.

Properties

Link copied to clipboard

Whether the canvas is currently in a drawing state.

Functions

Link copied to clipboard
fun Canvas.arc(cx: Int, cy: Int, radius: Float, startAngle: Float, endAngle: Float, segments: Int = 6, color: Color = Color.BLACK)

Draws an arc outline on the canvas.

Link copied to clipboard
fun Canvas.basisSpline(color: Color = Color.BLACK, thick: Float, vararg points: ERROR CLASS: Symbol not found for Pair<kotlin/Int, kotlin/Int>)
fun Canvas.basisSpline(color: Color = Color.BLACK, thick: Float, points: List<ERROR CLASS: Symbol not found for Pair<kotlin/Int, kotlin/Int>>)

Draws a basis spline on the canvas.

Link copied to clipboard
fun Canvas.billboard(camera: Camera3D, texture: Texture2D, x: Int, y: Int, z: Int, scale: Float = 1.0f, tint: Color = Color.WHITE)

Draws a billboard texture in 3D space.

Link copied to clipboard
fun Canvas.camera2D(camera: Camera2D, block: Canvas.() -> Unit)

Draws within a 2D camera context.

Link copied to clipboard
fun Canvas.camera3D(camera: Camera3D, block: Canvas.() -> Unit)

Draws within a 3D camera context.

Link copied to clipboard
fun Canvas.capsule(x1: Int, y1: Int, z1: Int, x2: Int, y2: Int, z2: Int, radius: Float, slices: Int = 8, rings: Int = 8, color: Color = Color.BLACK)

Draws a capsule's wires in 3D space.

Link copied to clipboard
fun Canvas.catmullRomSpline(color: Color = Color.BLACK, thick: Float, vararg points: ERROR CLASS: Symbol not found for Pair<kotlin/Int, kotlin/Int>)
fun Canvas.catmullRomSpline(color: Color = Color.BLACK, thick: Float, points: List<ERROR CLASS: Symbol not found for Pair<kotlin/Int, kotlin/Int>>)

Draws a Catmull-Rom spline on the canvas.

Link copied to clipboard
fun Canvas.circle(cx: Int, cy: Int, radius: Float, color: Color = Color.BLACK)

Draws a circle outline on the canvas.

Link copied to clipboard
fun Canvas.circle3(cx: Int, cy: Int, cz: Int, radius: Float, rotX: Float, rotY: Float, rotZ: Float, rotAngle: Float, color: Color = Color.BLACK)

Draws a circle in 3D space.

Link copied to clipboard
fun Canvas.cubicBezierSpline(color: Color = Color.BLACK, thick: Float, vararg points: ERROR CLASS: Symbol not found for Pair<kotlin/Int, kotlin/Int>)
fun Canvas.cubicBezierSpline(color: Color = Color.BLACK, thick: Float, points: List<ERROR CLASS: Symbol not found for Pair<kotlin/Int, kotlin/Int>>)

Draws a cubic bezier spline on the canvas.

Link copied to clipboard
fun Canvas.cylinder(x: Int, y: Int, z: Int, radius: Float, height: Float, color: Color = Color.BLACK)
fun Canvas.cylinder(x: Int, y: Int, z: Int, radiusTop: Float, radiusBottom: Float = radiusTop, height: Float, color: Color = Color.BLACK)
fun Canvas.cylinder(x: Int, y: Int, z: Int, radiusTop: Float, radiusBottom: Float = radiusTop, height: Float, slices: Int = 8, color: Color = Color.BLACK)

Draws a cylinder's wires in 3D space.

fun Canvas.cylinder(x1: Int, y1: Int, z1: Int, x2: Int, y2: Int, z2: Int, radiusTop: Float, radiusBottom: Float = radiusTop, sides: Int = 8, color: Color = Color.BLACK)

Draws a cylinder in 3D space with differing start and end points between bases.

Link copied to clipboard
fun draw(callback: Canvas.() -> Unit)

Draws on the canvas using the provided callback function.

Link copied to clipboard
fun Canvas.draw(x: Int, y: Int, color: Color = Color.BLACK)

Draws a pixel on the canvas.

fun Canvas.draw(x: Int, y: Int, z: Int, color: Color)

Draws a 3D point on the canvas.

Link copied to clipboard
fun Canvas.drawBoundingBox(box: BoundingBox, color: Color = Color.RED)

Draws a 3D bounding box on the canvas.

Link copied to clipboard
fun Canvas.drawImage(image: Image, x: Int, y: Int, tint: Color = Color.WHITE)

Draws an image on the canvas at the specified position with an optional tint color.

Link copied to clipboard
fun Canvas.drawMesh(mesh: Mesh, material: Material)

Draws a 3D mesh on the canvas with identity transform (at origin).

fun Canvas.drawMesh(mesh: Mesh, material: Material, transformations: List<Matrix4>)

Draws multiple instances of a 3D mesh on the canvas.

fun Canvas.drawMesh(mesh: Mesh, material: Material, transform: Matrix4)

Draws a 3D mesh on the canvas.

fun Canvas.drawMesh(mesh: Mesh, material: Material, position: ERROR CLASS: Symbol not found for Triple<kotlin/Float, kotlin/Float, kotlin/Float>, rotationAxis: ERROR CLASS: Symbol not found for Triple<kotlin/Float, kotlin/Float, kotlin/Float>, rotationAngle: Float, scale: ERROR CLASS: Symbol not found for Triple<kotlin/Float, kotlin/Float, kotlin/Float>)
fun Canvas.drawMesh(mesh: Mesh, material: Material, x: Float, y: Float, z: Float, rotX: Float = 0.0f, rotY: Float = 0.0f, rotZ: Float = 0.0f, rotAngle: Float = 0.0f, scaleX: Float = 0.0f, scaleY: Float = 0.0f, scaleZ: Float = 0.0f)
fun Canvas.drawMesh(mesh: Mesh, material: Material, x: Int, y: Int, z: Int, rotX: Float = 0.0f, rotY: Float = 0.0f, rotZ: Float = 0.0f, rotAngle: Float = 0.0f, scaleX: Float = 1.0f, scaleY: Float = 1.0f, scaleZ: Float = 1.0f)

Draws a 3D mesh on the canvas with position, rotation, and scale.

Link copied to clipboard
fun Canvas.drawModel(model: Model, position: ERROR CLASS: Symbol not found for Triple<kotlin/Int, kotlin/Int, kotlin/Int>, scale: Float = 1.0f, tint: Color = Color.WHITE)
fun Canvas.drawModel(model: Model, x: Int, y: Int, z: Int, scale: Float = 1.0f, tint: Color = Color.WHITE)

Draws a 3D model on the canvas.

fun Canvas.drawModel(model: Model, position: ERROR CLASS: Symbol not found for Triple<kotlin/Int, kotlin/Int, kotlin/Int>, rotation: ERROR CLASS: Symbol not found for Triple<kotlin/Float, kotlin/Float, kotlin/Float>, rotAngle: Float, scale: ERROR CLASS: Symbol not found for Triple<kotlin/Float, kotlin/Float, kotlin/Float> = (1F to 1F to 1F), tint: Color = Color.WHITE)
fun Canvas.drawModel(model: Model, position: ERROR CLASS: Symbol not found for Triple<kotlin/Int, kotlin/Int, kotlin/Int>, rotation: ERROR CLASS: Symbol not found for Triple<kotlin/Float, kotlin/Float, kotlin/Float>, rotAngle: Float, scaleX: Float = 1.0f, scaleY: Float = 1.0f, scaleZ: Float = 1.0f, tint: Color = Color.WHITE)
fun Canvas.drawModel(model: Model, x: Int, y: Int, z: Int, rotX: Float, rotY: Float, rotZ: Float, rotAngle: Float, scale: Float = 1.0f, tint: Color = Color.WHITE)
fun Canvas.drawModel(model: Model, x: Int, y: Int, z: Int, rotX: Float, rotY: Float, rotZ: Float, rotAngle: Float, scaleX: Float = 1.0f, scaleY: Float = 1.0f, scaleZ: Float = 1.0f, tint: Color = Color.WHITE)

Draws a 3D model on the canvas with extended parameters.

Link copied to clipboard
fun Canvas.drawModelWires(model: Model, position: ERROR CLASS: Symbol not found for Triple<kotlin/Int, kotlin/Int, kotlin/Int>, scale: Float = 1.0f, tint: Color = Color.BLACK)
fun Canvas.drawModelWires(model: Model, x: Int, y: Int, z: Int, scale: Float = 1.0f, tint: Color = Color.BLACK)

Draws the wires of a 3D model on the canvas.

fun Canvas.drawModelWires(model: Model, position: ERROR CLASS: Symbol not found for Triple<kotlin/Int, kotlin/Int, kotlin/Int>, rotation: ERROR CLASS: Symbol not found for Triple<kotlin/Float, kotlin/Float, kotlin/Float>, rotAngle: Float, scaleX: Float = 1.0f, scaleY: Float = 1.0f, scaleZ: Float = 1.0f, tint: Color = Color.BLACK)
fun Canvas.drawModelWires(model: Model, x: Int, y: Int, z: Int, rotX: Float, rotY: Float, rotZ: Float, rotAngle: Float, scaleX: Float = 1.0f, scaleY: Float = 1.0f, scaleZ: Float = 1.0f, tint: Color = Color.BLACK)

Draws the wires of a 3D model on the canvas with extended parameters.

Link copied to clipboard
fun Canvas.drawSprite(sprite: Sprite2D, x: Int = sprite.x, y: Int = sprite.y)

Draws the given sprite to the canvas at its current position or at the specified x and y coordinates.

fun Canvas.drawSprite(sprite: Sprite3D, x: Int = sprite.x, y: Int = sprite.y, z: Int = sprite.z)

Draws the given sprite to the canvas at its current position or at the specified x, y, and z coordinates.

Link copied to clipboard
fun Canvas.drawText(x: Int, y: Int, text: String, color: Color = Color.WHITE, fontSize: Int = font.baseSize, font: Font = Font.default(), spacing: Float = 0.0f, rotX: Float = 0.0f, rotY: Float = 0.0f, rotation: Float = 0.0f)

Draws text on the given canvas.

Link copied to clipboard
fun Canvas.drawTexture(texture: Texture2D, x: Int, y: Int, tint: Color = Color.WHITE)

Draws a texture on the canvas at the specified position with an optional tint color.

Link copied to clipboard
fun Canvas.ellipse(cx: Int, cy: Int, hradius: Float, vradius: Float, color: Color = Color.BLACK)

Draws an ellipse outline on the canvas.

Link copied to clipboard
fun end()

Ends the drawing process on the canvas.

Link copied to clipboard

Ends the 2D camera on the current window.

Link copied to clipboard

Ends the 3D camera on the current window.

Link copied to clipboard
fun Canvas.fillArc(cx: Int, cy: Int, radius: Float, startAngle: Float, endAngle: Float, segments: Int = 6, color: Color = Color.BLACK)

Draws an arc on the canvas as a filled sector.

Link copied to clipboard
fun Canvas.fillCapsule(x1: Int, y1: Int, z1: Int, x2: Int, y2: Int, z2: Int, radius: Float, slices: Int = 8, rings: Int = 8, color: Color = Color.BLACK)

Draws a capsule in 3D space.

Link copied to clipboard
fun Canvas.fillCircle(cx: Int, cy: Int, radius: Float, color: Color = Color.BLACK)

Draws a filled circle on the canvas.

Link copied to clipboard
fun Canvas.fillCircleGradient(cx: Int, cy: Int, radius: Float, inner: Color, outer: Color)

Draws a filled circle with a radial gradient on the canvas.

Link copied to clipboard
fun Canvas.fillCylinder(x: Int, y: Int, z: Int, radius: Float, height: Float, color: Color = Color.BLACK)
fun Canvas.fillCylinder(x: Int, y: Int, z: Int, radiusTop: Float, radiusBottom: Float = radiusTop, height: Float, color: Color = Color.BLACK)
fun Canvas.fillCylinder(x: Int, y: Int, z: Int, radiusTop: Float, radiusBottom: Float = radiusTop, height: Float, slices: Int = 8, color: Color = Color.BLACK)

Draws a cylinder in 3D space.

fun Canvas.fillCylinder(x1: Int, y1: Int, z1: Int, x2: Int, y2: Int, z2: Int, radiusTop: Float, radiusBottom: Float = radiusTop, sides: Int = 8, color: Color = Color.BLACK)

Draws a cylinder in 3D space with differing start and end points between bases.

Link copied to clipboard
fun Canvas.fillEllipse(cx: Int, cy: Int, hradius: Float, vradius: Float, color: Color = Color.BLACK)

Draws a filled ellipse on the canvas.

Link copied to clipboard
fun Canvas.fillPolygon(cx: Int, cy: Int, sides: Int, radius: Float, rotation: Float = 0.0f, color: Color = Color.BLACK)

Draws a filled polygon on the canvas.

Link copied to clipboard
fun Canvas.fillRect(x: Int, y: Int, width: Int, height: Int, color: Color = Color.BLACK)

Draws a filled rectangle on the canvas.

fun Canvas.fillRect(x: Int, y: Int, width: Int, height: Int, rotation: Float, color: Color = Color.BLACK)

Draws a rotated filled rectangle on the canvas.

Link copied to clipboard
fun Canvas.fillRectGradient(x: Int, y: Int, width: Int, height: Int, col1: Color, col2: Color, vertical: Boolean = true)

Draws a filled rectangle with a gradient on the canvas.

fun Canvas.fillRectGradient(x: Int, y: Int, width: Int, height: Int, topLeft: Color, bottomLeft: Color, topRight: Color, bottomRight: Color)

Draws a filled rectangle with a four-corner gradient on the canvas.

Link copied to clipboard
fun Canvas.fillRectPrism(x: Int, y: Int, z: Int, width: Float, height: Float, length: Float, color: Color = Color.BLACK)

Draws a rectangular prism in 3D space.

Link copied to clipboard
fun Canvas.fillRing(cx: Int, cy: Int, iradius: Float, oradius: Float, startAngle: Float, endAngle: Float, segments: Int = 6, color: Color = Color.BLACK)

Draws a filled ring on the canvas, in between two radii.

Link copied to clipboard
fun Canvas.fillRoundRect(x: Int, y: Int, width: Int, height: Int, roundness: Float, segments: Int = 0, color: Color = Color.BLACK)

Draws a filled rounded rectangle on the canvas.

Link copied to clipboard
fun Canvas.fillSphere(x: Int, y: Int, z: Int, radius: Float, color: Color)
fun Canvas.fillSphere(x: Int, y: Int, z: Int, radius: Float, rings: Int = 8, slices: Int = 8, color: Color = Color.BLACK)

Draws a sphere in 3D space.

Link copied to clipboard
fun Canvas.fillTriangle(x1: Int, y1: Int, x2: Int, y2: Int, x3: Int, y3: Int, color: Color = Color.BLACK)

Draws a filled triangle on the canvas.

Link copied to clipboard
fun Canvas.grid(slices: Int = 10, spacing: Float = 1.0f)

Draws a grid in 3D space.

Link copied to clipboard
fun Canvas.line(x1: Int, y1: Int, x2: Int, y2: Int, color: Color = Color.BLACK)

Draws a line on the canvas.

fun Canvas.line(x1: Int, y1: Int, x2: Int, y2: Int, thick: Float, color: Color = Color.BLACK)

Draws a line on the canvas using triangles and quads.

Link copied to clipboard
fun Canvas.line3(x1: Int, y1: Int, z1: Int, x2: Int, y2: Int, z2: Int, color: Color = Color.BLACK)

Draws a 3D line on the canvas.

Link copied to clipboard
fun Canvas.linearSpline(color: Color = Color.BLACK, thick: Float, vararg points: ERROR CLASS: Symbol not found for Pair<kotlin/Int, kotlin/Int>)
fun Canvas.linearSpline(color: Color = Color.BLACK, thick: Float, points: List<ERROR CLASS: Symbol not found for Pair<kotlin/Int, kotlin/Int>>)

Draws a linear spline on the canvas.

Link copied to clipboard
fun Canvas.lineBezier(x1: Int, y1: Int, x2: Int, y2: Int, thick: Float, color: Color = Color.BLACK)

Draws a cubic bezier line on the canvas.

Link copied to clipboard
fun Canvas.lineStrip(color: Color = Color.BLACK, vararg points: ERROR CLASS: Symbol not found for Pair<kotlin/Int, kotlin/Int>)
fun Canvas.lineStrip(color: Color = Color.BLACK, points: List<ERROR CLASS: Symbol not found for Pair<kotlin/Int, kotlin/Int>>)

Draws multiple lines on the canvas.

Link copied to clipboard
fun Canvas.polygon(cx: Int, cy: Int, sides: Int, radius: Float, rotation: Float = 0.0f, color: Color = Color.BLACK)
fun Canvas.polygon(cx: Int, cy: Int, sides: Int, radius: Float, rotation: Float = 0.0f, lineThick: Int, color: Color = Color.BLACK)

Draws a polygon outline on the canvas.

Link copied to clipboard
fun Canvas.quadraticBezierSpline(color: Color = Color.BLACK, thick: Float, vararg points: ERROR CLASS: Symbol not found for Pair<kotlin/Int, kotlin/Int>)
fun Canvas.quadraticBezierSpline(color: Color = Color.BLACK, thick: Float, points: List<ERROR CLASS: Symbol not found for Pair<kotlin/Int, kotlin/Int>>)

Draws a quadratic bezier spline on the canvas.

Link copied to clipboard
fun Canvas.ray(px: Int, py: Int, pz: Int, dx: Float, dy: Float, dz: Float, color: Color = Color.BLACK)

Draws a ray in 3D space.

Link copied to clipboard
fun Canvas.rect(x: Int, y: Int, width: Int, height: Int, color: Color = Color.BLACK)

Draws a rectangle outline on the canvas.

fun Canvas.rect(x: Int, y: Int, width: Int, height: Int, lineThick: Int, color: Color = Color.BLACK)

Draws a rectangle outline on the canvas with specified line thickness.

Link copied to clipboard
fun Canvas.rect3(x: Int, y: Int, z: Int, width: Float, height: Float, color: Color = Color.BLACK)

Draws a rectangular plane in 3D space.

Link copied to clipboard
fun Canvas.rectPrism(x: Int, y: Int, z: Int, width: Float, height: Float, length: Float, color: Color = Color.BLACK)

Draws a rectangular prism's wires in 3D space.

Link copied to clipboard
fun Canvas.ring(cx: Int, cy: Int, iradius: Float, oradius: Float, startAngle: Float, endAngle: Float, segments: Int = 6, color: Color = Color.BLACK)

Draws a ring outline on the canvas.

Link copied to clipboard
fun Canvas.roundRect(x: Int, y: Int, width: Int, height: Int, roundness: Float, segments: Int = 0, color: Color = Color.BLACK)
fun Canvas.roundRect(x: Int, y: Int, width: Int, height: Int, roundness: Float, lineThick: Int, segments: Int = 0, color: Color = Color.BLACK)

Draws a rounded rectangle outline on the canvas.

Link copied to clipboard

Sets the background color of the canvas.

Link copied to clipboard
fun Canvas.setLineSpacing(spacing: Int)

Sets the line spacing for text rendering on the given canvas.

Link copied to clipboard
fun Canvas.shader(shader: Shader, block: Canvas.() -> Unit)

Executes a block of code while using the given shader for 3D drawing on the canvas.

Link copied to clipboard
fun Canvas.sphere(x: Int, y: Int, z: Int, radius: Float, color: Color = Color.BLACK)
fun Canvas.sphere(x: Int, y: Int, z: Int, radius: Float, rings: Int = 8, slices: Int = 8, color: Color = Color.BLACK)

Draws a sphere's wires in 3D space.

Link copied to clipboard
fun start()

Begins the drawing process on the canvas.

Link copied to clipboard
fun Canvas.start2D(camera: Camera2D)

Starts a 2D camera on the current window.

Link copied to clipboard
fun Canvas.start3D(camera: Camera3D)

Starts a 3D camera on the current window.

Link copied to clipboard

Starts using the given shader for 3D drawing on the canvas.

Link copied to clipboard

Stops using the current shader for 3D drawing on the canvas.

Link copied to clipboard
fun Canvas.triangle(x1: Int, y1: Int, x2: Int, y2: Int, x3: Int, y3: Int, color: Color = Color.BLACK)

Draws a triangle outline on the canvas.

Link copied to clipboard
fun Canvas.triangle3(x1: Int, y1: Int, z1: Int, x2: Int, y2: Int, z2: Int, x3: Int, y3: Int, z3: Int, color: Color = Color.BLACK)

Draws a triangle in 3D space.

Link copied to clipboard
fun Canvas.triangleFan(color: Color = Color.BLACK, vararg points: ERROR CLASS: Symbol not found for Pair<kotlin/Int, kotlin/Int>)
fun Canvas.triangleFan(color: Color = Color.BLACK, points: List<ERROR CLASS: Symbol not found for Pair<kotlin/Int, kotlin/Int>>)

Draws a triangle fan on the canvas.

Link copied to clipboard
fun Canvas.triangleStrip(color: Color = Color.BLACK, vararg points: ERROR CLASS: Symbol not found for Pair<kotlin/Int, kotlin/Int>)
fun Canvas.triangleStrip(color: Color = Color.BLACK, points: List<ERROR CLASS: Symbol not found for Pair<kotlin/Int, kotlin/Int>>)

Draws a triangle strip on the canvas.

Link copied to clipboard
fun Canvas.triangleStrip3(color: Color = Color.BLACK, vararg points: ERROR CLASS: Symbol not found for Triple<kotlin/Int, kotlin/Int, kotlin/Int>)
fun Canvas.triangleStrip3(color: Color = Color.BLACK, points: List<ERROR CLASS: Symbol not found for Triple<kotlin/Int, kotlin/Int, kotlin/Int>>)

Draws a triangle strip in 3D space.