com.ignotus.aifile
Class BezShape

java.lang.Object
  extended by com.ignotus.aifile.DisplayComponent
      extended by com.ignotus.aifile.BezShape
All Implemented Interfaces:
ColorableINF, Visitable
Direct Known Subclasses:
BezCircle, BezCurve, BezCurveShape, BezEllipse, BezLine, BezMultiCurve, BezMultiLine, BezPoly, BezRectangle, BezRegularPoly, BezTriangle

public class BezShape
extends DisplayComponent
implements ColorableINF

Implements shapes composed of cubic Bezier curves and lines and methods to draw geometry to a display, perform geometric transforms, and write geometry to an Adobe Illustrator 7.0 file format.

The default initializations create a shape with the current fill, stroke, and stroke weight in Processing, closed unless you specify otherwise. You can call setColors at any time to capture Processing's current fill, stroke, and strokeWeight, and call setIsClosed with a value of false to make an open shape. Unlike Processing, closed shapes will be drawn as closed only if the start point and the end point are equal: this is required for correct output to Illustrator. You can also set fill, stroke, and weight with BezShape's own methods setFillColor, setStrokeColor and setWeight.

Geometry is stored as an initial vertex (startPoint) and a list of vertices (Vertex2DINF), which may be lines or Bezier curves. The curveIterator method returns an iterator over the vertices: note that the initial vertex is not included, but is easily accessed with x and y. The center of the shape is initially set to (0,0), as it would be in Processing. You can set the center to the center point of the geometry with a call to calculateCenter or to any desired point with setCenter.

Geometric transforms around the current center point can be executed with calls to translateShape, rotateShape and scaleShape. Generalized transforms around an arbitrary point can be executed by passing a transformation matrix to transform. Calling transform() with no argument uses the most recent transformation matrix, effectively repeating the previous call to transform. On initialization, Processing's current transform is store in ctm, but it is not used to transform the shape. You can retrieve ctm with getCtm. A call to getMatrix(PApplet) will set the internal matrix to Processing's current transformation matrix. This way you can synchronize BezShape transforms to Processing transforms. BezShape transforms are affected by Processing's current transforms (i.e., by calls to translate, rotate, and scale). Calling a BezShape transform while a Processing transform is active may lead to unexpected results. See sample code for examples of how to use and synchronize transforms.

The write() method writes the geometry and attributes of a shape in Adobe Illustrator 7.0 format. It is far easier to call write() than to call AIFileWriter directly to output geometry. See the various coding examples for different methods of writing an Illustrator file. In some instances, one line of code will do all the work.

Static methods provide automatic creation of multiCurves, multiLines, regular polygons, equilateral triangles, general triangles, rectangles, lines, curves, multilines and multicurves. These may become subclasses in the future.

+Example
/*
 * Demonstrates the basics of creating BezShapes and loading them into a list.  
 * Steps through the list to draw shapes to the display or write them to a file.
 * Demonstrates methods for creating colors and adding them to a palette that can
 * be used in Processing and exported to an Illustrator file.  
 * Note that display in Illustrator appears flipped on a horizontal axis because
 * Illustrator and Processing use different coordinate systems. Other examples 
 * show various solutions to this problem: the simplest remedy is to use the
 * writeWithAITransform() method in a DocumentComponent.
 */

import java.util.*;
import java.io.*;  
import com.ignotus.aifile.*;   // library that defines AIFileWriter and static file i/o methods
import com.ignotus.geom.*;   

/** a list of shapes to draw and save */
ArrayList shapes;
/** a palette of colors, stored as 32-bit integers */
ArrayList farben;
/** the file we'll save to */
String fileName = "simple.ai";


public void setup() {
  size(480,720);
  background(127);
  smooth();
  shapes = new ArrayList();
  farben = new ArrayList();
  createColors();
  createShapes();
  println("type 's' to output file");
}


/**
 * To draw, we just step through the shapes and tell each one to draw, passing
 * in a reference to the Processing PApplet "this" so that the shapes have access
 * to Processing's drawing functions. 
 */
public void draw() {
  for (BezShape bez : shapes) {
     bez.draw(); 
  }
}


void keyPressed() {
  if (key == 's') {
    saveAI(fileName, shapes, farben);
  }  
}


/**
 * Add some colors to the farben array. The static method Palette.colorPermutation
 * returns an array of all the unique permutations of the r, g and b color volues.
 */
public void createColors() {
  color c = color(32, 64, 128);
  farben.add(c);
  c = color(76, 123, 199);
  color[] perm = Palette.colorPermutation(c);
  for (color pc : perm) {
    farben.add(pc);
  }
}


/**
 * We create some shapes
 */
public void createShapes() {
  float x, y, radius, h, w;
  int sides;
  color c;
  int[] channelValues = {34, 55, 89, 144, 233};
  // add a background rectangle
  shapes.add(bgRect());
  for (int i = 0; i < 10; i++) {
    x = random(width);
    y = random(height);
    radius = random(2, 48);
    sides = int(random(3, 18));
    // call static method BezShape.bezRegularPoly to create a regular polygon
    BezShape bez = BezShape.bezRegularPoly(this, x, y, radius, sides);
    // generate a color using randomly selected values from an array for r, g and b
    c = Palette.randColor(channelValues);
    farben.add(c);
    bez.setFillColor(c);
    bez.setStrokeColor(0);
    shapes.add(bez);
  }
  for (int i = 0; i < 10; i++) {
    x = random(width);
    y = random(height);
    w = random(16, 96);
    h = random(16, 96);
    sides = int(random(4, 7));
    // call static method BezShape.bezEllipse to create an ellipse
    BezShape bez = BezShape.bezEllipse(this, x, y, w, h, sides);
    c = Palette.randColor(channelValues);
    farben.add(c);
    bez.setFillColor(c);
    bez.setNoStroke();
    shapes.add(bez);
  }
}


/**
 * Creates a rectangle from four points, with fill and stroke colors
 */
public BezShape bezRect(float left, float top, float right, float bottom, color f, color s) {
  BezShape r = new BezShape(this, left, top);
  r.setFillColor(f);
  r.setStrokeColor(s);
  r.setWeight(3.0);
  r.append(right, top);
  r.append(right, bottom);
  r.append(left, bottom);
  r.append(left, top);
  return r;
}


public BezShape bgRect() {
  color f = color(233, 231, 236);
  color s = color(21, 34, 55);
  return bezRect(0, height, width, 0, f, s);
}


 /**
  * saves shapes to an Adobe Illustrator file
  * Illustrator and Porcessing use different coordinate systems, so the AI file
  * will look the Processing window flipped on its horizontal axis.
  * @param aiFilename   name fo the file to save to
  * @param comps        an array of BezShapes to save to the file
  * @param colors       an array of Processing colors to use as the palette
  */
