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
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,4 +40,3 @@ fun main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -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 {
|
||||||
@@ -34,4 +33,3 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,4 +45,3 @@ fun main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -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
|
||||||
@@ -20,4 +19,3 @@ fun main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -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
|
||||||
@@ -22,4 +21,3 @@ fun main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -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 {
|
||||||
@@ -66,4 +67,3 @@ 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 {
|
||||||
@@ -42,4 +43,3 @@ fun main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -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 {
|
||||||
@@ -43,4 +42,3 @@ fun main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -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 {
|
||||||
@@ -64,4 +63,3 @@ fun main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -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,17 +30,21 @@ fun main() {
|
|||||||
|
|
||||||
for (r in 0 until ridges) {
|
for (r in 0 until ridges) {
|
||||||
isolated {
|
isolated {
|
||||||
translate(0.0,
|
translate(
|
||||||
|
0.0,
|
||||||
ridgeLength / 4.0 + r * ridgeLength + 6.0,
|
ridgeLength / 4.0 + r * ridgeLength + 6.0,
|
||||||
0.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(
|
||||||
|
0.0,
|
||||||
ridgeLength / 4.0 + ridgeLength / 2.0 + r * ridgeLength + 6.0,
|
ridgeLength / 4.0 + ridgeLength / 2.0 + r * ridgeLength + 6.0,
|
||||||
0.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)
|
||||||
}
|
}
|
||||||
@@ -80,4 +83,3 @@ fun main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -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)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,4 +102,3 @@ fun main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -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 {
|
||||||
@@ -45,4 +44,3 @@ fun main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -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 {
|
||||||
@@ -59,4 +58,3 @@ fun main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -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 {
|
||||||
@@ -64,4 +63,3 @@ fun main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -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()) {
|
||||||
@@ -68,4 +65,3 @@ fun main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -15,11 +15,10 @@ 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 {
|
||||||
@@ -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())
|
||||||
@@ -89,8 +85,6 @@ fun main() {
|
|||||||
|
|
||||||
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 {
|
||||||
@@ -83,4 +82,3 @@ fun main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -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 {
|
||||||
@@ -86,4 +85,3 @@ fun main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -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 {
|
||||||
@@ -90,7 +89,6 @@ fun main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val crossSection = Circle(Vector2.ZERO, 0.1).contour.transform(
|
val crossSection = Circle(Vector2.ZERO, 0.1).contour.transform(
|
||||||
transform { scale(5.0, 1.0, 1.0) }
|
transform { scale(5.0, 1.0, 1.0) }
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -53,4 +52,3 @@ 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
|
||||||
@@ -84,4 +83,3 @@ 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
|
||||||
@@ -40,11 +49,13 @@ fun main() {
|
|||||||
// 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
|
||||||
@@ -60,4 +59,3 @@ fun main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user