Java Code Examples for com.juankysoriano.rainbow.core.drawing.Modes#Shape

The following examples show how to use com.juankysoriano.rainbow.core.drawing.Modes#Shape . 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: RainbowGraphics.java    From rainbow with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Perform initialization specific to curveVertex(), and handle standard
 * error modes. Can be overridden by subclasses that need the flexibility.
 */
void curveVertexCheck(Modes.Shape shape) {
    if (shape != POLYGON) {
        throw new RuntimeException("You must use beginShape() or " + "beginShape(POLYGON) before curveVertex()");
    }
    // to improve code init time, allocate on first use.
    if (curveVertices == null) {
        curveVertices = new float[128][3];
    }

    if (curveVertexCount == curveVertices.length) {
        // Can't use Imagine.expand() cuz it doesn't do the copy
        // properly
        float[][] temp = new float[curveVertexCount << 1][3];
        System.arraycopy(curveVertices, 0, temp, 0, curveVertexCount);
        curveVertices = temp;
    }
    curveInitCheck();
}
 
Example 2
Source File: RainbowGraphics.java    From rainbow with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void bezierVertexCheck(Modes.Shape shape, int vertexCount) {
    if (shape == UNDEFINED || shape != POLYGON) {
        throw new RuntimeException("beginShape() or beginShape(POLYGON) " + "must be used before bezierVertex() or quadraticVertex()");
    }
    if (vertexCount == 0) {
        throw new RuntimeException("vertex() must be used at least once" + "before bezierVertex() or quadraticVertex()");
    }
}
 
Example 3
Source File: RainbowGraphics2D.java    From rainbow with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void endShape(Modes.Shape mode) {
    if (shapeMode == POINTS && stroke && vertexCount > 0) {
        endPointsShape();
    } else if (shapeMode == POLYGON) {
        endPolygonShape(mode);
    }
    shapeMode = UNDEFINED;
}
 
Example 4
Source File: RainbowGraphics2D.java    From rainbow with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void endPolygonShape(Modes.Shape mode) {
    if (!path.isEmpty()) {
        if (mode == CLOSE) {
            path.close();
        }
        drawPath();
    }
}
 
Example 5
Source File: RainbowGraphics.java    From rainbow with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void endShape(Modes.Shape mode) {
}
 
Example 6
Source File: RainbowGraphics2D.java    From rainbow with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void beginShape(Modes.Shape mode) {
    shapeMode = mode;
    vertexCount = 0;
    curveVertexCount = 0;
}
 
Example 7
Source File: RainbowGraphics.java    From rainbow with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Start a new shape.
 * <p/>
 * <B>Differences between beginShape() and line() and point() methods.</B>
 * <p/>
 * beginShape() is intended to be more flexible at the expense of being a
 * little more complicated to use. it handles more complicated shapes that
 * can consist of many connected lines (so you get joins) or lines mixed
 * with curves.
 * <p/>
 * The line() and point() command are for the far more common cases
 * (particularly for our audience) that simply need to draw a line or a
 * point on the screen.
 * <p/>
 * From the code side of things, line() may or may not call beginShape() to
 * do the drawing. In the beta code, they do, but in the alpha code, they
 * did not. they might be implemented one way or the other depending on
 * tradeoffs of runtime efficiency vs. implementation efficiency &mdash
 * meaning the speed that things run at vs. the speed it takes me to write
 * the code and maintain it. for beta, the latter is most important so
 * that's how things are implemented.
 */
public void beginShape(Modes.Shape mode) {
    shapeMode = mode;
}