Drawer

class Drawer(val driver: Driver)(source)

The Drawer class is a utility that provides various drawing operations such as drawing shapes, transformations, and managing drawing states in a graphical rendering context. It serves as the primary interface for rendering graphics and provides control for styling and transformations.

Constructors

Link copied to clipboard
constructor(driver: Driver)

Properties

Link copied to clipboard

The bounds of the drawable area as a Rectangle

Link copied to clipboard

Provides the current drawing context for rendering operations. This includes information about the model matrix, view matrix, projection matrix, the active render target's dimensions, content scale, and the model-view scaling factor. The provided context is dynamically derived based on the active rendering state.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Represents the style settings used for drawing operations. This variable specifies how shapes or paths should be rendered, such as stroke, fill, or other stylistic configurations.

Link copied to clipboard
Link copied to clipboard

The active fill color

Link copied to clipboard

The active fontmap, default is null

Link copied to clipboard
val height: Int
Link copied to clipboard

The active line cap method

Link copied to clipboard

The active line join method

Link copied to clipboard

When two line segments meet at a sharp angle and miter joins have been specified for lineJoin, it is possible for the miter to extend far beyond the thickness of the line stroking the path. The miterlimit imposes a limit on the ratio of the miter length to the strokeWeight.

Link copied to clipboard

Represents the transformation matrix of a model.

Link copied to clipboard

Represents a 4x4 transformation matrix used for projection in graphics rendering. Typically utilized in 3D rendering to define views, perspectives, or transformations. Defaults to the identity matrix, meaning no transformation is applied.

Link copied to clipboard
Link copied to clipboard

The active stroke color

Link copied to clipboard

The active stroke weight

Link copied to clipboard

Represents the transformation matrix for the view in a 3D rendering context.

Link copied to clipboard
val width: Int

Functions

Link copied to clipboard
fun circle(circle: Circle)

Draws a circle on the given context using the specified draw style and circle properties.

fun circle(position: Vector2, radius: Double)

Draws a circle at the specified position with the given radius.

fun circle(x: Double, y: Double, radius: Double)

Draws a circle with the specified parameters.

Link copied to clipboard

Create a stored batch of circles

Link copied to clipboard
fun circles(build: CircleBatchBuilder.() -> Unit)

Draws a batch of circles on a canvas using the provided building instructions.

fun circles(circles: List<Circle>)

Draws the given list of circles using the specified drawing context and style.

fun circles(positions: List<Vector2>, radius: Double)

Draws multiple circles at specified positions with a given radius.

fun circles(positions: List<Vector2>, radii: List<Double>)

Draws multiple circles on a given context using specified positions and radii.

fun circles(batch: CircleBatch, count: Int = batch.size)

Draws multiple circles in a batch using the specified drawing context and style.

Link copied to clipboard
fun clear(color: ColorRGBa)

Clears the current drawing buffer with the specified color.

Link copied to clipboard
fun contour(contour: ShapeContour)

Draws a single ShapeContour using fill, stroke and strokeWeight settings

Link copied to clipboard
fun contours(contours: List<ShapeContour>)

Draws org.openrndr.shape.contours using fill, stroke and strokeWeight settings

Link copied to clipboard
fun defaults()

Loads default values for draw style and transformations

Link copied to clipboard
fun image(colorBuffer: ColorBuffer)

Draws an image with its top-left corner at (0,0)

fun image(colorBuffer: ColorBuffer, rectangles: List<Pair<Rectangle, Rectangle>>)

Draws an image onto the specified context using the provided color buffer and rectangles.

fun image(colorBuffer: ColorBuffer, target: Rectangle)

Draws an image (ColorBuffer) into a target area

fun image(arrayTexture: ArrayTexture, layers: List<Int>, rectangles: List<Pair<Rectangle, Rectangle>>)

Draws an image using the given array texture, layers, and mapping of rectangles.

fun image(colorBuffer: ColorBuffer, source: Rectangle, target: Rectangle)

Draws a source area of an image (ColorBuffer) into a target area

