📅  最后修改于: 2020-10-14 01:34:04             🧑  作者: Mango
MotionBlur类似于高斯模糊效果。运动模糊效果还用于模糊节点。高斯模糊效果和运动模糊效果之间的唯一区别是,运动模糊效果使用指定的角度来模糊节点。
顾名思义,通过应用此效果,可以看到该节点处于运动中。类javafx.scene.effect.MotionBlur表示运动模糊效果。需要实例化此类以产生适当的效果。
下表中描述了类的属性以及setter方法。
Property | Description | Setter Methods |
---|---|---|
angle | It represents the angle of the motion effect. It is a double type property. | setAngle(Double value) |
input | It represents the input for the effect. It is an Effect object type property. | setInput(Effect value) |
radius | It represents the radius of the blur kernel. It is a double type property. | setRadius(Double radius) |
它包含下面描述的两个构造函数。
package application;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.MotionBlur;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class MotionBlurExample extends Application{
@Override
public void start(Stage primaryStage) throws Exception {
// TODO Auto-generated method stub
Text text = new Text("Welcome to javaTpoint");
text.setX(30);
text.setY(100);
text.setFont(Font.font("calibri",FontWeight.BOLD,FontPosture.ITALIC,40));
MotionBlur motion = new MotionBlur();
motion.setAngle(20);
motion.setRadius(10);
text.setEffect(motion);
Group root = new Group();
root.getChildren().addAll(text);
Scene scene = new Scene(root,600,200);
primaryStage.setScene(scene);
primaryStage.setTitle("MotionBlur Example");
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}