Skip to content

Instantly share code, notes, and snippets.

@skrb
Created December 17, 2015 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skrb/9814156b577fd292f457 to your computer and use it in GitHub Desktop.
Save skrb/9814156b577fd292f457 to your computer and use it in GitHub Desktop.
Crawler Demo 2
import javafx.animation.Animation;
import javafx.animation.Interpolator;
import javafx.animation.ParallelTransition;
import javafx.animation.PauseTransition;
import javafx.animation.RotateTransition;
import javafx.animation.ScaleTransition;
import javafx.animation.SequentialTransition;
import javafx.animation.TranslateTransition;
import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.geometry.Point3D;
import javafx.scene.Group;
import javafx.scene.PerspectiveCamera;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.util.Duration;
public class TextCrawler2 extends Application {
private static final String crawl = "Episode IV\n"
+ "A NEW HOPE\n\n"
+ "It is a period of civil war.\n"
+ "Rebel spaceships, striking\n"
+ "from a hidden base, have won\n"
+ "their first victory against\n"
+ "the evil Galactic Empire.\n"
+ "\n"
+ "During the battle, Rebel\n"
+ "spies managed to steal secret\n"
+ "plans to the Empire's\n"
+ "ultimate weapon, the DEATH\n"
+ "STAR, an armored space\n"
+ "station with enough power\n"
+ "to destroy an entire planet.\n"
+ "\n"
+ "Pursued by the Empire's\n"
+ "sinister agents, Princess\n"
+ "Leia races home aboard her\n"
+ "starship, custodian of the\n"
+ "stolen plans that can save her\n"
+ "people and restore\n"
+ "freedom to the galaxy....";
@Override
public void start(Stage stage) throws Exception {
Group root = new Group();
root.setTranslateX(400);
Scene scene = new Scene(root);
scene.setCamera(new PerspectiveCamera());
scene.setFill(Color.BLACK);
stage.setScene(scene);
stage.setWidth(800);
stage.setHeight(600);
stage.initStyle(StageStyle.UNDECORATED);
stage.show();
Text text = new Text(crawl);
text.setTextAlignment(TextAlignment.CENTER);
text.setFill(Color.YELLOW);
text.setFont(Font.font("Arial", FontPosture.REGULAR, 24));
text.setRotationAxis(new Point3D(1.0, 0.0, 0.0));
text.setRotate(-80.0);
text.setTranslateX(-150);
text.setTranslateY(1_200);
text.setScaleX(5.0);
text.setScaleY(5.0);
root.getChildren().add(text);
TranslateTransition trans = new TranslateTransition(Duration.millis(20_000), text);
trans.setFromY(1_000);
trans.setToY(-100);
trans.setInterpolator(Interpolator.EASE_OUT);
trans.setCycleCount(Animation.INDEFINITE);
trans.play();
ScaleTransition scale = new ScaleTransition(Duration.millis(20_000), text);
scale.setFromX(5.0);
scale.setFromY(5.0);
scale.setFromZ(5.0);
scale.setToX(0.01);
scale.setToY(0.01);
scale.setToZ(0.01);
scale.setInterpolator(Interpolator.LINEAR);
scale.setCycleCount(Animation.INDEFINITE);
scale.play();
RotateTransition rotate = new RotateTransition(Duration.millis(20_000), text);
rotate.setToAngle(-80.0);
rotate.setInterpolator(Interpolator.EASE_OUT);
rotate.setCycleCount(Animation.INDEFINITE);
rotate.play();
}
public static void main(String... args) {
launch(args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment