Add CMYKHalftone, LumaSobel, DropShadow and segmented waves
This commit is contained in:
@@ -4,6 +4,7 @@ import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.filterFragmentCode
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
import org.openrndr.extra.parameters.IntParameter
|
||||
|
||||
@Description("Horizontal wave")
|
||||
class HorizontalWave : Filter(Shader.createFromCode(filterVertexCode, filterFragmentCode("distort/horizontal-wave.frag"))) {
|
||||
@@ -16,10 +17,15 @@ class HorizontalWave : Filter(Shader.createFromCode(filterVertexCode, filterFrag
|
||||
@DoubleParameter("phase", -0.5, 0.5)
|
||||
var phase: Double by parameters
|
||||
|
||||
@IntParameter("segments", 0, 256)
|
||||
var segments: Int by parameters
|
||||
|
||||
|
||||
init {
|
||||
frequency = 1.0
|
||||
amplitude = 0.1
|
||||
phase = 0.0
|
||||
segments = 0
|
||||
}
|
||||
|
||||
var bicubicFiltering = true
|
||||
@@ -43,10 +49,15 @@ class VerticalWave : Filter(Shader.createFromCode(filterVertexCode, filterFragme
|
||||
@DoubleParameter("phase", -0.5, 0.5)
|
||||
var phase: Double by parameters
|
||||
|
||||
@IntParameter("segments", 0, 256)
|
||||
var segments: Int by parameters
|
||||
|
||||
|
||||
init {
|
||||
frequency = 1.0
|
||||
amplitude = 0.1
|
||||
phase = 0.0
|
||||
segments = 0
|
||||
}
|
||||
var bicubicFiltering = true
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
|
||||
27
orx-fx/src/main/kotlin/dither/CMYKHalftone.kt
Normal file
27
orx-fx/src/main/kotlin/dither/CMYKHalftone.kt
Normal file
@@ -0,0 +1,27 @@
|
||||
package org.openrndr.extra.fx.dither
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.draw.Shader
|
||||
import org.openrndr.extra.fx.filterFragmentCode
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
|
||||
@Description("CMYK Halftone")
|
||||
class CMYKHalftone: Filter(Shader.createFromCode(filterVertexCode, filterFragmentCode("dither/cmyk-halftone.frag"))) {
|
||||
|
||||
@DoubleParameter("scale", 1.0, 30.0, precision = 4)
|
||||
var scale: Double by parameters
|
||||
|
||||
@DoubleParameter("dotSize", 1.0, 3.0, precision = 4)
|
||||
var dotSize: Double by parameters
|
||||
|
||||
|
||||
@DoubleParameter("rotation", -180.0, 180.0)
|
||||
var rotation: Double by parameters
|
||||
|
||||
init {
|
||||
scale = 3.0
|
||||
rotation = 0.0
|
||||
dotSize = 1.0
|
||||
}
|
||||
}
|
||||
32
orx-fx/src/main/kotlin/edges/LumaSobel.kt
Normal file
32
orx-fx/src/main/kotlin/edges/LumaSobel.kt
Normal file
@@ -0,0 +1,32 @@
|
||||
package org.openrndr.extra.fx.edges
|
||||
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.draw.Shader
|
||||
import org.openrndr.extra.fx.filterFragmentCode
|
||||
import org.openrndr.extra.parameters.ColorParameter
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
|
||||
@Description("Luma threshold ")
|
||||
class LumaSobel : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("edges/luma-sobel.frag"))) {
|
||||
|
||||
@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
|
||||
}
|
||||
}
|
||||
71
orx-fx/src/main/kotlin/shadow/DropShadow.kt
Normal file
71
orx-fx/src/main/kotlin/shadow/DropShadow.kt
Normal file
@@ -0,0 +1,71 @@
|
||||
package org.openrndr.extra.fx.shadow
|
||||
|
||||
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.filterFragmentCode
|
||||
import org.openrndr.extra.parameters.ColorParameter
|
||||
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.resourceUrl
|
||||
|
||||
private class Blend: Filter(Shader.createFromCode(filterVertexCode, filterFragmentCode("shadow/dropshadow-blend.frag"))) {
|
||||
var shift: Vector2 by parameters
|
||||
}
|
||||
|
||||
@Description("Drop shadow")
|
||||
class DropShadow : Filter(Shader.createFromCode(filterVertexCode, filterFragmentCode("shadow/dropshadow-blur.frag"))) {
|
||||
|
||||
@IntParameter("blur window", 1, 25)
|
||||
var window: Int by parameters
|
||||
var spread: Double by parameters
|
||||
@DoubleParameter("gain", 0.0, 4.0)
|
||||
var gain: Double by parameters
|
||||
|
||||
var shift: Vector2 = Vector2.ZERO
|
||||
@ColorParameter("color")
|
||||
var color: ColorRGBa by parameters
|
||||
|
||||
private var intermediate: ColorBuffer? = null
|
||||
private var intermediate2: ColorBuffer? = null
|
||||
private var b = Blend()
|
||||
|
||||
init {
|
||||
color = ColorRGBa.BLACK
|
||||
window = 5
|
||||
spread = 1.0
|
||||
gain = 1.0
|
||||
}
|
||||
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
intermediate?.let {
|
||||
if (it.width != target[0].width || it.height != target[0].height) {
|
||||
intermediate = null
|
||||
}
|
||||
}
|
||||
intermediate2?.let {
|
||||
if (it.width != target[0].width || it.height != target[0].height) {
|
||||
intermediate2 = null
|
||||
}
|
||||
}
|
||||
if (intermediate == null) {
|
||||
intermediate = colorBuffer(target[0].width, target[0].height, target[0].contentScale, target[0].format, target[0].type)
|
||||
}
|
||||
if (intermediate2 == null) {
|
||||
intermediate2 = colorBuffer(target[0].width, target[0].height, target[0].contentScale, target[0].format, target[0].type)
|
||||
}
|
||||
|
||||
intermediate?.let {
|
||||
parameters["blurDirection"] = Vector2(1.0, 0.0)
|
||||
super.apply(source, arrayOf(it))
|
||||
|
||||
parameters["blurDirection"] = Vector2(0.0, 1.0)
|
||||
super.apply(arrayOf(it), arrayOf(intermediate2!!))
|
||||
|
||||
b.shift = shift / Vector2(target[0].width * 1.0, target[0].height * 1.0)
|
||||
b.apply(arrayOf(intermediate2!!, source[0]), target)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user