Search in sources :

Example 1 with QuadCurveTo

use of javafx.scene.shape.QuadCurveTo in project FXyzLib by Birdasaur.

the class Text3DHelper method getPoints.

private void getPoints(PathElement elem) {
    if (elem instanceof MoveTo) {
        list = new ArrayList<>();
        p0 = new Point3D((float) ((MoveTo) elem).getX(), (float) ((MoveTo) elem).getY(), 0f);
        list.add(p0);
    } else if (elem instanceof LineTo) {
        list.add(new Point3D((float) ((LineTo) elem).getX(), (float) ((LineTo) elem).getY(), 0f));
    } else if (elem instanceof CubicCurveTo) {
        Point3D ini = (list.size() > 0 ? list.get(list.size() - 1) : p0);
        IntStream.rangeClosed(1, POINTS_CURVE).forEach(i -> list.add(evalCubicBezier((CubicCurveTo) elem, ini, ((double) i) / POINTS_CURVE)));
    } else if (elem instanceof QuadCurveTo) {
        Point3D ini = (list.size() > 0 ? list.get(list.size() - 1) : p0);
        IntStream.rangeClosed(1, POINTS_CURVE).forEach(i -> list.add(evalQuadBezier((QuadCurveTo) elem, ini, ((double) i) / POINTS_CURVE)));
    } else if (elem instanceof ClosePath) {
        list.add(p0);
        // stored in a LineSegment: a continuous line that can change direction
        if (Math.abs(getArea()) > 0.001) {
            LineSegment line = new LineSegment(text);
            line.setHole(isHole());
            line.setPoints(list);
            line.setPath(generatePath());
            line.setOrigen(p0);
            polis.add(line);
        }
    }
}
Also used : IntStream(java.util.stream.IntStream) Path(javafx.scene.shape.Path) QuadCurveTo(javafx.scene.shape.QuadCurveTo) Color(javafx.scene.paint.Color) ClosePath(javafx.scene.shape.ClosePath) CubicCurveTo(javafx.scene.shape.CubicCurveTo) LineTo(javafx.scene.shape.LineTo) Font(javafx.scene.text.Font) PathElement(javafx.scene.shape.PathElement) Rectangle(javafx.scene.shape.Rectangle) DoubleProperty(javafx.beans.property.DoubleProperty) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Text(javafx.scene.text.Text) List(java.util.List) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) MoveTo(javafx.scene.shape.MoveTo) Point2D(javafx.geometry.Point2D) Shape(javafx.scene.shape.Shape) Point3D(org.fxyz.geometry.Point3D) ClosePath(javafx.scene.shape.ClosePath) MoveTo(javafx.scene.shape.MoveTo) LineTo(javafx.scene.shape.LineTo) QuadCurveTo(javafx.scene.shape.QuadCurveTo) Point3D(org.fxyz.geometry.Point3D) CubicCurveTo(javafx.scene.shape.CubicCurveTo)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 DoubleProperty (javafx.beans.property.DoubleProperty)1 SimpleDoubleProperty (javafx.beans.property.SimpleDoubleProperty)1 Point2D (javafx.geometry.Point2D)1 Color (javafx.scene.paint.Color)1 ClosePath (javafx.scene.shape.ClosePath)1 CubicCurveTo (javafx.scene.shape.CubicCurveTo)1 LineTo (javafx.scene.shape.LineTo)1 MoveTo (javafx.scene.shape.MoveTo)1 Path (javafx.scene.shape.Path)1 PathElement (javafx.scene.shape.PathElement)1 QuadCurveTo (javafx.scene.shape.QuadCurveTo)1 Rectangle (javafx.scene.shape.Rectangle)1 Shape (javafx.scene.shape.Shape)1 Font (javafx.scene.text.Font)1 Text (javafx.scene.text.Text)1 Point3D (org.fxyz.geometry.Point3D)1