Fixes and move to jvmDemo (#286)
This commit is contained in:
37
orx-compositor/src/jvmDemo/kotlin/DemoAside01.kt
Normal file
37
orx-compositor/src/jvmDemo/kotlin/DemoAside01.kt
Normal file
@@ -0,0 +1,37 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.ColorType
|
||||
import org.openrndr.extra.compositor.*
|
||||
import org.openrndr.extra.fx.blur.DirectionalBlur
|
||||
import org.openrndr.extra.fx.blur.HashBlurDynamic
|
||||
import org.openrndr.extra.fx.patterns.Checkers
|
||||
import kotlin.math.cos
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
val c = compose {
|
||||
layer {
|
||||
val a = aside(colorType = ColorType.FLOAT32) {
|
||||
post(Checkers()) {
|
||||
this.size = cos(seconds)*0.5 + 0.5
|
||||
}
|
||||
}
|
||||
draw {
|
||||
drawer.clear(ColorRGBa.GRAY.shade(0.5))
|
||||
drawer.circle(width/2.0, height/2.0, 100.0)
|
||||
}
|
||||
post(HashBlurDynamic(), a) {
|
||||
time = seconds
|
||||
radius = 25.0
|
||||
}
|
||||
}
|
||||
}
|
||||
extend {
|
||||
c.draw(drawer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
88
orx-compositor/src/jvmDemo/kotlin/DemoCompositor01.kt
Normal file
88
orx-compositor/src/jvmDemo/kotlin/DemoCompositor01.kt
Normal file
@@ -0,0 +1,88 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.color.rgb
|
||||
import org.openrndr.draw.Drawer
|
||||
import org.openrndr.extensions.SingleScreenshot
|
||||
import org.openrndr.extra.compositor.compose
|
||||
import org.openrndr.extra.compositor.draw
|
||||
import org.openrndr.extra.compositor.layer
|
||||
import org.openrndr.extra.compositor.post
|
||||
import org.openrndr.extra.fx.blur.ApproximateGaussianBlur
|
||||
import org.openrndr.math.Vector3
|
||||
import kotlin.random.Random
|
||||
|
||||
/**
|
||||
* Compositor demo showing 3 layers of moving items
|
||||
* with a different amount of blur in each layer,
|
||||
* simulating depth of field
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 900
|
||||
height = 900
|
||||
}
|
||||
|
||||
program {
|
||||
data class Item(var pos: Vector3, val color: ColorRGBa) {
|
||||
fun draw(drawer: Drawer) {
|
||||
pos -= Vector3(pos.z * 3.0, 0.0, 0.0)
|
||||
if (pos.x < -260.0) {
|
||||
pos = Vector3(width + 260.0, pos.y, pos.z)
|
||||
}
|
||||
drawer.fill = null
|
||||
drawer.stroke = color
|
||||
drawer.strokeWeight = 2.0 + 30.0 * pos.z * pos.z
|
||||
drawer.circle(pos.xy, 10.0 + 250.0 * pos.z * pos.z)
|
||||
}
|
||||
}
|
||||
|
||||
val items = List(50) {
|
||||
val pos = Vector3(Random.nextDouble() * width,
|
||||
Random.nextDouble(0.3, 0.7) * height,
|
||||
Random.nextDouble())
|
||||
Item(pos, ColorRGBa.PINK.shade(Random.nextDouble(0.2, 0.9)))
|
||||
}.sortedBy { it.pos.z }
|
||||
|
||||
val composite = compose {
|
||||
layer {
|
||||
draw {
|
||||
drawer.stroke = null
|
||||
items.filter { it.pos.z < 0.33 }.forEach {
|
||||
it.draw(drawer)
|
||||
}
|
||||
}
|
||||
post(ApproximateGaussianBlur()) {
|
||||
window = 25
|
||||
sigma = 5.00
|
||||
}
|
||||
}
|
||||
|
||||
layer {
|
||||
draw {
|
||||
drawer.stroke = null
|
||||
items.filter { it.pos.z in 0.33..0.66 }.forEach {
|
||||
it.draw(drawer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
layer {
|
||||
draw {
|
||||
drawer.stroke = null
|
||||
items.filter { it.pos.z > 0.66 }.forEach {
|
||||
it.draw(drawer)
|
||||
}
|
||||
}
|
||||
post(ApproximateGaussianBlur()) {
|
||||
window = 25
|
||||
sigma = 5.00
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extend {
|
||||
drawer.clear(rgb(0.2))
|
||||
composite.draw(drawer)
|
||||
}
|
||||
}
|
||||
}
|
||||
50
orx-compositor/src/jvmDemo/kotlin/DemoCompositor02.kt
Normal file
50
orx-compositor/src/jvmDemo/kotlin/DemoCompositor02.kt
Normal file
@@ -0,0 +1,50 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.BufferMultisample
|
||||
import org.openrndr.extra.compositor.blend
|
||||
import org.openrndr.extra.compositor.compose
|
||||
import org.openrndr.extra.compositor.draw
|
||||
import org.openrndr.extra.compositor.layer
|
||||
import org.openrndr.extra.fx.blend.Normal
|
||||
import org.openrndr.math.Vector2
|
||||
import org.openrndr.shape.Rectangle
|
||||
|
||||
/**
|
||||
* Demonstration of using [BufferMultisample] on a per layer basis.
|
||||
* Try changing which layer has multisampling applied and observe the results.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
|
||||
program {
|
||||
val layers = compose {
|
||||
layer(multisample = BufferMultisample.SampleCount(16)) {
|
||||
draw {
|
||||
drawer.translate(drawer.bounds.center)
|
||||
drawer.rotate(seconds)
|
||||
drawer.fill = ColorRGBa.PINK
|
||||
drawer.rectangle(Rectangle.fromCenter(Vector2.ZERO, 200.0))
|
||||
}
|
||||
|
||||
layer {
|
||||
blend(Normal()) {
|
||||
clip = true
|
||||
}
|
||||
draw {
|
||||
drawer.rotate(seconds * -2)
|
||||
drawer.fill = ColorRGBa.WHITE
|
||||
drawer.rectangle(Rectangle.fromCenter(Vector2.ZERO, 200.0))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.WHITE)
|
||||
layers.draw(drawer)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user