📅  最后修改于: 2020-10-14 01:43:07             🧑  作者: Mango
此效果用于减轻光源中的节点。有多种光源,即点光源,远距离光源和点光源。类javafx.scene.effect.Lighting表示照明效果。我们需要实例化此类,以便在节点上产生适当的效果。
下表描述了该类的属性以及setter方法。
Property | Description | Setter Methods |
---|---|---|
bumpInput | It is a Effect object type property. It represents the Bump map input for the effect. | setBumpInput(Effect value) |
contentInput | It is a Effect object type property. It represents the content input for the Effect. | setContentInput(Effect value) |
diffuseConstant | It is a Double type property. It represents the diffuse constant. | setDiffuseConstant(Double value) |
light | It is a Light object type property. It represents the light source for the effect. | setLight(Light value) |
specularConstant | It is a double type property. It represents specular constant. | setSpecularConstant(double value) |
specularExponent | It is a double type property. It represents Specular Exponent. | setSpecularExponent(double value) |
surfaceScale | It is double type property. It represents Surface scale of the light. | setSurfaceScale(double value) |
该类包含两个构造函数。
package application;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.Lighting;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
public class LightingExample1 extends Application {
@Override
public void start(Stage stage) {
Text text = new Text();
text.setFont(Font.font(null, FontWeight.BOLD, 35));
text.setX(60);
text.setY(100);
text.setText("Welcome to JavaTpoint");
text.setFill(Color.GREEN);
Image img = new Image("https://www.javatpoint.com/operating-system/images/operating-system-tutorial.png");
ImageView imgview = new ImageView(img);
imgview.setX(150);
imgview.setY(200);
Lighting lighting = new Lighting();
text.setEffect(lighting);
imgview.setEffect(lighting);
Group root = new Group(text,imgview);
Scene scene = new Scene(root, 580, 420);
stage.setTitle("lighting effect example");
stage.setScene(scene);
stage.show();
}
public static void main(String args[]){
launch(args);
}
}