Improved comments for Compositor
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
A growing library of assorted data structures, algorithms and utilities.
|
||||
|
||||
- [`orx-compositor`](orx-compositor/README.md), a simple toolkit to make composite (layered) images
|
||||
- [`orx-integral-image`](orx-integral-image/README.md), a CPU-based implementation for integral images (summed area tables)
|
||||
- `orx-jumpflood`, a filter/shader based implementation of the jump flood algorithm for finding fast approximate (directional) distance fields
|
||||
- `orx-kdtree`, a kd-tree implementation for fast nearest point searches
|
||||
|
||||
@@ -4,15 +4,17 @@ import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.*
|
||||
|
||||
/**
|
||||
* Layer representation
|
||||
* A single layer representation
|
||||
*/
|
||||
class Layer internal constructor() {
|
||||
|
||||
var drawFunc: () -> Unit = {}
|
||||
val children: MutableList<Layer> = mutableListOf()
|
||||
var blendFilter: Pair<Filter, Filter.() -> Unit>? = null
|
||||
val postFilters: MutableList<Pair<Filter, Filter.() -> Unit>> = mutableListOf()
|
||||
|
||||
/**
|
||||
* draw the layer
|
||||
*/
|
||||
fun draw(drawer: Drawer) {
|
||||
val rt = RenderTarget.active
|
||||
val layerTarget = renderTarget(rt.width, rt.height) {
|
||||
@@ -70,14 +72,23 @@ fun Layer.layer(function: Layer.() -> Unit) {
|
||||
children.add(Layer().apply { function() })
|
||||
}
|
||||
|
||||
/**
|
||||
* set the draw contents of the layer
|
||||
*/
|
||||
fun Layer.draw(function: () -> Unit) {
|
||||
drawFunc = function
|
||||
}
|
||||
|
||||
/**
|
||||
* add a post-processing filter to the layer
|
||||
*/
|
||||
fun <F : Filter> Layer.post(filter: F, configure: F.() -> Unit = {}) {
|
||||
postFilters.add(Pair(filter as Filter, configure as Filter.() -> Unit))
|
||||
}
|
||||
|
||||
/**
|
||||
* add a blend filter to the layer
|
||||
*/
|
||||
fun <F : Filter> Layer.blend(filter: F, configure: F.() -> Unit = {}) {
|
||||
blendFilter = Pair(filter as Filter, configure as Filter.() -> Unit)
|
||||
}
|
||||
@@ -89,6 +100,4 @@ fun compose(function: Layer.() -> Unit): Layer {
|
||||
val root = Layer()
|
||||
root.function()
|
||||
return root
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user