[orx-fx] Add PolarToRectangular, RectangularToPolar and LineBlur
This commit is contained in:
@@ -49,6 +49,8 @@ class BoxBlur : Filter(mppFilterShader(fx_box_blur,"box-blur")) {
|
||||
colorBuffer(target[0].width, target[0].height, target[0].contentScale, target[0].format, target[0].type)
|
||||
}
|
||||
|
||||
parameters["wrapX"] = false
|
||||
parameters["wrapY"] = false
|
||||
intermediate.let {
|
||||
parameters["blurDirection"] = Vector2(1.0, 0.0)
|
||||
super.apply(source, arrayOf(it))
|
||||
|
||||
65
orx-fx/src/commonMain/kotlin/blur/LineBlur.kt
Normal file
65
orx-fx/src/commonMain/kotlin/blur/LineBlur.kt
Normal file
@@ -0,0 +1,65 @@
|
||||
package org.openrndr.extra.fx.blur
|
||||
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.fx_box_blur
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.BooleanParameter
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
import org.openrndr.extra.parameters.IntParameter
|
||||
|
||||
import org.openrndr.math.Vector2
|
||||
import org.openrndr.math.asRadians
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.sin
|
||||
|
||||
/**
|
||||
* BoxBlur implemented as a separable filter
|
||||
*/
|
||||
@Description("Box-blur")
|
||||
class LineBlur : Filter(mppFilterShader(fx_box_blur, "line-blur")) {
|
||||
|
||||
/**
|
||||
* The sample window, default is 5
|
||||
*/
|
||||
@IntParameter("window size", 1, 25)
|
||||
var window: Int by parameters
|
||||
|
||||
/**
|
||||
* Spread multiplier, default is 1.0
|
||||
*/
|
||||
@DoubleParameter("kernel spread", 1.0, 4.0)
|
||||
var spread: Double by parameters
|
||||
|
||||
/**
|
||||
* Post-blur gain, default is 1.0
|
||||
*/
|
||||
@DoubleParameter("gain", 0.0, 4.0)
|
||||
var gain: Double by parameters
|
||||
|
||||
|
||||
@DoubleParameter("blur angle", -180.0, 180.0)
|
||||
var blurAngle: Double by parameters
|
||||
|
||||
@BooleanParameter("wrap x", order = 9)
|
||||
var wrapX: Boolean by parameters
|
||||
|
||||
@BooleanParameter("wrap y", order = 10)
|
||||
var wrapY: Boolean by parameters
|
||||
|
||||
|
||||
|
||||
init {
|
||||
window = 5
|
||||
spread = 1.0
|
||||
gain = 1.0
|
||||
blurAngle = 0.0
|
||||
wrapX = false
|
||||
wrapY = false
|
||||
}
|
||||
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
parameters["blurDirection"] = Vector2(cos(blurAngle.asRadians), sin(blurAngle.asRadians))
|
||||
super.apply(source, target)
|
||||
}
|
||||
}
|
||||
23
orx-fx/src/commonMain/kotlin/distort/PolarToRectangular.kt
Normal file
23
orx-fx/src/commonMain/kotlin/distort/PolarToRectangular.kt
Normal file
@@ -0,0 +1,23 @@
|
||||
package org.openrndr.extra.fx.distort
|
||||
|
||||
import org.openrndr.draw.ColorBuffer
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.draw.MagnifyingFilter
|
||||
import org.openrndr.draw.MinifyingFilter
|
||||
import org.openrndr.extra.fx.fx_polar_to_rectangular
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.Vector2Parameter
|
||||
import org.openrndr.math.Vector2
|
||||
|
||||
@Description("Polar to rectangular")
|
||||
class PolarToRectangular : Filter(mppFilterShader(fx_polar_to_rectangular, "polar-to-rectangular")) {
|
||||
var bicubicFiltering = true
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
if (bicubicFiltering && source.isNotEmpty()) {
|
||||
source[0].generateMipmaps()
|
||||
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
|
||||
}
|
||||
super.apply(source, target)
|
||||
}
|
||||
}
|
||||
23
orx-fx/src/commonMain/kotlin/distort/RectangularToPolar.kt
Normal file
23
orx-fx/src/commonMain/kotlin/distort/RectangularToPolar.kt
Normal file
@@ -0,0 +1,23 @@
|
||||
package org.openrndr.extra.fx.distort
|
||||
|
||||
import org.openrndr.draw.ColorBuffer
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.draw.MagnifyingFilter
|
||||
import org.openrndr.draw.MinifyingFilter
|
||||
import org.openrndr.extra.fx.fx_rectangular_to_polar
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.Vector2Parameter
|
||||
import org.openrndr.math.Vector2
|
||||
|
||||
@Description("Rectangular to polar")
|
||||
class RectangularToPolar : Filter(mppFilterShader(fx_rectangular_to_polar, "rectangular-to-polar")) {
|
||||
var bicubicFiltering = true
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
if (bicubicFiltering && source.isNotEmpty()) {
|
||||
source[0].generateMipmaps()
|
||||
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
|
||||
}
|
||||
super.apply(source, target)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user