[orx-math] Add orx-math module
This commit is contained in:
37
orx-math/src/jvmDemo/kotlin/linearrange/DemoLinearRange02.kt
Normal file
37
orx-math/src/jvmDemo/kotlin/linearrange/DemoLinearRange02.kt
Normal file
@@ -0,0 +1,37 @@
|
||||
package linearrange
|
||||
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.isolated
|
||||
import org.openrndr.extra.math.linearrange.rangeTo
|
||||
import org.openrndr.math.Vector2
|
||||
import org.openrndr.shape.Rectangle
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.sin
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val range = Rectangle.fromCenter(Vector2(36.0, 36.0), 72.0, 18.0)..
|
||||
Rectangle.fromCenter(Vector2(36.0, 36.0), 18.0, 72.0)
|
||||
extend {
|
||||
drawer.fill = ColorRGBa.PINK.opacify(0.9)
|
||||
drawer.stroke = null
|
||||
for (y in 0 until height step 72) {
|
||||
for (x in 0 until width step 72) {
|
||||
val u = cos(seconds + x * 0.007) * 0.5 + 0.5
|
||||
val s = sin(seconds*1.03 + y * 0.0075) * 0.5 + 0.5
|
||||
drawer.isolated {
|
||||
drawer.translate(x.toDouble(), y.toDouble())
|
||||
drawer.rectangle(range.value(u * s))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
41
orx-math/src/jvmDemo/kotlin/linearrange/DemoLinearRange03.kt
Normal file
41
orx-math/src/jvmDemo/kotlin/linearrange/DemoLinearRange03.kt
Normal file
@@ -0,0 +1,41 @@
|
||||
package linearrange
|
||||
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.isolated
|
||||
import org.openrndr.extra.math.linearrange.rangeTo
|
||||
import org.openrndr.math.Vector2
|
||||
import org.openrndr.shape.Rectangle
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.sin
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val range0 = Rectangle.fromCenter(Vector2(36.0, 36.0), 72.0, 18.0)..
|
||||
Rectangle.fromCenter(Vector2(36.0, 36.0), 18.0, 72.0)
|
||||
val range1 = Rectangle.fromCenter(Vector2(36.0, 0.0), 9.0, 9.0)..
|
||||
Rectangle.fromCenter(Vector2(36.0, 72.0), 9.0, 9.0)
|
||||
|
||||
val range = range0..range1
|
||||
extend {
|
||||
drawer.fill = ColorRGBa.PINK.opacify(0.9)
|
||||
drawer.stroke = null
|
||||
for (y in 0 until height step 72) {
|
||||
for (x in 0 until width step 72) {
|
||||
val u = cos(seconds* 2.0 + x * 0.01) * 0.5 + 0.5
|
||||
val v = sin(seconds * 1.03 + y * 0.01) * 0.5 + 0.5
|
||||
drawer.isolated {
|
||||
drawer.translate(x.toDouble(), y.toDouble())
|
||||
drawer.rectangle(range.value(u, v))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package simplexrange
|
||||
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.DrawPrimitive
|
||||
import org.openrndr.draw.isolated
|
||||
import org.openrndr.extra.camera.Orbital
|
||||
import org.openrndr.extra.meshgenerators.boxMesh
|
||||
import org.openrndr.extra.math.simplexrange.SimplexRange3D
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
|
||||
program {
|
||||
val box = boxMesh()
|
||||
extend(Orbital()) {
|
||||
eye = Vector3(1.0, -1.0, 1.0).normalized * 140.0
|
||||
fov = 15.0
|
||||
}
|
||||
extend {
|
||||
val sr = SimplexRange3D(
|
||||
ColorRGBa.PINK.toLinear(),
|
||||
ColorRGBa.RED.toLinear(),
|
||||
ColorRGBa.MAGENTA.toLinear(),
|
||||
ColorRGBa.BLUE.toLinear()
|
||||
)
|
||||
|
||||
for (z in 0 until 20)
|
||||
for (y in 0 until 20)
|
||||
for (x in 0 until 20) {
|
||||
drawer.isolated {
|
||||
drawer.translate(x - 10.0, y - 10.0, z - 10.0)
|
||||
drawer.fill = sr.value(x / 20.0, y / 20.0, z / 20.0)
|
||||
drawer.vertexBuffer(box, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user