public static Node createIconContent() { QuadCurve quadCurve = new QuadCurve(); quadCurve.setStartX(0); quadCurve.setStartY(50); quadCurve.setControlX(20); quadCurve.setControlY(0); quadCurve.setEndX(80); quadCurve.setEndY(50); quadCurve.setStroke(Color.web("#b9c0c5")); quadCurve.setStrokeWidth(5); quadCurve.getStrokeDashArray().addAll(15d,15d); quadCurve.setFill(null); javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow(); effect.setOffsetX(1); effect.setOffsetY(1); effect.setRadius(3); effect.setColor(Color.rgb(0,0,0,0.6)); quadCurve.setEffect(effect); return quadCurve; }
public static String convertQuadCurve(final QuadCurve QUAD_CURVE) { final StringBuilder fxPath = new StringBuilder(); fxPath .append("M ") .append(QUAD_CURVE.getStartX()) .append(" ") .append(QUAD_CURVE.getStartY()) .append(" ") .append("Q ") .append(QUAD_CURVE.getControlX()) .append(" ") .append(QUAD_CURVE.getControlY()) .append(QUAD_CURVE.getEndX()) .append(" ") .append(QUAD_CURVE.getEndY()); return fxPath.toString(); }
private Node buildArc(Point2D point, Node n1, Node n2, boolean bigDestination, boolean bigSource) { final int sourceRadius = bigSource ? BIG_RADIUS : SMALL_RADIUS; final int destRadius = bigDestination ? BIG_RADIUS : SMALL_RADIUS; final QuadCurve cubic = new QuadCurve(); cubic.startXProperty().bind(n1.layoutXProperty().add(destRadius)); cubic.startYProperty().bind(n1.layoutYProperty().add(destRadius)); cubic.endXProperty().bind(n2.layoutXProperty().add(sourceRadius)); cubic.endYProperty().bind(n2.layoutYProperty().add(sourceRadius)); cubic.setControlX(point.getX()); cubic.setControlY(0); cubic.setFill(Color.TRANSPARENT); cubic.setStrokeWidth(4); cubic.setStroke(Color.WHITE); // cubic.setEffect(getDropShadow()); cubic.setOpacity(0.0); linkLayer.getChildren().add(cubic); return cubic; }
public QuadCurveSample() { super(180,90); // Create quadCurve shape QuadCurve quadCurve = new QuadCurve(); quadCurve.setStartX(0); quadCurve.setStartY(45); quadCurve.setControlX(50); quadCurve.setControlY(10); quadCurve.setEndX(180); quadCurve.setEndY(45); quadCurve.setStroke(Color.RED); quadCurve.setFill(Color.ROSYBROWN); quadCurve.setStrokeWidth(2d); // show the quadCurve shape; getChildren().add(quadCurve); // REMOVE ME setControls( new SimplePropertySheet.PropDesc("Cubic Curve Fill", quadCurve.fillProperty()), new SimplePropertySheet.PropDesc("Cubic Curve Stroke", quadCurve.strokeProperty()), new SimplePropertySheet.PropDesc("Cubic Curve Start X", quadCurve.startXProperty(), 0d, 170d), new SimplePropertySheet.PropDesc("Cubic Curve Start Y", quadCurve.startYProperty(), 10d, 80d), new SimplePropertySheet.PropDesc("Cubic Curve Control X1", quadCurve.controlXProperty(), 0d, 180d), new SimplePropertySheet.PropDesc("Cubic Curve Control Y1", quadCurve.controlYProperty(), 0d, 90d), new SimplePropertySheet.PropDesc("Cubic Curve End X", quadCurve.endXProperty(), 10d, 180d), new SimplePropertySheet.PropDesc("Cubic Curve End Y", quadCurve.endYProperty(), 10d, 80d) ); // END REMOVE ME }
@Override protected void initUI() { Text text = getUIFactory().newText("Level 1", Color.WHITE, 48); getGameScene().addUINode(text); QuadCurve curve = new QuadCurve(-100, 0, getWidth() / 2, getHeight(), getWidth() + 100, 0); PathTransition transition = new PathTransition(Duration.seconds(4), curve, text); transition.setOnFinished(e -> { getGameScene().removeUINode(text); getBallControl().release(); }); transition.play(); }
@Override public void init() { double t = 0; for (int y = 0; y < ENEMY_ROWS; y++) { for (int x = 0; x < ENEMIES_PER_ROW; x++) { final int finalY = y; FXGL.getMasterTimer().runOnceAfter(() -> { Entity enemy = spawnEnemy(50, 50 + finalY*50); QuadCurve path = new QuadCurve(50, 50 + finalY*50, 250, 200 + finalY * 20, Config.WIDTH - 50 - 40, 50 + finalY*50); Animation<?> anim = Entities.animationBuilder() .autoReverse(true) .interpolator(Interpolators.BACK.EASE_IN_OUT()) .duration(Duration.seconds(3)) .repeat(Integer.MAX_VALUE) .translate(enemy) .alongPath(path) .buildAndPlay(); animations.add(anim); }, Duration.seconds(t)); t += 0.3; } } }
@Override protected void initGame() { player = Entities.builder() .at(100, 100) .viewFromNode(new Rectangle(40, 40)) .buildAndAttach(getGameWorld()); Animation<?> animation = Entities.animationBuilder() .duration(Duration.seconds(1)) .repeat(1) .rotate(player) .rotateTo(360) .build(); animation.setCycleCount(2); animation.setAutoReverse(true); animation.startInPlayState(); Entities.animationBuilder() .duration(Duration.seconds(3)) .repeat(2) .delay(Duration.millis(1002)) .interpolator(Interpolator.EASE_OUT) .translate(player) .alongPath(new QuadCurve(33, 33, 450, 544, 750, 4)) .buildAndPlay(); }
public static String shapeToSvgString(final Shape SHAPE) { final StringBuilder fxPath = new StringBuilder(); if (Line.class.equals(SHAPE.getClass())) { fxPath.append(convertLine((Line) SHAPE)); } else if (Arc.class.equals(SHAPE.getClass())) { fxPath.append(convertArc((Arc) SHAPE)); } else if (QuadCurve.class.equals(SHAPE.getClass())) { fxPath.append(convertQuadCurve((QuadCurve) SHAPE)); } else if (CubicCurve.class.equals(SHAPE.getClass())) { fxPath.append(convertCubicCurve((CubicCurve) SHAPE)); } else if (Rectangle.class.equals(SHAPE.getClass())) { fxPath.append(convertRectangle((Rectangle) SHAPE)); } else if (Circle.class.equals(SHAPE.getClass())) { fxPath.append(convertCircle((Circle) SHAPE)); } else if (Ellipse.class.equals(SHAPE.getClass())) { fxPath.append(convertEllipse((Ellipse) SHAPE)); } else if (Text.class.equals(SHAPE.getClass())) { Path path = (Path)(Shape.subtract(SHAPE, new Rectangle(0, 0))); fxPath.append(convertPath(path)); } else if (Path.class.equals(SHAPE.getClass())) { fxPath.append(convertPath((Path) SHAPE)); } else if (Polygon.class.equals(SHAPE.getClass())) { fxPath.append(convertPolygon((Polygon) SHAPE)); } else if (Polyline.class.equals(SHAPE.getClass())) { fxPath.append(convertPolyline((Polyline) SHAPE)); } else if (SVGPath.class.equals(SHAPE.getClass())) { fxPath.append(((SVGPath) SHAPE).getContent()); } return fxPath.toString(); }
public static String convertQuadCurve(final QuadCurve QUAD_CURVE) { final StringBuilder fxPath = new StringBuilder(); fxPath.append("M ").append(QUAD_CURVE.getStartX()).append(" ").append(QUAD_CURVE.getStartY()).append(" ") .append("Q ").append(QUAD_CURVE.getControlX()).append(" ").append(QUAD_CURVE.getControlY()) .append(QUAD_CURVE.getEndX()).append(" ").append(QUAD_CURVE.getEndY()); return fxPath.toString(); }
@Test public void testGetQuadCurveAdjuster() { Adjuster adjuster = Adjuster.getAdjuster(QuadCurve.class); assertThat(adjuster, is(instanceOf(QuadCurveAdjuster.class))); assertThat(adjuster.getNodeClass(), is(sameInstance(QuadCurve.class))); }
@Override public QuadCurve getLine() { return line; }
@Override public Class<? extends Node> getNodeClass() { return QuadCurve.class; }
QuadCurve getLine();