visionforge/demo/playground/src/jvmMain/kotlin/randomSpheres.kt

39 lines
1.1 KiB
Kotlin
Raw Normal View History

2021-03-07 16:19:43 +03:00
package space.kscience.visionforge.examples
2020-12-26 22:46:01 +03:00
import kotlinx.html.h1
2021-05-05 15:28:06 +03:00
import space.kscience.dataforge.context.Context
2021-03-07 16:19:43 +03:00
import space.kscience.visionforge.html.ResourceLocation
import space.kscience.visionforge.solid.*
2020-12-26 22:46:01 +03:00
import java.nio.file.Paths
import kotlin.random.Random
2021-05-05 15:28:06 +03:00
fun main() {
val context = Context {
plugin(Solids)
}
2020-12-28 22:39:37 +03:00
2020-12-26 22:46:01 +03:00
val random = Random(112233)
2021-05-05 15:28:06 +03:00
context.makeVisionFile(
Paths.get("randomSpheres.html"),
resourceLocation = ResourceLocation.EMBED
) {
2020-12-26 22:46:01 +03:00
h1 { +"Happy new year!" }
vision {
solid {
repeat(100) {
2020-12-28 22:39:37 +03:00
sphere(5, name = "sphere[$it]") {
2020-12-26 22:46:01 +03:00
x = random.nextDouble(-300.0, 300.0)
y = random.nextDouble(-300.0, 300.0)
z = random.nextDouble(-300.0, 300.0)
material {
color(random.nextInt())
specularColor(random.nextInt())
}
detail = 16
}
}
}
}
}
}