Demos: ensure 720px wide, reduce indentation
This commit is contained in:
@@ -11,15 +11,14 @@ import org.openrndr.shape.LineSegment
|
||||
* cursor are highlighted with circles and lines connecting them to the cursor.
|
||||
*
|
||||
* Key features:
|
||||
* - Generates 1000 random 2D points within the canvas dimensions (1080x720).
|
||||
* - Generates 1000 random 2D points within the canvas.
|
||||
* - Builds a KD-tree from the list of points for optimized spatial querying.
|
||||
* - Visualizes the points and highlights the 7 nearest neighbors to the user's cursor position dynamically.
|
||||
* - Highlights include red-colored circles around the nearest points and red lines connecting them to the cursor.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 1080
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
|
||||
@@ -40,5 +39,4 @@ fun main() {
|
||||
drawer.lineSegments(kNearest.map { LineSegment(mouse.position, it) })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@ import org.openrndr.extra.kdtree.kdTree
|
||||
import org.openrndr.math.Vector2
|
||||
|
||||
/**
|
||||
* Initializes an interactive graphical application that displays 1000 randomly distributed 2D points
|
||||
* on a canvas of dimensions 1280x720. The points are organized into a KD-tree for efficient spatial querying.
|
||||
* Initializes an interactive graphical application that displays 1000 randomly distributed 2D points.
|
||||
* The points are organized into a KD-tree for efficient spatial querying.
|
||||
*
|
||||
* Key functionality:
|
||||
* - Displays the points as small circles on the canvas.
|
||||
@@ -14,10 +14,9 @@ import org.openrndr.math.Vector2
|
||||
* - KD-tree structure enables efficient nearest-neighbor searches.
|
||||
* - The nearest point to the cursor is determined and visually emphasized in real-time as the cursor moves.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 1280
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
@@ -33,5 +32,4 @@ fun main() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,17 +11,15 @@ import org.openrndr.math.Vector2
|
||||
* user's cursor position.
|
||||
*
|
||||
* Key features:
|
||||
* - Generates and displays 1000 random 2D points within canvas dimensions of 1080x720.
|
||||
* - Generates and displays 1000 random 2D points within the canvas.
|
||||
* - Builds a KD-tree structure for optimized querying of spatial data.
|
||||
* - Dynamically highlights points within a specified radius (50.0) from the cursor position.
|
||||
* - Visualizes the current query radius around the cursor as an outline circle.
|
||||
* - Uses different fill and stroke styles to distinguish highlighted points and query visuals.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 1080
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
|
||||
@@ -46,5 +44,4 @@ fun main() {
|
||||
drawer.circle(mouse.position, radius)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,7 @@ import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.marchingsquares.findContours
|
||||
import org.openrndr.math.Vector2
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
@@ -19,5 +18,4 @@ fun main() {
|
||||
drawer.contours(contours)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,7 @@ import org.openrndr.math.Vector2
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.cos
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
@@ -21,5 +20,4 @@ fun main() {
|
||||
drawer.contours(contours)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,7 @@ import kotlin.math.PI
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.sin
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
@@ -21,9 +20,9 @@ fun main() {
|
||||
val p = v + Vector2(cos(v.y * 0.1 + seconds) * 40.0, sin(v.x * 0.1 + seconds) * 40.0)
|
||||
return cos((p.distanceTo(drawer.bounds.center) / 720.0) * 12 * PI)
|
||||
}
|
||||
|
||||
val contours = findContours(::f, drawer.bounds.offsetEdges(-2.0), 4.0)
|
||||
drawer.contours(contours)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,11 +7,10 @@ import org.openrndr.math.Vector2
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.cos
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 640
|
||||
height = 480
|
||||
width = 720
|
||||
height = 540
|
||||
}
|
||||
program {
|
||||
val image = loadImage("demo-data/images/image-001.png")
|
||||
@@ -22,15 +21,16 @@ fun main() {
|
||||
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
|
||||
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 contours = findContours(::f, drawer.bounds.offsetEdges(32.0), 4.0)
|
||||
drawer.drawStyle.colorMatrix = grayscale()
|
||||
drawer.scale(width.toDouble() / image.width, height.toDouble() / image.height)
|
||||
drawer.image(image)
|
||||
drawer.contours(contours)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,10 @@ import org.openrndr.math.Vector2
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.shape.Rectangle
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
program {
|
||||
@@ -65,5 +66,4 @@ fun main() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,10 @@ import org.openrndr.extra.camera.Orbital
|
||||
import org.openrndr.extra.meshgenerators.boxMesh
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
program {
|
||||
@@ -21,7 +22,7 @@ fun main() {
|
||||
val s = texture.shadow
|
||||
for (y in 0 until 256) {
|
||||
for (x in 0 until 256) {
|
||||
s[x, y] = ColorRGBa(x/256.0, y/256.0, 0.0, 1.0)
|
||||
s[x, y] = ColorRGBa(x / 256.0, y / 256.0, 0.0, 1.0)
|
||||
}
|
||||
}
|
||||
s.upload()
|
||||
@@ -41,5 +42,4 @@ fun main() {
|
||||
drawer.vertexBuffer(box, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,10 @@ import org.openrndr.extra.meshgenerators.buildTriangleMesh
|
||||
import org.openrndr.extra.meshgenerators.sphere
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
width = 720
|
||||
height = 720
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
program {
|
||||
@@ -42,5 +41,4 @@ fun main() {
|
||||
drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,10 @@ import org.openrndr.extra.meshgenerators.cylinder
|
||||
import org.openrndr.extra.meshgenerators.hemisphere
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
width = 720
|
||||
height = 720
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
program {
|
||||
@@ -63,5 +62,4 @@ fun main() {
|
||||
drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,11 +6,10 @@ import org.openrndr.extra.camera.Orbital
|
||||
import org.openrndr.extra.meshgenerators.*
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
width = 720
|
||||
height = 720
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
program {
|
||||
@@ -31,19 +30,23 @@ fun main() {
|
||||
|
||||
for (r in 0 until ridges) {
|
||||
isolated {
|
||||
translate(0.0,
|
||||
ridgeLength/4.0 + r * ridgeLength + 6.0,
|
||||
0.0)
|
||||
translate(
|
||||
0.0,
|
||||
ridgeLength / 4.0 + r * ridgeLength + 6.0,
|
||||
0.0
|
||||
)
|
||||
rotate(Vector3.UNIT_X, 270.0)
|
||||
taperedCylinder(32, 1, 5.0, ridgeRadius, ridgeLength/ 2.0, center = true)
|
||||
taperedCylinder(32, 1, 5.0, ridgeRadius, ridgeLength / 2.0, center = true)
|
||||
}
|
||||
|
||||
isolated {
|
||||
translate(0.0,
|
||||
ridgeLength/4.0 + ridgeLength/2.0 + r * ridgeLength + 6.0,
|
||||
0.0)
|
||||
translate(
|
||||
0.0,
|
||||
ridgeLength / 4.0 + ridgeLength / 2.0 + r * ridgeLength + 6.0,
|
||||
0.0
|
||||
)
|
||||
rotate(Vector3.UNIT_X, 270.0)
|
||||
taperedCylinder(32, 1, ridgeRadius, 5.0, ridgeLength/2.0, center = true)
|
||||
taperedCylinder(32, 1, ridgeRadius, 5.0, ridgeLength / 2.0, center = true)
|
||||
}
|
||||
}
|
||||
isolated {
|
||||
@@ -62,7 +65,7 @@ fun main() {
|
||||
rotate(Vector3.UNIT_Y, dphi * i)
|
||||
translate(baseRadius, 0.0, 0.0)
|
||||
rotate(Vector3.UNIT_Z, -15.0)
|
||||
translate(0.0, legLength/2.0, 0.0)
|
||||
translate(0.0, legLength / 2.0, 0.0)
|
||||
rotate(Vector3.UNIT_X, 90.0)
|
||||
cylinder(32, 1, legRadius, legLength, center = true)
|
||||
}
|
||||
@@ -79,5 +82,4 @@ fun main() {
|
||||
drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,11 +7,10 @@ import org.openrndr.extra.meshgenerators.*
|
||||
import org.openrndr.math.Vector2
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
width = 720
|
||||
height = 720
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
program {
|
||||
@@ -23,12 +22,14 @@ fun main() {
|
||||
val sides = 12
|
||||
isolated {
|
||||
translate(0.0, 12.0, 0.0)
|
||||
cap(sides, 5.0, listOf(
|
||||
cap(
|
||||
sides, 5.0, listOf(
|
||||
Vector2(0.0, 1.0),
|
||||
Vector2(0.5, 1.0),
|
||||
Vector2(0.5, 0.5),
|
||||
Vector2(0.9, 0.5),
|
||||
Vector2(1.0, 0.0))
|
||||
Vector2(1.0, 0.0)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -100,5 +101,4 @@ fun main() {
|
||||
drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,11 +11,10 @@ import org.openrndr.extra.meshgenerators.twist
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.shape.Circle
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
width = 720
|
||||
height = 720
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
program {
|
||||
@@ -44,5 +43,4 @@ fun main() {
|
||||
drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,11 +13,10 @@ import org.openrndr.math.Vector3
|
||||
* Interactive orbital camera.
|
||||
*
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
width = 720
|
||||
height = 720
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
program {
|
||||
@@ -37,7 +36,7 @@ fun main() {
|
||||
x * 0.16 + y * 0.17
|
||||
)
|
||||
// Drop some boxes
|
||||
if(simplex(0, pos1 * 0.5 + pos0 * 0.05) > 0) {
|
||||
if (simplex(0, pos1 * 0.5 + pos0 * 0.05) > 0) {
|
||||
translate(pos2)
|
||||
color = rgb(x, y, z)
|
||||
box(1.2, 1.2, 1.2)
|
||||
@@ -58,5 +57,4 @@ fun main() {
|
||||
drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,11 +11,10 @@ import org.openrndr.extra.shapes.splines.toPath3D
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.shape.Circle
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
width = 720
|
||||
height = 720
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
program {
|
||||
@@ -63,5 +62,4 @@ fun main() {
|
||||
drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,10 @@ import org.openrndr.math.Vector3
|
||||
import org.openrndr.shape.Circle
|
||||
import org.openrndr.shape.Shape
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
width = 720
|
||||
height = 720
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
program {
|
||||
@@ -47,8 +46,6 @@ fun main() {
|
||||
)
|
||||
translate(2.0, 0.0, 0.0)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
extend(Orbital()) {
|
||||
@@ -67,5 +64,4 @@ fun main() {
|
||||
drawer.vertexBuffer(m, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,15 +15,14 @@ import org.openrndr.shape.Path3D
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.exp
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
width = 720
|
||||
height = 720
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
program {
|
||||
fun spiralPath(a: Double, k: Double, cycles: Double, steps: Int, direction:Double = 1.0): Path3D {
|
||||
fun spiralPath(a: Double, k: Double, cycles: Double, steps: Int, direction: Double = 1.0): Path3D {
|
||||
val points = (0 until steps).map {
|
||||
|
||||
val theta = ((PI * 2.0 * cycles) / steps) * it
|
||||
@@ -73,9 +72,6 @@ fun main() {
|
||||
rotate(Vector3.UNIT_Y, 180.0 / 1.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
extend(Orbital())
|
||||
@@ -87,10 +83,8 @@ fun main() {
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
drawer.rotate(Vector3.UNIT_X, seconds*20.0)
|
||||
drawer.rotate(Vector3.UNIT_X, seconds * 20.0)
|
||||
drawer.vertexBuffer(spiral, DrawPrimitive.TRIANGLES)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,11 +16,10 @@ import org.openrndr.shape.Segment3D
|
||||
* Extruded Bézier tubes grown on a morphing Bézier surface.
|
||||
*
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
width = 720
|
||||
height = 720
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
program {
|
||||
@@ -64,7 +63,7 @@ fun main() {
|
||||
)
|
||||
), false
|
||||
)
|
||||
color = if(i % 2 == 0) ColorRGBa.PINK else ColorRGBa.WHITE.shade(0.1)
|
||||
color = if (i % 2 == 0) ColorRGBa.PINK else ColorRGBa.WHITE.shade(0.1)
|
||||
extrudeContourSteps(
|
||||
crossSection,
|
||||
path,
|
||||
@@ -82,5 +81,4 @@ fun main() {
|
||||
m.destroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,10 @@ import kotlin.math.cos
|
||||
* Extruded Bézier tubes grown on a morphing Bézier surface.
|
||||
*
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
width = 720
|
||||
height = 720
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
program {
|
||||
@@ -66,7 +65,7 @@ fun main() {
|
||||
)
|
||||
), false
|
||||
)
|
||||
color = if(i % 2 == 0) ColorRGBa.PINK else ColorRGBa.WHITE.shade(0.1)
|
||||
color = if (i % 2 == 0) ColorRGBa.PINK else ColorRGBa.WHITE.shade(0.1)
|
||||
extrudeContourStepsScaled(
|
||||
crossSection,
|
||||
path,
|
||||
@@ -85,5 +84,4 @@ fun main() {
|
||||
m.destroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,11 +22,10 @@ import kotlin.math.cos
|
||||
* based on the t value along a Path3D. In other words, a tube in which the cross-section does not need
|
||||
* to be constant, but can be scaled, rotated and displaced along its curvy axis.
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 800
|
||||
height = 800
|
||||
width = 720
|
||||
height = 720
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
program {
|
||||
@@ -89,7 +88,6 @@ fun main() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val crossSection = Circle(Vector2.ZERO, 0.1).contour.transform(
|
||||
|
||||
@@ -15,8 +15,7 @@ import java.io.File
|
||||
* Demonstrate decal generator as an object slicer
|
||||
* @see <img src="https://raw.githubusercontent.com/openrndr/orx/media/orx-mesh-generators/images/decal-DemoDecal01Kt.png">
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
@@ -52,5 +51,4 @@ fun main() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,7 @@ import kotlin.math.PI
|
||||
* Demonstrate decal generation and rendering
|
||||
* @see <img src="https://raw.githubusercontent.com/openrndr/orx/media/orx-mesh-generators/images/decal-DemoDecal02Kt.png">
|
||||
*/
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
@@ -83,5 +82,4 @@ fun main() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,10 @@ import org.openrndr.math.Vector3
|
||||
import java.io.File
|
||||
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val obj = loadOBJMeshData(File("demo-data/obj-models/suzanne/Suzanne.obj")).toMeshData().triangulate()
|
||||
val tangentObj = obj.estimateTangents()
|
||||
|
||||
@@ -25,7 +25,7 @@ Optionally, a static `backdrop` may be setup by providing custom code.
|
||||
- Example 1. Customising the backdrop with an image
|
||||
```kotlin
|
||||
extend(NoClear()) {
|
||||
val img = loadImage("data\\backdrop.png")
|
||||
val img = loadImage("data/backdrop.png")
|
||||
backdrop = {
|
||||
drawer.image(img, 0.0, 0.0, width * 1.0, height * 1.0)
|
||||
}
|
||||
|
||||
@@ -2,13 +2,17 @@ import org.openrndr.application
|
||||
import org.openrndr.color.ColorHSLa
|
||||
import org.openrndr.color.rgb
|
||||
import org.openrndr.draw.isolated
|
||||
import org.openrndr.extensions.SingleScreenshot
|
||||
import org.openrndr.extra.noclear.NoClear
|
||||
import org.openrndr.math.Polar
|
||||
import org.openrndr.shape.contour
|
||||
import kotlin.math.sin
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 540
|
||||
}
|
||||
program {
|
||||
var time = 0.0
|
||||
|
||||
@@ -19,12 +23,17 @@ fun main() {
|
||||
// That's the default in some other frameworks.
|
||||
// ------------------------------------------------------------
|
||||
extend(NoClear()) {
|
||||
// backdrop is optional and it sets the initial state
|
||||
// of the canvas. It can be a generative pattern, an image
|
||||
// loaded from disk... In this case we start with dark gray.
|
||||
// backdrop is optional, and it sets the initial state
|
||||
// of the canvas. It can be code generated or an image
|
||||
// loaded from disk. In this case we start with dark gray.
|
||||
backdrop = { drawer.clear(rgb(0.15)) }
|
||||
}
|
||||
|
||||
if (System.getProperty("takeScreenshot") == "true") {
|
||||
extensions.filterIsInstance<SingleScreenshot>().forEach {
|
||||
it.delayFrames = 60
|
||||
}
|
||||
}
|
||||
extend {
|
||||
// Draw something. For this demo *what* you draw is not so
|
||||
// important, only the fact that it stays on the canvas
|
||||
@@ -34,17 +43,19 @@ fun main() {
|
||||
// center the origin
|
||||
translate(bounds.center)
|
||||
|
||||
for(i in 0..5) {
|
||||
for (i in 0..5) {
|
||||
time += 0.01
|
||||
|
||||
// Make a list of 4 points rotating around the center at
|
||||
// different speeds
|
||||
val points = List(4) {
|
||||
Polar(time * (15.0 + it * 5),
|
||||
250.0 * sin(time + it * 65)).cartesian
|
||||
Polar(
|
||||
time * (15.0 + it * 5),
|
||||
250.0 * sin(time + it * 65)
|
||||
).cartesian
|
||||
}
|
||||
|
||||
// Use those 4 points to create a bezier curve
|
||||
// Use those 4 points to create a Bézier curve
|
||||
val c = contour {
|
||||
moveTo(points.first())
|
||||
curveTo(points[1], points[2], points.last())
|
||||
@@ -52,12 +63,13 @@ fun main() {
|
||||
|
||||
// Draw the curve with increasing hue and lightness modulation
|
||||
fill = null
|
||||
stroke = ColorHSLa(time * 10.0, 0.8,
|
||||
0.5 + 0.2 * sin(time * 3), 0.5).toRGBa()
|
||||
stroke = ColorHSLa(
|
||||
time * 10.0, 0.8,
|
||||
0.5 + 0.2 * sin(time * 3), 0.5
|
||||
).toRGBa()
|
||||
contour(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,32 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.draw.loadFont
|
||||
import org.openrndr.extra.objloader.loadOBJMeshData
|
||||
import org.openrndr.extra.objloader.toObj
|
||||
import org.openrndr.math.Vector2
|
||||
import java.io.File
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val path = "demo-data/obj-models"
|
||||
val cm = loadOBJMeshData(File("$path/suzanne/Suzanne.obj"))
|
||||
|
||||
println(cm.toObj())
|
||||
// Convert mesh data to Wavefront OBJ String representation
|
||||
val obj = cm.toObj()
|
||||
|
||||
println(obj)
|
||||
|
||||
val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 24.0)
|
||||
|
||||
extend {
|
||||
// Draw part of the OBJ data as text
|
||||
drawer.fontMap = font
|
||||
drawer.texts(obj.split("\n").take(50), List(50) {
|
||||
Vector2(10.0, 20.0 + it * 20.0)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,10 @@ import org.openrndr.extra.objloader.loadOBJasVertexBuffer
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 540
|
||||
}
|
||||
program {
|
||||
val mesh = loadOBJasVertexBuffer("demo-data/obj-models/suzanne/Suzanne.obj")
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.openrndr.extra.objloader.saveOBJ
|
||||
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 100
|
||||
}
|
||||
program {
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.openrndr.extra.objloader.saveOBJ
|
||||
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 100
|
||||
}
|
||||
program {
|
||||
|
||||
@@ -16,8 +16,7 @@ import org.openrndr.shape.Path3D
|
||||
import java.io.File
|
||||
import kotlin.math.cos
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
@@ -59,5 +58,4 @@ fun main() {
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user