Class PAGestureWriter

java.lang.Object
net.paulhertz.pixelaudio.curves.PAGestureWriter

public class PAGestureWriter extends Object
Reduced set of Adobe Illustrator 3.0 (ancient but still useful) path operators for recording curves. May be useful for future development. Experimental.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Binary flag for closed path operators.
    static final char
    Closed and filled path operator.
    static final char
    Closed, filled, and stroked path operator.
    static final char
    Closed and stroked path operator.
    static final int
    Binary flag for filled path operators.
    A number formatter: call fourPlaces.format(Number) to return a String with four decimal places.
    (package private) static final int
    Adobe Illustrator default curve recursion is 4
    (package private) static final char[]
     
    static final char
    Closed and non-printing (invisible) path operator.
    static final char
    Open and non-printing (invisible) path operator.
    static final char
    Open and filled path operator.
    static final char
    Open, filled, and stroked path operator.
    static final char
    Open and stroked path operator.
    static final int
    Binary flag for stroked path operators.
    protected static boolean
    optional transparency flag, for export to AI.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    If you set transparency, either set it for every object, or reset it to totally opaque by calling noTransparency.
    static void
    paintPath(char pathOp, PrintWriter pw)
    Closes a series of path construction operations with the appropriate operator.
    static void
    paintPath(int pathIndex, PrintWriter pw)
    Closes a series of path construction operations with the appropriate operator stored in gPathOps, {'N', 'n', 'S', 's', 'F', 'f', 'B', 'b'}.
    static void
    psCurveTo(double x1, double y1, double x2, double y2, double x3, double y3, PrintWriter pw)
    Writes current point and "c" operator to output.
    static void
    psLineTo(double x, double y, PrintWriter pw)
    Writes current point and "L" operator to output.
    static void
    psMoveTo(double[] pt, PrintWriter pw)
    Writes current point and "m" operator to output.
    static void
    psMoveTo(double x, double y, PrintWriter pw)
    Writes current point and "m" operator to output.
    static void
    psMoveTo(processing.core.PVector pt, PrintWriter pw)
    Writes current point and "m" operator to output.
    static void
    setRGBFill(double[] shade, PrintWriter pw)
    Writes RGB fill value and fill operator "Xa" to output.
    static void
    setRGBFill(double r, double g, double b, PrintWriter pw)
    Writes RGB fill value and fill operator "Xa" to output.
    static void
    setRGBFill(int shade, PrintWriter pw)
    Writes RGB fill value and fill operator "Xa" to output.
    static void
    setRGBStroke(double[] shade, PrintWriter pw)
    Writes RGB stroke value and fill operator "XA" to output.
    static void
    setRGBStroke(double r, double g, double b, PrintWriter pw)
    Writes RGB stroke value and fill operator "XA" to output.
    static void
    setRGBStroke(int shade, PrintWriter pw)
    Writes RGB stroke value and fill operator "XA" to output.
    static void
    setTransparency(double trans, PrintWriter pw)
    Writes current opacity to an Illustrator file (not part of the AI7 spec).
    static void
    setUseTransparency(boolean useTransparency)
    Pass a value of true to enable transparency when exporting to Adobe Illustrator, default is false.
    static void
    setWeight(double weight, PrintWriter pw)
    Writes weight (in points) and weight operator "w" to output.
    static boolean
     
    static void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • gPathOps

      static final char[] gPathOps
    • FILL

      public static final int FILL
      Binary flag for filled path operators. FILL, STROKE and CLOSE values can be summed to index a path operator tag
      See Also:
    • STROKE

      public static final int STROKE
      Binary flag for stroked path operators. FILL, STROKE and CLOSE values can be summed to index a path operator tag
      See Also:
    • CLOSE

      public static final int CLOSE
      Binary flag for closed path operators. FILL, STROKE and CLOSE values can be summed to index a path operator tag
      See Also:
    • CLOSED_FILLED_STROKED

      public static final char CLOSED_FILLED_STROKED
      Closed, filled, and stroked path operator.
      See Also:
    • OPEN_FILLED_STROKED

      public static final char OPEN_FILLED_STROKED
      Open, filled, and stroked path operator.
      See Also:
    • CLOSED_FILLED

      public static final char CLOSED_FILLED
      Closed and filled path operator.
      See Also:
    • OPEN_FILLED

      public static final char OPEN_FILLED
      Open and filled path operator.
      See Also:
    • CLOSED_STROKED

      public static final char CLOSED_STROKED
      Closed and stroked path operator.
      See Also:
    • OPEN_STROKED

      public static final char OPEN_STROKED
      Open and stroked path operator.
      See Also:
    • NONPRINTING_CLOSED

      public static final char NONPRINTING_CLOSED
      Closed and non-printing (invisible) path operator.
      See Also:
    • NONPRINTING_OPEN

      public static final char NONPRINTING_OPEN
      Open and non-printing (invisible) path operator.
      See Also:
    • gCurveRecursionDepth

      static final int gCurveRecursionDepth
      Adobe Illustrator default curve recursion is 4
      See Also:
    • fourPlaces

      public static DecimalFormat fourPlaces
      A number formatter: call fourPlaces.format(Number) to return a String with four decimal places.
    • useTransparency

      protected static boolean useTransparency
      optional transparency flag, for export to AI. Transparency is not part of the AI 7.0 spec, but we try to support it.
  • Constructor Details

    • PAGestureWriter

      public PAGestureWriter()
  • Method Details

    • writeHeader

      public static void writeHeader(PrintWriter pw, String title)
    • setRGBFill

      public static void setRGBFill(double r, double g, double b, PrintWriter pw)
      Writes RGB fill value and fill operator "Xa" to output.
      Parameters:
      r - red component (0..1)
      g - green component (0..1)
      b - blue component (0..1)
      pw - PrintWriter for file output
    • setRGBFill

      public static void setRGBFill(double[] shade, PrintWriter pw)
      Writes RGB fill value and fill operator "Xa" to output.
      Parameters:
      shade - an array of four doubles in the range (0..1)
      pw - PrintWriter for file output
    • setRGBFill

      public static void setRGBFill(int shade, PrintWriter pw)
      Writes RGB fill value and fill operator "Xa" to output.
      Parameters:
      shade - an RGBColor instance
      pw - PrintWriter for file output
    • setRGBStroke

      public static void setRGBStroke(double r, double g, double b, PrintWriter pw)
      Writes RGB stroke value and fill operator "XA" to output.
      Parameters:
      r - red component (0..1)
      g - green component (0..1)
      b - blue component (0..1)
      pw - PrintWriter for file output
    • setRGBStroke

      public static void setRGBStroke(double[] shade, PrintWriter pw)
      Writes RGB stroke value and fill operator "XA" to output.
      Parameters:
      shade - an array of four doubles in the range (0..1)
      pw - PrintWriter for file output
    • setRGBStroke

      public static void setRGBStroke(int shade, PrintWriter pw)
      Writes RGB stroke value and fill operator "XA" to output.
      Parameters:
      shade - a RGBColor instance
      pw - PrintWriter for file output
    • setWeight

      public static void setWeight(double weight, PrintWriter pw)
      Writes weight (in points) and weight operator "w" to output.
      Parameters:
      weight - stroke weight (positive decimal value)
      pw - PrintWriter for file output
    • useTransparency

      public static boolean useTransparency()
      Returns:
      true if transparency is enabled, false otherwise.
    • setUseTransparency

      public static void setUseTransparency(boolean useTransparency)
      Pass a value of true to enable transparency when exporting to Adobe Illustrator, default is false. Transparency markup is not supported in the AI7.0 specification, but it seems to work. Note that in Illustrator transparency affects the entire shape, both fill and stroke, unlike Processing, where fill and stroke can have separate transparency values. This means for stroked shapes, the stroke transparency will affect the whole shape in AI. See setTransparency(double, PrintWriter).
      Parameters:
      useTransparency -
    • setTransparency

      public static void setTransparency(double trans, PrintWriter pw)
      Writes current opacity to an Illustrator file (not part of the AI7 spec). This particular operator is pieced together from inspecting AI files It is not part of the AI7 specification, the last one published by Adobe. I do not know what each of the arguments to Xy does, but the second one controls opacity.
      Parameters:
      trans - transparency value, in the range 0..1
      pw - PrintWriter for file output
    • noTransparency

      public static void noTransparency(PrintWriter pw)
      If you set transparency, either set it for every object, or reset it to totally opaque by calling noTransparency.
      Parameters:
      pw - PrintWriter for file output
    • psMoveTo

      public static void psMoveTo(double x, double y, PrintWriter pw)
      Writes current point and "m" operator to output.
      Parameters:
      x - x coordinate
      y - y coordinate
      pw - PrintWriter for file output
    • psMoveTo

      public static void psMoveTo(double[] pt, PrintWriter pw)
      Writes current point and "m" operator to output.
      Parameters:
      pt - array of two double values, x and y coordinates
      pw - PrintWriter for file output
    • psMoveTo

      public static void psMoveTo(processing.core.PVector pt, PrintWriter pw)
      Writes current point and "m" operator to output.
      Parameters:
      pt - a Java Point2D instance
      pw - PrintWriter for file output
    • psLineTo

      public static void psLineTo(double x, double y, PrintWriter pw)
      Writes current point and "L" operator to output.
      Parameters:
      x - x coordinate
      y - y coordinate
      pw - PrintWriter for file output
    • psCurveTo

      public static void psCurveTo(double x1, double y1, double x2, double y2, double x3, double y3, PrintWriter pw)
      Writes current point and "c" operator to output.
      Parameters:
      x1 - control point 1 x coordinate
      y1 - control point 1 y coordinate
      x2 - control point 2 x coordinate
      y2 - control point 2 y coordinate
      x3 - end point x coordinate
      y3 - end point y coordinate
      pw - PrintWriter for file output
    • paintPath

      public static void paintPath(int pathIndex, PrintWriter pw)
      Closes a series of path construction operations with the appropriate operator stored in gPathOps, {'N', 'n', 'S', 's', 'F', 'f', 'B', 'b'}. Requires an index value for the path operator. It may be simpler to call the other paintPath method, that accepts character constant.
                              fill    stroke  close   
                       b        1               1               1             closed filled and stroked path
                       B        1               1               0             open filled and stroked path
                       f        1               0               1             closed filled path
                       F        1               0               0             open filled path
                       s        0               1               1             closed stroked path
                       S        0               1               0             open stroked path
                       n        0               0               1             non-printing closed path
                       N        0               0               0             non-printing open path
       
      Parameters:
      pathIndex - an int in the range (0..7)
      pw - PrintWriter for file output
    • paintPath

      public static void paintPath(char pathOp, PrintWriter pw)
      Closes a series of path construction operations with the appropriate operator.
      Parameters:
      pathOp - a char in {'N', 'n', 'S', 's', 'F', 'f', 'B', 'b'}

      It is simpler just to use one of the supplied constants CLOSED_FILLED_STROKED, OPEN_FILLED_STROKED, CLOSED_FILLED, OPEN_FILLED, CLOSED_STROKED, OPEN_STROKED, NONPRINTING_CLOSED, NONPRINTING_OPEN

      pw - PrintWriter for file output