public void saveAI(String aiFilename, ArrayList comps, ArrayList colors) {
  println("saving Adobe Illustrator file " + aiFilename + "...");
  PrintWriter output = createWriter(aiFilename);
  // create the document
  DocumentComponent doc = new DocumentComponent(this, "Simple Shape Export");
  // get its palette
  Palette pal = doc.getPalette();
  // add black, white, and gray to the palette
  pal.addBlackWhiteGray();
  // add our array of colors to the palette
  pal.addColors(colors);
  // include some information for Illustrator's header
  doc.setCreator("Ignotus");
  doc.setOrg("IgnoStudio");
  // set width and height of the document
  doc.setWidth(width);
  doc.setHeight(height);
  println("adding components...");
  // add the components to the the default layer of the document
  for (BezShape b : comps) {
    doc.add(b);
  }
  // writeWithAITransform(output) will transform Processing geometry 
  // into the Adobe Illustrator coordinate system
  doc.write(output);
}
  
  


Nested Class Summary
static class BezShape.BezType
           
 
Field Summary
 BezShape.BezType bezType
          type of BEZ_PATH, BEZ_TRIANGLE, BEZ_CIRCLE, BEZ_ELLIPSE, BEZ_CURVE_POLY, BEZ_REGULAR_POLY, etc.
static int CURVE_SEGMENT
          flag for curve segment type, associated with BezVertex
static double KAPPA
          KAPPA = (distance between Bezier anchor and its associated control point) / (circle radius) when a circle is divided into 4 sectors of 90 degrees.
static int LINE_SEGMENT
          flag for line segment type, associated with LineVertex
 
Constructor Summary
BezShape(PApplet parent)
          Creates a closed shape with initial point 0,0 Fill, stroke, and weight of shapes are set from their values in the Processing environment.
BezShape(PApplet parent, float x, float y)
          Creates a closed shape with initial point x,y.
BezShape(PApplet parent, float x, float y, boolean isClosed)
          Creates a BezShape with initial point x,y, closed or open according to the value of isClosed.
BezShape(PApplet parent, float ax1, float ay1, float cx1, float cy1, float cx2, float cy2, float ax2, float ay2)
          Creates a closed BezShape with initial point ax1, ay1, and appends a curve segment.
BezShape(PApplet parent, float ax1, float ay1, float cx1, float cy1, float cx2, float cy2, float ax2, float ay2, boolean isClosed)
          Creates a BezShape with initial point ax1, ay1, and appends a curve segment.
 
Method Summary
 void accept(ComponentVisitor visitor)
          Accepts a ComponentVisitor that traverses a document structure tree.
 void accept(ComponentVisitor visitor, boolean order)
          Accepts a ComponentVisitor that traverses a document structure tree in preorder or postorder.
 void add(ArrayList<? extends DisplayComponent> comps)
          Adds all components in a list to this component, throws an UnsupportedOperationException if component is terminal.
 void add(DisplayComponent component)
          Adds a component to children of this component, throws an UnsupportedOperationException if component is terminal.
 void append(float x, float y)
          Appends a LineVertex (line segment) to this BezShape.
 void append(float cx1, float cy1, float cx2, float cy2, float x, float y)
          Appends a BezVertex (cubic Bˇzier segment) to this BezShape.
 void append(Vertex2DINF vt)
          Appends a Vertex2DINF to this BezShape
 float[] asPolygon()
           
 float[] asPolygon(int steps)
           
 float[] asPolygon(PApplet parent)
          Extracts an approximated polygon from path data.
 float[] asPolygon(PApplet parent, int steps)
          Extracts an approximated polygon from path data, returning it as an array of floats.
static BezCircle bezCircle(PApplet parent, float xctr, float yctr, float radius, int sectors)
          Creates a circular BezShape with sectors number of Bezier curves.
static BezShape bezCurve(PApplet parent, float ax1, float ay1, float cx1, float cy1, float cx2, float cy2, float ax2, float ay2)
          Constructs a single Bˇzier curve.
static BezCurveShape bezCurveShape(PApplet parent, float[] coords)
          Returns a multi-segment Bˇzier curve from an array of float.
static BezEllipse bezEllipse(PApplet parent, float xctr, float yctr, float width, float height, int sectors)
          Creates an elliptical BezShape with sectors number of Bezier curves.
static BezLine bezLine(PApplet parent, float x1, float y1, float x2, float y2)
          Constructs a straight line between (x1, y1) and (x2, y2).
static BezMultiCurve bezMultiCurve(PApplet parent, float[] coords)
          Constructs a multi-segment Bˇzier curve from an array of float.
static BezMultiLine bezMultiLine(PApplet parent, float[] coords)
          Constructs a multi-segment line from an array of float.
static BezPoly bezPoly(PApplet parent, float[] coords)
          Constructs a multi-segment line from an array of float.
static BezRectangle bezRectangle(PApplet parent, float left, float top, float right, float bottom)
          Constructs a rectangular BezShape.
static BezRegularPoly bezRegularPoly(PApplet parent, float xctr, float yctr, float radius, int sides)
          Constructs a regular polygon BezShape with sides edges and radius radius.
static BezTriangle bezTriangle(PApplet parent, float xctr, float yctr, float radius)
          Constructs an equilateral triangle with supplied center (xctr, yctr) and radius.
static BezTriangle bezTriangle(PApplet parent, float x1, float y1, float x2, float y2, float x3, float y3)
          Constructs a triangle from three points.
 BezShape.BezType bezType()
           
 float[] bounds()
          returns array of floats with top, left, bottom, right coordinates of bounding box These are an approximation based on the derived polygon, accuracy can be improved by first calling asPolygon with an argument greater than the default of 16 segments per curve.
 float[] bounds(PApplet parent)
          returns array of floats with top, left, bottom, right coordinates of bounding box These are an approximation based on the derived polygon, accuracy can be improved by first calling asPolygon with an argument greater than the default of 16 segments per curve.
 BezRectangle boundsRect()
          Returns the bounding rectangle of this shape.
 void calculateCenter()
          Sets the center of transformation to the center of the bounding rectangle of this shape.
 LineVertex centerVertex()
           
 ArrayList<DisplayComponent> children()
          Returns null: this is a terminal node, with no children.
 BezShape clone()
          Creates a deep copy of this BezShape.
 boolean containsPoint(float x, float y)
           
 boolean containsPoint(PApplet parent, float x, float y)
          Tests if a point is inside this shape by generating a polygon approximation to curved paths and testing that.
 ListIterator<Vertex2DINF> curveIterator()
          Returns an iterator over the geometry of this shape.
 ArrayList<Vertex2DINF> curves()
          Returns the geometry of this shape as an ArrayList.
 ArrayList<Vertex2DINF> curvesCopy()
          Returns a copy of the geometry of this shape as an ArrayList.
 void draw()
          Draws this shape to the display.
 void draw(PGraphics pg)
          Draws this shape to an offscreen PGraphics.
 void drawQuick()
          Draws this shape to the display.
 int fillColor()
           
 int fillOpacity()
           
 DisplayComponent get(int index)
          Returns the component at index from the children of this component, throws an UnsupportedOperationException if component is terminal.
 LineVertex getAnchorCenter(BezShape shape)
          Returns the average of all anchor points of the vertices of this shape.
 LineVertex getBoundsCenter()
          Returns the center of the bounding rectangle of this shape as a LineVertex.
 float[] getCoords()
          Returns an array of all vertex coordinates.
 Matrix3 getCtm()
          Returns a copy of the most recent transformation matrix.
 LineVertex getGeoCenter()
          Returns the average of the x- and y-coordinates of this shape as a LineVertex.
