Example usage for com.lowagie.text.pdf PdfContentByte curveTo

List of usage examples for com.lowagie.text.pdf PdfContentByte curveTo

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfContentByte curveTo.

Prototype


public void curveTo(float x1, float y1, float x2, float y2, float x3, float y3) 

Source Link

Document

Appends a Bêzier curve to the path, starting from the current point.

Usage

From source file:org.xhtmlrenderer.pdf.ITextOutputDevice.java

License:Open Source License

private void followPath(Shape s, int drawType) {
    PdfContentByte cb = _currentPage;
    if (s == null)
        return;//from  w  ww.ja  v  a2  s  .com

    if (drawType == STROKE) {
        if (!(_stroke instanceof BasicStroke)) {
            s = _stroke.createStrokedShape(s);
            followPath(s, FILL);
            return;
        }
    }
    if (drawType == STROKE) {
        setStrokeDiff(_stroke, _oldStroke);
        _oldStroke = _stroke;
        ensureStrokeColor();
    } else if (drawType == FILL) {
        ensureFillColor();
    }

    PathIterator points;
    if (drawType == CLIP) {
        points = s.getPathIterator(IDENTITY);
    } else {
        points = s.getPathIterator(_transform);
    }
    float[] coords = new float[6];
    int traces = 0;
    while (!points.isDone()) {
        ++traces;
        int segtype = points.currentSegment(coords);
        normalizeY(coords);
        switch (segtype) {
        case PathIterator.SEG_CLOSE:
            cb.closePath();
            break;

        case PathIterator.SEG_CUBICTO:
            cb.curveTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);
            break;

        case PathIterator.SEG_LINETO:
            cb.lineTo(coords[0], coords[1]);
            break;

        case PathIterator.SEG_MOVETO:
            cb.moveTo(coords[0], coords[1]);
            break;

        case PathIterator.SEG_QUADTO:
            System.out.println("Quad to " + coords[0] + " " + coords[1] + " " + coords[2] + " " + coords[3]);
            cb.curveTo(coords[0], coords[1], coords[2], coords[3]);
            break;
        }
        points.next();
    }

    switch (drawType) {
    case FILL:
        if (traces > 0) {
            if (points.getWindingRule() == PathIterator.WIND_EVEN_ODD)
                cb.eoFill();
            else
                cb.fill();
        }
        break;
    case STROKE:
        if (traces > 0)
            cb.stroke();
        break;
    default: // drawType==CLIP
        if (traces == 0)
            cb.rectangle(0, 0, 0, 0);
        if (points.getWindingRule() == PathIterator.WIND_EVEN_ODD)
            cb.eoClip();
        else
            cb.clip();
        cb.newPath();
    }
}

From source file:questions.directcontent.Logo.java

public static void main(String[] args) {
    Rectangle rect = new Rectangle(36, 726, 136, 786);
    Document document = new Document(rect);
    try {/* w  w w . ja v  a 2  s .c  om*/
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT));
        document.open();
        PdfContentByte canvas = writer.getDirectContent();
        canvas.moveTo(63.73f, 735.47f);
        canvas.curveTo(72.13f, 737.94f, 75.73f, 758.15f, 79.67f, 768.04f);
        canvas.curveTo(84.82f, 767.79f, 94.41f, 772.38f, 85.69f, 772.97f);
        canvas.curveTo(83.19f, 768.56f, 63.84f, 779.61f, 60.55f, 779.7f);
        canvas.curveTo(48.58f, 780.03f, 74.62f, 769.75f, 74.68f, 769.99f);
        canvas.curveTo(74.64f, 769.8f, 69.43f, 743.55f, 66.08f, 740.12f);
        canvas.curveTo(59.24f, 733.11f, 52.73f, 745.57f, 53.35f, 752.21f);
        canvas.curveTo(53.6f, 754.85f, 64.32f, 747.14f, 57.21f, 755.02f);
        canvas.curveTo(45.66f, 767.82f, 49.11f, 731.17f, 63.73f, 735.47f);
        canvas.moveTo(93.61f, 741.57f);
        canvas.curveTo(109.15f, 721.02f, 112.42f, 746.51f, 118.3f, 761.57f);
        canvas.curveTo(124.73f, 761.48f, 129.8f, 765.3f, 124f, 765.62f);
        canvas.curveTo(119.84f, 761.88f, 108.12f, 770.22f, 100.92f, 771.57f);
        canvas.curveTo(94.24f, 769.12f, 115.02f, 764.34f, 114.24f, 761.53f);
        canvas.curveTo(109.9f, 751.94f, 107.5f, 721.65f, 95.84f, 744.74f);
        canvas.curveTo(100.15f, 747.38f, 109.63f, 766.92f, 95.28f, 748.57f);
        canvas.curveTo(91.45f, 743.68f, 89.6f, 766.35f, 77.99f, 754.83f);
        canvas.curveTo(74.22f, 751.07f, 84.27f, 747.81f, 81.6f, 745.28f);
        canvas.curveTo(67.39f, 750.93f, 74.66f, 719.55f, 93.61f, 741.57f);
        canvas.moveTo(78.37f, 743.72f);
        canvas.curveTo(78.19f, 743.22f, 89.27f, 744.04f, 82.46f, 749.7f);
        canvas.curveTo(76.28f, 754.83f, 85.17f, 760.2f, 90.72f, 746.97f);
        canvas.curveTo(94f, 739.15f, 73.88f, 730.88f, 78.37f, 743.72f);
        canvas.setCMYKColorFillF(1, 0.5f, 0, 0.467f);
        canvas.fill();
        canvas.setCMYKColorFillF(0, 0.467f, 1, 0);
        canvas.moveTo(58f, 764.8f);
        canvas.curveTo(58f, 767.01f, 56.21f, 768.8f, 54f, 768.8f);
        canvas.curveTo(51.79f, 768.8f, 50f, 767.01f, 50f, 764.8f);
        canvas.curveTo(50f, 762.59f, 51.79f, 760.8f, 54f, 760.8f);
        canvas.curveTo(56.21f, 760.8f, 58f, 762.59f, 58f, 764.8f);
        canvas.fill();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (DocumentException e) {
        e.printStackTrace();
    }
    document.close();
}