[orx-noise] Add hash functions
This commit is contained in:
33
orx-noise/src/jvmDemo/kotlin/DemoCircleHash01.kt
Normal file
33
orx-noise/src/jvmDemo/kotlin/DemoCircleHash01.kt
Normal file
@@ -0,0 +1,33 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.extra.noise.shapes.hash
|
||||
import org.openrndr.extra.noise.shapes.uniform
|
||||
import org.openrndr.shape.Circle
|
||||
import kotlin.random.Random
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
val b = drawer.bounds
|
||||
val b0 = b.sub(0.0, 0.0, 0.5, 1.0).offsetEdges(-10.0)
|
||||
val b1 = b.sub(0.5, 0.0, 1.0, 1.0).offsetEdges(-10.0)
|
||||
|
||||
val c0 = Circle(b0.center, b0.width/2.0)
|
||||
val c1 = Circle(b1.center, b1.width/2.0)
|
||||
|
||||
val r = Random(0)
|
||||
for (i in 0 until 2000) {
|
||||
drawer.circle(c0.uniform(r), 2.0)
|
||||
drawer.circle(c1.hash(909, i),2.0)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
29
orx-noise/src/jvmDemo/kotlin/DemoRectangleHash01.kt
Normal file
29
orx-noise/src/jvmDemo/kotlin/DemoRectangleHash01.kt
Normal file
@@ -0,0 +1,29 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.extra.noise.shapes.hash
|
||||
import org.openrndr.extra.noise.shapes.uniform
|
||||
import kotlin.random.Random
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
extend {
|
||||
val b = drawer.bounds
|
||||
val b0 = b.sub(0.0, 0.0, 0.5, 1.0).offsetEdges(-10.0)
|
||||
val b1 = b.sub(0.5, 0.0, 1.0, 1.0).offsetEdges(-10.0)
|
||||
|
||||
val r = Random(0)
|
||||
for (i in 0 until 20000) {
|
||||
drawer.circle(b0.uniform(r), 2.0)
|
||||
drawer.circle(b1.hash(909, i),2.0)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.noise.uniform
|
||||
import org.openrndr.extra.noise.shapes.hash
|
||||
import org.openrndr.shape.Triangle
|
||||
import kotlin.random.Random
|
||||
|
||||
/**
|
||||
* Demonstrate the generation of uniformly distributed points inside a list of triangles
|
||||
@@ -17,8 +16,10 @@ fun main() {
|
||||
program {
|
||||
val r = drawer.bounds.offsetEdges(-100.0)
|
||||
val triangle = Triangle(r.position(0.5, 0.0), r.position(0.0, 1.0), r.position(1.0, 1.0))
|
||||
val pts = listOf(triangle).uniform(1000, Random(0))
|
||||
//val pts = listOf(triangle).uniform(1000, Random(0))
|
||||
|
||||
extend {
|
||||
val pts = listOf(triangle).hash(1000, 0, (seconds*500.0).toInt())
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.stroke = null
|
||||
drawer.contour(triangle.contour)
|
||||
|
||||
Reference in New Issue
Block a user