Improved comments for Compositor
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
A growing library of assorted data structures, algorithms and utilities.
|
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-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-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
|
- `orx-kdtree`, a kd-tree implementation for fast nearest point searches
|
||||||
|
|||||||
@@ -4,15 +4,17 @@ import org.openrndr.color.ColorRGBa
|
|||||||
import org.openrndr.draw.*
|
import org.openrndr.draw.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer representation
|
* A single layer representation
|
||||||
*/
|
*/
|
||||||
class Layer internal constructor() {
|
class Layer internal constructor() {
|
||||||
|
|
||||||
var drawFunc: () -> Unit = {}
|
var drawFunc: () -> Unit = {}
|
||||||
val children: MutableList<Layer> = mutableListOf()
|
val children: MutableList<Layer> = mutableListOf()
|
||||||
var blendFilter: Pair<Filter, Filter.() -> Unit>? = null
|
var blendFilter: Pair<Filter, Filter.() -> Unit>? = null
|
||||||
val postFilters: MutableList<Pair<Filter, Filter.() -> Unit>> = mutableListOf()
|
val postFilters: MutableList<Pair<Filter, Filter.() -> Unit>> = mutableListOf()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* draw the layer
|
||||||
|
*/
|
||||||
fun draw(drawer: Drawer) {
|
fun draw(drawer: Drawer) {
|
||||||
val rt = RenderTarget.active
|
val rt = RenderTarget.active
|
||||||
val layerTarget = renderTarget(rt.width, rt.height) {
|
val layerTarget = renderTarget(rt.width, rt.height) {
|
||||||
@@ -70,14 +72,23 @@ fun Layer.layer(function: Layer.() -> Unit) {
|
|||||||
children.add(Layer().apply { function() })
|
children.add(Layer().apply { function() })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the draw contents of the layer
|
||||||
|
*/
|
||||||
fun Layer.draw(function: () -> Unit) {
|
fun Layer.draw(function: () -> Unit) {
|
||||||
drawFunc = function
|
drawFunc = function
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add a post-processing filter to the layer
|
||||||
|
*/
|
||||||
fun <F : Filter> Layer.post(filter: F, configure: F.() -> Unit = {}) {
|
fun <F : Filter> Layer.post(filter: F, configure: F.() -> Unit = {}) {
|
||||||
postFilters.add(Pair(filter as Filter, configure as Filter.() -> 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 = {}) {
|
fun <F : Filter> Layer.blend(filter: F, configure: F.() -> Unit = {}) {
|
||||||
blendFilter = Pair(filter as Filter, configure as Filter.() -> Unit)
|
blendFilter = Pair(filter as Filter, configure as Filter.() -> Unit)
|
||||||
}
|
}
|
||||||
@@ -89,6 +100,4 @@ fun compose(function: Layer.() -> Unit): Layer {
|
|||||||
val root = Layer()
|
val root = Layer()
|
||||||
root.function()
|
root.function()
|
||||||
return root
|
return root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user