package demo.coffeeCup; import javafx.animation.Animation; import javafx.animation.transition.*; import javafx.scene.*; import javafx.scene.shape.*; import javafx.scene.paint.*; import javafx.scene.effect.*; import javafx.animation.Timeline; import javafx.animation.KeyFrame; import javafx.scene.text.Text; import javafx.scene.text.Font; import javafx.scene.text.TextBoundsType; import javafx.scene.transform.Translate; import javafx.scene.transform.Scale; import javafx.animation.KeyValue; import javafx.application.Application; import javafx.application.Launcher; import javafx.binding.model.WritableDoubleValue; import javafx.collections.FXCollections; import javafx.collections.Sequence; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Group; import javafx.scene.shape.Ellipse; import javafx.scene.shape.Path; import javafx.scene.shape.Rectangle; import javafx.scene.shape.SVGPath; import javafx.stage.Screen; import javafx.stage.Stage; import javafx.stage.StageStyle; import javafx.util.Duration; public class Cup extends Application { private WritableDoubleValue backgroundOpacityValue; private WritableDoubleValue coffeeOpacityValue; private WritableDoubleValue coffeeWireframeOpacityValue; private WritableDoubleValue cupBaseOpacityValue; private WritableDoubleValue cupBaseWireframeOpacityValue; private WritableDoubleValue cupInsideOpacityValue; private WritableDoubleValue cupInsideWireframeOpacityValue; private WritableDoubleValue cupRimOpacityValue; private WritableDoubleValue cupRimWireframeOpacityValue; private WritableDoubleValue glowOpacityValue; private WritableDoubleValue handleOpacityValue; private WritableDoubleValue handleWireframeOpacityValue; private WritableDoubleValue logoOpacityValue; private WritableDoubleValue logoWireFrameOpacityValue; private Group root = new Group(); public static void main(String[] args) { Launcher.launch(Cup.class, null); } private static final int SPARK_COUNT = 200; private static final int SMOKE_COUNT = 75; private boolean SMALL_SCREEN = Screen.getPrimary().getBounds().getWidth() < 1600; private int SCREEN_WIDTH = SMALL_SCREEN ? 1100 : 1680; private int SCREEN_HEIGHT = SMALL_SCREEN ? 700 : 1050; // private int SCREEN_WIDTH = (int) Screen.getPrimary().getBounds().getWidth(); // private int SCREEN_HEIGHT = (int) Screen.getPrimary().getBounds().getHeight(); // private boolean FULLSCREEN = false; //Screen.getPrimary().getBounds().getWidth() == SCREEN_WIDTH; private boolean FULLSCREEN = Screen.getPrimary().getBounds().getWidth() == SCREEN_WIDTH; private WritableDoubleValue shadow1OpacityValue; private WritableDoubleValue shadow2OpacityValue; private WritableDoubleValue smokeGroupOpacityValue; private Sequence sparks; { sparks = FXCollections.sequence(); for (int i = 0; i <= SPARK_COUNT; i++) { Circle circle2 = new Circle(1 + Math.random() * 3); circle2.setId("Spark[" + i + "]"); circle2.setFill(Color.WHITE); sparks.add(circle2); } } private Sequence smoke; { smoke = FXCollections.sequence(); for (int i = 1; i <= SMOKE_COUNT / 3; i++) { double r = 30 + Math.random() * 40; Sequence circles = FXCollections.sequence(); Circle circle3 = new Circle(r * 1.4F); circle3.setFill(Color.rgb(255, 255, 255, 0.02F)); Circle circle4 = new Circle(r); circle4.setFill(Color.rgb(255, 255, 255, 0.2F)); Circle circle5 = new Circle(r / 2); circle5.setFill(Color.rgb(255, 255, 255, 0.2F)); circles.addAll(circle3, circle4, circle5); smoke.addAll(circles); } } private WritableDoubleValue sparksGroupOpacityValue; private WritableDoubleValue sparksPathsOpacityValue; private Text text; { text = new Text(); text.setFont(Font.font("Arial Black", 60)); text.setFill(Color.WHITE); text.setEffect(new DropShadow()); // content: "Vector Graphics & Effects" text.setBoundsType(TextBoundsType.VISUAL); text.setTranslateX(100.0F); text.setTranslateY(SCREEN_HEIGHT - 100); text.setOpacity(0.0F); } private double direction = 1.0F; private ParallelTransition smokeAnimation; private Sequence sparkAnimations = FXCollections.sequence(); private Sequence sparkAnimationPaths; { sparkAnimationPaths = FXCollections.sequence(); for (int i = 0; i < 30; i++) { direction = direction * -1; Path path2 = new Path(); path2.setStroke(Color.WHITE); path2.setStrokeWidth(1.0F); Sequence quadcurvetos = FXCollections.sequence(); for (int c = 1; c <= 4; c++) { QuadCurveTo quadcurveto = new QuadCurveTo((20 + 30 * c) * ((c % 2 == 0) ? (-1) : (1)) * direction * (0.4F + Math.random() * 0.6F), -19 + -20 * Math.random(), -30 + 60 * Math.random(), -20 + -20 * c + -10 * Math.random()); quadcurveto.setAbsolute(false); quadcurvetos.add(quadcurveto); } path2.getElements().clear(); path2.getElements().add(new MoveTo(-170 + 340 * Math.random(), 0.0F)); path2.getElements().addAll(quadcurvetos); sparkAnimationPaths.add(path2); } } private void createAnim(final Node spark) { direction = direction * -1; final Duration duration = Duration.valueOf(1000).add(Duration.valueOf(7000).multiply(Math.random())); final Path path = new Path(); Sequence quadcurvetos2 = FXCollections.sequence(); for (int c = 1; c <= 4; c++) { QuadCurveTo quadcurveto2 = new QuadCurveTo((20 + 30 * c) * ((c % 2 == 0) ? (-1) : (1)) * direction * (0.4F + Math.random() * 0.6F), -19 + -20 * Math.random(), -30 + 60 * Math.random(), -20 + -20 * c + -10 * Math.random()); quadcurveto2.setAbsolute(false); quadcurvetos2.add(quadcurveto2); } path.getElements().clear(); path.getElements().addAll(new MoveTo(-170 + 340 * Math.random(), 0.0F)); path.getElements().addAll(quadcurvetos2); final SequentialTransition sparkAnim = new SequentialTransition(); ParallelTransition paralleltransition = new ParallelTransition(); // fade in FadeTransition fadetransition = new FadeTransition(Duration.valueOf(200), spark); fadetransition.setFromValue(0.0F); fadetransition.setToValue(1.0F); PathTransition pathtransition = new PathTransition(); pathtransition.setDuration(duration); pathtransition.setNode(spark); pathtransition.setPath(AnimationPath.createFromPath(path)); SequentialTransition sequentialtransition = new SequentialTransition(); // fade out at end FadeTransition fadetransition2 = new FadeTransition(Duration.valueOf(900), spark); fadetransition2.setFromValue(1.0F); fadetransition2.setToValue(0.0F); sequentialtransition.getChildren().clear(); sequentialtransition.getChildren().addAll(new PauseTransition(duration.subtract(Duration.valueOf(900)))); sequentialtransition.getChildren().addAll(fadetransition2); paralleltransition.getChildren().clear(); paralleltransition.getChildren().addAll(fadetransition, pathtransition, sequentialtransition); sparkAnim.getChildren().clear(); sparkAnim.getChildren().addAll(new PauseTransition(Duration.valueOf(1000).multiply(Math.random()))); sparkAnim.getChildren().addAll(paralleltransition); sparkAnim.setOnFinished(new EventHandler() { public void handle(ActionEvent t) { int i2 = sparkAnimations.indexOf(sparkAnim); if (i2 != -1) { sparkAnimations.remove(i2); } createAnim(spark); } }); sparkAnimations.add(sparkAnim); sparkAnim.play(); } private void updateSmoke() { smokeAnimation = new ParallelTransition(); Sequence translatetransitions = FXCollections.sequence(); for (Circle circle : smoke) { TranslateTransition translatetransition = new TranslateTransition(Duration.valueOf(10000), circle); translatetransition.setToX(-250 + 500 * Math.random()); translatetransition.setToY(-root.getScene().getHeight() / 2 * Math.random()); translatetransitions.add(translatetransition); } smokeAnimation.getChildren().clear(); smokeAnimation.getChildren().addAll(translatetransitions); smokeAnimation.setOnFinished(new EventHandler() { public void handle(ActionEvent t) { updateSmoke(); } }); smokeAnimation.play(); } public void startAnimation(final Runnable onDone) { Timeline timeline = new Timeline(); Sequence keyvalues = FXCollections.sequence(); keyvalues.addAll(KeyValue.keyValue(background.opacityModel(), 0.0F)); Sequence keyvalues2 = FXCollections.sequence(); keyvalues2.addAll(KeyValue.keyValue(background.opacityModel(), 1.0F), KeyValue.keyValue(cupBaseWireframe.opacityModel(), 0.0F)); Sequence keyvalues3 = FXCollections.sequence(); keyvalues3.addAll(KeyValue.keyValue(cupBaseWireframe.opacityModel(), 1.0F), KeyValue.keyValue(cupRimWireframe.opacityModel(), 0.0F)); Sequence keyvalues4 = FXCollections.sequence(); keyvalues4.addAll(KeyValue.keyValue(cupRimWireframe.opacityModel(), 1.0F), KeyValue.keyValue(cupInsideWireframe.opacityModel(), 0.0F)); Sequence keyvalues5 = FXCollections.sequence(); keyvalues5.addAll(KeyValue.keyValue(cupInsideWireframe.opacityModel(), 1.0F), KeyValue.keyValue(coffeeWireframe.opacityModel(), 0.0F)); Sequence keyvalues6 = FXCollections.sequence(); keyvalues6.addAll(KeyValue.keyValue(coffeeWireframe.opacityModel(), 1.0F), KeyValue.keyValue(handleWireframe.opacityModel(), 0.0F)); Sequence keyvalues7 = FXCollections.sequence(); keyvalues7.addAll(KeyValue.keyValue(handleWireframe.opacityModel(), 1.0F), KeyValue.keyValue(logoWireFrame.opacityModel(), 0.0F)); Sequence keyvalues8 = FXCollections.sequence(); keyvalues8.addAll(KeyValue.keyValue(logoWireFrame.opacityModel(), 1.0F)); // =============================== Sequence keyvalues9 = FXCollections.sequence(); keyvalues9.addAll(KeyValue.keyValue(cupBaseWireframe.opacityModel(), 1.0F), KeyValue.keyValue(cupBase.opacityModel(), 0.0F)); Sequence keyvalues10 = FXCollections.sequence(); keyvalues10.addAll(KeyValue.keyValue(cupBaseWireframe.opacityModel(), 0.0F), KeyValue.keyValue(cupBase.opacityModel(), 1.0F), KeyValue.keyValue(cupRimWireframe.opacityModel(), 1.0F), KeyValue.keyValue(cupRim.opacityModel(), 0.0F)); Sequence keyvalues11 = FXCollections.sequence(); keyvalues11.addAll(KeyValue.keyValue(cupRimWireframe.opacityModel(), 0.0F), KeyValue.keyValue(cupRim.opacityModel(), 1.0F), KeyValue.keyValue(cupInsideWireframe.opacityModel(), 1.0F), KeyValue.keyValue(cupInside.opacityModel(), 0.0F)); Sequence keyvalues12 = FXCollections.sequence(); keyvalues12.addAll(KeyValue.keyValue(cupInsideWireframe.opacityModel(), 0.0F), KeyValue.keyValue(cupInside.opacityModel(), 1.0F), KeyValue.keyValue(coffeeWireframe.opacityModel(), 1.0F), KeyValue.keyValue(coffee.opacityModel(), 0.0F)); Sequence keyvalues13 = FXCollections.sequence(); keyvalues13.addAll(KeyValue.keyValue(coffeeWireframe.opacityModel(), 0.0F), KeyValue.keyValue(coffee.opacityModel(), 1.0F), KeyValue.keyValue(handleWireframe.opacityModel(), 1.0F), KeyValue.keyValue(handle.opacityModel(), 0.0F)); Sequence keyvalues14 = FXCollections.sequence(); keyvalues14.addAll(KeyValue.keyValue(handleWireframe.opacityModel(), 0.0F), KeyValue.keyValue(handle.opacityModel(), 1.0F), KeyValue.keyValue(logoWireFrame.opacityModel(), 1.0F), KeyValue.keyValue(logo.opacityModel(), 0.0F)); Sequence keyvalues15 = FXCollections.sequence(); keyvalues15.addAll(KeyValue.keyValue(logoWireFrame.opacityModel(), 0.0F), KeyValue.keyValue(logo.opacityModel(), 1.0F), KeyValue.keyValue(shadow1.opacityModel(), 0.0F), KeyValue.keyValue(shadow2.opacityModel(), 0.0F)); Sequence keyvalues16 = FXCollections.sequence(); keyvalues16.addAll(KeyValue.keyValue(shadow1.opacityModel(), 1.0F), KeyValue.keyValue(shadow2.opacityModel(), 0.5F)); // text.opacity => 0, // =============================== // FADE IN AND START SMOKE Sequence keyvalues17 = FXCollections.sequence(); keyvalues17.addAll(KeyValue.keyValue(smokeGroup.opacityModel(), 0.0F), KeyValue.keyValue(glow.opacityModel(), 0.0F)); Sequence keyvalues18 = FXCollections.sequence(); keyvalues18.addAll(KeyValue.keyValue(smokeGroup.opacityModel(), 1.0F)); Sequence keyvalues19 = FXCollections.sequence(); keyvalues19.addAll(KeyValue.keyValue(sparksPaths.opacityModel(), 0.0F)); Sequence keyvalues20 = FXCollections.sequence(); keyvalues20.addAll(KeyValue.keyValue(sparksPaths.opacityModel(), 1.0F)); Sequence keyvalues21 = FXCollections.sequence(); keyvalues21.addAll(KeyValue.keyValue(sparksGroup.opacityModel(), 0.0F), KeyValue.keyValue(glow.opacityModel(), 0.0F)); Sequence keyvalues22 = FXCollections.sequence(); keyvalues22.addAll(KeyValue.keyValue(sparksPaths.opacityModel(), 0.0F)); Sequence keyvalues23 = FXCollections.sequence(); keyvalues23.addAll(KeyValue.keyValue(sparksGroup.opacityModel(), 1.0F), KeyValue.keyValue(glow.opacityModel(), 1.0F)); timeline.getKeyFrames().clear(); timeline.getKeyFrames().addAll( new KeyFrame(Duration.valueOf(0), keyvalues.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(2600), keyvalues2.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(2900), keyvalues3.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(3200), keyvalues4.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(3500), keyvalues5.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(3800), keyvalues6.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(4100), keyvalues7.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(4400), keyvalues8.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(4700), keyvalues9.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(5000), keyvalues10.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(5300), keyvalues11.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(5600), keyvalues12.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(5900), keyvalues13.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(6200), keyvalues14.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(6500), keyvalues15.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(6800), keyvalues16.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(7000), new EventHandler() { public void handle(ActionEvent t) { updateSmoke(); } }, keyvalues17.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(7500), keyvalues18.toArray(new KeyValue[0]))/*, new KeyFrame(Duration.valueOf(10000), new EventHandler() { public void handle(ActionEvent t) { mainGroup.setBlendMode(BlendMode.COLOR_DODGE); BoxBlur boxblur = new BoxBlur(); boxblur.setWidth(60.0F); boxblur.setHeight(60.0F); boxblur.setIterations(2); smokeGroup.setEffect(boxblur); } }), new KeyFrame(Duration.valueOf(12000), keyvalues19.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(13500), keyvalues20.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(15000), new EventHandler() { public void handle(ActionEvent t) { // animate sparks for (Circle spark : sparks) { createAnim(spark); } } }, keyvalues21.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(16000), keyvalues22.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(16500), keyvalues23.toArray(new KeyValue[0])), new KeyFrame(Duration.valueOf(22000), new EventHandler() { public void handle(ActionEvent t) { // ALL DONE onDone.run(); } }), new KeyFrame(Duration.valueOf(23000), new EventHandler() { public void handle(ActionEvent t) { // STOP ALL ANIMATION smokeAnimation.stop(); for (Animation sparkAnim : sparkAnimations) sparkAnim.stop(); } })*/); timeline.play(); } private Rectangle background; private Ellipse shadow1; private Ellipse shadow2; private Path handleWireframe; private Path handle; private Path cupBaseWireframe; private Group cupBase; private Ellipse cupRimWireframe; private Group cupRim; private Ellipse cupInsideWireframe; private Group cupInside; private Path coffeeWireframe; private Path coffee; private SVGPath logoWireFrame = Logo.LOGO_WIREFRAME; private SVGPath logo = Logo.LOGO; private Group smokeGroup; private Group sparksGroup; private Group sparksPaths; private Ellipse glow; private Group mainGroup; @Override public void start() { Stage stage = new Stage(FULLSCREEN ? StageStyle.UNDECORATED : StageStyle.DECORATED); Scene scene = new Scene(root, SCREEN_WIDTH, SCREEN_HEIGHT, Color.BLACK); stage.setScene(scene); stage.setWidth(SCREEN_WIDTH); stage.setHeight(SCREEN_HEIGHT); background = new Rectangle(-root.getScene().getWidth() / 2, -root.getScene().getHeight() / 2, root.getScene().getWidth(), root.getScene().getHeight()); background.setOpacity(0.0F); RadialGradient radialgradient = new RadialGradient(0, 0, 0.5, 0.5, 0.8, true, CycleMethod.NO_CYCLE, new Stop[] { new Stop(0.0F,Color.web("#704219")), new Stop(1.0F,Color.BLACK) }); background.setFill(radialgradient); shadow1 = new Ellipse(170.0F, 20.0F); shadow1.setOpacity(0.0F); shadow1.setCenterY(190.0F); BoxBlur boxblur2 = new BoxBlur(); boxblur2.setWidth(60.0F); boxblur2.setHeight(60.0F); boxblur2.setIterations(3); shadow1.setEffect(boxblur2); shadow2 = new Ellipse(170.0F, 20.0F); shadow2.setOpacity(0.0F); shadow2.setCenterY(190.0F); BoxBlur boxblur3 = new BoxBlur(); boxblur3.setWidth(60.0F); boxblur3.setHeight(60.0F); boxblur3.setIterations(3); shadow2.setEffect(boxblur3); handleWireframe = new Path(); handleWireframe.setOpacity(0.0F); handleWireframe.setStroke(Color.WHITE); handleWireframe.setStrokeWidth(2.0F); handleWireframe.getElements().clear(); handleWireframe.getElements().addAll(new MoveTo(170.0F, 30.0F), new QuadCurveTo(220.0F, -10.0F, 230.0F, 20.0F), new QuadCurveTo(240.0F, 50.0F, 175.0F, 105.0F), new QuadCurveTo(140.0F, 135.0F, 100.0F, 130.0F)); handle = new Path(); handle.setOpacity(0.0F); handle.setStroke(Color.WHITE); InnerShadow innershadow = new InnerShadow(); innershadow.setColor(Color.rgb(200, 200, 200)); innershadow.setRadius(10.0F); innershadow.setOffsetY(10.0F); handle.setEffect(innershadow); handle.setStrokeWidth(25.0F); handle.getElements().clear(); handle.getElements().addAll(new MoveTo(170.0F, 30.0F), new QuadCurveTo(220.0F, -10.0F, 230.0F, 20.0F), new QuadCurveTo(240.0F, 50.0F, 175.0F, 105.0F), new QuadCurveTo(140.0F, 135.0F, 100.0F, 130.0F)); cupBaseWireframe = new Path(); cupBaseWireframe.setOpacity(0.0F); cupBaseWireframe.setStroke(Color.WHITE); Arc arc = new Arc(); arc.setStartAngle(0.0F); arc.setLength(-180.0F); arc.setRadiusX(180.0F); arc.setRadiusY(200.0F); cupBaseWireframe.getElements().clear(); cupBaseWireframe.getElements().addAll(AreaHelper.shapeSubtract(arc, new Ellipse(180.0F, 40.0F))); cupBase = new Group(); cupBase.setOpacity(0.0F); InnerShadow innershadow2 = new InnerShadow(); innershadow2.setColor(Color.WHITE); innershadow2.setRadius(3.0F); innershadow2.setOffsetY(3.0F); cupBase.setEffect(innershadow2); Path path3 = new Path(); Stop[] stops = new Stop[] { new Stop(0.0F, Color.WHITE), new Stop(1.0F, Color.rgb(220, 220, 220)) }; path3.setFill(new LinearGradient(0.0F, 0.0F, 1.0F, 0.0F, true, null, stops)); path3.setStroke(null); InnerShadow innershadow3 = new InnerShadow(); innershadow3.setColor(Color.rgb(0, 0, 0, 0.2F)); innershadow3.setRadius(100.0F); path3.setEffect(innershadow3); Arc arc2 = new Arc(); arc2.setStartAngle(0.0F); arc2.setLength(-180.0F); arc2.setRadiusX(180.0F); arc2.setRadiusY(200.0F); path3.getElements().clear(); path3.getElements().addAll(AreaHelper.shapeSubtract(arc2, new Ellipse(180.0F, 40.0F))); cupBase.getChildren().clear(); cupBase.getChildren().addAll(path3); cupRimWireframe = new Ellipse(180.0F, 40.0F); cupRimWireframe.setOpacity(0.0F); cupRimWireframe.setCenterY(1.0F); cupRimWireframe.setFill(null); cupRimWireframe.setStroke(Color.WHITE); cupRim = new Group(); // Cup Rim cupRim.setOpacity(0.0F); InnerShadow innershadow4 = new InnerShadow(); innershadow4.setColor(Color.WHITE); innershadow4.setRadius(3.0F); innershadow4.setOffsetY(0.0F); cupRim.setEffect(innershadow4); Ellipse ellipse = new Ellipse(180.0F, 40.0F); ellipse.setCenterY(1.0F); ellipse.setFill(Color.rgb(230, 230, 230)); cupRim.getChildren().clear(); cupRim.getChildren().addAll(ellipse); cupInsideWireframe = new Ellipse(170.0F, 32.0F); cupInsideWireframe.setOpacity(0.0F); cupInsideWireframe.setFill(null); cupInsideWireframe.setStroke(Color.WHITE); cupInside = new Group(); cupInside.setOpacity(0.0F); DropShadow dropshadow = new DropShadow(); dropshadow.setColor(Color.WHITE); dropshadow.setRadius(8.0F); cupInside.setEffect(dropshadow); Ellipse ellipse2 = new Ellipse(170.0F, 32.0F); InnerShadow innershadow5 = new InnerShadow(); innershadow5.setColor(Color.WHITE); innershadow5.setRadius(6.0F); ellipse2.setEffect(innershadow5); Stop[] stops2 = new Stop[] { new Stop(0.0F, Color.rgb(230, 230, 230)), new Stop(0.5F, Color.rgb(200, 200, 200)), new Stop(1.0F, Color.rgb(230, 230, 230)) }; ellipse2.setFill(new LinearGradient(0.0F, 0.0F, 1.0F, 0.0F, true, null, stops2)); cupInside.getChildren().clear(); cupInside.getChildren().addAll(ellipse2); coffeeWireframe = new Path(); coffeeWireframe.setOpacity(0.0F); coffeeWireframe.setStroke(Color.WHITE); Ellipse ellipse3 = new Ellipse(170.0F, 32.0F); ellipse3.setCenterY(15.0F); coffeeWireframe.getElements().clear(); coffeeWireframe.getElements().addAll(AreaHelper.shapeIntersect(new Ellipse(170.0F, 32.0F), ellipse3)); coffee = new Path(); coffee.setOpacity(0.0F); RadialGradient radialgradient2 = new RadialGradient(0, 0, 0.5, 0.5, 0.5, true, CycleMethod.NO_CYCLE, new Stop[] {new Stop(0.0F, Color.web("#f3c891")), new Stop(0.69F, Color.web("#da8c36")), new Stop(0.74F, Color.web("#d8852a")), new Stop(0.81F, Color.web("#efbc7e")), new Stop(0.85F, Color.web("#f4c78c")), new Stop(0.9F, Color.web("#f4d5ad")), new Stop(1.0F, Color.web("#f4c78c"))}); coffee.setFill(radialgradient2); coffee.setStroke(null); Ellipse ellipse4 = new Ellipse(170.0F, 32.0F); ellipse4.setCenterY(15.0F); coffee.getElements().clear(); coffee.getElements().addAll(AreaHelper.shapeIntersect(new Ellipse(170.0F, 32.0F), ellipse4)); smokeGroup = new Group(); // SMOKE smokeGroup.setOpacity(0.0F); // effect: BoxBlur{ width: 60 height: 60, iterations: 2 } double[] doubles = new double[] {-170.0F, 15.0F, -220.0F, -root.getScene().getHeight() / 2, 220.0F, -root.getScene().getHeight() / 2, 170.0F, 15.0F}; Polygon polygon = new Polygon(doubles); BoxBlur boxblur4 = new BoxBlur(); boxblur4.setWidth(100.0F); boxblur4.setHeight(100.0F); boxblur4.setIterations(2); polygon.setEffect(boxblur4); smokeGroup.setClip(polygon); smokeGroup.getChildren().clear(); // The following three lines are the workaround Polygon polygon2 = new Polygon(doubles); polygon2.setFill(Color.TRANSPARENT); // smokeGroup.getChildren().addAll(polygon2); // Uncomment this line to remove clipping problem smokeGroup.getChildren().addAll(smoke); sparksGroup = new Group(); sparksGroup.setOpacity(0.0F); BoxBlur boxblur5 = new BoxBlur(); boxblur5.setWidth(4.0F); boxblur5.setHeight(4.0F); sparksGroup.setEffect(boxblur5); sparksGroup.getChildren().clear(); sparksGroup.getChildren().addAll(sparks); sparksPaths = new Group(); sparksPaths.setOpacity(0.0F); sparksPaths.getChildren().clear(); sparksPaths.getChildren().addAll(sparkAnimationPaths); glow = new Ellipse(130.0F, 40.0F); glow.setOpacity(0.0F); glow.setCache(true); BoxBlur boxblur6 = new BoxBlur(); boxblur6.setWidth(60.0F); boxblur6.setHeight(60.0F); boxblur6.setIterations(3); glow.setEffect(boxblur6); glow.setFill(Color.rgb(255, 255, 255, 0.8F)); glow.setCenterY(-30.0F); mainGroup = new Group(); // translateX: SCREEN_WIDTH/2 // translateY: SCREEN_HEIGHT/2 // scaleX: 1.5, scaleY: 1.5 mainGroup.getTransforms().clear(); mainGroup.getTransforms().addAll(new Translate(SCREEN_WIDTH / 2.0F, SCREEN_HEIGHT / 2), new Scale(1.5F, 1.5F)); Group group = new Group(); group.getChildren().clear(); group.getChildren().addAll(background, shadow1, handle, cupBaseWireframe, cupBase, shadow2, cupRimWireframe, cupRim, cupInsideWireframe, cupInside, coffeeWireframe, coffee, logoWireFrame, logo, sparksPaths); mainGroup.getChildren().clear(); mainGroup.getChildren().addAll(group, smokeGroup, sparksGroup, glow); root.getChildren().addAll(mainGroup, text); stage.setVisible(true); startAnimation(new Runnable() { public void run() { System.exit(0); } }); } }