Drawer

class Drawer(driver: Driver)

The Drawer

Constructors

Drawer
Link copied to clipboard
common
fun Drawer(driver: Driver)

Functions

background
Link copied to clipboard
common
fun background(color: ColorRGBa)
fun background(r: Double, g: Double, b: Double, a: Double)
circle
Link copied to clipboard
common
fun circle(circle: Circle)
fun circle(position: Vector2, radius: Double)
fun circle(x: Double, y: Double, radius: Double)

Draw a circle

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

Create and draw batched circles

fun circles(circles: List<Circle>)
fun circles(positions: List<Vector2>, radius: Double)
fun circles(positions: List<Vector2>, radii: List<Double>)
fun circles(batch: CircleBatch, count: Int = batch.size)

Draw stored circle batch

clear
Link copied to clipboard
common
fun clear(color: ColorRGBa)
fun clear(r: Double, g: Double, b: Double, a: Double)
composition
Link copied to clipboard
common
fun composition(composition: Composition)

Draws a Composition

contour
Link copied to clipboard
common
fun contour(contour: ShapeContour)

Draws a single ShapeContour using fill, stroke and strokeWeight settings

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

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

defaults
Link copied to clipboard
common
fun defaults()

Loads default values for draw style and transformations

image
Link copied to clipboard
common
fun image(colorBuffer: ColorBuffer)

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

fun image(colorBuffer: ColorBuffer, rectangles: List<Pair<Rectangle, Rectangle>>)
fun image(arrayTexture: ArrayTexture, layers: List<Int>, rectangles: List<Pair<Rectangle, Rectangle>>)
fun image(arrayTexture: ArrayTexture, layer: Int = 0, source: Rectangle, target: Rectangle)
fun image(colorBuffer: ColorBuffer, source: Rectangle, target: Rectangle)

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

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

lineLoop
Link copied to clipboard
common
fun lineLoop(points: List<Vector2>)
@JvmName(name = "lineLoop3d")
fun lineLoop(points: List<Vector3>)
lineLoops
Link copied to clipboard
common
fun lineLoops(loops: List<List<Vector2>>)
@JvmName(name = "lineLoops3d")
fun lineLoops(loops: List<List<Vector3>>)
fun lineLoops(loops: List<List<Vector2>>, weights: List<Double>)
@JvmName(name = "lineLoops3d)")
fun lineLoops(loops: List<List<Vector3>>, weights: List<Double>)
lineSegment
Link copied to clipboard
common
fun lineSegment(lineSegment: LineSegment)
fun lineSegment(x0: Double, y0: Double, x1: Double, y1: Double)
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

lineSegments
Link copied to clipboard
common
fun lineSegments(segments: List<Vector2>)
@JvmName(name = "lineSegments3d")
fun lineSegments(segments: List<Vector3>)
@JvmName(name = "lineSegmentsFromLineSegmentList")
fun lineSegments(segments: List<LineSegment>)
fun lineSegments(segments: List<Vector2>, weights: List<Double>)
@JvmName(name = "lineSegments3d")
fun lineSegments(segments: List<Vector3>, weights: List<Double>)
@JvmName(name = "lineSegments3d")
fun lineSegments(segments: List<Vector3>, weights: List<Double>, colors: List<ColorRGBa>)
lineStrip
Link copied to clipboard
common
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

lineStrips
Link copied to clipboard
common
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

lookAt
Link copied to clipboard
common
fun lookAt(from: Vector3, to: Vector3, up: Vector3 = Vector3.UNIT_Y, target: TransformTarget = TransformTarget.VIEW)
ortho
Link copied to clipboard
common
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

path
Link copied to clipboard
common
fun path(path: Path3D)

Draws a single 3D path

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

Sets the projection to a perspective projection matrix

point
Link copied to clipboard
common
fun point(vector: Vector2)
fun point(vector: Vector3)
fun point(x: Double, y: Double, z: Double = 0.0)

Draw a single point

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

Create and draw batched points

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

Draw a list of 2D points

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

Draw a list of 3D points

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

Draw a stored batch of points

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

Pop the active projection matrix from the projection state stack

popStyle
Link copied to clipboard
common
fun popStyle()

Pop the draw style from the draw style stack

popTransforms
Link copied to clipboard
common
fun popTransforms()

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

popView
Link copied to clipboard
common
fun popView()
pushModel
Link copied to clipboard
common
fun pushModel(): Matrix44
pushProjection
Link copied to clipboard
common
fun pushProjection(): Matrix44

Push the active projection matrix on the projection state stack

pushStyle
Link copied to clipboard
common
fun pushStyle(): DrawStyle

Push the active draw style on the draw style stack

pushTransforms
Link copied to clipboard
common
fun pushTransforms()

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

pushView
Link copied to clipboard
common
fun pushView(): Matrix44
rectangle
Link copied to clipboard
common
fun rectangle(rectangle: Rectangle)
fun rectangle(corner: Vector2, width: Double, height: Double = width)
fun rectangle(x: Double, y: Double, width: Double, height: Double = width)
rectangles
Link copied to clipboard
common
fun rectangles(build: RectangleBatchBuilder.() -> Unit)

Create and draw batched rectangles

