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

42 lines
1.2 KiB
Kotlin
Raw Normal View History

2021-01-12 12:52:22 +03:00
package hep.dataforge.vision.examples
2020-12-26 22:46:01 +03:00
import hep.dataforge.meta.DFExperimental
2021-01-12 12:52:22 +03:00
import hep.dataforge.vision.VisionForge
2020-12-26 22:46:01 +03:00
import hep.dataforge.vision.VisionManager
2021-01-12 12:52:22 +03:00
import hep.dataforge.vision.html.ResourceLocation
2020-12-26 22:46:01 +03:00
import hep.dataforge.vision.html.fragment
2021-01-12 12:52:22 +03:00
import hep.dataforge.vision.solid.*
2020-12-26 22:46:01 +03:00
import kotlinx.html.h1
import java.nio.file.Paths
import kotlin.random.Random
@OptIn(DFExperimental::class)
fun main() {
2020-12-28 22:39:37 +03:00
2020-12-26 22:46:01 +03:00
val random = Random(112233)
val fragment = VisionManager.fragment {
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
}
}
}
}
}
2020-12-29 15:00:11 +03:00
VisionForge.makeVisionFile(
2020-12-28 22:39:37 +03:00
fragment,
Paths.get("randomSpheres.html"),
resourceLocation = ResourceLocation.EMBED
)
2020-12-26 22:46:01 +03:00
}