static Matrix3 getMatrix(PApplet applet)
          Captures a transformation matrix from a PApplet, for later use.
 boolean hasFill()
           
 boolean hasStroke()
           
 boolean isClosed()
           
 boolean isTerminal()
          Returns true: this is a terminal component.
 Iterator<DisplayComponent> iterator()
          Returns an iterator over children, throws an UnsupportedOperationException if component is terminal.
 void moveTo(float newXCtr, float newYCtr)
          Handy method to translate center point (xctr, yctr) and shape to a new location.
 int polySize()
           
 int polySize(PApplet parent)
           
 int polySteps()
          Returns the number of straight line segments used in fast calculation
 boolean remove(DisplayComponent component)
          Removes a component from children of this component, throws an UnsupportedOperationException if component is terminal.
 void rotateShape(float theta)
          Rotates this shape around its center point.
 void rotateShape(float xctr, float yctr, float theta)
          Rotates this shape around a supplied center point.
 void scaleShape(float xyScale)
          Uniformly scales this shape around its center point.
 void scaleShape(float xScale, float yScale)
          Scales this shape around its center point.
 void scaleShape(float xyScale, float x0, float y0)
          Uniformly scales this shape around a given point.
 void scaleShape(float xScale, float yScale, float x0, float y0)
          Scales this shape around a given point.
 void setBezType(BezShape.BezType newBezType)
           
 void setCenter(float xctr, float yctr)
          Sets center point for geometric transforms on this shape.
 void setCenter(LineVertex centerPoint)
          Sets the values of xctr and yctr
 void setCenter(Point2D pt)
          Sets center point for geometric transforms on this shape.
 void setColors(PApplet host)
          Sets fill and stroke using the current graphics state.
 void setCtm(Matrix3 ctm)
           
 void setCtm(PApplet applet)
          Captures the current transformation matrix from a PApplet and uses it to set our ctm.
 void setCtm(PMatrix2D m)
          Sets our ctm from a PMatrix2D.
 void setCurves(ArrayList<Vertex2DINF> newCurves)
           
 void setFillColor(int newFillColor)
          Sets the current fill color.
 void setFillOpacity(int opacity)
          Sets opacity of current fill color.
 void setHasFill(boolean newHasFill)
           
 void setHasStroke(boolean newHasStroke)
           
 void setIsClosed(boolean newIsClosed)
           
 void setNoFill()
          Equivalent to setHasFill(false).
 void setNoStroke()
          Equivalent to setHasStroke(false).
 void setPolySteps(int newPolySteps)
           
 void setStartPoint(float newX, float newY)
          Sets a new initial vertex for this BezShape.
 void setStartPoint(LineVertex startPoint)
           
 void setStartPoint(Point2D pt)
          Sets a new initial vertex for this BezShape.
 void setStrokeColor(int newStrokeColor)
          Sets the current stroke color.
 void setStrokeOpacity(int opacity)
          Sets opacity of current stroke color.
static void setUseTransparency(boolean useTransparency)
          Deprecated. preferred usage is AIFileWriter.setUseTransparency().
 void setWeight(float newWeight)
           
 void setX(float newX)
          Sets the x-coordinate of the initial point of the geometry of this shape.
 void setY(float newY)
          Sets the y-coordinate of the initial point of the geometry of this shape.
 LineVertex startVertex()
           
 float[] startVertexArray()
          return initial vertex as an array of two floats
 int strokeColor()
           
 int strokeOpacity()
           
 void transform()
          Calls transform with this shape's ctm, current transformation matrix.
 void transform(Matrix3 matx)
          Performs an affine geometric transformation on this shape using 3x3 matrix multiplication.
 void transformShape(Matrix3 matx)
          Deprecated.  
 void translateShape(float xTrans, float yTrans)
          Translates this shape.
static boolean useTransparency()
           
 float weight()
          Returns the current weight (in points) of stroked lines.
 void write(int pathOp, PrintWriter output)
          Writes Adobe Illustrator 7.0 tags describing the geometry of this shape to PrintWriter.
 void write(PrintWriter pw)
          Writes Adobe Illustrator 7.0 tags describing the geometry of this shape to PrintWriter.
 float x()
          Returns the x-coordinate of the initial point of the geometry of this shape.
 float[] xcoords()
           
 float[] xcoords(PApplet parent)
          Returns x-coordinates of the geometry of this shape.
 float xctr()
          Returns the value of the x-coordinate of center of transformation.
 float y()
          Returns the y-coordinate of the initial point of the geometry of this shape.
 float[] ycoords()
           
 float[] ycoords(PApplet parent)
          Returns y-coordinates of the geometry of this shape.
 float yctr()
          Returns the of the y-coordinate of center of transformation.
 
Methods inherited from class com.ignotus.aifile.DisplayComponent
hide, id, isLocked, isVisible, parentComponent, setLocked, setParentComponent, setVisible, show
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LINE_SEGMENT

public static final int LINE_SEGMENT
flag for line segment type, associated with LineVertex

See Also:
Constant Field Values

CURVE_SEGMENT

public static final int CURVE_SEGMENT
flag for curve segment type, associated with BezVertex

See Also:
Constant Field Values

bezType

public BezShape.BezType bezType
type of BEZ_PATH, BEZ_TRIANGLE, BEZ_CIRCLE, BEZ_ELLIPSE, BEZ_CURVE_POLY, BEZ_REGULAR_POLY, etc.


KAPPA

public static final double KAPPA
KAPPA = (distance between Bezier anchor and its associated control point) / (circle radius) when a circle is divided into 4 sectors of 90 degrees. see http://www.whizkidtech.redprince.net/bezier/circle/kappa/

See Also:
Constant Field Values
Constructor Detail

BezShape

