Search in sources :

Example 1 with CubicCurveTo

use of com.xenoage.zong.symbols.path.CubicCurveTo in project Zong by Xenoage.

the class SvgPathReader method cubicCurveTo.

private void cubicCurveTo(Point2f cp1, Point2f cp2, Point2f p) {
    pCurrent = p;
    elements.add(new CubicCurveTo(cp1, cp2, p));
}
Also used : CubicCurveTo(com.xenoage.zong.symbols.path.CubicCurveTo)

Example 2 with CubicCurveTo

use of com.xenoage.zong.symbols.path.CubicCurveTo in project Zong by Xenoage.

the class AwtPath method createShape.

public static Shape createShape(Path path) {
    GeneralPath shape = new GeneralPath();
    for (PathElement e : path.getElements()) {
        switch(e.getType()) {
            case ClosePath:
                shape.closePath();
                break;
            case CubicCurveTo:
                CubicCurveTo c = (CubicCurveTo) e;
                shape.curveTo(c.cp1.x, c.cp1.y, c.cp2.x, c.cp2.y, c.p.x, c.p.y);
                break;
            case LineTo:
                LineTo l = (LineTo) e;
                shape.lineTo(l.p.x, l.p.y);
                break;
            case MoveTo:
                MoveTo m = (MoveTo) e;
                shape.moveTo(m.p.x, m.p.y);
                break;
            case QuadraticCurveTo:
                QuadraticCurveTo q = (QuadraticCurveTo) e;
                shape.quadTo(q.cp.x, q.cp.y, q.p.x, q.p.y);
                break;
        }
    }
    return shape;
}
Also used : GeneralPath(java.awt.geom.GeneralPath) PathElement(com.xenoage.zong.symbols.path.PathElement) LineTo(com.xenoage.zong.symbols.path.LineTo) MoveTo(com.xenoage.zong.symbols.path.MoveTo) CubicCurveTo(com.xenoage.zong.symbols.path.CubicCurveTo) QuadraticCurveTo(com.xenoage.zong.symbols.path.QuadraticCurveTo)

Example 3 with CubicCurveTo

use of com.xenoage.zong.symbols.path.CubicCurveTo in project Zong by Xenoage.

the class JfxPath method drawPath.

public static void drawPath(Path path, GraphicsContext context) {
    context.beginPath();
    for (PathElement e : path.getElements()) {
        switch(e.getType()) {
            case ClosePath:
                context.closePath();
                break;
            case CubicCurveTo:
                CubicCurveTo c = (CubicCurveTo) e;
                context.bezierCurveTo(c.cp1.x, c.cp1.y, c.cp2.x, c.cp2.y, c.p.x, c.p.y);
                break;
            case LineTo:
                LineTo l = (LineTo) e;
                context.lineTo(l.p.x, l.p.y);
                break;
            case MoveTo:
                MoveTo m = (MoveTo) e;
                context.moveTo(m.p.x, m.p.y);
                break;
            case QuadraticCurveTo:
                QuadraticCurveTo q = (QuadraticCurveTo) e;
                context.quadraticCurveTo(q.cp.x, q.cp.y, q.p.x, q.p.y);
                break;
        }
    }
}
Also used : PathElement(com.xenoage.zong.symbols.path.PathElement) LineTo(com.xenoage.zong.symbols.path.LineTo) MoveTo(com.xenoage.zong.symbols.path.MoveTo) CubicCurveTo(com.xenoage.zong.symbols.path.CubicCurveTo) QuadraticCurveTo(com.xenoage.zong.symbols.path.QuadraticCurveTo)

Example 4 with CubicCurveTo

use of com.xenoage.zong.symbols.path.CubicCurveTo in project Zong by Xenoage.

the class SimpleSlurShape method createPath.

private Path createPath() {
    List<PathElement> elements = alist(5);
    float cap = interlineSpace / 4;
    elements.add(new MoveTo(p1top));
    // bezier curve from p1top to p2top
    elements.add(new CubicCurveTo(c1top, c2top, p2top));
    // cap at p2
    Point2f capDir = p2top.sub(c2top).normalize().scale(cap);
    elements.add(new CubicCurveTo(p2top.add(capDir), p2bottom.add(capDir), p2bottom));
    // bezier curve back from p2bottom to p1bottom
    elements.add(new CubicCurveTo(c2bottom, c1bottom, p1bottom));
    // cap at p1
    capDir = p1top.sub(c1top).normalize().scale(cap);
    elements.add(new CubicCurveTo(p1bottom.add(capDir), p1top.add(capDir), p1top));
    Path path = new Path(elements);
    return path;
}
Also used : Path(com.xenoage.zong.symbols.path.Path) Point2f(com.xenoage.utils.math.geom.Point2f) PathElement(com.xenoage.zong.symbols.path.PathElement) MoveTo(com.xenoage.zong.symbols.path.MoveTo) CubicCurveTo(com.xenoage.zong.symbols.path.CubicCurveTo)

Example 5 with CubicCurveTo

use of com.xenoage.zong.symbols.path.CubicCurveTo in project Zong by Xenoage.

the class AndroidPath method createPath.

public static Path createPath(com.xenoage.zong.symbols.path.Path path) {
    Path ret = new Path();
    for (PathElement e : path.getElements()) {
        switch(e.getType()) {
            case ClosePath:
                ret.close();
                break;
            case CubicCurveTo:
                CubicCurveTo c = (CubicCurveTo) e;
                ret.cubicTo(c.cp1.x, c.cp1.y, c.cp2.x, c.cp2.y, c.p.x, c.p.y);
                break;
            case LineTo:
                LineTo l = (LineTo) e;
                ret.lineTo(l.p.x, l.p.y);
                break;
            case MoveTo:
                MoveTo m = (MoveTo) e;
                ret.moveTo(m.p.x, m.p.y);
                break;
            case QuadraticCurveTo:
                QuadraticCurveTo q = (QuadraticCurveTo) e;
                ret.quadTo(q.cp.x, q.cp.y, q.p.x, q.p.y);
                break;
        }
    }
    return ret;
}
Also used : Path(android.graphics.Path) PathElement(com.xenoage.zong.symbols.path.PathElement) LineTo(com.xenoage.zong.symbols.path.LineTo) MoveTo(com.xenoage.zong.symbols.path.MoveTo) CubicCurveTo(com.xenoage.zong.symbols.path.CubicCurveTo) QuadraticCurveTo(com.xenoage.zong.symbols.path.QuadraticCurveTo)

Aggregations

CubicCurveTo (com.xenoage.zong.symbols.path.CubicCurveTo)5 MoveTo (com.xenoage.zong.symbols.path.MoveTo)4 PathElement (com.xenoage.zong.symbols.path.PathElement)4 LineTo (com.xenoage.zong.symbols.path.LineTo)3 QuadraticCurveTo (com.xenoage.zong.symbols.path.QuadraticCurveTo)3 Path (android.graphics.Path)1 Point2f (com.xenoage.utils.math.geom.Point2f)1 Path (com.xenoage.zong.symbols.path.Path)1 GeneralPath (java.awt.geom.GeneralPath)1