fun image(arrayTexture: ArrayTexture, layer: Int = 0, source: Rectangle, target: Rectangle)

Draws an image from a specified layer of an ArrayTexture onto a target rectangle.

fun image(colorBuffer: ColorBuffer, position: Vector2, width: Double = colorBuffer.width.toDouble(), height: Double = colorBuffer.height.toDouble())

Draws an image with its top-left corner at (position) and dimensions (width, height)

fun image(colorBuffer: ColorBuffer, x: Double, y: Double, width: Double = colorBuffer.width.toDouble(), height: Double = colorBuffer.height.toDouble())

Draws an image with its top-left corner at (x, y) and dimensions (width, height)

fun image(arrayTexture: ArrayTexture, layer: Int = 0, x: Double = 0.0, y: Double = 0.0, width: Double = arrayTexture.width.toDouble(), height: Double = arrayTexture.height.toDouble())

Draws an image using an ArrayTexture as source

Link copied to clipboard
fun Drawer.isolated(function: Drawer.() -> Unit)

Executes a given function within an isolated context where transforms and styles are managed. Ensures that the applied transforms and styles are reverted after the function execution, maintaining isolation for the block of code.

Link copied to clipboard
fun Drawer.isolatedWithTarget(target: RenderTarget, function: Drawer.() -> Unit)

Executes the given function within an isolated drawing context bound to the specified render target.

Link copied to clipboard
fun lineLoop(points: List<Vector2>)

Renders a closed loop of connected line segments given a list of points.

@JvmName(name = "lineLoop3d")
fun lineLoop(points: List<Vector3>)

Draws a closed loop connecting given 3D points.

Link copied to clipboard
fun lineLoops(loops: List<List<Vector2>>)

Renders a list of line loops based on the current drawing style and quality settings.

@JvmName(name = "lineLoops3d")
fun lineLoops(loops: List<List<Vector3>>)

Draws a series of line loops based on the provided list of loops.

fun lineLoops(loops: List<List<Vector2>>, weights: List<Double>)

Renders a series of line loops with specified weights.

@JvmName(name = "lineLoops3d)")
fun lineLoops(loops: List<List<Vector3>>, weights: List<Double>)

Draws line loops in either performance or quality mode based on the current draw style.

Link copied to clipboard
fun lineSegment(lineSegment: LineSegment)

Draws a line segment using the specified LineSegment.

fun lineSegment(start: Vector2, end: Vector2)

Draws a line segment from start to end using 2d coordinates

fun lineSegment(start: Vector3, end: Vector3)

Draws a line segment from start to end using 3d coordinates

fun lineSegment(x0: Double, y0: Double, x1: Double, y1: Double)

Draws a line segment between two points in a 2D space.

Link copied to clipboard
fun lineSegments(segments: List<Vector2>)
@JvmName(name = "lineSegmentsFromLineSegmentList")
fun lineSegments(segments: List<LineSegment>)
@JvmName(name = "lineSegments3d")
fun lineSegments(segments: List<Vector3>, weights: List<Double>, colors: List<ColorRGBa>)

@JvmName(name = "lineSegments3d")
fun lineSegments(segments: List<Vector3>)

Draws line segments using the specified list of 3D vectors.

fun lineSegments(segments: List<Vector2>, weights: List<Double>)

Draws a series of line segments with specified weights

@JvmName(name = "lineSegments3d")
fun lineSegments(segments: List<Vector3>, weights: List<Double>)

Draws a series of line segments based on the provided 3D vectors and weights.

Link copied to clipboard
fun lineStrip(points: List<Vector2>)

Draws a line strip with 2d coordinates

@JvmName(name = "lineStrip3d")
fun lineStrip(points: List<Vector3>)

Draws a line strip with 3d coordinates

Link copied to clipboard
fun lineStrips(strips: List<List<Vector2>>)
@JvmName(name = "lineStrips3d")
fun lineStrips(strips: List<List<Vector3>>)

Draws line strips with 3d coordinates

fun lineStrips(strips: List<List<Vector2>>, weights: List<Double>)

Draws line strips with 2d coordinates and stroke weights per strip