public BezShape(PApplet parent,
                float x,
                float y,
                boolean isClosed)
Creates a BezShape with initial point x,y, closed or open according to the value of isClosed. Fill, stroke, and weight of shapes are set from their values in the Processing environment. The Processing transformation matrix (set by calls to rotate, translate and scale) is saved to the instance variable ctm, but no transform is performed. Note that drawing is affected by the current Processing transform.

Parameters:
parent - PApplet used for calls to the Processing environment, notably for drawing
x - x-coordinate of initial point
y - y-coordinate of initial point
isClosed - true if shape is closed, false if it is open

BezShape

public BezShape(PApplet parent)
Creates a closed shape with initial point 0,0 Fill, stroke, and weight of shapes are set from their values in the Processing environment. The Processing transformation matrix (set by calls to rotate, translate and scale) is saved to the instance variable ctm, but no transform is performed. Note that drawing is affected by the current Processing transform.

Parameters:
parent - PApplet used for calls to the Processing environment, notably for drawing

BezShape

public BezShape(PApplet parent,
                float x,
                float y)
Creates a closed shape with initial point x,y. Fill, stroke, and weight of shapes are set from their values in the Processing environment. The Processing transformation matrix (set by calls to rotate, translate and scale) is saved to the instance variable ctm, but no transform is performed. Note that drawing is affected by the current Processing transform.

Parameters:
parent - PApplet used for calls to the Processing environment, notably for drawing
x - x-coordinate of initial point
y - y-coordinate of initial point

BezShape

public BezShape(PApplet parent,
                float ax1,
                float ay1,
                float cx1,
                float cy1,
                float cx2,
                float cy2,
                float ax2,
                float ay2)
Creates a closed BezShape with initial point ax1, ay1, and appends a curve segment. Fill, stroke, and weight of shapes are set from their values in the Processing environment. The Processing transformation matrix (set by calls to rotate, translate and scale) is saved to the instance variable ctm, but no transform is performed. Note that drawing is affected by the current Processing transform.

Parameters:
parent - PApplet used for calls to the Processing environment, notably for drawing
ax1 - x-coordinate of initial anchor point
ay1 - y-coordinate of initial anchor point
cx1 - x-coordinate of first control point
cy1 - y-coordinate of first control point
cx2 - x-coordinate of second control point
cy2 - y-coordinate of second control point
ax2 - x-coordinate of terminal anchor point
ay2 - y-coordinate of terminal anchor point

BezShape

public BezShape(PApplet parent,
                float ax1,
                float ay1,
                float cx1,
                float cy1,
                float cx2,
                float cy2,
                float ax2,
                float ay2,
                boolean isClosed)
Creates a BezShape with initial point ax1, ay1, and appends a curve segment. Fill, stroke, and weight of shapes are set from their values in the Processing environment. The Processing transformation matrix (set by calls to rotate, translate and scale) is saved to the instance variable ctm, but no transform is performed. Note that drawing is affected by the current Processing transform.

Parameters:
parent - PApplet used for calls to the Processing environment, notably for drawing
ax1 - x-coordinate of initial anchor point
ay1 - y-coordinate of initial anchor point
cx1 - x-coordinate of first control point
cy1 - y-coordinate of first control point
cx2 - x-coordinate of second control point
cy2 - y-coordinate of second control point
ax2 - x-coordinate of terminal anchor point
ay2 - y-coordinate of terminal anchor point
isClosed - true if shape is closed, false if it is open
Method Detail

clone

public BezShape clone()
Creates a deep copy of this BezShape.

Overrides:
clone in class Object
See Also:
Object.clone()

add

public void add(DisplayComponent component)
Description copied from class: DisplayComponent
Adds a component to children of this component, throws an UnsupportedOperationException if component is terminal.

Specified by:
add in class DisplayComponent
Parameters:
component - DisplayComponent to add to this component's children
Throws:
UnsupportedOperationException, - BezShape is a terminal (leaf) node

add

public void add(ArrayList<? extends DisplayComponent> comps)
Description copied from class: DisplayComponent
Adds all components in a list to this component, throws an UnsupportedOperationException if component is terminal.

Specified by:
add in class DisplayComponent
Parameters:
comps - an ArrayList of DisplayComponents
Throws:
UnsupportedOperationException, - BezShape is a terminal (leaf) node

remove

public boolean remove(DisplayComponent component)
Description copied from class: DisplayComponent
Removes a component from children of this component, throws an UnsupportedOperationException if component is terminal.

Overrides:
remove in class DisplayComponent
Parameters:
component - DisplayComponent to remove from this component's children
Returns:
true if component was found and removed, false otherwise.
Throws:
UnsupportedOperationException, - BezShape is a terminal (leaf) node

get

public DisplayComponent get(int index)
Description copied from class: DisplayComponent
Returns the component at index from the children of this component, throws an UnsupportedOperationException if component is terminal. Throws an IndexOutOfBoundsException if index is out of range (index < 0 || index >= size).

Overrides:
get in class DisplayComponent
Parameters:
index - index to component
Returns:
the DisplayComponent at the supplied index
Throws:
UnsupportedOperationException, - BezShape is a terminal (leaf) node

iterator

public Iterator<DisplayComponent> iterator()
Description copied from class: DisplayComponent
Returns an iterator over children, throws an UnsupportedOperationException if component is terminal.

Overrides:
iterator in class DisplayComponent
Returns:
an Iterator over the children array of this component
Throws:
UnsupportedOperationException, - BezShape is a terminal (leaf) node

children

public ArrayList<DisplayComponent> children()
Returns null: this is a terminal node, with no children.

Overrides:
children in class DisplayComponent
Returns:
null, BezShape is a terminal (leaf) node

isTerminal

public boolean isTerminal()
Returns true: this is a terminal component.

Specified by:
isTerminal in class DisplayComponent
Returns:
true, BezShape is a terminal (leaf) node

append

public void append(Vertex2DINF vt)
Appends a Vertex2DINF to this BezShape

Parameters:
vt - a Vertex2DINF (line segment or curve segment)

append

public void append(float cx1,
                   float cy1,
                   float cx2,
                   float cy2,
                   float x,
                   float y)
Appends a BezVertex (cubic Bˇzier segment) to this BezShape.

Parameters:
cx1 - x-coordinate of first control point
cy1 - y-coordinate of first control point
cx2 - x-coordinate of second control point
cy2 - y-coordinate of second control point
x - x-coordinate of terminal anchor point
y - y-coordinate of terminal anchor point

append

public void append(float x,
                   float y)
Appends a LineVertex (line segment) to this BezShape.

Parameters:
x -
y -

isClosed

public boolean isClosed()
Returns:
true if this shape is closed, false otherwise.

setIsClosed

