43 * An effect that shifts each pixel by a distance specified by 44 * the first two bands of of the specified {@link FloatMap}. 45 * For each pixel in the output, the corresponding data from the 46 * {@code mapData} is retrieved, scaled and offset by the {@code scale} 47 * and {@code offset} attributes, scaled again by the size of the 48 * source input image and used as an offset from the destination pixel 49 * to retrieve the pixel data from the source input. 50 * <pre> 51 * dst[x,y] = src[(x,y) + (offset+scale*map[x,y])*(srcw,srch)] 52 * </pre> 53 * A value of {@code (0.0, 0.0)} would specify no offset for the 54 * pixel data whereas a value of {@code (0.5, 0.5)} would specify 55 * an offset of half of the source image size. 56 * <p> 57 * <b>Note</b> that the mapping is the offset from a destination pixel to 58 * the source pixel location from which it is sampled which means that 59 * filling the map with all values of {@code 0.5} would displace the 60 * image by half of its size towards the upper left since each destination 61 * pixel would contain the data that comes from the source pixel below and 62 * to the right of it. 63 * <p> 64 * Also note that this effect does not adjust the coordinates of input 65 * events or any methods that measure containment on a {@code Node}. 66 * The results of mouse picking and the containment methods are undefined 67 * when a {@code Node} has a {@code DisplacementMap} effect in place. 68 * 69 * <p> 70 * Example: 71 * <pre><code> 72 * int width = 220; 73 * int height = 100; 74 * 75 * FloatMap floatMap = new FloatMap(); 76 * floatMap.setWidth(width); 77 * floatMap.setHeight(height); 78 * 79 * for (int i = 0; i < width; i++) { 80 * double v = (Math.sin(i / 20.0 * Math.PI) - 0.5) / 40.0; 81 * for (int j = 0; j < height; j++) { 82 * floatMap.setSamples(i, j, 0.0f, (float) v); 83 * } 84 * } 85 * 86 * DisplacementMap displacementMap = new DisplacementMap(); 87 * displacementMap.setMapData(floatMap); 88 * 89 * Text text = new Text(); 90 * text.setX(40.0); 91 * text.setY(80.0); 92 * text.setText("Wavy Text"); 93 * text.setFill(Color.web("0x3b596d")); 94 * text.setFont(Font.font(null, FontWeight.BOLD, 50)); 95 * text.setEffect(displacementMap); 96 * 97 * </pre></code> 98 * 99 * <p> The code above produces the following: </p> 100 * <p> <img src="doc-files/displacementmap.png"/> </p> 101 * @since JavaFX 2.0 | 43 * An effect that shifts each pixel by a distance specified by 44 * the first two bands of of the specified {@link FloatMap}. 45 * For each pixel in the output, the corresponding data from the 46 * {@code mapData} is retrieved, scaled and offset by the {@code scale} 47 * and {@code offset} attributes, scaled again by the size of the 48 * source input image and used as an offset from the destination pixel 49 * to retrieve the pixel data from the source input. 50 * <pre> 51 * dst[x,y] = src[(x,y) + (offset+scale*map[x,y])*(srcw,srch)] 52 * </pre> 53 * A value of {@code (0.0, 0.0)} would specify no offset for the 54 * pixel data whereas a value of {@code (0.5, 0.5)} would specify 55 * an offset of half of the source image size. 56 * <p> 57 * <b>Note</b> that the mapping is the offset from a destination pixel to 58 * the source pixel location from which it is sampled which means that 59 * filling the map with all values of {@code 0.5} would displace the 60 * image by half of its size towards the upper left since each destination 61 * pixel would contain the data that comes from the source pixel below and 62 * to the right of it. 63 * </p> 64 * <p> 65 * Also note that this effect does not adjust the coordinates of input 66 * events or any methods that measure containment on a {@code Node}. 67 * The results of mouse picking and the containment methods are undefined 68 * when a {@code Node} has a {@code DisplacementMap} effect in place. 69 * </p> 70 * <p> 71 * Example: 72 * <pre><code> 73 * int width = 220; 74 * int height = 100; 75 * 76 * FloatMap floatMap = new FloatMap(); 77 * floatMap.setWidth(width); 78 * floatMap.setHeight(height); 79 * 80 * for (int i = 0; i < width; i++) { 81 * double v = (Math.sin(i / 20.0 * Math.PI) - 0.5) / 40.0; 82 * for (int j = 0; j < height; j++) { 83 * floatMap.setSamples(i, j, 0.0f, (float) v); 84 * } 85 * } 86 * 87 * DisplacementMap displacementMap = new DisplacementMap(); 88 * displacementMap.setMapData(floatMap); 89 * 90 * Text text = new Text(); 91 * text.setX(40.0); 92 * text.setY(80.0); 93 * text.setText("Wavy Text"); 94 * text.setFill(Color.web("0x3b596d")); 95 * text.setFont(Font.font(null, FontWeight.BOLD, 50)); 96 * text.setEffect(displacementMap); 97 * 98 * </pre></code> 99 * 100 * <p> The code above produces the following: </p> 101 * <p> <img src="doc-files/displacementmap.png"/> </p> 102 * @since JavaFX 2.0 |