Search in sources :

Example 1 with Trapezoid

use of org.fxyz.shapes.Trapezoid in project FXyzLib by Birdasaur.

the class TrapezoidTest method generateShapes.

private void generateShapes() {
    for (int i = 0; i < 50; i++) {
        Random r = new Random();
        //A lot of magic numbers in here that just artificially constrain the math
        double randomSmallSize = (double) ((r.nextDouble() * 50) + 10);
        double randomBigSize = (double) ((r.nextDouble() * 100) + 50);
        double randomHeight = (double) ((r.nextDouble() * 50) + 25);
        double randomDepth = (double) ((r.nextDouble() * 50) + 25);
        Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
        Trapezoid trapezoid = new Trapezoid(randomSmallSize, randomBigSize, randomHeight, randomDepth, randomColor);
        //            Trapezoid trapezoid = new Trapezoid(50, 100, 50, 50, randomColor);
        trapezoid.setEmissiveLightingColor(randomColor);
        trapezoid.setEmissiveLightingOn(r.nextBoolean());
        trapezoid.setDrawMode(r.nextBoolean() ? DrawMode.FILL : DrawMode.LINE);
        double translationX = Math.random() * 1024;
        if (Math.random() >= 0.5) {
            translationX *= -1;
        }
        double translationY = Math.random() * 1024;
        if (Math.random() >= 0.5) {
            translationY *= -1;
        }
        double translationZ = Math.random() * 1024;
        if (Math.random() >= 0.5) {
            translationZ *= -1;
        }
        Translate translate = new Translate(translationX, translationY, translationZ);
        Rotate rotateX = new Rotate(Math.random() * 360, Rotate.X_AXIS);
        Rotate rotateY = new Rotate(Math.random() * 360, Rotate.Y_AXIS);
        Rotate rotateZ = new Rotate(Math.random() * 360, Rotate.Z_AXIS);
        trapezoid.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);
        shapeGroup.getChildren().add(trapezoid);
    }
}
Also used : Random(java.util.Random) Rotate(javafx.scene.transform.Rotate) Trapezoid(org.fxyz.shapes.Trapezoid) Color(javafx.scene.paint.Color) Translate(javafx.scene.transform.Translate)

Aggregations

Random (java.util.Random)1 Color (javafx.scene.paint.Color)1 Rotate (javafx.scene.transform.Rotate)1 Translate (javafx.scene.transform.Translate)1 Trapezoid (org.fxyz.shapes.Trapezoid)1