public void setIsClosed(boolean newIsClosed)
Parameters:
newIsClosed - true if this shape is closed, false otherwise

setColors

public void setColors(PApplet host)
Sets fill and stroke using the current graphics state.


hasFill

public boolean hasFill()
Specified by:
hasFill in interface ColorableINF
Returns:
true if this shape is filled, false otherwise

setHasFill

public void setHasFill(boolean newHasFill)
Parameters:
newHasFill - pass true if this shape has a fill, false otherwise. Note that the current fillColor will not be discarded by setting hasFill to false: the shape simply won't display or save to file with a fill.

setNoFill

public void setNoFill()
Equivalent to setHasFill(false).

Specified by:
setNoFill in interface ColorableINF

hasStroke

public boolean hasStroke()
Specified by:
hasStroke in interface ColorableINF
Returns:
true if this shape is stroked, false otherwise

setHasStroke

public void setHasStroke(boolean newHasStroke)
Parameters:
newHasStroke - pass true if this shape has a stroke, false otherwise. Note that the current strokeColor will not be discarded by setting hasStroke to false: the shape simply won't display or save to file with a stroke.

setNoStroke

public void setNoStroke()
Equivalent to setHasStroke(false).

Specified by:
setNoStroke in interface ColorableINF

fillColor

public int fillColor()
Specified by:
fillColor in interface ColorableINF
Returns:
the current fill color

setFillColor

public void setFillColor(int newFillColor)
Description copied from interface: ColorableINF
Sets the current fill color.

Specified by:
setFillColor in interface ColorableINF
Parameters:
newFillColor - a Processing color (32-bit int with ARGB bytes).

strokeColor

public int strokeColor()
Specified by:
strokeColor in interface ColorableINF
Returns:
the current stroke color

setStrokeColor

public void setStrokeColor(int newStrokeColor)
Description copied from interface: ColorableINF
Sets the current stroke color.

Specified by:
setStrokeColor in interface ColorableINF
Parameters:
newStrokeColor - a Processing color (32-bit int with ARGB bytes).

useTransparency

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

setUseTransparency

public static void setUseTransparency(boolean useTransparency)
Deprecated. preferred usage is AIFileWriter.setUseTransparency().

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 write(PrintWriter).

Parameters:
useTransparency -

setFillOpacity

public void setFillOpacity(int opacity)
Sets opacity of current fill color.

Specified by:
setFillOpacity in interface ColorableINF
Parameters:
opacity - a number in the range 0..255. Value is not checked!

fillOpacity

public int fillOpacity()
Specified by:
fillOpacity in interface ColorableINF
Returns:
the opacity value of the current fill color

setStrokeOpacity

public void setStrokeOpacity(int opacity)
Sets opacity of current stroke color.

Specified by:
setStrokeOpacity in interface ColorableINF
Parameters:
opacity - a number in the range 0..255. Value is not checked!

strokeOpacity

public int strokeOpacity()
Specified by:
strokeOpacity in interface ColorableINF
Returns:
the opacity value of the current stroke color

weight

public float weight()
Returns the current weight (in points) of stroked lines.

Specified by:
weight in interface ColorableINF
Returns:
the current weight (in points) of stroked lines. One point = one pixel on screen.

setWeight

public void setWeight(float newWeight)
Specified by:
setWeight in interface ColorableINF
Parameters:
newWeight - the new weight of stroked lines.

bezType

public BezShape.BezType bezType()
Returns:
type of shape (BEZ_PATH, BEZ_TRIANG, BEZ_CIRCLE, BEZ_ELLIPSE, BEZ_CURVE_POLY, BEZ_REGULAR_POLY)

setBezType

public void setBezType(BezShape.BezType newBezType)
Parameters:
newBezType - type of shape (BEZ_PATH, BEZ_TRIANG, BEZ_CIRCLE, BEZ_ELLIPSE, BEZ_CURVE_POLY, BEZ_REGULAR_POLY)

x

public float x()
Returns the x-coordinate of the initial point of the geometry of this shape.

Returns:
x-coordinate of initial vertex

setX

public void setX(float newX)
Sets the x-coordinate of the initial point of the geometry of this shape.

Parameters:
newX - new x-coordinate of initial vertex

y

public float y()
Returns the y-coordinate of the initial point of the geometry of this shape.

Returns:
y-coordinate of initial vertex

setY

public void setY(float newY)
Sets the y-coordinate of the initial point of the geometry of this shape.

Parameters:
newY - new y-coordinate of initial vertex

startVertex

public LineVertex startVertex()
Returns:
a LineVertex with start point coordinates of this shape

setStartPoint

public void setStartPoint(LineVertex startPoint)
Parameters:
startPoint - the startPoint to set

setStartPoint

public void setStartPoint(Point2D pt)
Sets a new initial vertex for this BezShape.

Parameters:
pt - a Point2D

setStartPoint

public void setStartPoint(float newX,
                          float newY)
Sets a new initial vertex for this BezShape.

Parameters:
newX -
newY -

startVertexArray

public float[] startVertexArray()
return initial vertex as an array of two floats

Returns:
x and y coordinates of initial vertex in an array
Since:
Oct. 20, 2011 renamed from startVertex to startVertexArray

xctr

public float xctr()
Returns the value of the x-coordinate of center of transformation. Will calculate center of bounding box if center has not been set.

Returns:
x-coordinate of center of transformation.

yctr

public float yctr()
Returns the of the y-coordinate of center of transformation. Will calculate center of bounding box if center has not been set.

Returns:
y-coordinate of center of transformation.

centerVertex

public LineVertex centerVertex()
Returns:
the center coordinates xctr, yctr as a LineVertex

setCenter

public void setCenter(float xctr,
                      float yctr)
Sets center point for geometric transforms on this shape.

Parameters:
xctr -
yctr -

setCenter

public void setCenter(Point2D pt)
Sets center point for geometric transforms on this shape.

Parameters:
pt -

setCenter

public void setCenter(LineVertex centerPoint)
Sets the values of xctr and yctr

Parameters:
centerPoint - a LineVertext encapsulating the center coordinates to set

calculateCenter

public void calculateCenter()
Sets the center of transformation to the center of the bounding rectangle of this shape. Sets the xcoords and ycoords arrays, if required. By default, the center point is (0,0), as in Processing. If you want shapes to transform around their center points (i.e., to scale or rotate in place), call calculateCenter before calling rotateShape or scaleShape. transform uses the point of transformation set in its transformation matrix, so you can use it for transformations around any arbitrary point.


getBoundsCenter

public LineVertex getBoundsCenter()
Returns the center of the bounding rectangle of this shape as a LineVertex. Sets the xcoords and ycoords arrays, if required.

