个性化阅读
专注于IT技术分析

JavaFX发光效果

本文概述

像Bloom效果一样, Glow效果也用于发光图像的像素。但是, 它会使图像更亮。类javafx.scene.effect.Glow表示发光效果。该类包含各种属性, 可以将这些属性设置为某些值, 以应用适当的效果。

物产

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

属性 描述 设置方法
input 这代表效果的输入。这是一个效果类对象类型属性。 setInput(Effect value)
level 它表示一个值, 该值控制节点上的发光效果的强度。 setLevel(double value)

建设者

该类中有两个构造函数。

  1. Public Glow():这是默认构造函数。它使用默认参数实例化该类。
  2. Public Glow(双重级别):它使用指定的级别值创建实例。

例:

package application;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.Glow;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
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;
public class GlowEffect extends Application{

	@Override
	public void start(Stage primaryStage) throws Exception {
		// TODO Auto-generated method stub
		Image img1 = new Image("https://www.srcmini02.com/linux/images/linux-first.png");
		Image img2 = new Image("https://www.srcmini02.com/linux/images/linux-first.png");
		
		ImageView imgview1 = new ImageView(img1);
		ImageView imgview2 = new ImageView(img2);
		Text text1 = new Text();
		Text text2 = new Text();
		text1.setText("Glowing with level 10");
		text2.setText("Not Glowing");
		text1.setX(60);
		text1.setY(300);
		text2.setX(325);
		text2.setY(300);
		text1.setFont(Font.font("Courier 10 Pitch", FontWeight.BOLD, FontPosture.REGULAR, 16));
		text2.setFont(Font.font("Courier 10 Pitch", FontWeight.BOLD, FontPosture.REGULAR, 16));
		text1.setFill(Color.RED);
		text2.setFill(Color.RED);
		text1.setStroke(Color.BLACK);
		text2.setStroke(Color.BLACK);
		imgview1.setX(70);
		imgview1.setY(90);
		imgview2.setX(300);
		imgview2.setY(90);
		Glow glow = new Glow(); 
		glow.setLevel(10);
		imgview1.setEffect(glow);
		Group root = new Group();
		root.getChildren().addAll(imgview1, imgview2, text1, text2);
		Scene scene = new Scene(root, 500, 350);
		primaryStage.setScene(scene);
		primaryStage.setTitle("Glow Effect Example");
		primaryStage.show();	
		
	}
	public static void main(String[] args) {
		launch(args);
		
	}
}
JavaFX发光效果
赞(0)
未经允许不得转载:srcmini » JavaFX发光效果

相关推荐

评论 抢沙发

评论前必须登录!