[orx-shade-styles] Write comments on demos
This commit is contained in:
@@ -15,6 +15,20 @@ import org.openrndr.math.Vector3
|
||||
import org.openrndr.shape.path3D
|
||||
import kotlin.random.Random
|
||||
|
||||
/**
|
||||
* Demonstrates how to create a 3D path and attach cylinders to it at regular intervals with the correct orientation.
|
||||
*
|
||||
* - The path is constructed using the `path3D` builder.
|
||||
* - A rectified copy is created to be able to sample it at equal-length intervals.
|
||||
* - We call the `frames` method on the rectified contour to generate a list with 100 transformation matrices which
|
||||
* make it possible to attach oriented 3D objects at specific locations in the curve.
|
||||
* - We finally use the transformation matrices to draw cylinders along the 3D path.
|
||||
*
|
||||
* The orbital camera extension enables interactive 3D view manipulation.
|
||||
*
|
||||
* A fixed random seed is used to make sure this demo outputs a specific output. We can delete the
|
||||
* `random` arguments to get a unique result each time the program runs.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
|
||||
@@ -5,13 +5,24 @@ import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.shapes.hobbycurve.hobbyCurve
|
||||
import org.openrndr.math.Vector2
|
||||
|
||||
/**
|
||||
* Demonstrates how to use the hobbyCurve function to render a smooth closed contour
|
||||
* passing through a predefined set of points.
|
||||
*/
|
||||
fun main() = application {
|
||||
program {
|
||||
extend {
|
||||
val points = listOf(Vector2(150.0, 350.0), Vector2(325.0, 100.0), Vector2(500.0, 350.0), Vector2(325.0, 250.0))
|
||||
val points = listOf(
|
||||
Vector2(150.0, 350.0),
|
||||
Vector2(325.0, 100.0),
|
||||
Vector2(500.0, 350.0),
|
||||
Vector2(325.0, 250.0)
|
||||
)
|
||||
|
||||
drawer.stroke = ColorRGBa.BLACK
|
||||
drawer.fill = ColorRGBa.PINK
|
||||
drawer.contour(hobbyCurve(points, closed=true))
|
||||
drawer.contour(hobbyCurve(points, closed = true))
|
||||
|
||||
drawer.fill = ColorRGBa.WHITE
|
||||
drawer.circles(points, 4.0)
|
||||
}
|
||||
|
||||
@@ -7,6 +7,10 @@ import org.openrndr.extra.shapes.hobbycurve.hobbyCurve
|
||||
import org.openrndr.math.Vector2
|
||||
import kotlin.random.Random
|
||||
|
||||
/**
|
||||
* This demo creates a list of random 2D points, finds the alpha shape contour for those points,
|
||||
* and finally makes that contour smooth by calling `hobbyCurve()`.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
@@ -15,16 +19,17 @@ fun main() = application {
|
||||
program {
|
||||
val points = List(40) {
|
||||
Vector2(
|
||||
Random.nextDouble(width*0.25, width*0.75),
|
||||
Random.nextDouble(height*0.25, height*0.75)
|
||||
Random.nextDouble(width * 0.25, width * 0.75),
|
||||
Random.nextDouble(height * 0.25, height * 0.75)
|
||||
)
|
||||
}
|
||||
val alphaShape = AlphaShape(points)
|
||||
val c = alphaShape.createContour()
|
||||
val hobby = hobbyCurve(c.segments.map { it.start }, closed=true)
|
||||
val hobby = c.hobbyCurve()
|
||||
extend {
|
||||
drawer.fill = ColorRGBa.PINK
|
||||
drawer.contour(hobby)
|
||||
|
||||
drawer.fill = ColorRGBa.WHITE
|
||||
drawer.circles(points, 4.0)
|
||||
}
|
||||
|
||||
@@ -2,27 +2,28 @@ package hobbycurve
|
||||
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.noise.scatter
|
||||
import org.openrndr.extra.shapes.hobbycurve.hobbyCurve
|
||||
import org.openrndr.extra.shapes.ordering.hilbertOrder
|
||||
import kotlin.random.Random
|
||||
import org.openrndr.extra.shapes.primitives.regularStar
|
||||
|
||||
/**
|
||||
* This demo shows how the [org.openrndr.shape.ShapeContour]'s method `hobbyCurve()` can be used
|
||||
* to round contours with linear segments.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val star = regularStar(5, 100.0, 300.0, drawer.bounds.center)
|
||||
val hobby = star.hobbyCurve()
|
||||
extend {
|
||||
for (i in -20..20) {
|
||||
val t = i / 10.0
|
||||
val points = drawer.bounds.offsetEdges(-50.0).scatter(25.0, random = Random(0)).hilbertOrder()
|
||||
drawer.stroke = ColorRGBa.WHITE.opacify(0.5)
|
||||
drawer.fill = null
|
||||
drawer.contour(hobbyCurve(points, closed = false, tensions = { i, inAngle, outAngle ->
|
||||
Pair(t, t)
|
||||
}))
|
||||
}
|
||||
drawer.fill = ColorRGBa.PINK
|
||||
drawer.contour(hobby)
|
||||
|
||||
drawer.fill = null
|
||||
drawer.stroke = ColorRGBa.WHITE.opacify(0.5)
|
||||
drawer.contour(star)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user