Fixes and move to jvmDemo (#286)
This commit is contained in:
80
orx-jumpflood/src/jvmDemo/kotlin/DemoDirectionField01.kt
Normal file
80
orx-jumpflood/src/jvmDemo/kotlin/DemoDirectionField01.kt
Normal file
@@ -0,0 +1,80 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.jumpfill.DirectionalField
|
||||
import org.openrndr.extra.noise.simplex
|
||||
import org.openrndr.math.Vector2
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.shape.Rectangle
|
||||
|
||||
/**
|
||||
* Shows how to use the [DirectionalField] filter.
|
||||
* Draws moving white shapes on black background,
|
||||
* then applies the DirectionalField filter which returns a [ColorBuffer] in which
|
||||
* the red and green components encode the direction to the closest black/white edge.
|
||||
*
|
||||
* Hold down a mouse button to see the raw animation.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 1024
|
||||
height = 1024
|
||||
}
|
||||
|
||||
program {
|
||||
val rt = renderTarget(width, height) { colorBuffer() }
|
||||
val directionalField = DirectionalField().also {
|
||||
it.distanceScale = 0.004
|
||||
}
|
||||
|
||||
// Needs to be FLOAT32 so we can have negative values
|
||||
val result = colorBuffer(width, height, type = ColorType.FLOAT32)
|
||||
val shader = shadeStyle {
|
||||
fragmentTransform = """
|
||||
x_fill.rgb = vec3(x_fill.rg + 0.5, x_fill.b);
|
||||
|
||||
// interesting when distanceScale = 1.0
|
||||
//x_fill.rgb = vec3(1.0 / (x_fill.r + x_fill.g));
|
||||
"""
|
||||
}
|
||||
|
||||
extend {
|
||||
// Draw moving white shapes on a black background
|
||||
drawer.isolatedWithTarget(rt) {
|
||||
clear(ColorRGBa.BLACK)
|
||||
stroke = null
|
||||
fill = ColorRGBa.WHITE
|
||||
repeat(10) {
|
||||
val pos = Vector2.simplex(it, seconds * 0.2) *
|
||||
bounds.center + bounds.center
|
||||
val size = (it * it + 5.0) * 2.0
|
||||
|
||||
isolated {
|
||||
translate(pos)
|
||||
if (it % 2 == 0) {
|
||||
circle(Vector2.ZERO, size)
|
||||
} else {
|
||||
rotate(Vector3.UNIT_Z, pos.x)
|
||||
rectangle(
|
||||
Rectangle.fromCenter(
|
||||
Vector2.ZERO, size, size * 2
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
directionalField.apply(rt.colorBuffer(0), result)
|
||||
|
||||
drawer.isolated {
|
||||
if (mouse.pressedButtons.isEmpty()) {
|
||||
shadeStyle = shader
|
||||
image(result)
|
||||
} else {
|
||||
image(rt.colorBuffer(0))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
85
orx-jumpflood/src/jvmDemo/kotlin/DemoDistanceField01.kt
Normal file
85
orx-jumpflood/src/jvmDemo/kotlin/DemoDistanceField01.kt
Normal file
@@ -0,0 +1,85 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.jumpfill.DistanceField
|
||||
import org.openrndr.extra.noise.simplex
|
||||
import org.openrndr.math.Vector2
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.shape.Rectangle
|
||||
|
||||
/**
|
||||
* Shows how to use the [DistanceField] filter.
|
||||
* Draws moving white shapes on black background,
|
||||
* then applies the DistanceField filter which returns a [ColorBuffer] in which
|
||||
* the red component encodes the distance to the closest black/white edge.
|
||||
* The value is positive when on the black background and negative
|
||||
* when inside white shapes. The sign is used in the [shadeStyle] to choose
|
||||
* between two colors. The inverse of the distance is used to obtain a
|
||||
* non-linear brightness.
|
||||
* Hold down a mouse button to see the raw animation.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 1024
|
||||
height = 1024
|
||||
}
|
||||
|
||||
program {
|
||||
val rt = renderTarget(width, height) { colorBuffer() }
|
||||
val distanceField = DistanceField()
|
||||
|
||||
// Needs to be FLOAT32 so we can have negative values
|
||||
val result = colorBuffer(width, height, type = ColorType.FLOAT32)
|
||||
val shader = shadeStyle {
|
||||
fragmentTransform = """
|
||||
float distance = abs(x_fill.r);
|
||||
float bri = 1.0 / (1.0 + 0.03 * distance);
|
||||
|
||||
// wavy effect
|
||||
// bri *= (1.0 + 0.2 * sin(distance * 0.2));
|
||||
|
||||
x_fill.rgb = bri * (x_fill.r > 0 ?
|
||||
vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 1.0));
|
||||
"""
|
||||
}
|
||||
|
||||
extend {
|
||||
// Draw moving white shapes on a black background
|
||||
drawer.isolatedWithTarget(rt) {
|
||||
clear(ColorRGBa.BLACK)
|
||||
stroke = null
|
||||
fill = ColorRGBa.WHITE
|
||||
repeat(10) {
|
||||
val pos = Vector2.simplex(it, seconds * 0.2) *
|
||||
bounds.center + bounds.center
|
||||
val size = (it * it + 5.0) * 2.0
|
||||
|
||||
isolated {
|
||||
translate(pos)
|
||||
if (it % 2 == 0) {
|
||||
circle(Vector2.ZERO, size)
|
||||
} else {
|
||||
rotate(Vector3.UNIT_Z, pos.x)
|
||||
rectangle(
|
||||
Rectangle.fromCenter(
|
||||
Vector2.ZERO, size, size * 2
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
distanceField.apply(rt.colorBuffer(0), result)
|
||||
|
||||
drawer.isolated {
|
||||
if (mouse.pressedButtons.isEmpty()) {
|
||||
shadeStyle = shader
|
||||
image(result)
|
||||
} else {
|
||||
image(rt.colorBuffer(0))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
32
orx-jumpflood/src/jvmDemo/kotlin/DemoInnerGlow01.kt
Normal file
32
orx-jumpflood/src/jvmDemo/kotlin/DemoInnerGlow01.kt
Normal file
@@ -0,0 +1,32 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
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.patterns.Checkers
|
||||
import org.openrndr.extra.jumpfill.fx.InnerGlow
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
val c = compose {
|
||||
layer {
|
||||
post(Checkers())
|
||||
}
|
||||
layer {
|
||||
draw {
|
||||
drawer.fill = ColorRGBa.PINK.shade(0.5)
|
||||
drawer.stroke = null
|
||||
drawer.circle(width / 2.0, height / 2.0, width * 0.35)
|
||||
}
|
||||
post(InnerGlow()) {
|
||||
color = ColorRGBa(-1.0, -1.0, -1.0, 0.25);
|
||||
width = 30.0
|
||||
}
|
||||
}
|
||||
}
|
||||
extend {
|
||||
c.draw(drawer)
|
||||
}
|
||||
}
|
||||
}
|
||||
33
orx-jumpflood/src/jvmDemo/kotlin/DemoInnerGlow02.kt
Normal file
33
orx-jumpflood/src/jvmDemo/kotlin/DemoInnerGlow02.kt
Normal file
@@ -0,0 +1,33 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
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.patterns.Checkers
|
||||
import org.openrndr.extra.jumpfill.fx.InnerGlow
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
val c = compose {
|
||||
layer {
|
||||
post(Checkers())
|
||||
}
|
||||
layer {
|
||||
draw {
|
||||
drawer.fill = ColorRGBa.PINK.shade(0.5)
|
||||
drawer.stroke = null
|
||||
drawer.circle(width / 2.0, height / 2.0, width * 0.35)
|
||||
}
|
||||
post(InnerGlow()) {
|
||||
color = ColorRGBa(1.0, 1.0, 1.0, 0.25);
|
||||
width = 30.0
|
||||
}
|
||||
}
|
||||
}
|
||||
extend {
|
||||
c.draw(drawer)
|
||||
}
|
||||
}
|
||||
}
|
||||
30
orx-jumpflood/src/jvmDemo/kotlin/DemoShapeSDF01.kt
Normal file
30
orx-jumpflood/src/jvmDemo/kotlin/DemoShapeSDF01.kt
Normal file
@@ -0,0 +1,30 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.draw.ColorFormat
|
||||
import org.openrndr.draw.ColorType
|
||||
import org.openrndr.draw.colorBuffer
|
||||
import org.openrndr.extra.jumpfill.ShapeSDF
|
||||
import org.openrndr.svg.loadSVG
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val sdf = ShapeSDF()
|
||||
val df = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
|
||||
|
||||
val shapes = loadSVG("orx-jumpflood/src/jvmDemo/resources/name.svg").findShapes().map { it.shape }
|
||||
sdf.setShapes(shapes)
|
||||
sdf.apply(emptyArray(), df)
|
||||
|
||||
extend {
|
||||
if(mouse.pressedButtons.isEmpty())
|
||||
drawer.image(df)
|
||||
else
|
||||
drawer.shapes(shapes)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
61
orx-jumpflood/src/jvmDemo/kotlin/DemoShapeSDF02.kt
Normal file
61
orx-jumpflood/src/jvmDemo/kotlin/DemoShapeSDF02.kt
Normal file
@@ -0,0 +1,61 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.ColorFormat
|
||||
import org.openrndr.draw.ColorType
|
||||
import org.openrndr.draw.colorBuffer
|
||||
import org.openrndr.extra.jumpfill.ShapeSDF
|
||||
import org.openrndr.extra.jumpfill.draw.SDFStrokeFill
|
||||
import org.openrndr.extra.jumpfill.ops.SDFOnion
|
||||
import org.openrndr.extra.jumpfill.ops.SDFSmoothIntersection
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.math.transforms.transform
|
||||
import org.openrndr.svg.loadSVG
|
||||
import kotlin.math.min
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val sdf0 = ShapeSDF()
|
||||
val df0 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
|
||||
|
||||
val sdf1 = ShapeSDF()
|
||||
val df1 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
|
||||
|
||||
val shapes = loadSVG("orx-jumpflood/src/jvmDemo/resources/name.svg").findShapes().map { it.shape }
|
||||
|
||||
val union = SDFSmoothIntersection()
|
||||
val onion = SDFOnion()
|
||||
|
||||
|
||||
val strokeFill = SDFStrokeFill()
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
|
||||
sdf0.setShapes(shapes)
|
||||
|
||||
sdf1.setShapes(shapes.map {
|
||||
it.transform(transform {
|
||||
translate(1280 / 2.0, 720.0 / 2)
|
||||
rotate(Vector3.Companion.UNIT_Z, seconds * 45.0 - 30.0)
|
||||
translate(-1280 / 2.0, -720.0 / 2.0)
|
||||
})
|
||||
})
|
||||
|
||||
sdf0.apply(emptyArray(), df0)
|
||||
sdf1.apply(emptyArray(), df1)
|
||||
union.radius = 10.0 + min(mouse.position.y, 100.0)
|
||||
union.apply(arrayOf(df0, df1), df0)
|
||||
onion.radius = 20.0
|
||||
onion.apply(df0, df0)
|
||||
strokeFill.strokeWeight = 2.0
|
||||
strokeFill.apply(df0, df0)
|
||||
drawer.image(df0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
54
orx-jumpflood/src/jvmDemo/kotlin/DemoShapeSDF03.kt
Normal file
54
orx-jumpflood/src/jvmDemo/kotlin/DemoShapeSDF03.kt
Normal file
@@ -0,0 +1,54 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.ColorFormat
|
||||
import org.openrndr.draw.ColorType
|
||||
import org.openrndr.draw.colorBuffer
|
||||
import org.openrndr.extra.fx.distort.FluidDistort
|
||||
import org.openrndr.extra.jumpfill.ShapeSDF
|
||||
import org.openrndr.extra.jumpfill.draw.SDFStrokeFill
|
||||
import org.openrndr.extra.jumpfill.ops.SDFSmoothDifference
|
||||
import org.openrndr.svg.loadSVG
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val sdf0 = ShapeSDF()
|
||||
val sdf1 = ShapeSDF()
|
||||
val df0 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
|
||||
val df1 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
|
||||
|
||||
val fd = FluidDistort()
|
||||
fd.outputUV = true
|
||||
|
||||
val uvmap = colorBuffer(width, height, type = ColorType.FLOAT16)
|
||||
|
||||
val shapes = loadSVG("orx-jumpflood/src/jvmDemo/resources/name.svg").findShapes().map { it.shape }
|
||||
val union = SDFSmoothDifference()
|
||||
|
||||
sdf0.setShapes(shapes)
|
||||
sdf1.setShapes(shapes)
|
||||
|
||||
val strokeFill = SDFStrokeFill()
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
|
||||
fd.apply(emptyArray(), uvmap)
|
||||
|
||||
sdf0.useUV = true
|
||||
sdf0.apply(uvmap, df0)
|
||||
sdf1.apply(uvmap, df1)
|
||||
union.radius = 10.0
|
||||
union.apply(arrayOf(df0, df1), df0)
|
||||
|
||||
strokeFill.strokeWeight = 10.0
|
||||
strokeFill.apply(df0, df0)
|
||||
drawer.image(df0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
61
orx-jumpflood/src/jvmDemo/kotlin/DemoShapeSDF04.kt
Normal file
61
orx-jumpflood/src/jvmDemo/kotlin/DemoShapeSDF04.kt
Normal file
@@ -0,0 +1,61 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.ColorFormat
|
||||
import org.openrndr.draw.ColorType
|
||||
import org.openrndr.draw.colorBuffer
|
||||
import org.openrndr.extra.fx.distort.Perturb
|
||||
import org.openrndr.extra.gui.GUI
|
||||
import org.openrndr.extra.jumpfill.ShapeSDF
|
||||
import org.openrndr.extra.jumpfill.draw.SDFStrokeFill
|
||||
import org.openrndr.extra.jumpfill.ops.SDFSmoothDifference
|
||||
import org.openrndr.shape.Circle
|
||||
import org.openrndr.svg.loadSVG
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val gui = GUI()
|
||||
val sdf0 = ShapeSDF()
|
||||
val sdf1 = ShapeSDF()
|
||||
val df0 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
|
||||
val df1 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
|
||||
|
||||
val perturb = Perturb()
|
||||
perturb.outputUV = true
|
||||
|
||||
val uvmap = colorBuffer(width, height, type = ColorType.FLOAT16)
|
||||
|
||||
val circleShapes = List(1) { Circle(width/2.0, height/2.0, 200.0).shape}
|
||||
val shapes = loadSVG("orx-jumpflood/src/jvmDemo/resources/name.svg").findShapes().map { it.shape }
|
||||
|
||||
sdf0.setShapes(circleShapes)
|
||||
sdf1.setShapes(shapes)
|
||||
|
||||
val difference = SDFSmoothDifference()
|
||||
val strokeFill = SDFStrokeFill()
|
||||
|
||||
gui.add(perturb)
|
||||
extend(gui)
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
|
||||
perturb.phase = seconds * 0.1
|
||||
perturb.apply(uvmap, uvmap)
|
||||
|
||||
sdf0.useUV = true
|
||||
sdf0.apply(uvmap, df0)
|
||||
sdf1.apply(uvmap, df1)
|
||||
difference.radius = 10.0
|
||||
difference.apply(arrayOf(df0, df1), df0)
|
||||
|
||||
strokeFill.strokeWeight = 10.0
|
||||
strokeFill.apply(df0, df0)
|
||||
drawer.image(df0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
75
orx-jumpflood/src/jvmDemo/kotlin/DemoShapeSDF05.kt
Normal file
75
orx-jumpflood/src/jvmDemo/kotlin/DemoShapeSDF05.kt
Normal file
@@ -0,0 +1,75 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.ColorFormat
|
||||
import org.openrndr.draw.ColorType
|
||||
import org.openrndr.draw.colorBuffer
|
||||
import org.openrndr.extra.fx.distort.Perturb
|
||||
import org.openrndr.extra.gui.GUI
|
||||
import org.openrndr.extra.jumpfill.ShapeSDF
|
||||
import org.openrndr.extra.jumpfill.draw.SDFStrokeFill
|
||||
import org.openrndr.extra.jumpfill.ops.SDFSmoothDifference
|
||||
import org.openrndr.math.Vector2
|
||||
import org.openrndr.shape.Circle
|
||||
import org.openrndr.svg.loadSVG
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.sin
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val gui = GUI()
|
||||
val sdf0 = ShapeSDF()
|
||||
val sdf1 = ShapeSDF()
|
||||
val df0 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
|
||||
val df1 = colorBuffer(width, height, format = ColorFormat.RGBa, type = ColorType.FLOAT32)
|
||||
|
||||
val perturb = Perturb()
|
||||
|
||||
perturb.outputUV = true
|
||||
|
||||
val uvmap = colorBuffer(width, height, type = ColorType.FLOAT16)
|
||||
val uvmap2 = colorBuffer(width, height, type = ColorType.FLOAT16)
|
||||
|
||||
val circleShapes = List(1) { Circle(width/2.0, height/2.0, 200.0).shape}
|
||||
val shapes = loadSVG("orx-jumpflood/src/jvmDemo/resources/name.svg").findShapes().map { it.shape }
|
||||
|
||||
sdf0.setShapes(circleShapes)
|
||||
sdf1.setShapes(shapes)
|
||||
|
||||
val difference = SDFSmoothDifference()
|
||||
val strokeFill = SDFStrokeFill()
|
||||
sdf0.useUV = true
|
||||
gui.add(sdf0)
|
||||
gui.add(perturb)
|
||||
gui.add(strokeFill)
|
||||
gui.add(difference)
|
||||
|
||||
extend(gui)
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
|
||||
perturb.offset = Vector2(cos(seconds*0.2), sin(seconds*0.2))
|
||||
perturb.outputUV = true
|
||||
perturb.phase = seconds * 0.1
|
||||
perturb.apply(uvmap, uvmap)
|
||||
|
||||
perturb.offset = Vector2.ZERO
|
||||
perturb.outputUV = false
|
||||
perturb.phase = seconds * 0.05
|
||||
perturb.apply(uvmap, uvmap2)
|
||||
|
||||
sdf0.apply(uvmap2, df0)
|
||||
sdf1.apply(uvmap2, df1)
|
||||
|
||||
difference.apply(arrayOf(df0, df1), df0)
|
||||
|
||||
strokeFill.apply(df0, df0)
|
||||
drawer.image(df0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
48
orx-jumpflood/src/jvmDemo/kotlin/DemoSkeleton01.kt
Normal file
48
orx-jumpflood/src/jvmDemo/kotlin/DemoSkeleton01.kt
Normal file
@@ -0,0 +1,48 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.ColorType
|
||||
import org.openrndr.draw.createEquivalent
|
||||
|
||||
import org.openrndr.draw.isolatedWithTarget
|
||||
import org.openrndr.draw.renderTarget
|
||||
import org.openrndr.extensions.SingleScreenshot
|
||||
import org.openrndr.extra.jumpfill.fx.Skeleton
|
||||
import org.openrndr.extra.noise.simplex
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val skeleton = Skeleton()
|
||||
|
||||
val input = renderTarget(width, height) {
|
||||
colorBuffer()
|
||||
}
|
||||
val field = input.colorBuffer(0).createEquivalent(type = ColorType.FLOAT32)
|
||||
extend {
|
||||
drawer.isolatedWithTarget(input) {
|
||||
// -- draw something interesting
|
||||
drawer.stroke = null
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.fill = ColorRGBa.WHITE
|
||||
drawer.circle(mouse.position, 300.0)
|
||||
drawer.fill = ColorRGBa.BLACK
|
||||
drawer.circle(mouse.position, 150.0)
|
||||
drawer.fill = ColorRGBa.WHITE
|
||||
for (i in 0 until 30) {
|
||||
val time = seconds * 0.25
|
||||
val x = simplex(i * 20, time) * width / 2 + width / 2
|
||||
val y = simplex(i * 20 + 5, time) * height / 2 + height / 2
|
||||
val r = simplex(i*30, time) * 50.0 + 50.0
|
||||
drawer.circle(x, y, r)
|
||||
}
|
||||
}
|
||||
skeleton.apply(input.colorBuffer(0), field)
|
||||
drawer.image(field)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
47
orx-jumpflood/src/jvmDemo/kotlin/DemoStraightSkeleton01.kt
Normal file
47
orx-jumpflood/src/jvmDemo/kotlin/DemoStraightSkeleton01.kt
Normal file
@@ -0,0 +1,47 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.ColorType
|
||||
import org.openrndr.draw.createEquivalent
|
||||
|
||||
import org.openrndr.draw.isolatedWithTarget
|
||||
import org.openrndr.draw.renderTarget
|
||||
import org.openrndr.extra.jumpfill.fx.StraightSkeleton
|
||||
import org.openrndr.extra.noise.simplex
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val straightSkeleton = StraightSkeleton()
|
||||
val input = renderTarget(width, height) {
|
||||
colorBuffer()
|
||||
}
|
||||
val field = input.colorBuffer(0).createEquivalent(type = ColorType.FLOAT32)
|
||||
|
||||
extend {
|
||||
drawer.isolatedWithTarget(input) {
|
||||
// -- draw something interesting
|
||||
drawer.stroke = null
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.fill = ColorRGBa.WHITE
|
||||
drawer.circle(mouse.position, 300.0)
|
||||
drawer.fill = ColorRGBa.BLACK
|
||||
drawer.circle(mouse.position, 150.0)
|
||||
drawer.fill = ColorRGBa.WHITE
|
||||
for (i in 0 until 30) {
|
||||
val time = seconds * 0.25
|
||||
val x = simplex(i * 20, time) * width / 2 + width / 2
|
||||
val y = simplex(i * 20 + 5, time) * height / 2 + height / 2
|
||||
val r = simplex(i*30, time) * 50.0 + 50.0
|
||||
drawer.circle(x, y, r)
|
||||
}
|
||||
}
|
||||
straightSkeleton.apply(input.colorBuffer(0), field)
|
||||
drawer.image(field)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
68
orx-jumpflood/src/jvmDemo/kotlin/DemoVoronoi01.kt
Normal file
68
orx-jumpflood/src/jvmDemo/kotlin/DemoVoronoi01.kt
Normal file
@@ -0,0 +1,68 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.blend.Passthrough
|
||||
import org.openrndr.extra.jumpfill.EncodePoints
|
||||
import org.openrndr.extra.jumpfill.IdContourPoints
|
||||
import org.openrndr.extra.jumpfill.JumpFlooder
|
||||
import kotlin.math.cos
|
||||
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 512
|
||||
height = 512
|
||||
}
|
||||
program {
|
||||
val rt = renderTarget(512, 512, 1.0) {
|
||||
colorBuffer(type = ColorType.FLOAT32)
|
||||
}
|
||||
val encoder = EncodePoints()
|
||||
val jf = JumpFlooder(512, 512, encodePoints = Passthrough())
|
||||
val jf2 = JumpFlooder(512, 512, encodePoints = Passthrough())
|
||||
val idcontours = IdContourPoints()
|
||||
val contoured = colorBuffer(512, 512, type = ColorType.FLOAT32)
|
||||
extend {
|
||||
fun plot(x: Double, y: Double, id: Double) {
|
||||
drawer.fill = ColorRGBa(id, 0.0, 0.0, 1.0)
|
||||
drawer.point(x, y)
|
||||
}
|
||||
|
||||
drawer.isolatedWithTarget(rt) {
|
||||
drawer.clear(ColorRGBa(-1.0, -1.0, -1.0, 0.0))
|
||||
val o = cos(seconds) * 200.0 + 200.0
|
||||
|
||||
for (i in 0 until 20) {
|
||||
plot(o + 100.0 + i * 4, 100.0, 0.25)
|
||||
}
|
||||
|
||||
for (i in 0 until 20) {
|
||||
plot(200.0 + i * 4, 150.0 + i, 0.5)
|
||||
}
|
||||
for (i in 0 until 20) {
|
||||
plot(300.0 + i * 4, 250.0 + i, 0.7)
|
||||
}
|
||||
|
||||
for (i in 0 until 20) {
|
||||
plot(400.0 + i * 4, 250.0 + i, 0.75)
|
||||
}
|
||||
}
|
||||
encoder.apply(rt.colorBuffer(0), rt.colorBuffer(0))
|
||||
val flooded = jf.jumpFlood(rt.colorBuffer(0))
|
||||
drawer.image(flooded)
|
||||
idcontours.apply(flooded, contoured)
|
||||
drawer.image(contoured)
|
||||
val flooded2 = jf2.jumpFlood(contoured)
|
||||
|
||||
drawer.image(flooded2, 512.0, 0.0)
|
||||
|
||||
drawer.shadeStyle = shadeStyle {
|
||||
fragmentTransform = """
|
||||
float d = length(va_texCoord0.xy - x_fill.xy);
|
||||
x_fill = vec4(d,d,x_fill.z, 1.0);
|
||||
""".trimIndent()
|
||||
}
|
||||
drawer.image(flooded2, 0.0, 0.0)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
55
orx-jumpflood/src/jvmDemo/kotlin/DemoVoronoi02.kt
Normal file
55
orx-jumpflood/src/jvmDemo/kotlin/DemoVoronoi02.kt
Normal file
@@ -0,0 +1,55 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.jumpfill.*
|
||||
import kotlin.math.cos
|
||||
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 512
|
||||
height = 512
|
||||
}
|
||||
program {
|
||||
val rt = renderTarget(512, 512, 1.0) {
|
||||
colorBuffer(type = ColorType.FLOAT32)
|
||||
}
|
||||
|
||||
val flowfield = colorBuffer(512, 512, type = ColorType.FLOAT32)
|
||||
val cluster = ClusteredField(decodeMode = DecodeMode.DISTANCE, outputDistanceToContours = true)
|
||||
|
||||
|
||||
cluster.normalizedDistance = true
|
||||
|
||||
extend {
|
||||
fun plot(x: Double, y: Double, id: Double) {
|
||||
drawer.fill = ColorRGBa(id, 0.0, 0.0, 1.0)
|
||||
drawer.point(x, y)
|
||||
}
|
||||
|
||||
drawer.isolatedWithTarget(rt) {
|
||||
drawer.clear(ColorRGBa(-1.0, -1.0, -1.0, 0.0))
|
||||
val o = cos(seconds) * 200.0 + 200.0
|
||||
|
||||
for (i in 0 until 20) {
|
||||
plot(o + 100.0 + i * 4, 100.0, 0.25)
|
||||
}
|
||||
|
||||
for (i in 0 until 20) {
|
||||
plot(200.0 + i * 4, 150.0 + i, 0.5)
|
||||
}
|
||||
for (i in 0 until 20) {
|
||||
plot(300.0 + i * 4, 250.0 + i, 0.7)
|
||||
}
|
||||
|
||||
for (i in 0 until 20) {
|
||||
plot(400.0 + i * 4, 250.0 + i, 0.75)
|
||||
}
|
||||
}
|
||||
cluster.apply(rt.colorBuffer(0), flowfield)
|
||||
drawer.drawStyle.colorMatrix = tint(ColorRGBa(10.0, 10.0, 1.0))
|
||||
drawer.image(flowfield)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
43
orx-jumpflood/src/jvmDemo/kotlin/DemoVoronoi03.kt
Normal file
43
orx-jumpflood/src/jvmDemo/kotlin/DemoVoronoi03.kt
Normal file
@@ -0,0 +1,43 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.blend.Passthrough
|
||||
import org.openrndr.extra.jumpfill.*
|
||||
import org.openrndr.extra.noise.scatter
|
||||
import org.openrndr.extra.noise.uniformRing
|
||||
import org.openrndr.math.Vector2
|
||||
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val rt = renderTarget(720, 720, 1.0) {
|
||||
colorBuffer(type = ColorType.FLOAT32)
|
||||
}
|
||||
val flowfield = colorBuffer(width, height, type = ColorType.FLOAT32)
|
||||
val cluster = ClusteredField(decodeMode = DecodeMode.DISTANCE, outputDistanceToContours = true)
|
||||
|
||||
cluster.normalizedDistance = true
|
||||
|
||||
extend {
|
||||
drawer.isolatedWithTarget(rt) {
|
||||
drawer.ortho(rt)
|
||||
drawer.clear(ColorRGBa(-1.0, -1.0, -1.0, 0.0))
|
||||
val points = drawer.bounds.scatter(20.0)
|
||||
drawer.points {
|
||||
for ((index, point) in points.withIndex()) {
|
||||
fill = ColorRGBa((index+1.0)/points.size, 0.0, 0.0, 1.0)
|
||||
for (i in 0 until 30) {
|
||||
point(point + Vector2.uniformRing(15.0, 25.0)* Vector2(1.0, 1.0))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cluster.apply(rt.colorBuffer(0), flowfield)
|
||||
drawer.drawStyle.colorMatrix = tint(ColorRGBa(100.0, 100.0, 0.0))
|
||||
drawer.image(flowfield)
|
||||
}
|
||||
}
|
||||
}
|
||||
12
orx-jumpflood/src/jvmDemo/resources/name.svg
Normal file
12
orx-jumpflood/src/jvmDemo/resources/name.svg
Normal file
@@ -0,0 +1,12 @@
|
||||
<svg version="1.1" baseProfile="tiny" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 1280 720" xml:space="preserve">
|
||||
<polygon fill="#FF00FF" stroke="#000000" stroke-miterlimit="2.6131" points="1013.8,424.3 1013.8,238 957.1,238 957.1,238
|
||||
794.7,238 794.7,294.7 957.1,294.7 957.1,318.9 794.7,318.9 794.7,375.6 957.1,375.6 957.1,424.3 794.7,424.3 794.7,481 957.1,481
|
||||
1013.8,481 1037.8,481 1037.8,424.3 "/>
|
||||
<path fill="#FF00FF" stroke="#000000" stroke-miterlimit="2.6131" d="M705.7,263.3H576V239h-56.7v119.2l0,0V401h93.2v24.3h-93.2V482
|
||||
h243.1v-56.7h-93.2V401h93.2V239h-56.7V263.3L705.7,263.3z M705.7,344.3H576V320h129.7V344.3z"/>
|
||||
<path fill="#FF00FF" d="M356.6,279L356.6,279L356.6,279z"/>
|
||||
<path fill="#FF00FF" stroke="#000000" stroke-miterlimit="2.6131" d="M356.6,279c-9.2-3.3-19-5-28.8-5c-47.2,0-85.5,38.3-85.5,85.5
|
||||
s38.3,85.5,85.5,85.5s85.5-38.3,85.5-85.5c0-0.1,0-0.3,0-0.4C413.3,323.1,390.5,291,356.6,279z M327.8,387.4
|
||||
c-15.7,0-28.4-12.7-28.4-28.4c0-15.7,12.7-28.4,28.4-28.4c15.6,0,28.4,12.7,28.4,28.4C356.1,374.7,343.4,387.4,327.8,387.4z"/>
|
||||
<rect x="430.1" y="238" fill="#FF00FF" stroke="#000000" stroke-miterlimit="2.6131" width="56.7" height="243"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
Reference in New Issue
Block a user