Search in sources :

Example 11 with CubicCurveTo

use of javafx.scene.shape.CubicCurveTo 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)

Example 12 with CubicCurveTo

use of javafx.scene.shape.CubicCurveTo in project tilesfx by HanSolo.

the class StockTileSkin method drawTriangle.

private void drawTriangle() {
    MoveTo moveTo = new MoveTo(0.056 * size * 0.5, 0.032 * size * 0.5);
    CubicCurveTo cubicCurveTo1 = new CubicCurveTo(0.060 * size * 0.5, 0.028 * size * 0.5, 0.064 * size * 0.5, 0.028 * size * 0.5, 0.068 * size * 0.5, 0.032 * size * 0.5);
    CubicCurveTo cubicCurveTo2 = new CubicCurveTo(0.068 * size * 0.5, 0.032 * size * 0.5, 0.120 * size * 0.5, 0.080 * size * 0.5, 0.12 * size * 0.5, 0.080 * size * 0.5);
    CubicCurveTo cubicCurveTo3 = new CubicCurveTo(0.128 * size * 0.5, 0.088 * size * 0.5, 0.124 * size * 0.5, 0.096 * size * 0.5, 0.112 * size * 0.5, 0.096 * size * 0.5);
    CubicCurveTo cubicCurveTo4 = new CubicCurveTo(0.112 * size * 0.5, 0.096 * size * 0.5, 0.012 * size * 0.5, 0.096 * size * 0.5, 0.012 * size * 0.5, 0.096 * size * 0.5);
    CubicCurveTo cubicCurveTo5 = new CubicCurveTo(0.0, 0.096 * size * 0.5, -0.004 * size * 0.5, 0.088 * size * 0.5, 0.004 * size * 0.5, 0.080 * size * 0.5);
    CubicCurveTo cubicCurveTo6 = new CubicCurveTo(0.004 * size * 0.5, 0.080 * size * 0.5, 0.056 * size * 0.5, 0.032 * size * 0.5, 0.056 * size * 0.5, 0.032 * size * 0.5);
    ClosePath closePath = new ClosePath();
    triangle.getElements().setAll(moveTo, cubicCurveTo1, cubicCurveTo2, cubicCurveTo3, cubicCurveTo4, cubicCurveTo5, cubicCurveTo6, closePath);
}
Also used : ClosePath(javafx.scene.shape.ClosePath) MoveTo(javafx.scene.shape.MoveTo) CubicCurveTo(javafx.scene.shape.CubicCurveTo)

Example 13 with CubicCurveTo

use of javafx.scene.shape.CubicCurveTo in project tilesfx by HanSolo.

the class GaugeTileSkin method drawNeedle.

private void drawNeedle() {
    double needleWidth = size * 0.05;
    double needleHeight = size * 0.3325;
    needle.setCache(false);
    needle.getElements().clear();
    needle.getElements().add(new MoveTo(0.25 * needleWidth, 0.924812030075188 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.25 * needleWidth, 0.9022556390977443 * needleHeight, 0.35 * needleWidth, 0.8872180451127819 * needleHeight, 0.5 * needleWidth, 0.8872180451127819 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.65 * needleWidth, 0.8872180451127819 * needleHeight, 0.75 * needleWidth, 0.9022556390977443 * needleHeight, 0.75 * needleWidth, 0.924812030075188 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.75 * needleWidth, 0.9473684210526315 * needleHeight, 0.65 * needleWidth, 0.9624060150375939 * needleHeight, 0.5 * needleWidth, 0.9624060150375939 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.35 * needleWidth, 0.9624060150375939 * needleHeight, 0.25 * needleWidth, 0.9473684210526315 * needleHeight, 0.25 * needleWidth, 0.924812030075188 * needleHeight));
    needle.getElements().add(new ClosePath());
    needle.getElements().add(new MoveTo(0.0, 0.924812030075188 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.0, 0.9699248120300752 * needleHeight, 0.2 * needleWidth, needleHeight, 0.5 * needleWidth, needleHeight));
    needle.getElements().add(new CubicCurveTo(0.8 * needleWidth, needleHeight, needleWidth, 0.9699248120300752 * needleHeight, needleWidth, 0.924812030075188 * needleHeight));
    needle.getElements().add(new CubicCurveTo(needleWidth, 0.8947368421052632 * needleHeight, 0.85 * needleWidth, 0.8646616541353384 * needleHeight, 0.65 * needleWidth, 0.849624060150376 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.65 * needleWidth, 0.849624060150376 * needleHeight, 0.65 * needleWidth, 0.022556390977443608 * needleHeight, 0.65 * needleWidth, 0.022556390977443608 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.65 * needleWidth, 0.007518796992481203 * needleHeight, 0.6 * needleWidth, 0.0, 0.5 * needleWidth, 0.0));
    needle.getElements().add(new CubicCurveTo(0.4 * needleWidth, 0.0, 0.35 * needleWidth, 0.007518796992481203 * needleHeight, 0.35 * needleWidth, 0.022556390977443608 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.35 * needleWidth, 0.022556390977443608 * needleHeight, 0.35 * needleWidth, 0.849624060150376 * needleHeight, 0.35 * needleWidth, 0.849624060150376 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.15 * needleWidth, 0.8646616541353384 * needleHeight, 0.0, 0.8947368421052632 * needleHeight, 0.0, 0.924812030075188 * needleHeight));
    needle.getElements().add(new ClosePath());
    needle.setCache(true);
    needle.setCacheHint(CacheHint.ROTATE);
}
Also used : ClosePath(javafx.scene.shape.ClosePath) MoveTo(javafx.scene.shape.MoveTo) CubicCurveTo(javafx.scene.shape.CubicCurveTo)

