📜  JavaFX Effects

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

JavaFX效果

效果基本上是可以改善图形外观的动作。 JavaFX提供了名为javafx.scene.effect的程序包,其中包含各种类,可用于在UI图形组件(如图像和形状)上应用效果。下表中给出了效果及其说明。

SN Effect Description
1 ColorAdjust This Effect adjusts the color of the node by varying the properties like Hue, Saturation, Brightness, contrast etc. javafx.scene.effect.ColorAdjust class deals with all the stuff regarding adjustments of colors of the node.
2 ColorInput javafx.scene.ColorInput class represents ColorInput effect. It makes a coloured rectangle. This displays a rectangular box if applied to a node.
3 ImageInput ImageInput effect is used to bind the image to the scene. It basically passes the specified image to some effect.
4 Blend javafx.scene.effect.Blend class represents the blend effect. This effect joins the pixels of two inputs and produces the combined output at the same location. There are various blend modes defined in the class which can alter the output appearance.
5 Bloom javafx.scene.effect.Bloom class represents bloom effect. This effect makes the pixels of a few portions of the component glow.
6 Glow This effect is very much similar to Bloom. This can make the input image glow by enhancing the brightness of the bright pixels.
7 BoxBlur The blur makes the image unclear. JavaFX provides the class javafx.scene.effect.BoxBlur which needs to be instantiated in order to apply the blur effect to the nodes. The Box filter is used in the case of BoxBlur effect in JavaFX.
8 GaussionBlur In JavaFX, GaussionBlur is used to blur the nodes. This class uses Gaussion Convolution Kernel for this purpose.
9 MotionBlur MotionBlur effect is used to make the nodes blur. By applying this effect, the nodes are seemed to be blurred as they are in motion. javafx.scene.effect.MotionBlur class represents this effect.
10 Reflection It adds the reflection of the node on the bottom of the node. The class named as javafx.scene.effect.Reflection represents Reflection effect.
11 SepiaTone SapiaTone effect makes the node toned with radish brown color. The class named as javafx.scene.effect.SepiaTone class represents SapiaTone effect. The resulting nodes are similar to antique photographs.
12 Shadow This duplicates the nodes with the blurry edges. The class named as javafx.scene.effect.Shadow represents Shadow effect.
13 DropShadow This is a high level effect that is used to display the duplicate content behind the original content with the specified color and size.
14 InnerShadow This effect displays the shadow inside the edges of the nodes to which it is applied.
15 Lighting This effect is used to lighten the node from a light source. This effect is represented by javafx.scene.effect.Lighting class.
16 Light.Distant It implements lighting on the node from a distant light source. It is represented by Light.Distant class.
17 Light.Spot It implements lighting on a node from a spot light source. It is represented by Light.Spot class.
18 Light.Point It implements lighting on a node from a point light source. It is represented by Light.Point class.

如何将效果应用于节点

JavaFX提供了一个名为setEffect()的方法,该方法需要通过节点对象进行调用。我们需要将效果类对象传递给此方法。要将任何效果应用于节点,我们需要遵循以下步骤。

  • 创建节点
  • 创建要应用于节点的相应效果类的对象。
  • 设置效果的属性。
  • 通过节点对象调用setEffect()方法,并将Effect类对象传递给它。