fun rectangles(rectangles: List<Rectangle>)
fun rectangles(positions: List<Vector2>, dimensions: List<Vector2>)
fun rectangles(batch: RectangleBatch, count: Int = batch.size)
fun rectangles(positions: List<Vector2>, width: Double, height: Double = width)
reset
Link copied to clipboard
common
fun reset()

Resets state stacks and load default values for draw style and transformations. This destroys the state stacks, consider using defaults() instead of reset()

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

Applies a rotation over the z-axis to the model matrix

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

Applies a rotation over an arbitrary axis to the model matrix

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

Apply a uniform scale to the model matrix

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

Applies non-uniform scale to the model matrix

segment
Link copied to clipboard
common
fun segment(segment: Segment)

Draw a single segment

fun segment(segment: Segment3D)

Draws a single 3D segment

segments
Link copied to clipboard
common
fun segments(segments: List<Segment3D>)

Draws a list of 3D segments

@JvmName(name = "segments2d")
fun segments(segments: List<Segment>)

Draws a list of 2D segments

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

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

shape
Link copied to clipboard
common
fun shape(shape: Shape)

Draws a single Shape using fill, stroke and strokeWeight settings

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

Draws shapes using fill, stroke and strokeWeight settings

text
Link copied to clipboard
common
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)

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

Draws texts at positions)

transform
Link copied to clipboard
common
fun transform(transform: TransformTarget): KMutableProperty0<Matrix44>
translate
Link copied to clipboard
common
fun translate(t: Vector2, target: TransformTarget = TransformTarget.MODEL)
fun translate(x: Double, y: Double, target: TransformTarget = TransformTarget.MODEL)

Applies a two-dimensional translation to the model matrix

fun translate(t: Vector3, target: TransformTarget = TransformTarget.MODEL)

Applies three-dimensional translation to the model matrix

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

Applies a three-dimensional translation to the model matrix

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

Draws a VertexBuffer using primitive

vertexBufferInstances
Link copied to clipboard
common
fun vertexBufferInstances(vertexBuffers: List<VertexBuffer>, instanceAttributes: List<VertexBuffer>, primitive: DrawPrimitive, instanceCount: Int, offset: Int = 0, vertexCount: Int = vertexBuffers[0].vertexCount)
fun vertexBufferInstances(indexBuffer: IndexBuffer, vertexBuffers: List<VertexBuffer>, instanceAttributes: List<VertexBuffer>, primitive: DrawPrimitive, instanceCount: Int, offset: Int = 0, indexCount: Int = indexBuffer.indexCount)
withTarget
Link copied to clipboard
common
fun withTarget(target: RenderTarget, action: Drawer.() -> Unit)

Properties

bounds
Link copied to clipboard
common
val bounds: Rectangle

The bounds of the drawable area as a Rectangle

context
Link copied to clipboard
common
val context: DrawContext

The draw context holds references to model, view, projection matrices, width, height and content-scale

cullTestPass
Link copied to clipboard
common
var cullTestPass: CullTestPass
depthTestPass
Link copied to clipboard
common
var depthTestPass: DepthTestPass
depthWrite
Link copied to clipboard
common
var depthWrite: Boolean
drawStyle
Link copied to clipboard
common
var drawStyle: DrawStyle
driver
Link copied to clipboard
common
val driver: Driver
fill
Link copied to clipboard
common
var fill: ColorRGBa?

The active fill color

fontImageMapDrawer
Link copied to clipboard
common
val fontImageMapDrawer: FontImageMapDrawer
fontMap
Link copied to clipboard
common
var fontMap: FontMap?

The active fontmap, default is null

height
Link copied to clipboard
common
val height: Int
lineCap
Link copied to clipboard
common
var lineCap: LineCap

The active line cap method

lineJoin
Link copied to clipboard
common
var lineJoin: LineJoin

The active line join method

miterLimit
Link copied to clipboard
common
var miterLimit: Double

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.

model
Link copied to clipboard
common
var model: Matrix44

The active model matrix

projection
Link copied to clipboard
common
var projection: Matrix44

The active projection matrix

shadeStyle
Link copied to clipboard
common
var shadeStyle: ShadeStyle?
stroke
Link copied to clipboard
common
var stroke: ColorRGBa?

The active stroke color

strokeWeight
Link copied to clipboard
common
var strokeWeight: Double

The active stroke weight

view
Link copied to clipboard
common
var view: Matrix44

The active view matrix

width
Link copied to clipboard
common
val width: Int

Extensions

circleBatch
Link copied to clipboard
common
fun Drawer.circleBatch(build: CircleBatchBuilder.() -> Unit): CircleBatch

Create a stored batch of circles

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

Pushes style, view- and projection matrix, calls function and pops.

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

Pushes style, view- and projection matrix, sets render target, calls function and pops,

pointBatch
Link copied to clipboard
common
fun Drawer.pointBatch(build: PointBatchBuilder.() -> Unit): PointBatch

Create a stored batch of points

rectangleBatch
Link copied to clipboard
common
fun Drawer.rectangleBatch(build: RectangleBatchBuilder.() -> Unit): RectangleBatch

Create a stored batch of rectangles

writer
Link copied to clipboard
common
@JvmName(name = "drawerWriter")
fun <T> Drawer.writer(f: Writer.() -> T): T