[orx-marching-squares] Change findContours to return List<ShapeContour>

This commit is contained in:
Edwin Jakobs
2023-02-02 22:03:51 +01:00
parent 9019e7e7ea
commit 5e6123c958
5 changed files with 65 additions and 18 deletions

View File

@@ -6,7 +6,6 @@ import org.openrndr.extra.marchingsquares.findContours
import org.openrndr.math.Vector2
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin
fun main() {
application {
@@ -20,16 +19,17 @@ fun main() {
extend {
drawer.clear(ColorRGBa.BLACK)
drawer.stroke = ColorRGBa.BLACK
drawer.fill = null
fun f(v: Vector2): Double {
val iv = v.toInt()
val d = if (iv.x >= 0 && iv.y >= 0 && iv.x < image.width && iv.y < image.height) image.shadow[iv.x, iv.y].luminance else 0.0
return cos(d * PI * 8.0 + seconds)
}
val segments = findContours(::f, drawer.bounds.offsetEdges(32.0), 4.0)
val contours = findContours(::f, drawer.bounds.offsetEdges(32.0), 4.0)
drawer.drawStyle.colorMatrix = grayscale()
drawer.image(image)
drawer.lineSegments(segments)
drawer.contours(contours)
}
}
}