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