JavaFX Blend Effect

In general, blend effect produces the output that is generated as a result of the mixture of two or more different input nodes. It takes the pixels of two or more nodes, mix them according to the applied blend mode and produces the output node at the same location.

If the two images are overlapping each other then the blend mode is applied on the overlapped area of both the images.

Properties

The class contains four properties which are described along with their setter methods in the following table.

PropertyDescriptionSetter Methods
bottomInputThe bottom input for the blend operation. This is a object type property.setBottomInput(Effect value)
modeThe mode according to which, the inputs are blend together.setMode(BlendMode value)
opacityThis is the opacity value of double type.setOpacity(double value)
topInputThe top input for the blend operation.setTopInput(Effect Value)

Constructors

There are three constructors in this class.

  1. Blend() : Instantiate Blend class with the default values.
  2. Blend(BlendMode mode): Instantiate Blend class with the specified mode
  3. Blend(BlendMode mode, Effect BottomInput, Effect TopInput): Instantiate Blend class with the specified blend mode, Bottom Input effect and Top Input effect

Example:


JavaFX Blend Effect

Blend Mode

JavaFX provides various blendmodes which can be applied in order to modify the Blend Effect.

Blend ModeDescriptionOutput
AddThe color components of the top input are added to that from the bottom input.JavaFX Blend Mode Add Output
BlueOnly Blue components of the bottom input gets replaced by the blue component of top input.JavaFX Blend Mode Blue Output
COLOR_BURNThe bottom input color gets inverted and divided by the top input color components. The result is again inverted to get the output color.JavaFX Blend Mode COLORBURN Output
COLOR_DODGEThe top color components gets inverted and divide the bottom color components to produce the output color.JavaFX Blend Mode COLOR DODGE Output
DARKENThe color which is darker of the two input component colors is selected to produce the resulting color.JavaFX Blend Mode DARKEN Output
DIFFERENCEThe darker of the two input color is subtracted from the lighter color to produce the resulting color.JavaFX Blend Mode DIFFERENCE Output
EXCLUSIONThe two input color components are multiplied and doubled and then subtracted from the sum of bottom color components to produce the desired color.JavaFX Blend Mode EXCLUSION Output
GREENThe green component from the bottom input is replaced by the green input of top component.JavaFX Blend Mode GREEN Output
HARD_LIGHTThe input color components are either multiplied or screened depending upon the bottom color.JavaFX Blend Mode HARD LIGHT Output
LIGHTENThe lighter color of the two color components is produced as output.JavaFX Blend Mode LIGHTEN Output
MULTIPLYBoth the color components get multiplied to produce the output color.JavaFX Blend Mode MULTIPLY Output
OVERLAYThe input color components gets either screened or multiplied depending upon the bottom color.JavaFX Blend Mode OVERLAY Output
REDThe red components of bottom input gets replaced with the red components of top input.JavaFX Blend Mode RED Output
SCREENBoth color components are inverted, multiplied and again inverted to produce the desired result.JavaFX Blend Mode SCREEN Output
SOFT_LIGHTThe input color components become lighten or darken.JavaFX Blend Mode SOFT LIGHT Output
SRC_ATOPThe part of the top input that is lying over the bottom input gets blended.JavaFX Blend Mode SRC ATOP Output
SRC_OVERTop input gets blended over bottom input.JavaFX Blend Mode SRC OVER Output





Latest Courses