直线类Line
矩形类Rectangle
圆类 Circle
椭圆类Ellipse
弧类 Arc
多边形类Polygon
折线类Polyline
Line line = new Line(0,0,150,150);
borderPane.getChildren().add(line);
交互式系统设计
鼠标拖动绘图的基本思想是用很多短直线一次相连代替直线
动画程序设计
淡入淡出动画
FadeTransition()
package sample;
import javafx.animation.Animation;
import javafx.animation.FadeTransition;
import javafx.application.Application;
import javafx.geometry.Orientation;
import javafx.scene.Scene;
import javafx.scene.control.CheckMenuItem;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.Slider;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Line;
import javafx.stage.Stage;
import javafx.scene.input.MouseEvent;
import javafx.util.Duration;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
BorderPane borderPane = new BorderPane();
Circle circle = new Circle(150,150,100);
circle.setFill(Color.BLACK);
FadeTransition ft = new FadeTransition(Duration.millis(2000));
ft.setCycleCount(Animation.INDEFINITE);
ft.setFromValue(1.0);
ft.setToValue(0.0);
ft.setAutoReverse(true);
ft.setNode(circle);
ft.play();
borderPane.setCenter(circle);
primaryStage.setScene(new Scene(borderPane,300,300));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
移动效果
Pathtransition()
时间轴动画
太多了懒得写了