📜  JavaFX BoxBlur效果

📅  最后修改于: 2020-10-14 01:31:42             🧑  作者: Mango

JavaFX BoxBlur效果

JavaFX允许我们使用JavaFX模糊效果使节点模糊。通常,模糊会使图像不清楚。 JavaFX提供了类javafx.scene.effect.BoxBlur,需要实例化该类才能将模糊效果应用于节点。在JavaFX中的BoxBlur效果的情况下使用Box过滤器。

物产

下表描述了该类的属性以及setter方法。

Property Description Setter Methods
height This is a double type property. It represents the height of the blur effect. setHeight(double value)
width This is a double type property. It represents the width of the blur effect. setWidth(double value)
input This property is of Effect type. This represents the input for the effect. setInput(Effect value)
iterations It represents the number of repetitions of the blur effect. This is of integer type. setIterations(int value)

建设者

该类包含两个构造函数

  • public BoxBlur():使用属性的默认值创建新实例。
  • public BoxBlur(Double width,Double height,int迭代):创建具有指定值的新实例。

例:

package application;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.BoxBlur;
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 BoxBlurExample 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);
BoxBlur b = new BoxBlur();
b.setHeight(5);
b.setWidth(2);
b.setIterations(1);
text.setEffect(b);
Group root = new Group();
root.getChildren().add(text);
Scene scene = new Scene(root,450,200);
primaryStage.setScene(scene);
primaryStage.setTitle("BoxBlur Example");
primaryStage.show();
}
publicstaticvoid main(String[] args) {
launch(args);
}
}