[orx-jumpflood] fix readme examples (use filter) (#320)

This commit is contained in:
Abe Pazos
2023-06-24 05:55:25 +00:00
committed by GitHub
parent 9412e41c3d
commit 7a4f0b163b

View File

@@ -16,10 +16,10 @@ the distance in red and the original bitmap in green.
```kotlin ```kotlin
import org.openrndr.application import org.openrndr.application
import org.openrndr.draw.* import org.openrndr.draw.*
import org.openrndr.extra.fx.blur.ApproximateGaussianBlur
import org.openrndr.extra.jumpfill.DistanceField
import org.openrndr.extra.jumpfill.Threshold import org.openrndr.extra.jumpfill.Threshold
import org.openrndr.extra.jumpfill.distanceFieldFromBitmap
import org.openrndr.ffmpeg.VideoPlayerFFMPEG import org.openrndr.ffmpeg.VideoPlayerFFMPEG
import org.openrndr.filter.blur.ApproximateGaussianBlur
fun main() = application { fun main() = application {
configure { configure {
@@ -34,7 +34,8 @@ fun main() = application {
val thresholdFilter = Threshold() val thresholdFilter = Threshold()
val thresholded = colorBuffer(width, height) val thresholded = colorBuffer(width, height)
val distanceField = colorBuffer(width, height, type = ColorType.FLOAT32) val distanceField = DistanceField()
val distanceFieldBuffer = colorBuffer(width, height, type = ColorType.FLOAT32)
val videoCopy = renderTarget(width, height) { val videoCopy = renderTarget(width, height) {
colorBuffer() colorBuffer()
@@ -58,7 +59,7 @@ fun main() = application {
thresholdFilter.threshold = 0.5 thresholdFilter.threshold = 0.5
thresholdFilter.apply(blurred, thresholded) thresholdFilter.apply(blurred, thresholded)
distanceFieldFromBitmap(thresholded, result = distanceField) distanceField.apply(thresholded, distanceFieldBuffer)
drawer.isolated { drawer.isolated {
// -- use a shadestyle to visualize the distance field // -- use a shadestyle to visualize the distance field
@@ -72,7 +73,7 @@ fun main() = application {
} }
""" """
} }
drawer.image(distanceField) drawer.image(distanceFieldBuffer)
} }
} }
} }
@@ -88,10 +89,10 @@ x-direction in red, y-direction in green, and the original bitmap in blue.
```kotlin ```kotlin
import org.openrndr.application import org.openrndr.application
import org.openrndr.draw.* import org.openrndr.draw.*
import org.openrndr.extra.fx.blur.ApproximateGaussianBlur
import org.openrndr.extra.jumpfill.DirectionalField
import org.openrndr.extra.jumpfill.Threshold import org.openrndr.extra.jumpfill.Threshold
import org.openrndr.extra.jumpfill.directionFieldFromBitmap
import org.openrndr.ffmpeg.VideoPlayerFFMPEG import org.openrndr.ffmpeg.VideoPlayerFFMPEG
import org.openrndr.filter.blur.ApproximateGaussianBlur
fun main() = application { fun main() = application {
configure { configure {
@@ -106,7 +107,8 @@ fun main() = application {
val thresholdFilter = Threshold() val thresholdFilter = Threshold()
val thresholded = colorBuffer(width, height) val thresholded = colorBuffer(width, height)
val directionField = colorBuffer(width, height, type = ColorType.FLOAT32) val directionField = DirectionalField()
val directionalFieldBuffer = colorBuffer(width, height, type = ColorType.FLOAT32)
val videoPlayer = VideoPlayerFFMPEG.fromDevice(imageWidth = width, imageHeight = height) val videoPlayer = VideoPlayerFFMPEG.fromDevice(imageWidth = width, imageHeight = height)
videoPlayer.play() videoPlayer.play()
@@ -131,7 +133,7 @@ fun main() = application {
thresholdFilter.threshold = 0.5 thresholdFilter.threshold = 0.5
thresholdFilter.apply(blurred, thresholded) thresholdFilter.apply(blurred, thresholded)
directionFieldFromBitmap(thresholded, result = directionField) directionField.apply(thresholded, directionalFieldBuffer)
drawer.isolated { drawer.isolated {
// -- use a shadestyle to visualize the direction field // -- use a shadestyle to visualize the direction field
@@ -145,7 +147,7 @@ fun main() = application {
} }
""" """
} }
drawer.image(directionField) drawer.image(directionalFieldBuffer)
} }
} }
} }