📅  最后修改于: 2020-10-14 01:32:49             🧑  作者: Mango
高斯模糊效应与BoxBlur效应非常相似。两者之间的唯一区别是,高斯模糊效应使用高斯卷积核来模糊节点。但是,JavaFX提供了类javafx.scene.effect.GaussianBlur来在节点上实现GaussianBlur。需要实例化此类,以便在节点上施加适当的效果。
下表描述了该类的属性以及setter方法。
Property | Description | Setter Methods |
---|---|---|
input | This property is of effect type. It represents the input for the effect. | setInput(Effect value) |
radius | This property is of double type. It represents the radius of the blur kernel. | setRadius(Double value) |
该类包含两个构造函数。
package application;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.BoxBlur;
import javafx.scene.effect.GaussianBlur;
import javafx.scene.paint.Color;
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 GaussianBlurExample extends Application{
@Override
public void start(Stage primaryStage) throws Exception {
// TODO Auto-generated method stub
Text text = new Text();
text.setText("Welcome to JavaTpoint");
text.setX(100);
text.setY(100);
text.setFont(Font.font("Calibri",FontWeight.BLACK,FontPosture.ITALIC,20));
text.setFill(Color.RED);
text.setStroke(Color.BLACK);
text.setUnderline(true);
GaussianBlur g = new GaussianBlur();
g.setRadius(5);
text.setEffect(g);
Group root = new Group();
root.getChildren().add(text);
Scene scene = new Scene(root,450,200);
primaryStage.setScene(scene);
primaryStage.setTitle("GaussianBlur Example");
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}