List of usage examples for javafx.scene.effect FloatMap setSamples
public void setSamples(int x, int y, float s0, float s1)
From source file:Main.java
static Node displacementMap() { int w = 220;//from w w w .jav a2 s . c o m int h = 100; FloatMap map = new FloatMap(); map.setWidth(w); map.setHeight(h); for (int i = 0; i < w; i++) { double v = (Math.sin(i / 50.0 * Math.PI) - 0.5) / 40.0; for (int j = 0; j < h; j++) { map.setSamples(i, j, 0.0f, (float) v); } } Group g = new Group(); DisplacementMap dm = new DisplacementMap(); dm.setMapData(map); Rectangle r = new Rectangle(); r.setX(20.0f); r.setY(20.0f); r.setWidth(w); r.setHeight(h); r.setFill(Color.BLUE); g.getChildren().add(r); Text t = new Text(); t.setX(40.0f); t.setY(80.0f); t.setText("Wavy Text"); t.setFill(Color.YELLOW); t.setFont(Font.font("null", FontWeight.BOLD, 36)); g.getChildren().add(t); g.setEffect(dm); g.setCache(true); g.setTranslateX(400); g.setTranslateY(200); return g; }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle(""); Group root = new Group(); Scene scene = new Scene(root, 300, 250, Color.WHITE); int w = 220;//from w ww .j a v a 2s . c om int h = 100; FloatMap map = new FloatMap(); map.setWidth(w); map.setHeight(h); for (int i = 0; i < w; i++) { double v = (Math.sin(i / 20.0 * Math.PI) - 0.5) / 40.0; for (int j = 0; j < h; j++) { map.setSamples(i, j, 0.0f, (float) v); } } Group g = new Group(); DisplacementMap dm = new DisplacementMap(); dm.setMapData(map); g.setEffect(dm); g.setCache(true); Rectangle r = new Rectangle(); r.setX(20.0); r.setY(20.0); r.setWidth(w); r.setHeight(h); r.setFill(Color.BLUE); g.getChildren().add(r); Text t = new Text(); t.setX(40.0); t.setY(80.0); t.setText("Wavy Text"); t.setFill(Color.YELLOW); t.setFont(Font.font(null, FontWeight.BOLD, 36)); g.getChildren().add(t); root.getChildren().add(g); primaryStage.setScene(scene); primaryStage.show(); }