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
access | name | type | Can Read | Can Init | Can Write | Default Value | description |
---|---|---|---|---|---|---|---|
public | input | Effect | null |
The input for this The input for this |
|||
public | mapData | FloatMap | an empty map |
The map data for this |
|||
public | offsetX | Number | 0.0 |
The offset by which all x coordinate offset values in the
The offset by which all x coordinate offset values in the
Min: n/a Max: n/a Default: 0.0 Identity: 0.00.0 |
|||
public | offsetY | Number | 0.0 |
The offset by which all y coordinate offset values in the
The offset by which all y coordinate offset values in the
Min: n/a Max: n/a Default: 0.0 Identity: 0.00.0 |
|||
public | scaleX | Number | 1.0 |
The scale factor by which all x coordinate offset values in the
The scale factor by which all x coordinate offset values in the
Min: n/a Max: n/a Default: 1.0 Identity: 1.01.0 |
|||
public | scaleY | Number | 1.0 |
The scale factor by which all y coordinate offset values in the
The scale factor by which all y coordinate offset values in the
Min: n/a Max: n/a Default: 1.0 Identity: 1.01.0 |
|||
public | wrap | Boolean | false |
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/afalse |
Inherited Variables
Function Summary
- public impl_getImpl() : com.sun.scenario.effect.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 thisEffect
on the givenGraphicsConfiguration
.Returns a
String
representing the type of hardware acceleration, if any, that is used when applying thisEffect
on the givenGraphicsConfiguration
. This method is intended for informational or debugging purposes only.-
Parameters
- config
-
Returns
- String
- public abstract impl_getImpl() : com.sun.scenario.effect.Effect