[orx-shapes] Add alpha shapes (#203)

This commit is contained in:
Steven van den Broek
2021-10-24 20:41:40 +02:00
committed by GitHub
parent af524b8e42
commit ee3a3603c0
7 changed files with 186 additions and 2 deletions

View File

@@ -0,0 +1,24 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extra.shapes.AlphaShape
import org.openrndr.math.Vector2
import kotlin.random.Random
fun main() = application {
program {
val points = List(20) {
Vector2(
Random.nextDouble(width*0.25, width*0.75),
Random.nextDouble(height*0.25, height*0.75)
)
}
val alphaShape = AlphaShape(points)
val c = alphaShape.create()
extend {
drawer.fill = ColorRGBa.PINK
drawer.contour(c)
drawer.fill = ColorRGBa.WHITE
drawer.circles(points, 4.0)
}
}
}

View File

@@ -2,9 +2,9 @@ import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.loadFont
import org.openrndr.extensions.SingleScreenshot
import org.openrndr.extra.color.spaces.toOKLABa
import org.openrndr.extra.shapes.bezierPatch
import org.openrndr.extra.shapes.drawers.bezierPatch
import org.openrndr.extras.color.spaces.toOKLABa
import org.openrndr.shape.Circle
fun main() {

View File

@@ -6,7 +6,7 @@ import org.openrndr.extensions.SingleScreenshot
import org.openrndr.extra.shapes.bezierPatch
import org.openrndr.extra.shapes.drawers.bezierPatch
import org.openrndr.extra.shapes.grid
import org.openrndr.extras.color.spaces.toOKLABa
import org.openrndr.extra.color.spaces.toOKLABa
import org.openrndr.math.Vector2
import org.openrndr.math.Vector3
import org.openrndr.math.min

View File

@@ -10,6 +10,8 @@ fun main() = application {
drawer.stroke = ColorRGBa.BLACK
drawer.fill = ColorRGBa.PINK
drawer.contour(hobbyCurve(points, closed=true))
drawer.fill = ColorRGBa.WHITE
drawer.circles(points, 4.0)
}
}
}

View File

@@ -0,0 +1,26 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extra.shapes.AlphaShape
import org.openrndr.extra.shapes.hobbyCurve
import org.openrndr.math.Vector2
import kotlin.random.Random
fun main() = application {
program {
val points = List(20) {
Vector2(
Random.nextDouble(width*0.25, width*0.75),
Random.nextDouble(height*0.25, height*0.75)
)
}
val alphaShape = AlphaShape(points)
val c = alphaShape.create()
val hobby = hobbyCurve(c.segments.map { it.start }, closed=true)
extend {
drawer.fill = ColorRGBa.PINK
drawer.contour(hobby)
drawer.fill = ColorRGBa.WHITE
drawer.circles(points, 4.0)
}
}
}