Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
GroovyFX.start({
def sg = new SceneGraphBuilder(it);
DisplacementMap
displacementMap(int w, int h) {
    FloatMap map FloatMap mapData = new FloatMap();
    mapmapData.setWidth(w220);
    mapmapData.setHeight(h100);

  for  for (int i = 0; i < w220; i++) {
        double double v = (Math.sin(i / 50.0 * Math.PI) - 0.5) / 40.0;
        for for (int j = 0; j < h100; j++) {
            map   mapData.setSamples(i, j, 0.0f, (float) v);
         }
    }

  
 DisplacementMap dm = new DisplacementMap();
    dm.setMapData(map);

    return dm;

}
sg.stage(
    title: "DisplacementMap Effect Example",
    x: 100, y: 100, width: 400, height:400,
    visible: true,
    style: "decorated",
) {

    scene(fill: hsb(128, 0.5, 0.5, 0.5) ) {
        text(content: "Blurry Text!", fill: "red", font: "bold 36pt", x: 10, y: 10, textOrigin: "top") {
            displacementMap(mapData: mapData)
        }
    }
}

});