Example 14 with CubicCurveTo

use of javafx.scene.shape.CubicCurveTo in project tilesfx by HanSolo.

the class GaugeTileSkin method drawAlertIcon.

private void drawAlertIcon() {
    alertIcon.setCache(false);
    double iconWidth = size * 0.155;
    double iconHeight = size * 0.135;
    alertIcon.getElements().clear();
    alertIcon.getElements().add(new MoveTo(0.4411764705882353 * iconWidth, 0.3380952380952381 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.4411764705882353 * iconWidth, 0.3 * iconHeight, 0.4684873949579832 * iconWidth, 0.2714285714285714 * iconHeight, 0.5 * iconWidth, 0.2714285714285714 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.5315126050420168 * iconWidth, 0.2714285714285714 * iconHeight, 0.5588235294117647 * iconWidth, 0.3 * iconHeight, 0.5588235294117647 * iconWidth, 0.3380952380952381 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.5588235294117647 * iconWidth, 0.3380952380952381 * iconHeight, 0.5588235294117647 * iconWidth, 0.6 * iconHeight, 0.5588235294117647 * iconWidth, 0.6 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.5588235294117647 * iconWidth, 0.6357142857142857 * iconHeight, 0.5315126050420168 * iconWidth, 0.6666666666666666 * iconHeight, 0.5 * iconWidth, 0.6666666666666666 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.4684873949579832 * iconWidth, 0.6666666666666666 * iconHeight, 0.4411764705882353 * iconWidth, 0.6357142857142857 * iconHeight, 0.4411764705882353 * iconWidth, 0.6 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.4411764705882353 * iconWidth, 0.6 * iconHeight, 0.4411764705882353 * iconWidth, 0.3380952380952381 * iconHeight, 0.4411764705882353 * iconWidth, 0.3380952380952381 * iconHeight));
    alertIcon.getElements().add(new ClosePath());
    alertIcon.getElements().add(new MoveTo(0.4411764705882353 * iconWidth, 0.8 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.4411764705882353 * iconWidth, 0.7642857142857142 * iconHeight, 0.4684873949579832 * iconWidth, 0.7333333333333333 * iconHeight, 0.5 * iconWidth, 0.7333333333333333 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.5315126050420168 * iconWidth, 0.7333333333333333 * iconHeight, 0.5588235294117647 * iconWidth, 0.7642857142857142 * iconHeight, 0.5588235294117647 * iconWidth, 0.8 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.5588235294117647 * iconWidth, 0.8380952380952381 * iconHeight, 0.5315126050420168 * iconWidth, 0.8666666666666667 * iconHeight, 0.5 * iconWidth, 0.8666666666666667 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.4684873949579832 * iconWidth, 0.8666666666666667 * iconHeight, 0.4411764705882353 * iconWidth, 0.8380952380952381 * iconHeight, 0.4411764705882353 * iconWidth, 0.8 * iconHeight));
    alertIcon.getElements().add(new ClosePath());
    alertIcon.getElements().add(new MoveTo(0.5504201680672269 * iconWidth, 0.04285714285714286 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.523109243697479 * iconWidth, -0.011904761904761904 * iconHeight, 0.47689075630252103 * iconWidth, -0.011904761904761904 * iconHeight, 0.4495798319327731 * iconWidth, 0.04285714285714286 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.4495798319327731 * iconWidth, 0.04285714285714286 * iconHeight, 0.012605042016806723 * iconWidth, 0.9 * iconHeight, 0.012605042016806723 * iconWidth, 0.9 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(-0.014705882352941176 * iconWidth, 0.9547619047619048 * iconHeight, 0.0063025210084033615 * iconWidth, iconHeight, 0.06302521008403361 * iconWidth, iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.06302521008403361 * iconWidth, iconHeight, 0.9369747899159664 * iconWidth, iconHeight, 0.9369747899159664 * iconWidth, iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.9936974789915967 * iconWidth, iconHeight, 1.0147058823529411 * iconWidth, 0.9547619047619048 * iconHeight, 0.9873949579831933 * iconWidth, 0.9 * iconHeight));
    alertIcon.getElements().add(new CubicCurveTo(0.9873949579831933 * iconWidth, 0.9 * iconHeight, 0.5504201680672269 * iconWidth, 0.04285714285714286 * iconHeight, 0.5504201680672269 * iconWidth, 0.04285714285714286 * iconHeight));
    alertIcon.getElements().add(new ClosePath());
    alertIcon.setCache(true);
    alertIcon.setCacheHint(CacheHint.SPEED);
}
Also used : ClosePath(javafx.scene.shape.ClosePath) MoveTo(javafx.scene.shape.MoveTo) CubicCurveTo(javafx.scene.shape.CubicCurveTo)

Aggregations

CubicCurveTo (javafx.scene.shape.CubicCurveTo)14 MoveTo (javafx.scene.shape.MoveTo)13 ClosePath (javafx.scene.shape.ClosePath)9 LineTo (javafx.scene.shape.LineTo)8 Path (javafx.scene.shape.Path)4 PathElement (javafx.scene.shape.PathElement)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 QuadCurveTo (javafx.scene.shape.QuadCurveTo)2 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 ArcTo (javafx.scene.shape.ArcTo)1 HLineTo (javafx.scene.shape.HLineTo)1 Rectangle (javafx.scene.shape.Rectangle)1 SVGPath (javafx.scene.shape.SVGPath)1 Shape (javafx.scene.shape.Shape)1