public static Node createIconContent() { javafx.scene.Group g = new javafx.scene.Group( createKey("A", 0d, 28d), createKey("S", 25d, 28d), createKey("D", 50d, 28d), createKey("W", 20d, 0d) ); g.setLayoutX(30); g.setLayoutY(20); PerspectiveTransform pt = new PerspectiveTransform(); pt.setLlx(0); pt.setLly(90); pt.setLrx(90); pt.setLry(90); pt.setUlx(15); pt.setUly(10); pt.setUrx(80); pt.setUry(5); g.setEffect(pt); return g; }
static PerspectiveTransform computeEnd(ObservableValue<? extends Number> x, ObservableValue<? extends Number> y, ObservableValue<? extends Number> width, ObservableValue<? extends Number> height, ObservableValue<Pos> noEffectPos) { double ratioX = x.getValue().doubleValue() / width.getValue().doubleValue() * 3; double ratioY = y.getValue().doubleValue() / height.getValue().doubleValue() * 3; ObjectBinding<Perspective> perspective = Bindings.createObjectBinding(() -> new Perspective(ratioX, ratioY, width.getValue().doubleValue(), height.getValue().doubleValue(), noEffectPos.getValue()), width, height, noEffectPos); PerspectiveTransform effect = new PerspectiveTransform(); effect.ulxProperty().bind(createPerspectivePropertyBinding(p -> p.ulx, perspective)); effect.ulyProperty().bind(createPerspectivePropertyBinding(p -> p.uly, perspective)); effect.urxProperty().bind(createPerspectivePropertyBinding(p -> p.urx, perspective)); effect.uryProperty().bind(createPerspectivePropertyBinding(p -> p.ury, perspective)); effect.lrxProperty().bind(createPerspectivePropertyBinding(p -> p.lrx, perspective)); effect.lryProperty().bind(createPerspectivePropertyBinding(p -> p.lry, perspective)); effect.llxProperty().bind(createPerspectivePropertyBinding(p -> p.llx, perspective)); effect.llyProperty().bind(createPerspectivePropertyBinding(p -> p.lly, perspective)); return effect; }
/** Draws the current image. * @param topLeft where the top-left corner of the current image should be rendered * @param topRight where the top-right corner of the current image should be rendered * @param bottomRight where the bottom-right corner of the current image should be rendered * @param bottomLeft where the bottom-left corner of the current image should be rendered */ public void drawImage(Point2D topLeft, Point2D topRight, Point2D bottomRight, Point2D bottomLeft) { ensureRealized(); PerspectiveTransform t = new PerspectiveTransform(); t.setUlx(topLeft.getX()); t.setUly(topLeft.getY()); t.setUrx(topRight.getX()); t.setUry(topRight.getY()); t.setLrx(bottomRight.getX()); t.setLry(bottomRight.getY()); t.setLlx(bottomLeft.getX()); t.setLly(bottomLeft.getY()); context.setEffect(t); context.drawImage(currentImage, 0, 0); if (autoFlush) { flush(); } }
private void initShadowOverlay() { transformLeft = new PerspectiveTransform(); transformRight = new PerspectiveTransform(); leftImage = new ImageView(); leftImage.setFitWidth(PREF_PANE_WIDTH); leftImage.setFitHeight(SIZE.getHeight()); leftImage.setEffect(transformLeft); leftImage.setMouseTransparent(true); rightImage = new ImageView(); rightImage.setFitWidth(PREF_PANE_WIDTH); rightImage.setFitHeight(SIZE.getHeight()); rightImage.setEffect(transformRight); rightImage.setMouseTransparent(true); shadowRect = new Rectangle(SIZE.getWidth() * 0.45, SIZE.getHeight()); shadowRect.setFill(Color.BLACK); shadowRect.setOpacity(SHADOW_OPACITY); shadowRect.setEffect(transformRight); shadowOverlay = new Pane(); shadowOverlay.setPrefSize(0, SIZE.getHeight()); shadowOverlay.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY))); shadowOverlay.getChildren().addAll(leftImage, rightImage, shadowRect); }
List<NamedEffect> getNamedEffectList() { List<NamedEffect> nes = new ArrayList<NamedEffect>(); PerspectiveTransform pt = new PerspectiveTransform(); pt.setUlx(10); pt.setUly(10); pt.setUrx(150); pt.setUry(50); pt.setLrx(150); pt.setLry(100); pt.setLlx(10); pt.setLly(70); nes.add(new NamedEffect("perspective", pt)); return nes; }
private void showEffect() { if (showTileEffectProperty.get()) { ObservableValue<Double> xConstant = FxConstants.object(mouseX.get()); ObservableValue<Double> yConstant = FxConstants.object(mouseY.get()); PerspectiveTransform transform = TilePerspectiveUtils.computeEnd(xConstant, yConstant, widthProperty(), heightProperty(), noEffectPosProperty); setEffect(transform); } }