@JvmName(name = "lineStrips3d")
fun lineStrips(strips: List<List<Vector3>>, weights: List<Double>)
@JvmName(name = "lineStrips3d")
fun lineStrips(strips: List<List<Vector3>>, weights: List<Double>, colors: List<ColorRGBa>)

Draws line strips with 3d coordinates and stroke weights per strip

Link copied to clipboard
fun lookAt(from: Vector3, to: Vector3, up: Vector3 = Vector3.UNIT_Y, target: TransformTarget = TransformTarget.VIEW)

Rotates a transform to look at a given target point in 3D space.

Link copied to clipboard
fun ortho()

Sets the projection matrix to orthogonal using the drawer's current size

fun ortho(renderTarget: RenderTarget)

Sets the projection matrix to orthogonal using the sizes of a RenderTarget

fun ortho(left: Double, right: Double, bottom: Double, top: Double, near: Double, far: Double)

Sets the projection matrix to orthogonal using left, right, bottom, top, near, far

Link copied to clipboard
fun path(path: Path3D)

Draws a single 3D path

Link copied to clipboard
fun paths(paths: List<Path3D>, weights: List<Double> = emptyList(), colors: List<ColorRGBa> = emptyList())

Draw a list of Path3D

Link copied to clipboard
fun perspective(fovY: Double, aspectRatio: Double, zNear: Double, zFar: Double)

Sets the projection to a perspective projection matrix

Link copied to clipboard
fun point(vector: Vector2)

Draws a point on the canvas at the specified vector's coordinates.

fun point(vector: Vector3)

Draws a point in 3D space using the specified vector.

fun point(x: Double, y: Double, z: Double = 0.0)

Draws a point in a 2D or 3D space.

Link copied to clipboard

Create a stored batch of points

Link copied to clipboard
fun points(build: PointBatchBuilder.() -> Unit)

Draws a batch of points using the provided configuration builder.

@JvmName(name = "points2D")
fun points(points: List<Vector2>)

Draws a list of 2D points using the specified context and draw style.

@JvmName(name = "points3D")
fun points(points: List<Vector3>)

Draws a list of 3D points using the specified drawing style and context.

fun points(batch: PointBatch, count: Int = batch.size)

Draws a specified number of points from the given point batch.

Link copied to clipboard
fun popModel()
Link copied to clipboard

Pop the active projection matrix from the projection state stack

Link copied to clipboard
fun popStyle()

Pop the draw style from the draw style stack

Link copied to clipboard

Pop the active the model, view and projection matrices from their respective stacks

Link copied to clipboard
fun popView()
Link copied to clipboard
Link copied to clipboard

Push the active projection matrix on the projection state stack

Link copied to clipboard

Push the active draw style on the draw style stack

Link copied to clipboard

Push the active model, view and projection matrices on their respective stacks

Link copied to clipboard

Pushes the current view onto the view stack and returns the top entry of the stack after the push operation.

Link copied to clipboard
fun rectangle(rectangle: Rectangle)

Draws a rectangle based on the specified properties.

fun rectangle(corner: Vector2, width: Double, height: Double = width)

Draws a rectangle on the canvas using the specified parameters.

fun rectangle(x: Double, y: Double, width: Double, height: Double = width)

Draws a rectangle on the canvas based on the provided position and dimensions.

Link copied to clipboard

Create a stored batch of rectangles

Link copied to clipboard

Facilitates the construction and rendering of rectangles in a batch process.

fun rectangles(rectangles: List<Rectangle>)

Draws a list of rectangles on the specified context using the given draw style.

fun rectangles(positions: List<Vector2>, dimensions: List<Vector2>)

Draws multiple rectangles based on the specified positions and dimensions.

fun rectangles(batch: RectangleBatch, count: Int = batch.size)

Draws a specified number of rectangles from the given rectangle batch.

fun rectangles(positions: List<Vector2>, width: Double, height: Double = width)

Draws a set of rectangles based on the given positions and dimensions.

Link copied to clipboard
fun rotate(rotationInDegrees: Double, target: TransformTarget = TransformTarget.MODEL)

