[orx-marching-squares] Add demo texts.
This commit is contained in:
@@ -3,6 +3,22 @@ import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.marchingsquares.findContours
|
||||
import org.openrndr.math.Vector2
|
||||
|
||||
/**
|
||||
* A simple demonstration of using the `findContours` method provided by `orx-marching-squares`.
|
||||
*
|
||||
* `findContours` lets one generate contours by providing a mathematical function to be
|
||||
* sampled within the provided area and with the given cell size. Contours are generated
|
||||
* between the areas in which the function returns positive and negative values.
|
||||
*
|
||||
* In this example, the `f` function returns the distance of a point to the center of the window minus 200.0.
|
||||
* Therefore, sampled locations which are less than 200 pixels away from the center return
|
||||
* negative values and all others return positive values, effectively generating a circle of radius 200.0.
|
||||
*
|
||||
* Try increasing the cell size to see how the precision of the circle reduces.
|
||||
*
|
||||
* The circular contour created in this program has over 90 segments. The number of segments depends on the cell
|
||||
* size, and the resulting radius.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
|
||||
@@ -5,6 +5,16 @@ import org.openrndr.math.Vector2
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.cos
|
||||
|
||||
/**
|
||||
* This Marching Square demonstration shows the effect of wrapping a distance function
|
||||
* within a cosine (or sine). These mathematical functions return values that periodically
|
||||
* alternate between negative and positive, creating nested contours as the distance increases.
|
||||
*
|
||||
* The `/ 100.0) * 2 * PI` part of the formula is only a scaling factor, more or less
|
||||
* equivalent to 0.06. Increasing or decreasing this value will change how close the generated
|
||||
* parallel curves are to each other.
|
||||
*
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
|
||||
@@ -6,6 +6,13 @@ import kotlin.math.PI
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.sin
|
||||
|
||||
/**
|
||||
* Demonstrates how Marching Squares can be used to generate animations, by using a time-related
|
||||
* variable like `seconds`. The evaluated function is somewhat more complex than previous ones,
|
||||
* but one can arrive to such functions by exploration and experimentation, nesting trigonometrical
|
||||
* functions and making use of `seconds`, v.x and v.y.
|
||||
*
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
|
||||
@@ -7,6 +7,18 @@ import org.openrndr.math.Vector2
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.cos
|
||||
|
||||
/**
|
||||
* Demonstrates using Marching Squares while reading the pixel colors of a loaded image.
|
||||
*
|
||||
* Notice how the area defined when calling `findContours` is larger than the window.
|
||||
*
|
||||
* Using point coordinates from such an area to read from image pixels might cause problems when points are
|
||||
* outside the image bounds, therefore the `f` function checks whether the requested `v` is within bounds,
|
||||
* and only reads from the image when it is.
|
||||
*
|
||||
* The `seconds` built-in variable is used to generate an animated effect, serving as a shifting cut-off point
|
||||
* that specifies at which brightness level to create curves.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
|
||||
Reference in New Issue
Block a user