Class CalligraphyPathWriter



  • public class CalligraphyPathWriter
    extends PathWriter
    This creates a calligraphic or ribbon-like effect while tracing a shape.

    There are two separate shape bodies being written. If you paint them separately: this creates an "over" and "under" effect. If you paint them the same color: then this class is basically a java.awt.Stroke.

    • Constructor Detail

      • CalligraphyPathWriter

        public CalligraphyPathWriter(float angle,
                                     float offset1,
                                     float offset2,
                                     GeneralPath destination)
        Create a new CalligraphyPathWriter.
        Parameters:
        angle - the angle of the nib in this path.
        offset1 - the offset of one side of the traced shape. One side of shape you trace will be offset by:
        (+offset1*cos(angle), +offset1*sin(angle) )

        It is possible for this value to be zero, which means one side of this path will exactly line up with the original shape being traced.

        If both offsets are equal: then no new path segments will be visible because they will be pencil then.

        To achieve a simple stroke: one offset should be (+width/2), and the other offset should be (-width/2).

        offset2 - the offset of the other side of the traced shape. This side of shape will be offset by:
        (+offset2*cos(angle), +offset2*sin(angle) )
        destination - the destination for the data to write.
      • CalligraphyPathWriter

        public CalligraphyPathWriter(float angle,
                                     float offset1,
                                     float offset2,
                                     PathWriter dest1,
                                     PathWriter dest2)
        Create a new CalligraphyPathWriter.
        Parameters:
        angle - the angle of the nib in this path.
        offset1 - the offset of one side of the traced shape. One side of shape you trace will be offset by:
        (+offset1*cos(angle), +offset1*sin(angle) )

        It is possible for this value to be zero, which means one side of this path will exactly line up with the original shape being traced.

        If both offsets are equal: then no new path segments will be visible because they will be pencil then.

        To achieve a simple stroke: one offset should be (+width/2), and the other offset should be (-width/2).

        offset2 - the offset of the other side of the traced shape. This side of shape will be offset by:
        (+offset2*cos(angle), +offset2*sin(angle) )
        dest1 - the destination for half of the calligraphic shape.
        dest2 - the destination for the other half. This may be the same as dest1 if you plan on painting this path at the same time with the same fill.
    • Method Detail

      • moveTo

        public void moveTo(float x,
                           float y)
      • lineTo

        public void lineTo(float x,
                           float y)
      • quadTo

        public void quadTo(float cx,
                           float cy,
                           float x,
                           float y)
      • curveTo

        public void curveTo(float cx1,
                            float cy1,
                            float cx2,
                            float cy2,
                            float x,
                            float y)
      • closePath

        public void closePath()
      • write

        public void write(Shape s)
      • flush

        public void flush()