📅  最后修改于: 2020-10-14 01:27:41             🧑  作者: Mango
该效果主要用于传递未修改的图像作为其他效果的输入。类javafx.scene.effect.ImageInput表示ImageInput效果。此类包含各种属性,可以将这些属性设置为某个值,以呈现适当的图像。
下表描述了类的属性及其设置方法。
Property | Description | Setter Methods |
---|---|---|
source | URL of the source image. | setSource(Image image) |
X | The X coordinate of the image | setX(Double value) |
Y | The Y coordinate of the image | setY(Double value) |
该类包含以下描述的三个构造函数。
package application;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.ImageInput;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class ImageInputExample extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
// TODO Auto-generated method stub
Image img = new Image("https://www.javatpoint.com/jogl/images/jogl-3d-triangle.gif");
ImageInput imginput = new ImageInput();
Rectangle rect = new Rectangle();
imginput.setSource(img);
imginput.setX(20);
imginput.setY(100);
Group root = new Group();
rect.setEffect(imginput);
root.getChildren().add(rect);
Scene scene = new Scene(root,530,500,Color.BLACK);
primaryStage.setScene(scene);
primaryStage.setTitle("ImageInput Example");
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}