openrndr / org.openrndr.draw / Drawer

Drawer

class Drawer (source)

The Drawer

Constructors

<init>

The Drawer

Drawer(driver: Driver)

Properties

bounds

The bounds of the drawable area as a Rectangle

val bounds: Rectangle

context

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

val context: DrawContext

cullTestPass

var cullTestPass: CullTestPass

depthTestPass

var depthTestPass: DepthTestPass

depthWrite

var depthWrite: Boolean

drawStyle

var drawStyle: DrawStyle

driver

val driver: Driver

fill

The active fill color

var fill: ColorRGBa?

fontMap

The active fontmap, default is null

var fontMap: FontMap?

height

var height: Int

lineCap

The active line cap method

var lineCap: LineCap

lineJoin

var lineJoin: LineJoin

model

var model: Matrix44

projection

The active view matrix

var projection: Matrix44

shadeStyle

var shadeStyle: ShadeStyle?

stroke

The active stroke color

var stroke: ColorRGBa?

strokeWeight

The active stroke weight

var strokeWeight: Double

view

The active model matrix

var view: Matrix44

width

var width: Int

Functions

circle

fun circle(x: Double, y: Double, radius: Double): Unit
fun circle(position: Vector2, radius: Double): Unit
fun circle(circle: Circle): Unit

circles

fun circles(positions: List<Vector2>, radius: Double): Unit
fun circles(positions: List<Vector2>, radii: List<Double>): Unit
fun circles(circles: List<Circle>): Unit
fun circles(vertexBuffer: VertexBuffer, count: Int = vertexBuffer.vertexCount): Unit

clear

fun clear(r: Double, g: Double, b: Double, a: Double): Unit
fun clear(color: ColorRGBa): Unit

composition

Draws a Composition

fun composition(composition: Composition): Unit

contour

Draws a single ShapeContour using fill, stroke and strokeWeight settings

fun contour(contour: ShapeContour): Unit

contours

Draws contours using fill, stroke and strokeWeight settings

fun contours(contours: List<ShapeContour>): Unit

defaults

Loads default values for draw style and transformations

fun defaults(): Unit

image

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

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

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

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

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

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

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

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

Draws an image using an ArrayTexture as source

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()): Unit

lineLoop

fun lineLoop(points: List<Vector2>): Unit
fun lineLoop(points: List<Vector3>): Unit

lineLoops

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

lineSegment

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

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

fun lineSegment(start: Vector2, end: Vector2): Unit

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

fun lineSegment(start: Vector3, end: Vector3): Unit

lineSegments

fun lineSegments(segments: List<Vector2>): Unit
fun lineSegments(segments: List<Vector2>, weights: List<Double>): Unit
fun lineSegments(segments: List<Vector3>): Unit
fun lineSegments(segments: List<Vector3>, weights: List<Double>): Unit
fun lineSegments(segments: List<Vector3>, weights: List<Double>, colors: List<ColorRGBa>): Unit
fun lineSegments(segments: List<LineSegment>): Unit

lineStrip

Draws a line strip with 2d coordinates

fun lineStrip(points: List<Vector2>): Unit

Draws a line strip with 3d coordinates

fun lineStrip(points: List<Vector3>): Unit

lineStrips

Draws line strips with 3d coordinates

fun lineStrips(strips: List<List<Vector2>>): Unit
fun lineStrips(strips: List<List<Vector3>>): Unit

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

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

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

fun lineStrips(strips: List<List<Vector3>>, weights: List<Double>): Unit
fun lineStrips(strips: List<List<Vector3>>, weights: List<Double>, colors: List<ColorRGBa>): Unit

lookAt

fun lookAt(from: Vector3, to: Vector3, up: Vector3 = Vector3.UNIT_Y): Unit

ortho

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

fun ortho(renderTarget: RenderTarget): Unit

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

fun ortho(): Unit

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

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

path

Draws a single 3D path

fun path(path: Path3D): Unit

perspective

Sets the projection to a perspective projection matrix

fun perspective(fovY: Double, aspectRatio: Double, zNear: Double, zFar: Double): Unit