Rotates the target by the specified angle in degrees around the Z-axis.

fun rotate(axis: Vector3, rotationInDegrees: Double, target: TransformTarget = TransformTarget.MODEL)

Rotates a transformation using the specified axis and angle in degrees, applying the rotation to the given transformation target.

Link copied to clipboard
fun scale(s: Double, target: TransformTarget = TransformTarget.MODEL)

Scales the target transformation uniformly along all axes by the given scalar value.

fun scale(x: Double, y: Double, target: TransformTarget = TransformTarget.MODEL)

Applies non-uniform scale to the model matrix

fun scale(x: Double, y: Double, z: Double, target: TransformTarget = TransformTarget.MODEL)

Scales a transformation matrix by the specified factors along the x, y, and z axes.

Link copied to clipboard
fun segment(segment: Segment2D)

Draw a single segment

fun segment(segment: Segment3D)

Draws a single 3D segment

Link copied to clipboard
@JvmName(name = "segments2d")
fun segments(segments: List<Segment2D>)

Draws a list of 2D segments

fun segments(segments: List<Segment3D>)

Draws a list of 3D segments

fun segments(segments: List<Segment3D>, weights: List<Double>, colors: List<ColorRGBa>)

Draws a list of 3D segments, each with their weight and color

Link copied to clipboard
fun shape(shape: Shape)

Renders a given shape on the current render target. Supports shapes with different topology types: CLOSED, OPEN, and MIXED.

Link copied to clipboard
fun shapes(shapes: List<Shape>)

Draws shapes using fill, stroke and strokeWeight settings

Link copied to clipboard
fun text(text: String, position: Vector2)

Draws text at (position)

fun text(text: String, x: Double = 0.0, y: Double = 0.0)

Draws text at (x, y)

Link copied to clipboard
fun texts(texts: List<String>, positions: List<Vector2>)

Draws texts at positions)

Link copied to clipboard
fun translate(t: Vector2, target: TransformTarget = TransformTarget.MODEL)
fun translate(t: Vector3, target: TransformTarget = TransformTarget.MODEL)

Applies a translation transformation to the specified target.

fun translate(x: Double, y: Double, target: TransformTarget = TransformTarget.MODEL)

Translates a point or object by the given x and y offsets.

fun translate(x: Double, y: Double, z: Double, target: TransformTarget = TransformTarget.MODEL)

Translates the target by the specified x, y, and z values.

Link copied to clipboard
fun vertexBuffer(vertexBuffers: List<VertexBuffer>, primitive: DrawPrimitive, offset: Int = 0, vertexCount: Int = vertexBuffers[0].vertexCount)

Draws the specified vertex buffers using the given draw primitive and parameters.

fun vertexBuffer(vertexBuffer: VertexBuffer, primitive: DrawPrimitive, vertexOffset: Int = 0, vertexCount: Int = vertexBuffer.vertexCount)

Draws a VertexBuffer using primitive

fun vertexBuffer(indexBuffer: IndexBuffer, vertexBuffers: List<VertexBuffer>, primitive: DrawPrimitive, offset: Int = 0, indexCount: Int = indexBuffer.indexCount)

Draws a vertex buffer using the specified parameters.

Link copied to clipboard
fun vertexBufferInstances(vertexBuffers: List<VertexBuffer>, instanceAttributes: List<VertexBuffer>, primitive: DrawPrimitive, instanceCount: Int, offset: Int = 0, vertexCount: Int = vertexBuffers[0].vertexCount)

Issues a draw call for rendering geometry using multiple vertex buffers with instancing.

fun vertexBufferInstances(indexBuffer: IndexBuffer, vertexBuffers: List<VertexBuffer>, instanceAttributes: List<VertexBuffer>, primitive: DrawPrimitive, instanceCount: Int, offset: Int = 0, indexCount: Int = indexBuffer.indexCount)

Draws instances of a vertex buffer with the specified parameters.

Link copied to clipboard
fun withTarget(target: RenderTarget, action: Drawer.() -> Unit)