2021-01-12 12:52:22 +03:00
|
|
|
package hep.dataforge.vision.examples
|
2020-12-26 22:46:01 +03:00
|
|
|
|
2021-02-16 14:49:15 +03:00
|
|
|
import hep.dataforge.misc.DFExperimental
|
2021-01-12 12:52:22 +03:00
|
|
|
import hep.dataforge.vision.VisionForge
|
|
|
|
import hep.dataforge.vision.html.ResourceLocation
|
2020-12-26 22:46:01 +03:00
|
|
|
import hep.dataforge.vision.html.fragment
|
2021-02-26 13:03:40 +03:00
|
|
|
import hep.dataforge.vision.invoke
|
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)
|
2021-02-27 21:40:58 +03:00
|
|
|
fun main() = VisionForge(Solids) {
|
2020-12-28 22:39:37 +03:00
|
|
|
|
2020-12-26 22:46:01 +03:00
|
|
|
val random = Random(112233)
|
2021-02-26 13:03:40 +03:00
|
|
|
val fragment = fragment {
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-02-26 13:03:40 +03:00
|
|
|
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
|
|
|
}
|