Returns:
an array of two floats, the average x- and y-coordinates of the shape's anchor points.
Since:
October 21, 2011

getAnchorCenter

public LineVertex getAnchorCenter(BezShape shape)
Returns the average of all anchor points of the vertices of this shape.

Returns:
the average x- and y-coordinates of the shape's anchor points.
Since:
October 21, 2011

getGeoCenter

public LineVertex getGeoCenter()
Returns the average of the x- and y-coordinates of this shape as a LineVertex. The result is an approximation based on the derived polygon. Accuracy can be improved by first calling asPolygon with an argument greater than the default of 16 segments per curve.

Returns:
a LineVertex at the geometric mean of the points of this shape

curveIterator

public ListIterator<Vertex2DINF> curveIterator()
Returns an iterator over the geometry of this shape. Preferred method for accessing geometry.

Returns:
an iterator over the Vertex2DINF segments that comprise the geometry of this shape

curves

public ArrayList<Vertex2DINF> curves()
Returns the geometry of this shape as an ArrayList. Note that the startPoint is not included, you can obtain that separately from startVertex() or from x() and y().

Returns:
an ArrayList with all the Vertex2DINF segments that compose this shape, in order appended Use with caution, changing geometry directly instead of with transform() and other built-in methods can have unexpected consequences. Call curvesCopy instead.

curvesCopy

public ArrayList<Vertex2DINF> curvesCopy()
Returns a copy of the geometry of this shape as an ArrayList. Note that the startPoint is not included, you can obtain that separately from startVertex() or from x() and y().

Returns:
an ArrayList with all the Vertex2DINF segments that compose this shape, in order appended
Since:
October 3, 2011

setCurves

public void setCurves(ArrayList<Vertex2DINF> newCurves)
Parameters:
newCurves - an ArrayList of Vertex2DINF segments that will define the geometry of this shape. Does not change the startPoint. You can do that with setStartPoint(float, float) or with setX(float) and setY(float). Sets xcoords and ycoords to null. Does not update centerPoint. You can do that with calculateCenter() or the various methods for setting centerPoint directly, setCenter(LineVertex), setCenter(float, float). Use with caution.

getCoords

public float[] getCoords()
Returns an array of all vertex coordinates. A LineVertex adds two values to the array and a BezVertex adds six values (two control points and an anchor point). There is no inherent way to distinguish which values represent control points and which represent anchor points.

Returns:
an array of float generated from the vertices of this shape.
See Also:
asPolygon(PApplet, int).

asPolygon

public float[] asPolygon(PApplet parent,
                         int steps)
Extracts an approximated polygon from path data, returning it as an array of floats. Rebuilds the xcoords and ycoords arrays. Polygon data is not cached, but the xcoords and ycoords arrays are. You can use them to construct a polygon once they have been initialized. If, against our good advice, you munge around with shape geometry, you can reset xcoords and ycoords with a call to this method, which always recalculates xcoords and ycoords and boundsRect

Parameters:
steps - number of straight line segments to divide Bezier curves into
parent - reference to a PApplet needed to build a polygon from a Bezier curve

asPolygon

public float[] asPolygon(PApplet parent)
Extracts an approximated polygon from path data. Returns the polygon as an array of floats using a default value of 16 steps for curve segments. Call setPolySteps() to change the level of approximation of the polygon to the actual paths.

Parameters:
parent - reference to a PApplet needed to build a polygon from a Bezier curve

asPolygon

public float[] asPolygon(int steps)

asPolygon

public float[] asPolygon()

containsPoint

public boolean containsPoint(PApplet parent,
                             float x,
                             float y)
Tests if a point is inside this shape by generating a polygon approximation to curved paths and testing that. It is possible to get an erroneous answer. Precision may be increased by calling setPolySteps with a value above the default 16 steps. May be slow the first time you call it, but will used cached data after that.

Parameters:
parent - reference to a Processing PApplet, probably the one calling this code
x - x-coordinate of test point
y - y-coordinate of test point
Returns:
true if point is inside the polygon approximation of this shape

containsPoint

public boolean containsPoint(float x,
                             float y)

xcoords

public float[] xcoords(PApplet parent)
Returns x-coordinates of the geometry of this shape. The shape is first rendered as a polygon (see asPolygon) for details.

Parameters:
parent - reference to a PApplet needed to build a polygon from a Bezier curve
Returns:
x-coordinate array of the geometry of this shape

xcoords

public float[] xcoords()

ycoords

public float[] ycoords(PApplet parent)
Returns y-coordinates of the geometry of this shape. The shape is first rendered as a polygon (see asPolygon) for details.

Parameters:
parent - reference to a PApplet needed to build a polygon from a Bezier curve
Returns:
y-coordinate array

ycoords

public float[] ycoords()

polySize

public int polySize(PApplet parent)
Parameters:
parent - reference to a PApplet needed to build a polygon from a Bezier curve
Returns:
number of points in polygon representation of this shape

polySize

public int polySize()

polySteps

public int polySteps()
Returns the number of straight line segments used in fast calculation

Returns:
default number of steps in polyline representation of a curve segment

setPolySteps

public void setPolySteps(int newPolySteps)
Parameters:
newPolySteps - default number of steps in polyline representation of a curve segment

bounds

public float[] bounds(PApplet parent)
returns array of floats with top, left, bottom, right coordinates of bounding box These are an approximation based on the derived polygon, accuracy can be improved by first calling asPolygon with an argument greater than the default of 16 segments per curve.

Parameters:
parent - reference to a PApplet needed to build a polygon from a Bezier curve
Returns:
array of float: left, top, right, bottom coordinates

bounds

public float[] bounds()
returns array of floats with top, left, bottom, right coordinates of bounding box These are an approximation based on the derived polygon, accuracy can be improved by first calling asPolygon with an argument greater than the default of 16 segments per curve. For speed, it is better to call the boundsRect() method, which returns cached data.

Returns:
array of float: left, top, right, bottom coordinates

boundsRect

public BezRectangle boundsRect()
Returns the bounding rectangle of this shape. If it has not yet been calculated, creates it from the calculated xcoords and ycoords arrays. The boundsRect is aligned to the x- and y-axes. It is cached in between calls, and set to null after a transform.

Returns:
the bounding rectangle of this shape

translateShape

public void translateShape(float xTrans,
                           float yTrans)
Translates this shape. Moves center point, calculating it if necessary. Sets xcoords and ycoords arrays to null: they will have to be recalculated after a transform, which will be done through lazy initialization when xcoords() or ycoords() are called.

Parameters:
xTrans - translation on x-axis
yTrans - translation on y-axis
Since:
2011.10.07 faster code, uses instance vars directly

moveTo

public void moveTo(float newXCtr,
                   float newYCtr)
