[orx-fx] convert to MPP

This commit is contained in:
Edwin Jakobs
2021-06-27 21:07:44 +02:00
parent 7d524df2de
commit 4dfc5c31c8
144 changed files with 1197 additions and 847 deletions

View File

@@ -0,0 +1,35 @@
package org.openrndr.extra.fx.edges
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.Filter
import org.openrndr.extra.fx.fx_contour
import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.ColorParameter
import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter
@Description("Contour")
class Contour : Filter(mppFilterShader(fx_contour, "contour")) {
@DoubleParameter("levels", 1.0, 16.0)
var levels: Double by parameters
@DoubleParameter("contour width", 0.0, 4.0)
var contourWidth: Double by parameters
@DoubleParameter("contour opacity", 0.0, 1.0)
var contourOpacity: Double by parameters
@DoubleParameter("background opacity", 0.0, 1.0)
var backgroundOpacity: Double by parameters
@ColorParameter("contour color")
var contourColor: ColorRGBa by parameters
init {
levels = 6.0
contourWidth = 0.4
contourColor = ColorRGBa.BLACK
backgroundOpacity = 1.0
contourOpacity = 1.0
}
}

View File

@@ -0,0 +1,60 @@
package org.openrndr.extra.fx.edges
import org.openrndr.draw.*
import org.openrndr.extra.fx.ColorBufferDescription
import org.openrndr.extra.fx.fx_edges_work_1
import org.openrndr.extra.fx.fx_edges_work_2
import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.IntParameter
import org.openrndr.math.Vector2
internal class EdgesWork1 : Filter(mppFilterShader(fx_edges_work_1, "edges-work-1")) {
var delta: Vector2 by parameters
init {
delta = Vector2.ZERO
}
}
@Description("Edges Work")
open class EdgesWork : Filter(mppFilterShader(fx_edges_work_2, "edges-work-2")) {
/**
* radius, default value is 1.0
*/
@IntParameter("radius", 1, 400)
var radius: Int by parameters
private var delta: Vector2 by parameters
private val work1 = EdgesWork1()
private var intermediateCache = mutableMapOf<ColorBufferDescription, ColorBuffer>()
init {
radius = 1
delta = Vector2.ZERO
}
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
val intermediateDescription = ColorBufferDescription(
target[0].width,
target[0].height,
target[0].contentScale,
target[0].format,
target[0].type
)
val intermediate = intermediateCache.getOrPut(intermediateDescription) {
colorBuffer(target[0].width, target[0].height, target[0].contentScale, target[0].format, target[0].type)
}
intermediate.let {
work1.delta = Vector2(radius / it.effectiveWidth.toDouble(), 0.0)
work1.apply(source, arrayOf(it))
parameters["delta"] = Vector2(0.0, radius / it.effectiveHeight.toDouble())
super.apply(arrayOf(it), target)
}
}
}

View File

@@ -0,0 +1,31 @@
package org.openrndr.extra.fx.edges
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.Filter
import org.openrndr.extra.fx.fx_luma_sobel
import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.ColorParameter
import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter
@Description("Luma Sobel")
class LumaSobel : Filter(mppFilterShader(fx_luma_sobel, "luma-sobel")) {
@ColorParameter("background color")
var backgroundColor: ColorRGBa by parameters
@ColorParameter("edge color")
var edgeColor: ColorRGBa by parameters
@DoubleParameter("background opacity", 0.0, 1.0)
var backgroundOpacity: Double by parameters
@DoubleParameter("edge opacity", 0.0, 1.0)
var edgeOpacity: Double by parameters
init {
backgroundColor = ColorRGBa.BLACK
edgeColor = ColorRGBa.WHITE
edgeOpacity = 1.0
backgroundOpacity = 1.0
}
}