[orx-poisson-fill] Add content scale support

This commit is contained in:
Edwin Jakobs
2022-11-30 21:34:28 +01:00
parent aa708ee091
commit 947f6476a7
2 changed files with 29 additions and 4 deletions

View File

@@ -0,0 +1,27 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extra.fx.Post
import org.openrndr.math.Polar
import org.openrndr.poissonfill.PoissonFill
fun main() = application {
program {
extend(Post()) {
val pf = PoissonFill()
post { input, output ->
pf.apply(input, output)
}
}
extend {
drawer.stroke = null
drawer.clear(ColorRGBa.TRANSPARENT)
drawer.fill = ColorRGBa.RED
drawer.circle(Polar(60.0 * seconds, 200.0).cartesian + drawer.bounds.center, 20.0)
drawer.fill = ColorRGBa.BLUE
drawer.circle(Polar(-60.0 * seconds, 200.0).cartesian + drawer.bounds.center, 20.0)
}
}
}

View File

@@ -42,18 +42,16 @@ class PoissonFiller(val width: Int, val height: Int, type: ColorType = ColorType
class PoissonFill : Filter() {
private var filler: PoissonFiller? = null
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
if (target.isNotEmpty()) {
filler?.let {
if (it.width != target[0].width || it.height != target[0].height) {
if (it.width != target[0].effectiveWidth || it.height != target[0].effectiveHeight) {
it.destroy()
filler = null
}
}
if (filler == null) {
filler = PoissonFiller(target[0].width, target[0].height)
filler = PoissonFiller(target[0].effectiveWidth, target[0].effectiveHeight)
}
filler?.let {