Handy method to translate center point (xctr, yctr) and shape to a new location.

Parameters:
newXCtr -
newYCtr -

scaleShape

public void scaleShape(float xScale,
                       float yScale,
                       float x0,
                       float y0)
Scales this shape around a given point. Sets xcoords and ycoords arrays to null: they will have to be recalculated after a transform, which will be done through lazy initialization when xcoords() or ycoords() are called.

Parameters:
xScale - scaling on x-axis
yScale - scaling on y-axis

scaleShape

public void scaleShape(float xScale,
                       float yScale)
Scales this shape around its center point. You can change the center point by calling setCenter or calculateCenter. Sets xcoords and ycoords arrays to null: they will have to be recalculated after a transform, which will be done through lazy initialization when xcoords() or ycoords() are called.

Parameters:
xScale - scaling on x-axis
yScale - scaling on y-axis

scaleShape

public void scaleShape(float xyScale)
Uniformly scales this shape around its center point. You can change the center point by calling setCenter or calculateCenter. Sets xcoords and ycoords arrays to null: they will have to be recalculated after a transform, which will be done through lazy initialization when xcoords() or ycoords() are called.

Parameters:
xyScale - uniform scaling on x-axis and y-axis

scaleShape

public void scaleShape(float xyScale,
                       float x0,
                       float y0)
Uniformly scales this shape around a given point.

Parameters:
xyScale - uniform scaling on x-axis and y-axis

rotateShape

public void rotateShape(float theta)
Rotates this shape around its center point. You can change the center point by calling setCenter or calculateCenter. Sets xcoords and ycoords arrays to null: they will have to be recalculated after a transform, which will be done through lazy initialization when xcoords() or ycoords() are called.

Parameters:
theta - degrees to rotate (in radians) TODO for theta very near PI, 0, or TWO_PI, insure correct rotation.

rotateShape

public void rotateShape(float xctr,
                        float yctr,
                        float theta)
Rotates this shape around a supplied center point.

Parameters:
theta - degrees to rotate (in radians) TODO for theta very near PI, 0, or TWO_PI, insure correct rotation.

getMatrix

public static Matrix3 getMatrix(PApplet applet)
Captures a transformation matrix from a PApplet, for later use.

Parameters:
applet - a PApplet, probably the one that's running the show.
Returns:
a Matrix3 that encapsulates Processing's current transformation matrix

getCtm

public Matrix3 getCtm()
Returns a copy of the most recent transformation matrix. Returns the identity matrix if no transforms have been performed. The ctm keeps a record of the most recent transformation matrix passed as an argument to transform. It can be used directly (and repeatedly) with a call to transform.

Returns:
a copy of the ctm

setCtm

public void setCtm(Matrix3 ctm)
Parameters:
ctm - the ctm to set

setCtm

public void setCtm(PApplet applet)
Captures the current transformation matrix from a PApplet and uses it to set our ctm.

Parameters:
applet - a PApplet from which the current matrix will be used to set the ctm

setCtm

public void setCtm(PMatrix2D m)
Sets our ctm from a PMatrix2D.

Parameters:
m - a PMatrix2D to set the ctm

transformShape

public void transformShape(Matrix3 matx)
Deprecated. 

Alternate method of calling transform.

Parameters:
matx -

transform

public void transform(Matrix3 matx)
Performs an affine geometric transformation on this shape using 3x3 matrix multiplication. Sets xcoords and ycoords arrays to null: they will have to be recalculated after a transform, which will be done through lazy initialization when xcoords() or ycoords() are called.

Specified by:
transform in class DisplayComponent
Parameters:
matx - a 3x3 matrix see Matrix3 class for methods of loading transforms

transform

public void transform()
Calls transform with this shape's ctm, current transformation matrix.


draw

public void draw()
Draws this shape to the display. Calls beginShape and endShape on its own.

Specified by:
draw in class DisplayComponent

draw

public void draw(PGraphics pg)
Draws this shape to an offscreen PGraphics. Calls beginShape and endShape on its own. It's up to the user to call beginDraw() and endDraw() on the PGraphics instance.

Parameters:
pg - a PGraphics instance

drawQuick

public void drawQuick()
Draws this shape to the display. Calls beginShape and endShape on its own. Uses current fill, stroke and weight from Processing environment.


write

public void write(PrintWriter pw)
Writes Adobe Illustrator 7.0 tags describing the geometry of this shape to PrintWriter. Brackets calls to AIFIleWriter curve and line drawing methods with AIFIleWriter.psMoveTo and AIFIleWriter.paintPath. Sets fill, stroke, and weight from values for fillColor, strokeColor and weight, where applicable. If you want to output transparency, call setUseTransparency() with a argument of true before calling write(). Because Illustrator does not support separate transparency for fill and stroke, assigning a transparent color to either on will make the the entire object transparent. If stroke and fill transparency have different values, stroke transparency will be assigned to the object.

Specified by:
write in class DisplayComponent
Parameters:
pw - a PrintWriter for file output.

write

public void write(int pathOp,
                  PrintWriter output)
Writes Adobe Illustrator 7.0 tags describing the geometry of this shape to PrintWriter. Brackets calls to AIFIleWriter curve and line drawing methods with AIFIleWriter.psMoveTo and AIFIleWriter.paintPath. Omits fill and stroke and weight calls: these are assumed to be already set in current Illustrator graphics state. Omits visibility and locking status: these are also assumed to be set in the current graphics state. Closure, fill, and stroke rendering of the path are determined by the pathOp parameter. If you have set transparency, you'll need to call AIFileWriter.noTransparency when your graphics calls are finished. This is not called from the DisplayComponent hierarchy, which always calls write(PrintWriter). It is primarily of use in writing out files with direct calls to AiFileWriter.

Parameters:
pathOp - @see com.ignotus.aifile.AIFileWriter#paintPath
output - a PrintWriter that writes vector graphics in the Adobe Illustrator 7.0 file format

accept

public void accept(ComponentVisitor visitor)
Description copied from interface: Visitable
Accepts a ComponentVisitor that traverses a document structure tree.

When called from an object that implements the Visitable interface:

  1. each visited object passes a reference to itself back to the visitor
  2. each visited object calls accept( visitor ) on all its children

The reference is passed back to the visitor through a method of the form visitor.visit<ComponentClassName>( this ); See ComponentVisitor

The order of steps 1 and 2 determines if traversal of the composite structure is preorder or postorder. As shown above, it's preorder. Depending on what you want to do, one traversal may be better suited than the other. Preorder visits parents first, postorder visits children first.

Specified by:
accept in interface Visitable
Parameters:
visitor - a ComponentVisitor

accept

public void accept(ComponentVisitor visitor,
                   boolean order)