point

Draw a single point

fun point(x: Double, y: Double, z: Double = 0.0): Unit
fun point(vector: Vector2): Unit
fun point(vector: Vector3): Unit

points

Draw a list of 2D points

fun points(points: List<Vector2>): Unit

Draw a list of 3D points

fun points(points: List<Vector3>): Unit

popModel

fun popModel(): Unit

popProjection

Pop the active projection matrix from the projection state stack

fun popProjection(): Unit

popStyle

Pop the draw style from the draw style stack

fun popStyle(): Unit

popTransforms

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

fun popTransforms(): Unit

popView

fun popView(): Unit

pushModel

fun pushModel(): Matrix44

pushProjection

Push the active projection matrix on the projection state stack

fun pushProjection(): Matrix44

pushStyle

Push the active draw style on the draw style stack

fun pushStyle(): DrawStyle

pushTransforms

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

fun pushTransforms(): Unit

pushView

fun pushView(): Matrix44

rectangle

fun rectangle(rectangle: Rectangle): Unit
fun rectangle(x: Double, y: Double, width: Double, height: Double): Unit
fun rectangle(corner: Vector2, width: Double, height: Double): Unit

rectangles

fun rectangles(positions: List<Vector2>, width: Double, height: Double): Unit
fun rectangles(positions: List<Vector2>, dimensions: List<Vector2>): Unit
fun rectangles(rectangles: List<Rectangle>): Unit

rotate

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

fun rotate(rotationInDegrees: Double): Unit

Applies a rotation over an arbitrary axis to the model matrix

fun rotate(axis: Vector3, rotationInDegrees: Double): Unit

scale

Apply a uniform scale to the model matrix

fun scale(s: Double): Unit

Applies non-uniform scale to the model matrix

fun scale(x: Double, y: Double): Unit
fun scale(x: Double, y: Double, z: Double): Unit

segment

Draw a single segment

fun segment(segment: Segment): Unit

Draws a single 3D segment

fun segment(segment: Segment3D): Unit

segments

Draws a list of 2D segments

fun segments(segments: List<Segment>): Unit

Draws a list of 3D segments

fun segments(segments: List<Segment3D>): Unit

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

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

shape

Draws a single Shape using fill, stroke and strokeWeight settings

fun shape(shape: Shape): Unit

shapes

Draws shapes using fill, stroke and strokeWeight settings

fun shapes(shapes: List<Shape>): Unit

size

fun size(width: Int, height: Int): Unit

text

Draws text at (position)

fun text(text: String, position: Vector2): Unit

Draws text at (x, y)

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

texts

Draws texts at positions)

fun texts(texts: List<String>, positions: List<Vector2>): Unit

translate

Applies a two-dimensional translation to the model matrix

fun translate(t: Vector2): Unit
fun translate(x: Double, y: Double): Unit

Applies three-dimensional translation to the model matrix

fun translate(t: Vector3): Unit

Applies a three-dimensional translation to the model matrix

fun translate(x: Double, y: Double, z: Double): Unit

vertexBuffer

Draws a VertexBuffer using primitive

fun vertexBuffer(vertexBuffer: VertexBuffer, primitive: DrawPrimitive, vertexOffset: Int = 0, vertexCount: Int = vertexBuffer.vertexCount): Unitfun vertexBuffer(vertexBuffers: List<VertexBuffer>, primitive: DrawPrimitive, offset: Int = 0, vertexCount: Int = vertexBuffers[0].vertexCount): Unit
fun vertexBuffer(indexBuffer: IndexBuffer, vertexBuffers: List<VertexBuffer>, primitive: DrawPrimitive, offset: Int = 0, indexCount: Int = indexBuffer.indexCount): Unit

vertexBufferInstances

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

withTarget

fun withTarget(target: RenderTarget, action: Drawer.() -> Unit): Unit

Extension Functions

isolated

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

fun Drawer.isolated(function: Drawer.() -> Unit): Unit

isolatedWithTarget

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

fun Drawer.isolatedWithTarget(target: RenderTarget, function: Drawer.() -> Unit): Unit