Spec-Zone .ru
спецификации, руководства, описания, API

JavaFX: Bringing Rich Experiences To All the Screens Of Your Life

Profile: desktop, common

Overview

An effect that shifts each pixel by a distance specified by the first two bands of of the specified FloatMap. For each pixel in the output, the corresponding data from the mapData is retrieved, scaled and offset by the scale and offset attributes, scaled again by the size of the source input image and used as an offset from the destination pixel to retrieve the pixel data from the source input.

     dst[x,y] = src[(x,y) + (offset+scale*map[x,y])*(srcw,srch)]
 
A value of (0.0, 0.0) would specify no offset for the pixel data whereas a value of (0.5, 0.5) would specify an offset of half of the source image size.

Note that the mapping is the offset from a destination pixel to the source pixel location from which it is sampled which means that filling the map with all values of 0.5 would displace the image by half of its size towards the upper left since each destination pixel would contain the data that comes from the source pixel below and to the right of it.

Also note that this effect does not adjust the coordinates of input events or any methods that measure containment on a Node. The results of mouse picking and the containment methods are undefined when a Node has a DisplacementMap effect in place.

the code:

import java.lang.Math;
import javafx.scene.*;
import javafx.scene.text.*;
import javafx.scene.shape.*;
import javafx.scene.paint.*;
import javafx.scene.effect.*;

var w = 220;
var h = 100;
var map = FloatMap { width: w height: h }
for (i:Integer in [0..w-1]) {
    var v = (Math.sin(i/50.0*Math.PI)-0.5)/40.0;
    for (j:Integer in [0..h-1]) {
        map.setSamples(i, j, 0.0, v);
    }
}
Group {
    effect: DisplacementMap { mapData: map }
    cache: true
    content: [
        Rectangle {
            x: 20 y: 20
            width: w
            height: h
            fill: Color.BLUE
        },
        Text {
            x: 40 y: 80
            content: "Wavy Text"
            fill: Color.YELLOW
            font: Font.font(null, FontWeight.BOLD, 36);
        },
    ]
}

produces:

Profile: desktop

Variable Summary

accessnametypeCan ReadCan InitCan WriteDefault Valuedescription
publicinputEffectnull

The input for this Effect.

The input for this Effect. If set to null, or left unspecified, a graphical image of the Node to which the Effect is attached will be used as the input.

null  
publicmapDataFloatMapan empty map

The map data for this Effect.

publicoffsetXNumber0.0

The offset by which all x coordinate offset values in the FloatMap are displaced after they are scaled.

The offset by which all x coordinate offset values in the FloatMap are displaced after they are scaled.

       Min: n/a
       Max: n/a
   Default: 0.0
  Identity: 0.0
 

0.0  
publicoffsetYNumber0.0

The offset by which all y coordinate offset values in the FloatMap are displaced after they are scaled.

The offset by which all y coordinate offset values in the FloatMap are displaced after they are scaled.

       Min: n/a
       Max: n/a
   Default: 0.0
  Identity: 0.0
 

0.0  
publicscaleXNumber1.0

The scale factor by which all x coordinate offset values in the FloatMap are multiplied.

The scale factor by which all x coordinate offset values in the FloatMap are multiplied.

       Min: n/a
       Max: n/a
   Default: 1.0
  Identity: 1.0
 

1.0  
publicscaleYNumber1.0

The scale factor by which all y coordinate offset values in the FloatMap are multiplied.

The scale factor by which all y coordinate offset values in the FloatMap are multiplied.

       Min: n/a
       Max: n/a
   Default: 1.0
  Identity: 1.0
 

1.0  
publicwrapBooleanfalse

Defines whether values taken from outside the edges of the map "wrap around" or not.

Defines whether values taken from outside the edges of the map "wrap around" or not.

       Min:  n/a
       Max:  n/a
   Default: false
  Identity:  n/a
 

false  

Inherited Variables

Function Summary

public impl_getImpl() : com.sun.scenario.effect.Effect
Returns
Effect
 

Inherited Functions

javafx.scene.effect.Effect

public getAccelType(config: java.awt.GraphicsConfiguration) : java.lang.String

Returns a String representing the type of hardware acceleration, if any, that is used when applying this Effect on the given GraphicsConfiguration.

Returns a String representing the type of hardware acceleration, if any, that is used when applying this Effect on the given GraphicsConfiguration. This method is intended for informational or debugging purposes only.

Parameters
config
Returns
String
 
public abstract impl_getImpl() : com.sun.scenario.effect.Effect
Returns
Effect