Description copied from interface: Visitable
Accepts a ComponentVisitor that traverses a document structure tree in preorder or postorder.

Specified by:
accept in interface Visitable
Parameters:
visitor - a ComponentVisitor
order - boolean to determine if traversal is preorder or postorder accept( visitor ) should implement the default order of traversal, accept( visitor, <false> ) should implement the other order.

bezCircle

public static BezCircle bezCircle(PApplet parent,
                                  float xctr,
                                  float yctr,
                                  float radius,
                                  int sectors)
Creates a circular BezShape with sectors number of Bezier curves. Fill, stroke, and weight are set from their values in the Processing environment.

Parameters:
sectors - number of equal divisions of circle
radius - radius of circle
xctr - x-coordinate of center of circle
yctr - y-coordinate of center of circle
Returns:
a circular BezShape of type BezShape.BEZ_CIRCLE

bezEllipse

public static BezEllipse bezEllipse(PApplet parent,
                                    float xctr,
                                    float yctr,
                                    float width,
                                    float height,
                                    int sectors)
Creates an elliptical BezShape with sectors number of Bezier curves. Fill, stroke, and weight are set from their values in the Processing environment.

Parameters:
sectors - integer for number of equal divisions of circle
width - width of the ellipse
height - height of the ellipse
xctr - x-coordinate of center of circle
yctr - y-coordinate of center of circle
Returns:
an elliptical BezShape of type BezShape.BEZ_ELLIPSE

bezRegularPoly

public static BezRegularPoly bezRegularPoly(PApplet parent,
                                            float xctr,
                                            float yctr,
                                            float radius,
                                            int sides)
Constructs a regular polygon BezShape with sides edges and radius radius. Fill, stroke, and weight are set from their values in the Processing environment.

Parameters:
xctr - x-coordinate of center of polygon
yctr - y-coordinate of center of polygon
radius - radius of the polygon
sides - number of sides of the polygon
Returns:
a polygonal BezShape of type BezShape.BEZ_REGULAR_POLY

bezCurveShape

public static BezCurveShape bezCurveShape(PApplet parent,
                                          float[] coords)
Returns a multi-segment Bˇzier curve from an array of float. Fill, stroke, and weight are set from their values in the Processing environment. The first coordinate pair is the initial anchor point, the following coordinate pairs correspond to the first control point, second control point, and final anchor point of each additional curve. The final anchor point and the first coordinate pair should be identical for a properly closed shape. The shape will be closed and consist only of Bezier curves with no straight lines.

Parameters:
coords - an array of coordinate pairs
Returns:
a multi-segment curved line of type BezShape.BEZ_MULTICURVE

bezTriangle

public static BezTriangle bezTriangle(PApplet parent,
                                      float xctr,
                                      float yctr,
                                      float radius)
Constructs an equilateral triangle with supplied center (xctr, yctr) and radius. The base is aligned with the x-axis, apex points down. Fill, stroke, and weight are set from their values in the Processing environment.

Parameters:
xctr - x-coordinate of center of triangle
yctr - y-coordinate of center of triangle
radius - radius of the triangle
Returns:
an equilateral triangle BezShape of type BezShape.BEZ_TRIANGLE

bezTriangle

public static BezTriangle bezTriangle(PApplet parent,
                                      float x1,
                                      float y1,
                                      float x2,
                                      float y2,
                                      float x3,
                                      float y3)
Constructs a triangle from three points. Fill, stroke, and weight of shapes are set from their values in the Processing environment.

Parameters:
x1 - x-coordinate of first point
y1 - y-coordinate of first point
x2 - x-coordinate of second point
y2 - y-coordinate of second point
x3 - x-coordinate of third point
y3 - y-coordinate of third point
Returns:
a triangular BezShape of type BezShape.BEZ_TRIANGLE

bezRectangle

public static BezRectangle bezRectangle(PApplet parent,
                                        float left,
                                        float top,
                                        float right,
                                        float bottom)
Constructs a rectangular BezShape. Fill, stroke, and weight are set from their values in the Processing environment.

Parameters:
left - the left x-coordinate of the rectangle
top - the top y-coordinate of the rectangle
right - the right x-coordinate of the rectangle
bottom - the bottom y-coordinate of the rectangle
Returns:
a rectangular BezShape of type BezShape.BEZ_RECTANGLE

bezLine

public static BezLine bezLine(PApplet parent,
                              float x1,
                              float y1,
                              float x2,
                              float y2)
Constructs a straight line between (x1, y1) and (x2, y2). Fill, stroke, and weight are set from their values in the Processing environment.

Parameters:
x1 - x-coordinate of first point
y1 - y-coordinate of first point
x2 - x-coordinate of second point
y2 - y-coordinate of second point
Returns:
a straight line BezShape of type BezShape.BEZ_LINE

bezCurve

public static BezShape bezCurve(PApplet parent,
                                float ax1,
                                float ay1,
                                float cx1,
                                float cy1,
                                float cx2,
                                float cy2,
                                float ax2,
                                float ay2)
Constructs a single Bˇzier curve. Fill, stroke, and weight are set from their values in the Processing environment.

Parameters:
ax1 - x-coordinate of initial anchor point
ay1 - y-coordinate of initial anchor point
cx1 - x-coordinate of first control point
cy1 - y-coordinate of first control point
cx2 - x-coordinate of second control point
cy2 - y-coordinate of second control point
ax2 - x-coordinate of terminal anchor point
ay2 - y-coordinate of terminal anchor point
Returns:
a curved line BezShape of type BezShape.BEZ_CURVE

bezMultiLine

public static BezMultiLine bezMultiLine(PApplet parent,
                                        float[] coords)
Constructs a multi-segment line from an array of float. Fill, stroke, and weight are set from their values in the Processing environment.

Parameters:
coords - an array of coordinate pairs
Returns:
a multi-segment line of type BezShape.BEZ_MULTILINE

bezPoly

public static BezPoly bezPoly(PApplet parent,
                              float[] coords)
Constructs a multi-segment line from an array of float. Fill, stroke, and weight are set from their values in the Processing environment.

Parameters:
coords - an array of coordinate pairs
Returns:
a multi-segment line of type BezShape.BEZ_MULTILINE

bezMultiCurve

public static BezMultiCurve bezMultiCurve(PApplet parent,
                                          float[] coords)
Constructs a multi-segment Bˇzier curve from an array of float. Fill, stroke, and weight are set from their values in the Processing environment. The first coordinate pair is the initial anchor point, the following coordinate pairs correspond to the first control point, second control point, and final anchor point of each additional curve.

Parameters:
coords - an array of coordinate pairs
Returns:
a multi-segment curved line of type BezShape.BEZ_MULTICURVE


processing library IgnoCodeLib by Paul Hertz. (c) 2011