Java Code Examples for processing.core.PApplet#expand()

The following examples show how to use processing.core.PApplet#expand() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PShape.java    From CPE552-Java with GNU General Public License v3.0 6 votes vote down vote up
public void vertex(float x, float y) {
  if (vertices == null) {
    vertices = new float[10][2];
  } else if (vertices.length == vertexCount) {
    vertices = (float[][]) PApplet.expand(vertices);
  }
  vertices[vertexCount++] = new float[] { x, y };

  if (vertexCodes == null) {
    vertexCodes = new int[10];
  } else if (vertexCodes.length == vertexCodeCount) {
    vertexCodes = PApplet.expand(vertexCodes);
  }
  vertexCodes[vertexCodeCount++] = VERTEX;

  if (x > width) {
    width = x;
  }
  if (y > height) {
    height = y;
  }
}
 
Example 2
Source File: PShape.java    From CPE552-Java with GNU General Public License v3.0 6 votes vote down vote up
public void bezierVertex(float x2, float y2,
                         float x3, float y3,
                         float x4, float y4) {
  if (vertices == null) {
    vertices = new float[10][];
  } else if (vertexCount + 2 >= vertices.length) {
    vertices = (float[][]) PApplet.expand(vertices);
  }
  vertices[vertexCount++] = new float[] { x2, y2 };
  vertices[vertexCount++] = new float[] { x3, y3 };
  vertices[vertexCount++] = new float[] { x4, y4 };

  // vertexCodes must be allocated because a vertex() call is required
  if (vertexCodes.length == vertexCodeCount) {
    vertexCodes = PApplet.expand(vertexCodes);
  }
  vertexCodes[vertexCodeCount++] = BEZIER_VERTEX;

  if (x4 > width) {
    width = x4;
  }
  if (y4 > height) {
    height = y4;
  }
}
 
Example 3
Source File: PShape.java    From CPE552-Java with GNU General Public License v3.0 6 votes vote down vote up
public void quadraticVertex(float cx, float cy,
                            float x3, float y3) {
  if (vertices == null) {
    vertices = new float[10][];
  } else if (vertexCount + 1 >= vertices.length) {
    vertices = (float[][]) PApplet.expand(vertices);
  }
  vertices[vertexCount++] = new float[] { cx, cy };
  vertices[vertexCount++] = new float[] { x3, y3 };

  // vertexCodes must be allocated because a vertex() call is required
  if (vertexCodes.length == vertexCodeCount) {
    vertexCodes = PApplet.expand(vertexCodes);
  }
  vertexCodes[vertexCodeCount++] = QUADRATIC_VERTEX;

  if (x3 > width) {
    width = x3;
  }
  if (y3 > height) {
    height = y3;
  }
}
 
Example 4
Source File: PShape.java    From CPE552-Java with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param idx the layer position in which to insert the new child
 */
public void addChild(PShape who, int idx) {
  if (idx < childCount) {
    if (childCount == children.length) {
      children = (PShape[]) PApplet.expand(children);
    }

    // Copy [idx, childCount - 1] to [idx + 1, childCount]
    for (int i = childCount - 1; i >= idx; i--) {
      children[i + 1] = children[i];
    }
    childCount++;

    children[idx] = who;

    who.parent = this;

    if (who.getName() != null) {
      addName(who.getName(), who);
    }
  }
}
 
Example 5
Source File: PShape.java    From CPE552-Java with GNU General Public License v3.0 5 votes vote down vote up
protected void beginContourImpl() {
  if (vertexCodes == null) {
    vertexCodes = new int[10];
  } else if (vertexCodes.length == vertexCodeCount) {
    vertexCodes = PApplet.expand(vertexCodes);
  }
  vertexCodes[vertexCodeCount++] = BREAK;
}
 
Example 6
Source File: PShape.java    From CPE552-Java with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @webref pshape:method
 * @brief Adds a new child
 * @param who any variable of type PShape
 * @see PShape#getChild(int)
 */
public void addChild(PShape who) {
  if (children == null) {
    children = new PShape[1];
  }
  if (childCount == children.length) {
    children = (PShape[]) PApplet.expand(children);
  }
  children[childCount++] = who;
  who.parent = this;

  if (who.getName() != null) {
    addName(who.getName(), who);
  }
}