凌烟£苍穹

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

 

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;

public class CirCleTest extends Application {
    public static void main(String[] args) {
        Application.launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        //Create the pane
        GridPane pane = new GridPane();
        pane.setAlignment(Pos.CENTER);

        Group textGroup = new Group();

        //Font class instance
        Font font = Font.font("Times New Roman", FontWeight.BOLD, FontPosture.REGULAR, 35);
        
        String welcome = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
        double rotation = -20;

        double radius = 200d;

        //Loop
        for (char c : welcome.toCharArray()) {
            // ignore whitespace, otherwise add rotated char
            if (!Character.isWhitespace(c)) {
                Text text = new Text(Character.toString(c));
                text.setFont(font);

                Rotate rotationMatrix = new Rotate(rotation, 0, radius);
                text.getTransforms().add(rotationMatrix);

                textGroup.getChildren().add(text);
            }
            rotation += 7;
        }

        pane.getChildren().add(textGroup);

        //Create the scene for the application
        Scene scene = new Scene(pane, 500, 500);
        primaryStage.setTitle("Characters around circle");
        primaryStage.setScene(scene);

        //Display
        primaryStage.show();
    }
}

 

posted on 2021-06-03 18:45  凌烟£苍穹  阅读(16)  评论(0)    收藏  举报  来源