Demos: ensure all use fun main() = application {
- Adjust some demo window sizes. - Replace Random.double by Double.uniform - Tweak some demos so screenshots look more interesting
This commit is contained in:
@@ -6,8 +6,6 @@ import org.openrndr.math.Vector2
|
||||
import org.openrndr.shape.Circle
|
||||
|
||||
/**
|
||||
* Entry point of the application.
|
||||
*
|
||||
* This method sets up a graphical application using the OPENRNDR framework
|
||||
* to visually demonstrate Delaunay triangulation on a set of points scattered
|
||||
* along a circle with Poisson disk sampling.
|
||||
@@ -22,30 +20,28 @@ import org.openrndr.shape.Circle
|
||||
* and triangle order.
|
||||
*
|
||||
* This method demonstrates concepts of computational geometry and procedural
|
||||
* rendering with a focus on interactive visual applications.
|
||||
* rendering.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
title = "Delaunator"
|
||||
}
|
||||
program {
|
||||
val circle = Circle(Vector2(400.0), 250.0)
|
||||
val points = circle.shape.scatter(30.0)
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
title = "Delaunator"
|
||||
}
|
||||
program {
|
||||
val circle = Circle(Vector2(400.0), 250.0)
|
||||
val points = circle.shape.scatter(30.0)
|
||||
|
||||
val delaunay = (points + circle.contour.equidistantPositions(40)).delaunayTriangulation()
|
||||
val triangles = delaunay.triangles().map { it.contour }
|
||||
val delaunay = (points + circle.contour.equidistantPositions(40)).delaunayTriangulation()
|
||||
val triangles = delaunay.triangles().map { it.contour }
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
for ((i, triangle) in triangles.withIndex()) {
|
||||
drawer.fill = ColorRGBa.PINK.shade(1.0 - i / (triangles.size * 1.2))
|
||||
drawer.stroke = ColorRGBa.PINK.shade(i / (triangles.size * 1.0) + 0.1)
|
||||
drawer.contour(triangle)
|
||||
}
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
for ((i, triangle) in triangles.withIndex()) {
|
||||
drawer.fill = ColorRGBa.PINK.shade(1.0 - i / (triangles.size * 1.2))
|
||||
drawer.stroke = ColorRGBa.PINK.shade(i / (triangles.size * 1.0) + 0.1)
|
||||
drawer.contour(triangle)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,33 +2,29 @@ import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.noise.scatter
|
||||
import org.openrndr.extra.triangulation.delaunayTriangulation
|
||||
import org.openrndr.math.Vector2
|
||||
import org.openrndr.shape.Rectangle
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
val frame = Rectangle.fromCenter(Vector2(400.0), 600.0, 600.0)
|
||||
val points = frame.scatter(50.0)
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val frame = drawer.bounds.offsetEdges(-50.0)
|
||||
val points = frame.scatter(50.0)
|
||||
|
||||
val delaunay = points.delaunayTriangulation()
|
||||
val halfedges = delaunay.halfedges()
|
||||
//val hull = delaunay.hull()
|
||||
val delaunay = points.delaunayTriangulation()
|
||||
val halfedges = delaunay.halfedges()
|
||||
//val hull = delaunay.hull()
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
|
||||
drawer.fill = null
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
drawer.contours(halfedges)
|
||||
drawer.fill = null
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
drawer.contours(halfedges)
|
||||
|
||||
//drawer.stroke = ColorRGBa.GREEN
|
||||
//drawer.contour(hull)
|
||||
}
|
||||
//drawer.stroke = ColorRGBa.GREEN
|
||||
//drawer.contour(hull)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,30 +17,28 @@ import org.openrndr.shape.Rectangle
|
||||
* - Extracts the cell polygons of the Voronoi diagram.
|
||||
* - Renders the Voronoi cell polygons on the canvas, with a pink stroke on a black background.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
}
|
||||
program {
|
||||
val circle = Circle(Vector2(400.0), 250.0)
|
||||
val frame = Rectangle.fromCenter(Vector2(400.0), 600.0, 600.0)
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val circle = Circle(Vector2(400.0), 250.0)
|
||||
val frame = drawer.bounds.offsetEdges(-50.0)
|
||||
|
||||
val points = poissonDiskSampling(drawer.bounds, 30.0)
|
||||
.filter { circle.contains(it) }
|
||||
val points = poissonDiskSampling(drawer.bounds, 30.0)
|
||||
.filter { circle.contains(it) }
|
||||
|
||||
val delaunay = (points + circle.contour.equidistantPositions(40)).delaunayTriangulation()
|
||||
val voronoi = delaunay.voronoiDiagram(frame)
|
||||
val delaunay = (points + circle.contour.equidistantPositions(40)).delaunayTriangulation()
|
||||
val voronoi = delaunay.voronoiDiagram(frame)
|
||||
|
||||
val cells = voronoi.cellPolygons()
|
||||
val cells = voronoi.cellPolygons()
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.fill = null
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
drawer.contours(cells)
|
||||
}
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.fill = null
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
drawer.contours(cells)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,30 +4,28 @@ import org.openrndr.extra.shapes.primitives.grid
|
||||
import org.openrndr.extra.triangulation.delaunayTriangulation
|
||||
import org.openrndr.shape.Circle
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
val r = drawer.bounds.offsetEdges(-50.0)
|
||||
val grid = r.grid(8, 8).flatten()
|
||||
val circles = grid.map { Circle(it.center, it.width / 4.0) }
|
||||
val points = circles.flatMap { it.contour.equidistantPositions(6) }
|
||||
drawer.circles(points, 5.0)
|
||||
val d = points.delaunayTriangulation()
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
drawer.contours(d.halfedges())
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
val r = drawer.bounds.offsetEdges(-50.0)
|
||||
val grid = r.grid(8, 8).flatten()
|
||||
val circles = grid.map { Circle(it.center, it.width / 4.0) }
|
||||
val points = circles.flatMap { it.contour.equidistantPositions(6) }
|
||||
drawer.circles(points, 5.0)
|
||||
val d = points.delaunayTriangulation()
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
drawer.contours(d.halfedges())
|
||||
|
||||
drawer.stroke = ColorRGBa.YELLOW
|
||||
drawer.fill = null
|
||||
drawer.contours(d.voronoiDiagram(drawer.bounds.offsetEdges(-50.0)).cellPolygons())
|
||||
drawer.stroke = ColorRGBa.YELLOW
|
||||
drawer.fill = null
|
||||
drawer.contours(d.voronoiDiagram(drawer.bounds.offsetEdges(-50.0)).cellPolygons())
|
||||
|
||||
drawer.stroke = ColorRGBa.GRAY
|
||||
drawer.contours(d.triangles().map { it.contour })
|
||||
}
|
||||
drawer.stroke = ColorRGBa.GRAY
|
||||
drawer.contours(d.triangles().map { it.contour })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,35 +7,35 @@ import org.openrndr.math.Vector3
|
||||
import org.openrndr.math.transforms.buildTransform
|
||||
import org.openrndr.shape.Circle
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 750
|
||||
height = 1000
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
val r = drawer.bounds.offsetEdges(-100.0)
|
||||
val grid = r.grid(3,6).flatten()
|
||||
val circles = grid.map { Circle(Vector2.ZERO, 158.975).contour.transform(
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 1000
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
val r = drawer.bounds.offsetEdges(-100.0)
|
||||
val grid = r.grid(3, 6).flatten()
|
||||
val circles = grid.map {
|
||||
Circle(Vector2.ZERO, 158.975).contour.transform(
|
||||
buildTransform {
|
||||
translate(it.center)
|
||||
rotate(Vector3.UNIT_Z, 0.0)
|
||||
}
|
||||
) }
|
||||
val points = circles.flatMap { it.contour.equidistantPositions(16) }
|
||||
drawer.circles(points, 5.0)
|
||||
val d = points.delaunayTriangulation()
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
drawer.contours(d.halfedges())
|
||||
|
||||
drawer.stroke = ColorRGBa.YELLOW
|
||||
drawer.fill = ColorRGBa.GRAY.opacify(0.5)
|
||||
drawer.contours(d.voronoiDiagram(drawer.bounds).cellPolygons())
|
||||
|
||||
drawer.stroke = ColorRGBa.GRAY
|
||||
drawer.contours(d.triangles().map { it.contour })
|
||||
)
|
||||
}
|
||||
val points = circles.flatMap { it.contour.equidistantPositions(16) }
|
||||
drawer.circles(points, 5.0)
|
||||
val d = points.delaunayTriangulation()
|
||||
drawer.stroke = ColorRGBa.PINK
|
||||
drawer.contours(d.halfedges())
|
||||
|
||||
drawer.stroke = ColorRGBa.YELLOW
|
||||
drawer.fill = ColorRGBa.GRAY.opacify(0.5)
|
||||
drawer.contours(d.voronoiDiagram(drawer.bounds).cellPolygons())
|
||||
|
||||
drawer.stroke = ColorRGBa.GRAY
|
||||
drawer.contours(d.triangles().map { it.contour })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user