diff --git a/README.md b/README.md index 7a74052f..8ab41764 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/orx-compositor/src/main/kotlin/Compositor.kt b/orx-compositor/src/main/kotlin/Compositor.kt index f12c6e35..590d9e95 100644 --- a/orx-compositor/src/main/kotlin/Compositor.kt +++ b/orx-compositor/src/main/kotlin/Compositor.kt @@ -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 = mutableListOf() var blendFilter: Pair Unit>? = null val postFilters: MutableList 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 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 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 -} - - +} \ No newline at end of file