Added orx-no-clear
This commit is contained in:
10
README.md
10
README.md
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
A growing library of assorted data structures, algorithms and utilities.
|
A growing library of assorted data structures, algorithms and utilities.
|
||||||
|
|
||||||
- orx-kdtree, a kd-tree implementation for fast nearest point searches
|
- `orx-integral-image`, 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-integral-image, a CPU-based implementation for integral images (summed area tables)
|
- `orx-kdtree`, a kd-tree implementation for fast nearest point searches
|
||||||
|
- `orx-no-clear`, a simple extension that provides drawing without clearing the background
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
ORX is build against OPENRNDR 0.3.28, make sure you use this version in your project.
|
ORX is build against OPENRNDR 0.3.28, make sure you use this version in your project.
|
||||||
@@ -22,6 +22,6 @@ repositories {
|
|||||||
Add dependency:
|
Add dependency:
|
||||||
```
|
```
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.github.openrndr.orx:<orx-artifact>:v0.0.8'
|
compile 'com.github.openrndr.orx:<orx-artifact>:v0.0.9'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ plugins {
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
group 'org.openrndr.extra'
|
group 'org.openrndr.extra'
|
||||||
version '0.0.8'
|
version '0.0.9'
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@@ -15,7 +15,6 @@ ext {
|
|||||||
openrndrVersion = "0.3.28"
|
openrndrVersion = "0.3.28"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
|
|
||||||
apply plugin: 'kotlin'
|
apply plugin: 'kotlin'
|
||||||
@@ -31,7 +30,7 @@ subprojects {
|
|||||||
dependencies {
|
dependencies {
|
||||||
compile "org.openrndr:openrndr-core:$openrndrVersion"
|
compile "org.openrndr:openrndr-core:$openrndrVersion"
|
||||||
compile "org.openrndr:openrndr-filter:$openrndrVersion"
|
compile "org.openrndr:openrndr-filter:$openrndrVersion"
|
||||||
compile group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: '0.27.0'
|
compile group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: '1.0.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
package org.openrndr.extra.kdtree
|
package org.openrndr.extra.kdtree
|
||||||
|
|
||||||
import kotlinx.coroutines.experimental.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.experimental.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.experimental.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.experimental.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.openrndr.math.IntVector2
|
import org.openrndr.math.IntVector2
|
||||||
import org.openrndr.math.Vector2
|
import org.openrndr.math.Vector2
|
||||||
import org.openrndr.math.Vector3
|
import org.openrndr.math.Vector3
|
||||||
import org.openrndr.math.Vector4
|
import org.openrndr.math.Vector4
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.atomic.AtomicInteger
|
|
||||||
import kotlin.IllegalStateException
|
import kotlin.IllegalStateException
|
||||||
|
|
||||||
/** built-in mapper for [Vector2] */
|
/** built-in mapper for [Vector2] */
|
||||||
|
|||||||
21
orx-no-clear/README.md
Normal file
21
orx-no-clear/README.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# orx-no-clear
|
||||||
|
|
||||||
|
A simple OPENRNDR Extension that provides the classical drawing-without-clearing-the-screen functionality that
|
||||||
|
OPENRNDR does not support natively.
|
||||||
|
|
||||||
|
#### Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
class NoClearProgram: Program() {
|
||||||
|
|
||||||
|
override fun setup() {
|
||||||
|
backgroundColor = ColorRGBa.PINK
|
||||||
|
extend(NoClear())
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun draw() {
|
||||||
|
drawer.circle(Math.cos(seconds) * width / 2.0 + width / 2.0, Math.sin(seconds * 0.24) * height / 2.0 + height / 2.0, 20.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
45
orx-no-clear/src/main/kotlin/NoClear.kt
Normal file
45
orx-no-clear/src/main/kotlin/NoClear.kt
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import org.openrndr.Extension
|
||||||
|
import org.openrndr.Program
|
||||||
|
import org.openrndr.color.ColorRGBa
|
||||||
|
import org.openrndr.draw.Drawer
|
||||||
|
import org.openrndr.draw.RenderTarget
|
||||||
|
import org.openrndr.draw.isolated
|
||||||
|
import org.openrndr.draw.renderTarget
|
||||||
|
|
||||||
|
class NoClear : Extension {
|
||||||
|
override var enabled: Boolean = true
|
||||||
|
private var renderTarget: RenderTarget? = null
|
||||||
|
|
||||||
|
|
||||||
|
override fun beforeDraw(drawer: Drawer, program: Program) {
|
||||||
|
if (renderTarget == null || renderTarget?.width != program.width || renderTarget?.height != program.height) {
|
||||||
|
renderTarget?.let {
|
||||||
|
it.colorBuffer(0).destroy()
|
||||||
|
it.detachColorBuffers()
|
||||||
|
it.destroy()
|
||||||
|
}
|
||||||
|
renderTarget = renderTarget(program.width, program.height) {
|
||||||
|
colorBuffer()
|
||||||
|
depthBuffer()
|
||||||
|
}
|
||||||
|
|
||||||
|
renderTarget?.let {
|
||||||
|
drawer.withTarget(it) {
|
||||||
|
background(program.backgroundColor ?: ColorRGBa.TRANSPARENT)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
renderTarget?.bind()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun afterDraw(drawer: Drawer, program: Program) {
|
||||||
|
renderTarget?.unbind()
|
||||||
|
|
||||||
|
renderTarget?.let {
|
||||||
|
drawer.isolated {
|
||||||
|
drawer.ortho()
|
||||||
|
drawer.image(it.colorBuffer(0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
rootProject.name = 'orx'
|
rootProject.name = 'orx'
|
||||||
|
|
||||||
include 'orx-jumpflood',
|
include 'orx-integral-image',
|
||||||
|
'orx-jumpflood',
|
||||||
'orx-kdtree',
|
'orx-kdtree',
|
||||||
'orx-integral-image'
|
'orx-no-clear'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user