From 232390c02c9dd7295f6a0341abbabfa8dbdb2a2b Mon Sep 17 00:00:00 2001
From: benfry
Date: Sat, 1 Sep 2012 18:05:24 +0000
Subject: [PATCH] move PConstants around a bit, add annotations for overrides,
cleaning up unapproved PShape additions
---
.../core/.settings/org.eclipse.jdt.core.prefs | 24 +-
android/core/src/processing/core/PApplet.java | 7 +-
.../core/src/processing/core/PConstants.java | 70 +--
.../core/src/processing/core/PGraphics.java | 81 +++
android/core/src/processing/core/PShape.java | 566 ++++++++++++------
.../src/processing/opengl/PGraphics2D.java | 5 +-
.../src/processing/opengl/PGraphics3D.java | 5 +-
.../processing/opengl/PGraphicsOpenGL.java | 12 +-
.../processing/opengl/tess/PriorityQSort.java | 6 +-
core/.settings/org.eclipse.jdt.core.prefs | 6 +-
core/src/processing/core/PApplet.java | 2 +-
core/src/processing/core/PConstants.java | 83 +--
core/src/processing/core/PGraphics.java | 98 ++-
core/src/processing/core/PMatrix2D.java | 18 +-
core/src/processing/core/PMatrix3D.java | 14 +-
core/src/processing/core/PShape.java | 190 +++---
core/src/processing/opengl/PGL.java | 3 +
core/src/processing/opengl/PGraphics2D.java | 5 +-
core/src/processing/opengl/PGraphics3D.java | 5 +-
.../processing/opengl/PGraphicsOpenGL.java | 13 +-
core/src/processing/opengl/PShapeOpenGL.java | 2 +
21 files changed, 753 insertions(+), 462 deletions(-)
diff --git a/android/core/.settings/org.eclipse.jdt.core.prefs b/android/core/.settings/org.eclipse.jdt.core.prefs
index 19a6a3ffa..e2271273c 100644
--- a/android/core/.settings/org.eclipse.jdt.core.prefs
+++ b/android/core/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,9 @@
eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
@@ -17,6 +22,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
@@ -24,33 +30,48 @@ org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=disabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
@@ -63,6 +84,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverridin
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
diff --git a/android/core/src/processing/core/PApplet.java b/android/core/src/processing/core/PApplet.java
index 2beb4cab6..18fff07ee 100644
--- a/android/core/src/processing/core/PApplet.java
+++ b/android/core/src/processing/core/PApplet.java
@@ -45,6 +45,7 @@ import android.os.Handler;
import android.text.format.Time;
import android.util.*;
import android.view.*;
+import android.view.ViewGroup.LayoutParams;
import android.widget.*;
import org.apache.http.client.HttpClient;
@@ -493,8 +494,8 @@ public class PApplet extends Activity implements PConstants, Runnable {
// can keep your "talentless hack" comments to yourself. Ahem.)
RelativeLayout overallLayout = new RelativeLayout(this);
RelativeLayout.LayoutParams lp =
- new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
- RelativeLayout.LayoutParams.WRAP_CONTENT);
+ new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
+ LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.CENTER_IN_PARENT);
LinearLayout layout = new LinearLayout(this);
@@ -9225,7 +9226,7 @@ public class PApplet extends Activity implements PConstants, Runnable {
* built with Processing.
*/
static public int blendColor(int c1, int c2, int mode) {
- return PGraphics.blendColor(c1, c2, mode);
+ return PImage.blendColor(c1, c2, mode);
}
diff --git a/android/core/src/processing/core/PConstants.java b/android/core/src/processing/core/PConstants.java
index 777d9e8f1..3c397b130 100644
--- a/android/core/src/processing/core/PConstants.java
+++ b/android/core/src/processing/core/PConstants.java
@@ -35,80 +35,14 @@ import android.view.KeyEvent;
* as possible. For instance, the constant is TIFF instead of
* FILE_TYPE_TIFF. We'll do this as long as we can get away with it.
*/
-public interface PConstants {
- // vertex fields
+public interface PConstants {
+ // vertex fields
static public final int X = 0; // model coords xyz (formerly MX/MY/MZ)
static public final int Y = 1;
static public final int Z = 2;
- static public final int R = 3; // actual rgb, after lighting
- static public final int G = 4; // fill stored here, transform in place
- static public final int B = 5; // TODO don't do that anymore (?)
- static public final int A = 6;
-
- static public final int U = 7; // texture
- static public final int V = 8;
-
- static public final int NX = 9; // normal
- static public final int NY = 10;
- static public final int NZ = 11;
-
- static public final int EDGE = 12;
-
- // stroke
-
- /** stroke argb values */
- static public final int SR = 13;
- static public final int SG = 14;
- static public final int SB = 15;
- static public final int SA = 16;
-
- /** stroke weight */
- static public final int SW = 17;
-
- /*
- static public final int TX = 18; // transformed xyzw
- static public final int TY = 19;
- static public final int TZ = 20;
-
- static public final int VX = 21; // view space coords
- static public final int VY = 22;
- static public final int VZ = 23;
- static public final int VW = 24;
-
- // Ambient color (usually to be kept the same as diffuse)
- // fill(_) sets both ambient and diffuse.
- static public final int AR = 25;
- static public final int AG = 26;
- static public final int AB = 27;
-
- // Diffuse is shared with fill.
- static public final int DR = 3; // TODO needs to not be shared, this is a material property
- static public final int DG = 4;
- static public final int DB = 5;
- static public final int DA = 6;
-
- // specular (by default kept white)
- static public final int SPR = 28;
- static public final int SPG = 29;
- static public final int SPB = 30;
-
- static public final int SHINE = 31;
-
- // emissive (by default kept black)
- static public final int ER = 32;
- static public final int EG = 33;
- static public final int EB = 34;
- */
-
- // has this vertex been assigned a normal yet
- static public final int HAS_NORMAL = 18;
-
- static public final int VERTEX_FIELD_COUNT = 19;
-
// built-in rendering options
-
static final String JAVA2D = "processing.core.PGraphicsAndroid2D";
static final String P2D = "processing.opengl.PGraphics2D";
static final String P3D = "processing.opengl.PGraphics3D";
diff --git a/android/core/src/processing/core/PGraphics.java b/android/core/src/processing/core/PGraphics.java
index 3eeb2606e..a06394fba 100644
--- a/android/core/src/processing/core/PGraphics.java
+++ b/android/core/src/processing/core/PGraphics.java
@@ -170,6 +170,87 @@ public class PGraphics extends PImage implements PConstants {
protected boolean[] hints = new boolean[HINT_COUNT];
+ ////////////////////////////////////////////////////////////
+
+ // Vertex fields, moved from PConstants (after 2.0a8) because they're too
+ // general to show up in all sketches as defined variables.
+
+ // X, Y and Z are still stored in PConstants because of their general
+ // usefulness, and that X we'll always want to be 0, etc.
+
+ static public final int R = 3; // actual rgb, after lighting
+ static public final int G = 4; // fill stored here, transform in place
+ static public final int B = 5; // TODO don't do that anymore (?)
+ static public final int A = 6;
+
+ static public final int U = 7; // texture
+ static public final int V = 8;
+
+ static public final int NX = 9; // normal
+ static public final int NY = 10;
+ static public final int NZ = 11;
+
+ static public final int EDGE = 12;
+
+ // stroke
+
+ /** stroke argb values */
+ static public final int SR = 13;
+ static public final int SG = 14;
+ static public final int SB = 15;
+ static public final int SA = 16;
+
+ /** stroke weight */
+ static public final int SW = 17;
+
+ // transformations (2D and 3D)
+
+ static public final int TX = 18; // transformed xyzw
+ static public final int TY = 19;
+ static public final int TZ = 20;
+
+ static public final int VX = 21; // view space coords
+ static public final int VY = 22;
+ static public final int VZ = 23;
+ static public final int VW = 24;
+
+
+ // material properties
+
+ // Ambient color (usually to be kept the same as diffuse)
+ // fill(_) sets both ambient and diffuse.
+ static public final int AR = 25;
+ static public final int AG = 26;
+ static public final int AB = 27;
+
+ // Diffuse is shared with fill.
+ static public final int DR = 3; // TODO needs to not be shared, this is a material property
+ static public final int DG = 4;
+ static public final int DB = 5;
+ static public final int DA = 6;
+
+ // specular (by default kept white)
+ static public final int SPR = 28;
+ static public final int SPG = 29;
+ static public final int SPB = 30;
+
+ static public final int SHINE = 31;
+
+ // emissive (by default kept black)
+ static public final int ER = 32;
+ static public final int EG = 33;
+ static public final int EB = 34;
+
+ // has this vertex been lit yet
+ static public final int BEEN_LIT = 35;
+
+ // has this vertex been assigned a normal yet
+ static public final int HAS_NORMAL = 36;
+
+ static public final int VERTEX_FIELD_COUNT = 37;
+
+
+
////////////////////////////////////////////////////////////
// STYLE PROPERTIES
diff --git a/android/core/src/processing/core/PShape.java b/android/core/src/processing/core/PShape.java
index 407386756..6e47a5958 100644
--- a/android/core/src/processing/core/PShape.java
+++ b/android/core/src/processing/core/PShape.java
@@ -26,6 +26,22 @@ import java.util.HashMap;
/**
+ * ( begin auto-generated from PShape.xml )
+ *
+ * Datatype for storing shapes. Processing can currently load and display
+ * SVG (Scalable Vector Graphics) shapes. Before a shape is used, it must
+ * be loaded with the loadShape() function. The shape()
+ * function is used to draw the shape to the display window. The
+ * PShape object contain a group of methods, linked below, that can
+ * operate on the shape data.
+ *
+ * The loadShape() function supports SVG files created with Inkscape
+ * and Adobe Illustrator. It is not a full SVG implementation, but offers
+ * some straightforward support for handling vector data.
+ *
+ * ( end auto-generated )
+ * Advanced
+ *
* In-progress class to handle shape data, currently to be considered of
* alpha or beta quality. Major structural work may be performed on this class
* after the release of Processing 1.0. Such changes may include:
@@ -50,14 +66,22 @@ import java.util.HashMap;
* Library developers are encouraged to create PShape objects when loading
* shape data, so that they can eventually hook into the bounty that will be
* the PShape interface, and the ease of loadShape() and shape().
+ *
+ * @webref shape
+ * @usage Web & Application
+ * @see PApplet#shape(PShape)
+ * @see PApplet#loadShape(String)
+ * @see PApplet#shapeMode(int)
+ * @instanceName sh any variable of type PShape
*/
public class PShape implements PConstants {
protected String name;
protected HashMap nameTable;
- /** Generic, only draws its child objects. */
- static public final int GROUP = 0;
+// /** Generic, only draws its child objects. */
+// static public final int GROUP = 0;
+ // GROUP now inherited from PConstants
/** A line, ellipse, arc, image, etc. */
static public final int PRIMITIVE = 1;
/** A series of vertex, curveVertex, and bezierVertex calls. */
@@ -81,14 +105,24 @@ public class PShape implements PConstants {
//protected float width;
//protected float height;
/**
+ * ( begin auto-generated from PShape_width.xml )
+ *
* The width of the PShape document.
- * @webref
+ *
+ * ( end auto-generated )
+ * @webref pshape:field
+ * @usage web_application
* @brief Shape document width
*/
public float width;
/**
- * The width of the PShape document.
- * @webref
+ * ( begin auto-generated from PShape_height.xml )
+ *
+ * The height of the PShape document.
+ *
+ * ( end auto-generated )
+ * @webref pshape:field
+ * @usage web_application
* @brief Shape document height
*/
public float height;
@@ -117,7 +151,7 @@ public class PShape implements PConstants {
/** Temporary toggle for whether styles should be honored. */
protected boolean style = true;
- /** For primitive shapes in particular, parms like x/y/w/h or x1/y1/x2/y2. */
+ /** For primitive shapes in particular, params like x/y/w/h or x1/y1/x2/y2. */
protected float[] params;
protected int vertexCount;
@@ -128,15 +162,6 @@ public class PShape implements PConstants {
*/
protected float[][] vertices;
- static public final int VERTEX = 0;
- static public final int BEZIER_VERTEX = 1;
- static public final int QUAD_BEZIER_VERTEX = 2;
- static public final int CURVE_VERTEX = 3;
- static public final int BREAK = 4;
-
- // should this be called vertices (consistent with PGraphics internals)
- // or does that hurt flexibility?
-
protected PShape parent;
protected int childCount;
protected PShape[] children;
@@ -178,6 +203,11 @@ public class PShape implements PConstants {
/** True if colorMode(RGB, 255) */
boolean colorModeDefault; // = true;
+
+ // should this be called vertices (consistent with PGraphics internals)
+ // or does that hurt flexibility?
+
+
// POINTS, LINES, xLINE_STRIP, xLINE_LOOP
// TRIANGLES, TRIANGLE_STRIP, TRIANGLE_FAN
// QUADS, QUAD_STRIP
@@ -215,6 +245,9 @@ public class PShape implements PConstants {
}
+/**
+ * @nowebref
+ */
public PShape(int family) {
this.family = family;
}
@@ -235,11 +268,18 @@ public class PShape implements PConstants {
}
/**
- * Returns a boolean value "true" if the image is set to be visible, "false" if not. This is modified with the setVisible() parameter.
- *
The visibility of a shape is usually controlled by whatever program created the SVG file.
- * For instance, this parameter is controlled by showing or hiding the shape in the layers palette in Adobe Illustrator.
+ * ( begin auto-generated from PShape_isVisible.xml )
*
- * @webref
+ * Returns a boolean value "true" if the image is set to be visible,
+ * "false" if not. This is modified with the setVisible() parameter.
+ *
+ * The visibility of a shape is usually controlled by whatever program
+ * created the SVG file. For instance, this parameter is controlled by
+ * showing or hiding the shape in the layers palette in Adobe Illustrator.
+ *
+ * ( end auto-generated )
+ * @webref pshape:method
+ * @usage web_application
* @brief Returns a boolean value "true" if the image is set to be visible, "false" if not
*/
public boolean isVisible() {
@@ -247,12 +287,20 @@ public class PShape implements PConstants {
}
/**
- * Sets the shape to be visible or invisible. This is determined by the value of the visible parameter.
- *
The visibility of a shape is usually controlled by whatever program created the SVG file.
- * For instance, this parameter is controlled by showing or hiding the shape in the layers palette in Adobe Illustrator.
- * @param visible "false" makes the shape invisible and "true" makes it visible
- * @webref
+ * ( begin auto-generated from PShape_setVisible.xml )
+ *
+ * Sets the shape to be visible or invisible. This is determined by the
+ * value of the visible parameter.
+ *
+ * The visibility of a shape is usually controlled by whatever program
+ * created the SVG file. For instance, this parameter is controlled by
+ * showing or hiding the shape in the layers palette in Adobe Illustrator.
+ *
+ * ( end auto-generated )
+ * @webref pshape:mathod
+ * @usage web_application
* @brief Sets the shape to be visible or invisible
+ * @param visible "false" makes the shape invisible and "true" makes it visible
*/
public void setVisible(boolean visible) {
this.visible = visible;
@@ -260,12 +308,19 @@ public class PShape implements PConstants {
/**
- * Disables the shape's style data and uses Processing's current styles. Styles include attributes such as colors, stroke weight, and stroke joints.
- * =advanced
+ * ( begin auto-generated from PShape_disableStyle.xml )
+ *
+ * Disables the shape's style data and uses Processing's current styles.
+ * Styles include attributes such as colors, stroke weight, and stroke
+ * joints.
+ *
+ * ( end auto-generated )
+ * Advanced
* Overrides this shape's style information and uses PGraphics styles and
* colors. Identical to ignoreStyles(true). Also disables styles for all
* child shapes.
- * @webref
+ * @webref pshape:method
+ * @usage web_application
* @brief Disables the shape's style data and uses Processing styles
*/
public void disableStyle() {
@@ -278,8 +333,16 @@ public class PShape implements PConstants {
/**
- * Enables the shape's style data and ignores Processing's current styles. Styles include attributes such as colors, stroke weight, and stroke joints.
- * @webref
+ * ( begin auto-generated from PShape_enableStyle.xml )
+ *
+ * Enables the shape's style data and ignores Processing's current styles.
+ * Styles include attributes such as colors, stroke weight, and stroke
+ * joints.
+ *
+ * ( end auto-generated )
+ *
+ * @webref pshape:method
+ * @usage web_application
* @brief Enables the shape's style data and ignores the Processing styles
*/
public void enableStyle() {
@@ -331,13 +394,14 @@ public class PShape implements PConstants {
}
- // TODO: need to discuss about these two (four).
- public PVector getTop() {
+
+ // TODO unapproved
+ protected PVector getTop() {
return getTop(null);
}
- public PVector getTop(PVector top) {
+ protected PVector getTop(PVector top) {
if (top == null) {
top = new PVector();
}
@@ -345,12 +409,12 @@ public class PShape implements PConstants {
}
- public PVector getBottom() {
+ protected PVector getBottom() {
return getBottom(null);
}
- public PVector getBottom(PVector bottom) {
+ protected PVector getBottom(PVector bottom) {
if (bottom == null) {
bottom = new PVector();
}
@@ -374,6 +438,15 @@ public class PShape implements PConstants {
}
+ /**
+ * Return true if this shape requires rendering through OpenGL. Defaults to false.
+ */
+ // TODO unapproved
+ public boolean isGL() {
+ return false;
+ }
+
+
///////////////////////////////////////////////////////////
//
@@ -386,7 +459,8 @@ public class PShape implements PConstants {
public void noTexture() {
}
- public void solid(boolean solid) {
+ // TODO unapproved
+ protected void solid(boolean solid) {
}
public void beginContour() {
@@ -418,7 +492,8 @@ public class PShape implements PConstants {
//////////////////////////////////////////////////////////////
- // Stroke cap/join/weight set/update
+ // STROKE CAP/JOIN/WEIGHT
+
public void strokeWeight(float weight) {
}
@@ -431,7 +506,7 @@ public class PShape implements PConstants {
//////////////////////////////////////////////////////////////
- // Fill set/update
+ // FILL COLOR
public void noFill() {
}
@@ -456,7 +531,7 @@ public class PShape implements PConstants {
//////////////////////////////////////////////////////////////
- // Stroke (color) set/update
+ // STROKE COLOR
public void noStroke() {
}
@@ -481,7 +556,7 @@ public class PShape implements PConstants {
//////////////////////////////////////////////////////////////
- // Tint set/update
+ // TINT COLOR
public void noTint() {
@@ -667,7 +742,7 @@ public class PShape implements PConstants {
}
- public void post(PGraphics g) {
+ protected void post(PGraphics g) {
// for (int i = 0; i < childCount; i++) {
// children[i].draw(g);
// }
@@ -701,7 +776,8 @@ public class PShape implements PConstants {
// Shape copy
- static public PShape createShape(PApplet parent, PShape src) {
+ // TODO unapproved
+ static protected PShape createShape(PApplet parent, PShape src) {
PShape dest = null;
if (src.family == GROUP) {
dest = parent.createShape(GROUP);
@@ -721,7 +797,8 @@ public class PShape implements PConstants {
}
- static public void copyGroup(PApplet parent, PShape src, PShape dest) {
+ // TODO unapproved
+ static protected void copyGroup(PApplet parent, PShape src, PShape dest) {
copyMatrix(src, dest);
copyStyles(src, dest);
copyImage(src, dest);
@@ -732,14 +809,16 @@ public class PShape implements PConstants {
}
- static public void copyPrimitive(PShape src, PShape dest) {
+ // TODO unapproved
+ static protected void copyPrimitive(PShape src, PShape dest) {
copyMatrix(src, dest);
copyStyles(src, dest);
copyImage(src, dest);
}
- static public void copyGeometry(PShape src, PShape dest) {
+ // TODO unapproved
+ static protected void copyGeometry(PShape src, PShape dest) {
copyMatrix(src, dest);
copyStyles(src, dest);
copyImage(src, dest);
@@ -754,13 +833,17 @@ public class PShape implements PConstants {
// s.emissive(vert[ER] * 255, vert[EG] * 255, vert[EB] * 255);
// s.shininess(vert[SHINE]);
- dest.normal(vert[NX], vert[NY], vert[NZ]);
- dest.vertex(vert[X], vert[Y], vert[Z], vert[U], vert[V]);
+ dest.normal(vert[PGraphics.NX],
+ vert[PGraphics.NY],
+ vert[PGraphics.NZ]);
+ dest.vertex(vert[X], vert[Y], vert[Z],
+ vert[PGraphics.U],
+ vert[PGraphics.V]);
}
} else {
for (int i = 0; i < src.vertexCount; i++) {
float[] vert = src.vertices[i];
- if (vert[PGraphics.Z] == 0) {
+ if (vert[Z] == 0) {
dest.vertex(vert[X], vert[Y]);
} else {
dest.vertex(vert[X], vert[Y], vert[Z]);
@@ -772,7 +855,8 @@ public class PShape implements PConstants {
}
- static public void copyPath(PShape src, PShape dest) {
+ // TODO unapproved
+ static protected void copyPath(PShape src, PShape dest) {
copyMatrix(src, dest);
copyStyles(src, dest);
copyImage(src, dest);
@@ -781,13 +865,16 @@ public class PShape implements PConstants {
}
- static public void copyMatrix(PShape src, PShape dest) {
+ // TODO unapproved
+ static protected void copyMatrix(PShape src, PShape dest) {
if (src.matrix != null) {
dest.applyMatrix(src.matrix);
}
}
- static public void copyStyles(PShape src, PShape dest) {
+
+ // TODO unapproved
+ static protected void copyStyles(PShape src, PShape dest) {
if (src.stroke) {
dest.stroke = true;
dest.strokeColor = src.strokeColor;
@@ -807,7 +894,8 @@ public class PShape implements PConstants {
}
- static public void copyImage(PShape src, PShape dest) {
+ // TODO unapproved
+ static protected void copyImage(PShape src, PShape dest) {
if (src.image != null) {
dest.texture(src.image);
}
@@ -819,7 +907,7 @@ public class PShape implements PConstants {
/**
* Called by the following (the shape() command adds the g)
- * PShape s = loadShapes("blah.svg");
+ * PShape s = loadShape("blah.svg");
* shape(s);
*/
public void draw(PGraphics g) {
@@ -910,6 +998,7 @@ public class PShape implements PConstants {
protected void drawGeometry(PGraphics g) {
+ // get cache object using g.
g.beginShape(kind);
if (style) {
for (int i = 0; i < vertexCount; i++) {
@@ -918,7 +1007,7 @@ public class PShape implements PConstants {
} else {
for (int i = 0; i < vertexCount; i++) {
float[] vert = vertices[i];
- if (vert[PGraphics.Z] == 0) {
+ if (vert[Z] == 0) {
g.vertex(vert[X], vert[Y]);
} else {
g.vertex(vert[X], vert[Y], vert[Z]);
@@ -989,6 +1078,7 @@ public class PShape implements PConstants {
// http://dev.processing.org/bugs/show_bug.cgi?id=982
if (vertices == null) return;
+ boolean insideContour = false;
g.beginShape();
if (vertexCodeCount == 0) { // each point is a simple vertex
@@ -1043,9 +1133,14 @@ public class PShape implements PConstants {
case CURVE_VERTEX:
g.curveVertex(vertices[index][X], vertices[index][Y]);
index++;
+ break;
case BREAK:
- g.breakShape();
+ if (insideContour) {
+ g.endContour();
+ }
+ g.beginContour();
+ insideContour = true;
}
}
} else { // drawing a 3D path
@@ -1077,12 +1172,20 @@ public class PShape implements PConstants {
case CURVE_VERTEX:
g.curveVertex(vertices[index][X], vertices[index][Y], vertices[index][Z]);
index++;
+ break;
case BREAK:
- g.breakShape();
+ if (insideContour) {
+ g.endContour();
+ }
+ g.beginContour();
+ insideContour = true;
+ }
}
}
}
+ if (insideContour) {
+ g.endContour();
}
g.endShape(close ? CLOSE : OPEN);
}
@@ -1107,7 +1210,16 @@ public class PShape implements PConstants {
/**
+ * ( begin auto-generated from PShape_getChild.xml )
*
+ * Extracts a child shape from a parent shape. Specify the name of the
+ * shape with the target parameter. The shape is returned as a
+ * PShape object, or null is returned if there is an error.
+ *
+ * ( end auto-generated )
+ * @webref pshape:method
+ * @usage web_application
+ * @brief Returns a child element of a shape as a PShape object
* @param index the layer position of the shape to get
*/
public PShape getChild(int index) {
@@ -1116,11 +1228,7 @@ public class PShape implements PConstants {
/**
- * Extracts a child shape from a parent shape. Specify the name of the shape with the target parameter.
- * The shape is returned as a PShape object, or null is returned if there is an error.
* @param target the name of the shape to get
- * @webref
- * @brief Returns a child element of a shape as a PShape object
*/
public PShape getChild(String target) {
if (name != null && name.equals(target)) {
@@ -1241,10 +1349,6 @@ public class PShape implements PConstants {
}
- public void updateRoot(PShape root) {
- }
-
-
public PShape getTessellation() {
return null;
}
@@ -1283,7 +1387,7 @@ public class PShape implements PConstants {
}
- public void setParams(float[] source) {
+ protected void setParams(float[] source) {
if (params == null) {
params = new float[source.length];
}
@@ -1300,7 +1404,7 @@ public class PShape implements PConstants {
}
- public void setPath(int vcount, float[][] verts, int ccount, int[] codes) {
+ protected void setPath(int vcount, float[][] verts, int ccount, int[] codes) {
if (verts == null || verts.length < vcount) return;
if (0 < ccount && (codes == null || codes.length < ccount)) return;
@@ -1357,7 +1461,8 @@ public class PShape implements PConstants {
public void setVertex(int index, float x, float y) {
- setVertex(index, x, y, 0);
+ vertices[index][X] = x;
+ vertices[index][Y] = y;
}
@@ -1368,6 +1473,13 @@ public class PShape implements PConstants {
}
+ public void setVertex(int index, PVector vec) {
+ vertices[index][X] = vec.x;
+ vertices[index][Y] = vec.y;
+ vertices[index][Z] = vec.z;
+ }
+
+
public PVector getNormal(int index) {
return getNormal(index, null);
}
@@ -1377,127 +1489,146 @@ public class PShape implements PConstants {
if (vec == null) {
vec = new PVector();
}
- vec.x = vertices[index][NX];
- vec.y = vertices[index][NY];
- vec.z = vertices[index][NZ];
+ vec.x = vertices[index][PGraphics.NX];
+ vec.y = vertices[index][PGraphics.NY];
+ vec.z = vertices[index][PGraphics.NZ];
return vec;
}
public float getNormalX(int index) {
- return vertices[index][NX];
+ return vertices[index][PGraphics.NX];
}
public float getNormalY(int index) {
- return vertices[index][NY];
+ return vertices[index][PGraphics.NY];
}
public float getNormalZ(int index) {
- return vertices[index][NZ];
+ return vertices[index][PGraphics.NZ];
}
public void setNormal(int index, float nx, float ny, float nz) {
- vertices[index][NX] = nx;
- vertices[index][NY] = ny;
- vertices[index][NZ] = nz;
+ vertices[index][PGraphics.NX] = nx;
+ vertices[index][PGraphics.NY] = ny;
+ vertices[index][PGraphics.NZ] = nz;
}
public float getTextureU(int index) {
- return vertices[index][U];
+ return vertices[index][PGraphics.U];
}
public float getTextureV(int index) {
- return vertices[index][V];
+ return vertices[index][PGraphics.V];
}
public void setTextureUV(int index, float u, float v) {
- vertices[index][U] = u;
- vertices[index][V] = v;
+ vertices[index][PGraphics.U] = u;
+ vertices[index][PGraphics.V] = v;
}
public int getFill(int index) {
- int a = (int) (vertices[index][A] * 255);
- int r = (int) (vertices[index][R] * 255);
- int g = (int) (vertices[index][G] * 255);
- int b = (int) (vertices[index][B] * 255);
+ int a = (int) (vertices[index][PGraphics.A] * 255);
+ int r = (int) (vertices[index][PGraphics.R] * 255);
+ int g = (int) (vertices[index][PGraphics.G] * 255);
+ int b = (int) (vertices[index][PGraphics.B] * 255);
return (a << 24) | (r << 16) | (g << 8) | b;
}
public void setFill(int index, int fill) {
- vertices[index][A] = ((fill >> 24) & 0xFF) / 255.0f;
- vertices[index][R] = ((fill >> 16) & 0xFF) / 255.0f;
- vertices[index][G] = ((fill >> 8) & 0xFF) / 255.0f;
- vertices[index][B] = ((fill >> 0) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.A] = ((fill >> 24) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.R] = ((fill >> 16) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.G] = ((fill >> 8) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.B] = ((fill >> 0) & 0xFF) / 255.0f;
}
public int getStroke(int index) {
- int a = (int) (vertices[index][SA] * 255);
- int r = (int) (vertices[index][SR] * 255);
- int g = (int) (vertices[index][SG] * 255);
- int b = (int) (vertices[index][SB] * 255);
+ int a = (int) (vertices[index][PGraphics.SA] * 255);
+ int r = (int) (vertices[index][PGraphics.SR] * 255);
+ int g = (int) (vertices[index][PGraphics.SG] * 255);
+ int b = (int) (vertices[index][PGraphics.SB] * 255);
return (a << 24) | (r << 16) | (g << 8) | b;
}
public void setStroke(int index, int stroke) {
- vertices[index][SA] = ((stroke >> 24) & 0xFF) / 255.0f;
- vertices[index][SR] = ((stroke >> 16) & 0xFF) / 255.0f;
- vertices[index][SG] = ((stroke >> 8) & 0xFF) / 255.0f;
- vertices[index][SB] = ((stroke >> 0) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.SA] = ((stroke >> 24) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.SR] = ((stroke >> 16) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.SG] = ((stroke >> 8) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.SB] = ((stroke >> 0) & 0xFF) / 255.0f;
}
- public float getStrokeWeight(int index) {
- return vertices[index][SW];
+ protected float getStrokeWeight(int index) {
+ return vertices[index][PGraphics.SW];
}
- public void setStrokeWeight(int index, float weight) {
- vertices[index][SW] = weight;
+ protected void setStrokeWeight(int index, float weight) {
+ vertices[index][PGraphics.SW] = weight;
}
- public int getAmbient(int index) {
- return 0;
+ protected int getAmbient(int index) {
+ int r = (int) (vertices[index][PGraphics.AR] * 255);
+ int g = (int) (vertices[index][PGraphics.AG] * 255);
+ int b = (int) (vertices[index][PGraphics.AB] * 255);
+ return 0xff000000 | (r << 16) | (g << 8) | b;
}
- public void setAmbient(int index, int ambient) {
+ protected void setAmbient(int index, int ambient) {
+ vertices[index][PGraphics.AR] = ((ambient >> 16) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.AG] = ((ambient >> 8) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.AB] = ((ambient >> 0) & 0xFF) / 255.0f;
}
- public int getSpecular(int index) {
- return 0;
+ protected int getSpecular(int index) {
+ int r = (int) (vertices[index][PGraphics.SPR] * 255);
+ int g = (int) (vertices[index][PGraphics.SPG] * 255);
+ int b = (int) (vertices[index][PGraphics.SPB] * 255);
+ return 0xff000000 | (r << 16) | (g << 8) | b;
}
- public void setSpecular(int index, int specular) {
+ protected void setSpecular(int index, int specular) {
+ vertices[index][PGraphics.SPR] = ((specular >> 16) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.SPG] = ((specular >> 8) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.SPB] = ((specular >> 0) & 0xFF) / 255.0f;
}
- public int getEmissive(int index) {
- return 0;
+ protected int getEmissive(int index) {
+ int r = (int) (vertices[index][PGraphics.ER] * 255);
+ int g = (int) (vertices[index][PGraphics.EG] * 255);
+ int b = (int) (vertices[index][PGraphics.EB] * 255);
+ return 0xff000000 | (r << 16) | (g << 8) | b;
}
- public void setEmissive(int index, int emissive) {
+ protected void setEmissive(int index, int emissive) {
+ vertices[index][PGraphics.ER] = ((emissive >> 16) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.EG] = ((emissive >> 8) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.EB] = ((emissive >> 0) & 0xFF) / 255.0f;
}
- public float getShininess(int index) {
- return 0;
+ protected float getShininess(int index) {
+ return vertices[index][PGraphics.SHINE];
}
- public void setShininess(int index, float shine) {
+ protected void setShininess(int index, float shine) {
+ vertices[index][PGraphics.SHINE] = shine;
}
@@ -1557,32 +1688,41 @@ public class PShape implements PConstants {
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
- public void center(float cx, float cy) {
-
- }
-
- public void center(float cx, float cy, float cz) {
-
- }
-
// translate, rotate, scale, apply (no push/pop)
// these each call matrix.translate, etc
// if matrix is null when one is called,
// it is created and set to identity
+
+/**
+ * ( begin auto-generated from PShape_translate.xml )
+ *
+ * Specifies an amount to displace the shape. The x parameter
+ * specifies left/right translation, the y parameter specifies
+ * up/down translation, and the z parameter specifies translations
+ * toward/away from the screen. Subsequent calls to the method accumulates
+ * the effect. For example, calling translate(50, 0) and then
+ * translate(20, 0) is the same as translate(70, 0). This
+ * transformation is applied directly to the shape, it's not refreshed each
+ * time draw() is run.
+ *
+ * Using this method with the z parameter requires using the P3D
+ * parameter in combination with size.
+ *
+ * ( end auto-generated )
+ * @webref pshape:method
+ * @usage web_application
+ * @brief Displaces the shape
+ * @param tx left/right translation
+ * @param ty up/down translation
+ */
public void translate(float tx, float ty) {
checkMatrix(2);
matrix.translate(tx, ty);
}
/**
- * Specifies an amount to displace the shape. The x parameter specifies left/right translation, the y parameter specifies up/down translation, and the z parameter specifies translations toward/away from the screen. Subsequent calls to the method accumulates the effect. For example, calling translate(50, 0) and then translate(20, 0) is the same as translate(70, 0). This transformation is applied directly to the shape, it's not refreshed each time draw() is run.
- *
Using this method with the z parameter requires using the P3D or OPENGL parameter in combination with size.
- * @webref
- * @param tx left/right translation
- * @param ty up/down translation
* @param tz forward/back translation
- * @brief Displaces the shape
*/
public void translate(float tx, float ty, float tz) {
checkMatrix(3);
@@ -1590,28 +1730,58 @@ public class PShape implements PConstants {
}
/**
- * Rotates a shape around the x-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method.
- *
Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction.
- * Subsequent calls to the method accumulates the effect. For example, calling rotateX(HALF_PI) and then rotateX(HALF_PI) is the same as rotateX(PI).
- * This transformation is applied directly to the shape, it's not refreshed each time draw() is run.
- *
This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above.
- * @param angle angle of rotation specified in radians
- * @webref
+ * ( begin auto-generated from PShape_rotateX.xml )
+ *
+ * Rotates a shape around the x-axis the amount specified by the
+ * angle parameter. Angles should be specified in radians (values
+ * from 0 to TWO_PI) or converted to radians with the radians() method.
+ *
+ * Shapes are always rotated around the upper-left corner of their bounding
+ * box. Positive numbers rotate objects in a clockwise direction.
+ * Subsequent calls to the method accumulates the effect. For example,
+ * calling rotateX(HALF_PI) and then rotateX(HALF_PI) is the
+ * same as rotateX(PI). This transformation is applied directly to
+ * the shape, it's not refreshed each time draw() is run.
+ *
+ * This method requires a 3D renderer. You need to use P3D as a third
+ * parameter for the size() function as shown in the example above.
+ *
+ * ( end auto-generated )
+ * @webref pshape:method
+ * @usage web_application
* @brief Rotates the shape around the x-axis
+ * @param angle angle of rotation specified in radians
*/
public void rotateX(float angle) {
rotate(angle, 1, 0, 0);
}
/**
- * Rotates a shape around the y-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method.
- *
Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction.
- * Subsequent calls to the method accumulates the effect. For example, calling rotateY(HALF_PI) and then rotateY(HALF_PI) is the same as rotateY(PI).
- * This transformation is applied directly to the shape, it's not refreshed each time draw() is run.
- *
This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above.
- * @param angle angle of rotation specified in radians
- * @webref
+ * ( begin auto-generated from PShape_rotateY.xml )
+ *
+ * Rotates a shape around the y-axis the amount specified by the
+ * angle parameter. Angles should be specified in radians (values
+ * from 0 to TWO_PI) or converted to radians with the radians() method.
+ *
+ * Shapes are always rotated around the upper-left corner of their bounding
+ * box. Positive numbers rotate objects in a clockwise direction.
+ * Subsequent calls to the method accumulates the effect. For example,
+ * calling rotateY(HALF_PI) and then rotateY(HALF_PI) is the
+ * same as rotateY(PI). This transformation is applied directly to
+ * the shape, it's not refreshed each time draw() is run.
+ *
+ * This method requires a 3D renderer. You need to use P3D as a third
+ * parameter for the size() function as shown in the example above.
+ *
+ * ( end auto-generated )
+ *
+ * @webref pshape:method
+ * @usage web_application
* @brief Rotates the shape around the y-axis
+ * @param angle angle of rotation specified in radians
+ * @see PShape#rotate(float)
+ * @see PShape#rotateX(float)
+ * @see PShape#rotateZ(float)
*/
public void rotateY(float angle) {
rotate(angle, 0, 1, 0);
@@ -1619,37 +1789,71 @@ public class PShape implements PConstants {
/**
- * Rotates a shape around the z-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method.
- *
Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction.
- * Subsequent calls to the method accumulates the effect. For example, calling rotateZ(HALF_PI) and then rotateZ(HALF_PI) is the same as rotateZ(PI).
- * This transformation is applied directly to the shape, it's not refreshed each time draw() is run.
- *
This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above.
- * @param angle angle of rotation specified in radians
- * @webref
+ * ( begin auto-generated from PShape_rotateZ.xml )
+ *
+ * Rotates a shape around the z-axis the amount specified by the
+ * angle parameter. Angles should be specified in radians (values
+ * from 0 to TWO_PI) or converted to radians with the radians() method.
+ *
+ * Shapes are always rotated around the upper-left corner of their bounding
+ * box. Positive numbers rotate objects in a clockwise direction.
+ * Subsequent calls to the method accumulates the effect. For example,
+ * calling rotateZ(HALF_PI) and then rotateZ(HALF_PI) is the
+ * same as rotateZ(PI). This transformation is applied directly to
+ * the shape, it's not refreshed each time draw() is run.
+ *
+ * This method requires a 3D renderer. You need to use P3D as a third
+ * parameter for the size() function as shown in the example above.
+ *
+ * ( end auto-generated )
+ * @webref pshape:method
+ * @usage web_application
* @brief Rotates the shape around the z-axis
+ * @param angle angle of rotation specified in radians
*/
public void rotateZ(float angle) {
rotate(angle, 0, 0, 1);
}
/**
- * Rotates a shape the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method.
- *
Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction.
- * Transformations apply to everything that happens after and subsequent calls to the method accumulates the effect.
- * For example, calling rotate(HALF_PI) and then rotate(HALF_PI) is the same as rotate(PI).
- * This transformation is applied directly to the shape, it's not refreshed each time draw() is run.
- * @param angle angle of rotation specified in radians
- * @webref
+ * ( begin auto-generated from PShape_rotate.xml )
+ *
+ * Rotates a shape the amount specified by the angle parameter.
+ * Angles should be specified in radians (values from 0 to TWO_PI) or
+ * converted to radians with the radians() method.
+ *
+ * Shapes are always rotated around the upper-left corner of their bounding
+ * box. Positive numbers rotate objects in a clockwise direction.
+ * Transformations apply to everything that happens after and subsequent
+ * calls to the method accumulates the effect. For example, calling
+ * rotate(HALF_PI) and then rotate(HALF_PI) is the same as
+ * rotate(PI). This transformation is applied directly to the shape,
+ * it's not refreshed each time draw() is run.
+ *
+ * ( end auto-generated )
+ * @webref pshape:method
+ * @usage web_application
* @brief Rotates the shape
+ * @param angle angle of rotation specified in radians
*/
public void rotate(float angle) {
checkMatrix(2); // at least 2...
matrix.rotate(angle);
}
-
+/**
+ * @nowebref
+ */
public void rotate(float angle, float v0, float v1, float v2) {
checkMatrix(3);
+ float norm2 = v0 * v0 + v1 * v1 + v2 * v2;
+ if (Math.abs(norm2 - 1) > EPSILON) {
+ // The rotation vector is not normalized.
+ float norm = PApplet.sqrt(norm2);
+ v0 /= norm;
+ v1 /= norm;
+ v2 /= norm;
+ }
matrix.rotate(angle, v0, v1, v2);
}
@@ -1657,7 +1861,25 @@ public class PShape implements PConstants {
//
/**
- * @param s percentage to scale the object
+ * ( begin auto-generated from PShape_scale.xml )
+ *
+ * Increases or decreases the size of a shape by expanding and contracting
+ * vertices. Shapes always scale from the relative origin of their bounding
+ * box. Scale values are specified as decimal percentages. For example, the
+ * method call scale(2.0) increases the dimension of a shape by
+ * 200%. Subsequent calls to the method multiply the effect. For example,
+ * calling scale(2.0) and then scale(1.5) is the same as
+ * scale(3.0). This transformation is applied directly to the shape,
+ * it's not refreshed each time draw() is run.
+ *
+ * Using this method with the z parameter requires using the P3D
+ * parameter in combination with size.
+ *
+ * ( end auto-generated )
+ * @webref pshape:method
+ * @usage web_application
+ * @brief Increases and decreases the size of a shape
+ * @param s percentate to scale the object
*/
public void scale(float s) {
checkMatrix(2); // at least 2...
@@ -1672,16 +1894,9 @@ public class PShape implements PConstants {
/**
- * Increases or decreases the size of a shape by expanding and contracting vertices. Shapes always scale from the relative origin of their bounding box.
- * Scale values are specified as decimal percentages. For example, the method call scale(2.0) increases the dimension of a shape by 200%.
- * Subsequent calls to the method multiply the effect. For example, calling scale(2.0) and then scale(1.5) is the same as scale(3.0).
- * This transformation is applied directly to the shape, it's not refreshed each time draw() is run.
- *
Using this fuction with the z parameter requires passing P3D or OPENGL into the size() parameter.
* @param x percentage to scale the object in the x-axis
* @param y percentage to scale the object in the y-axis
* @param z percentage to scale the object in the z-axis
- * @webref
- * @brief Increases and decreases the size of a shape
*/
public void scale(float x, float y, float z) {
checkMatrix(3);
@@ -1689,14 +1904,19 @@ public class PShape implements PConstants {
}
- public void centerAt(float cx, float cy, float cz) {
-
- }
-
-
//
-
+/**
+ * ( begin auto-generated from PShape_resetMatrix.xml )
+ *
+ * Replaces the current matrix of a shape with the identity matrix. The
+ * equivalent function in OpenGL is glLoadIdentity().
+ *
+ * ( end auto-generated )
+ * @webref pshape:method
+ * @brief Replaces the current matrix of a shape with the identity matrix
+ * @usage web_application
+ */
public void resetMatrix() {
checkMatrix(2);
matrix.reset();
@@ -1723,14 +1943,12 @@ public class PShape implements PConstants {
public void applyMatrix(float n00, float n01, float n02,
float n10, float n11, float n12) {
checkMatrix(2);
- matrix.apply(n00, n01, n02, 0,
- n10, n11, n12, 0,
- 0, 0, 1, 0,
- 0, 0, 0, 1);
+ matrix.apply(n00, n01, n02,
+ n10, n11, n12);
}
- public void apply(PMatrix3D source) {
+ public void applyMatrix(PMatrix3D source) {
applyMatrix(source.m00, source.m01, source.m02, source.m03,
source.m10, source.m11, source.m12, source.m13,
source.m20, source.m21, source.m22, source.m23,
@@ -1797,8 +2015,6 @@ public class PShape implements PConstants {
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
- // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
public void colorMode(int mode) {
colorMode(mode, colorModeX, colorModeY, colorModeZ, colorModeA);
diff --git a/android/core/src/processing/opengl/PGraphics2D.java b/android/core/src/processing/opengl/PGraphics2D.java
index 44d704a1c..c8722e8c9 100644
--- a/android/core/src/processing/opengl/PGraphics2D.java
+++ b/android/core/src/processing/opengl/PGraphics2D.java
@@ -26,6 +26,7 @@ import java.io.InputStream;
import java.util.zip.GZIPInputStream;
import processing.core.PApplet;
+import processing.core.PConstants;
import processing.core.PGraphics;
import processing.core.PMatrix3D;
import processing.core.PShape;
@@ -274,8 +275,8 @@ public class PGraphics2D extends PGraphicsOpenGL {
static protected PShape2D createShapeImpl(PApplet parent, int type) {
PShape2D shape = null;
- if (type == PShape.GROUP) {
- shape = new PShape2D(parent, PShape.GROUP);
+ if (type == PConstants.GROUP) {
+ shape = new PShape2D(parent, PConstants.GROUP);
} else if (type == PShape.PATH) {
shape = new PShape2D(parent, PShape.PATH);
} else if (type == POINTS) {
diff --git a/android/core/src/processing/opengl/PGraphics3D.java b/android/core/src/processing/opengl/PGraphics3D.java
index c85847fb2..824b79172 100644
--- a/android/core/src/processing/opengl/PGraphics3D.java
+++ b/android/core/src/processing/opengl/PGraphics3D.java
@@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.Hashtable;
import processing.core.PApplet;
+import processing.core.PConstants;
import processing.core.PGraphics;
import processing.core.PImage;
import processing.core.PShape;
@@ -247,8 +248,8 @@ public class PGraphics3D extends PGraphicsOpenGL {
static protected PShape3D createShapeImpl(PApplet parent, int type) {
PShape3D shape = null;
- if (type == PShape.GROUP) {
- shape = new PShape3D(parent, PShape.GROUP);
+ if (type == PConstants.GROUP) {
+ shape = new PShape3D(parent, PConstants.GROUP);
} else if (type == PShape.PATH) {
shape = new PShape3D(parent, PShape.PATH);
} else if (type == POINTS) {
diff --git a/android/core/src/processing/opengl/PGraphicsOpenGL.java b/android/core/src/processing/opengl/PGraphicsOpenGL.java
index c39d7dc0a..ab6bfb0c9 100644
--- a/android/core/src/processing/opengl/PGraphicsOpenGL.java
+++ b/android/core/src/processing/opengl/PGraphicsOpenGL.java
@@ -8412,7 +8412,7 @@ public class PGraphicsOpenGL extends PGraphics {
PApplet.max(MIN_POINT_ACCURACY,
(int) (TWO_PI * PApplet.dist(sx1, sy1, sx2, sy2) /
POINT_ACCURACY_FACTOR));
- float inc = (float) PGraphicsOpenGL.SINCOS_LENGTH / accuracy;
+ float inc = (float) SINCOS_LENGTH / accuracy;
if (fill) {
addVertex(centerX, centerY, VERTEX);
@@ -8421,10 +8421,10 @@ public class PGraphicsOpenGL extends PGraphics {
idx0 = pidx = idx = 0;
float val = 0;
for (int i = 0; i < accuracy; i++) {
- idx = addVertex(centerX + PGraphicsOpenGL.cosLUT[(int) val] * radiusH,
- centerY + PGraphicsOpenGL.sinLUT[(int) val] * radiusV,
+ idx = addVertex(centerX + cosLUT[(int) val] * radiusH,
+ centerY + sinLUT[(int) val] * radiusV,
VERTEX);
- val = (val + inc) % PGraphicsOpenGL.SINCOS_LENGTH;
+ val = (val + inc) % SINCOS_LENGTH;
if (0 < i) {
if (stroke) addEdge(pidx, idx, i == 1, false);
@@ -8435,8 +8435,8 @@ public class PGraphicsOpenGL extends PGraphics {
pidx = idx;
}
// Back to the beginning
- addVertex(centerX + PGraphicsOpenGL.cosLUT[0] * radiusH,
- centerY + PGraphicsOpenGL.sinLUT[0] * radiusV,
+ addVertex(centerX + cosLUT[0] * radiusH,
+ centerY + sinLUT[0] * radiusV,
VERTEX);
if (stroke) addEdge(idx, idx0, false, true);
}
diff --git a/android/core/src/processing/opengl/tess/PriorityQSort.java b/android/core/src/processing/opengl/tess/PriorityQSort.java
index d6a14d632..bdd6209fe 100644
--- a/android/core/src/processing/opengl/tess/PriorityQSort.java
+++ b/android/core/src/processing/opengl/tess/PriorityQSort.java
@@ -81,11 +81,11 @@ class PriorityQSort extends PriorityQ {
}
private static boolean LT(PriorityQ.Leq leq, Object x, Object y) {
- return (!PriorityQHeap.LEQ(leq, y, x));
+ return (!PriorityQ.LEQ(leq, y, x));
}
private static boolean GT(PriorityQ.Leq leq, Object x, Object y) {
- return (!PriorityQHeap.LEQ(leq, x, y));
+ return (!PriorityQ.LEQ(leq, x, y));
}
private static void Swap(int[] array, int a, int b) {
@@ -252,7 +252,7 @@ class PriorityQSort extends PriorityQ {
sortMin = keys[order[size - 1]];
if (!heap.pqIsEmpty()) {
heapMin = heap.pqMinimum();
- if (PriorityQHeap.LEQ(leq, heapMin, sortMin)) {
+ if (PriorityQ.LEQ(leq, heapMin, sortMin)) {
return heapMin;
}
}
diff --git a/core/.settings/org.eclipse.jdt.core.prefs b/core/.settings/org.eclipse.jdt.core.prefs
index 4dce02721..bc90b9a0d 100644
--- a/core/.settings/org.eclipse.jdt.core.prefs
+++ b/core/.settings/org.eclipse.jdt.core.prefs
@@ -23,7 +23,7 @@ org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
@@ -33,7 +33,7 @@ org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
@@ -53,7 +53,7 @@ org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java
index 6a1ddc466..17ea00aa0 100644
--- a/core/src/processing/core/PApplet.java
+++ b/core/src/processing/core/PApplet.java
@@ -14433,7 +14433,7 @@ public class PApplet extends Applet
* @see PApplet#color(float, float, float, float)
*/
static public int blendColor(int c1, int c2, int mode) {
- return PGraphics.blendColor(c1, c2, mode);
+ return PImage.blendColor(c1, c2, mode);
}
diff --git a/core/src/processing/core/PConstants.java b/core/src/processing/core/PConstants.java
index 37d132d14..7635a8cd5 100644
--- a/core/src/processing/core/PConstants.java
+++ b/core/src/processing/core/PConstants.java
@@ -38,82 +38,11 @@ import java.awt.event.KeyEvent;
* @usage Web & Application
*/
public interface PConstants {
- // vertex fields
- static public final int X = 0; // model coords xyz (formerly MX/MY/MZ)
+ static public final int X = 0;
static public final int Y = 1;
static public final int Z = 2;
- static public final int R = 3; // actual rgb, after lighting
- static public final int G = 4; // fill stored here, transform in place
- static public final int B = 5; // TODO don't do that anymore (?)
- static public final int A = 6;
-
- static public final int U = 7; // texture
- static public final int V = 8;
-
- static public final int NX = 9; // normal
- static public final int NY = 10;
- static public final int NZ = 11;
-
- static public final int EDGE = 12;
-
- // stroke
-
- /** stroke argb values */
- static public final int SR = 13;
- static public final int SG = 14;
- static public final int SB = 15;
- static public final int SA = 16;
-
- /** stroke weight */
- static public final int SW = 17;
-
- // transformations (2D and 3D)
-
- static public final int TX = 18; // transformed xyzw
- static public final int TY = 19;
- static public final int TZ = 20;
-
- static public final int VX = 21; // view space coords
- static public final int VY = 22;
- static public final int VZ = 23;
- static public final int VW = 24;
-
-
- // material properties
-
- // Ambient color (usually to be kept the same as diffuse)
- // fill(_) sets both ambient and diffuse.
- static public final int AR = 25;
- static public final int AG = 26;
- static public final int AB = 27;
-
- // Diffuse is shared with fill.
- static public final int DR = 3; // TODO needs to not be shared, this is a material property
- static public final int DG = 4;
- static public final int DB = 5;
- static public final int DA = 6;
-
- // specular (by default kept white)
- static public final int SPR = 28;
- static public final int SPG = 29;
- static public final int SPB = 30;
-
- static public final int SHINE = 31;
-
- // emissive (by default kept black)
- static public final int ER = 32;
- static public final int EG = 33;
- static public final int EB = 34;
-
- // has this vertex been lit yet
- static public final int BEEN_LIT = 35;
-
- // has this vertex been assigned a normal yet
- static public final int HAS_NORMAL = 36;
-
- static public final int VERTEX_FIELD_COUNT = 37;
// renderers known to processing.core
@@ -405,15 +334,15 @@ public interface PConstants {
/** texture coordinates based on image width/height */
static final int IMAGE = 2;
-
+
// texture wrapping modes
-
+
/** textures are clamped to their edges */
public static final int CLAMP = 0;
/** textures wrap around when uv values go outside 0..1 range */
- public static final int REPEAT = 1;
+ public static final int REPEAT = 1;
+
-
// text placement modes
/**
@@ -542,7 +471,7 @@ public interface PConstants {
static final int DISABLE_TEXTURE_MIPMAPS = 11;
static final int ENABLE_TEXTURE_MIPMAPS = -11;
-
+
static final int HINT_COUNT = 12;
// error messages
diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java
index 56060675d..8cead17c3 100644
--- a/core/src/processing/core/PGraphics.java
+++ b/core/src/processing/core/PGraphics.java
@@ -197,6 +197,86 @@ public class PGraphics extends PImage implements PConstants {
protected boolean[] hints = new boolean[HINT_COUNT];
+ ////////////////////////////////////////////////////////////
+
+ // Vertex fields, moved from PConstants (after 2.0a8) because they're too
+ // general to show up in all sketches as defined variables.
+
+ // X, Y and Z are still stored in PConstants because of their general
+ // usefulness, and that X we'll always want to be 0, etc.
+
+ static public final int R = 3; // actual rgb, after lighting
+ static public final int G = 4; // fill stored here, transform in place
+ static public final int B = 5; // TODO don't do that anymore (?)
+ static public final int A = 6;
+
+ static public final int U = 7; // texture
+ static public final int V = 8;
+
+ static public final int NX = 9; // normal
+ static public final int NY = 10;
+ static public final int NZ = 11;
+
+ static public final int EDGE = 12;
+
+ // stroke
+
+ /** stroke argb values */
+ static public final int SR = 13;
+ static public final int SG = 14;
+ static public final int SB = 15;
+ static public final int SA = 16;
+
+ /** stroke weight */
+ static public final int SW = 17;
+
+ // transformations (2D and 3D)
+
+ static public final int TX = 18; // transformed xyzw
+ static public final int TY = 19;
+ static public final int TZ = 20;
+
+ static public final int VX = 21; // view space coords
+ static public final int VY = 22;
+ static public final int VZ = 23;
+ static public final int VW = 24;
+
+
+ // material properties
+
+ // Ambient color (usually to be kept the same as diffuse)
+ // fill(_) sets both ambient and diffuse.
+ static public final int AR = 25;
+ static public final int AG = 26;
+ static public final int AB = 27;
+
+ // Diffuse is shared with fill.
+ static public final int DR = 3; // TODO needs to not be shared, this is a material property
+ static public final int DG = 4;
+ static public final int DB = 5;
+ static public final int DA = 6;
+
+ // specular (by default kept white)
+ static public final int SPR = 28;
+ static public final int SPG = 29;
+ static public final int SPB = 30;
+
+ static public final int SHINE = 31;
+
+ // emissive (by default kept black)
+ static public final int ER = 32;
+ static public final int EG = 33;
+ static public final int EB = 34;
+
+ // has this vertex been lit yet
+ static public final int BEEN_LIT = 35;
+
+ // has this vertex been assigned a normal yet
+ static public final int HAS_NORMAL = 36;
+
+ static public final int VERTEX_FIELD_COUNT = 37;
+
+
////////////////////////////////////////////////////////////
// STYLE PROPERTIES
@@ -1078,11 +1158,11 @@ public class PGraphics extends PImage implements PConstants {
this.textureMode = mode;
}
-
+
public void textureWrap(int wrap) {
showMissingWarning("textureWrap");
- }
-
+ }
+
/**
* ( begin auto-generated from texture.xml )
@@ -1520,8 +1600,8 @@ public class PGraphics extends PImage implements PConstants {
showMissingWarning("loadShader");
return null;
}
-
-
+
+
public PShader loadShader(String fragFilename, String vertFilename) {
showMissingWarning("loadShader");
return null;
@@ -1532,7 +1612,7 @@ public class PGraphics extends PImage implements PConstants {
showMissingWarning("shader");
}
-
+
public void shader(PShader shader, int kind) {
showMissingWarning("shader");
}
@@ -1540,9 +1620,9 @@ public class PGraphics extends PImage implements PConstants {
public void resetShader() {
showMissingWarning("resetShader");
- }
-
-
+ }
+
+
public void resetShader(int kind) {
showMissingWarning("resetShader");
}
diff --git a/core/src/processing/core/PMatrix2D.java b/core/src/processing/core/PMatrix2D.java
index fb18dd7d1..d5616b58d 100644
--- a/core/src/processing/core/PMatrix2D.java
+++ b/core/src/processing/core/PMatrix2D.java
@@ -411,11 +411,11 @@ public class PMatrix2D implements PMatrix {
//////////////////////////////////////////////////////////////
- // TODO these need to be added as regular API, but the naming and
+ // TODO these need to be added as regular API, but the naming and
// implementation needs to be improved first. (e.g. actually keeping track
// of whether the matrix is in fact identity internally.)
-
+
protected boolean isIdentity() {
return ((m00 == 1) && (m01 == 0) && (m02 == 0) &&
(m10 == 0) && (m11 == 1) && (m12 == 0));
@@ -424,31 +424,31 @@ public class PMatrix2D implements PMatrix {
// TODO make this more efficient, or move into PMatrix2D
protected boolean isWarped() {
- return ((m00 != 1) || (m01 != 0) &&
+ return ((m00 != 1) || (m01 != 0) &&
(m10 != 0) || (m11 != 1));
}
//////////////////////////////////////////////////////////////
-
- private final float max(float a, float b) {
+
+ static private final float max(float a, float b) {
return (a > b) ? a : b;
}
- private final float abs(float a) {
+ static private final float abs(float a) {
return (a < 0) ? -a : a;
}
- private final float sin(float angle) {
+ static private final float sin(float angle) {
return (float)Math.sin(angle);
}
- private final float cos(float angle) {
+ static private final float cos(float angle) {
return (float)Math.cos(angle);
}
- private final float tan(float angle) {
+ static private final float tan(float angle) {
return (float)Math.tan(angle);
}
}
diff --git a/core/src/processing/core/PMatrix3D.java b/core/src/processing/core/PMatrix3D.java
index 4732ed6eb..533988454 100644
--- a/core/src/processing/core/PMatrix3D.java
+++ b/core/src/processing/core/PMatrix3D.java
@@ -233,15 +233,15 @@ public final class PMatrix3D implements PMatrix /*, PConstants*/ {
if (norm2 < PConstants.EPSILON) {
// The vector is zero, cannot apply rotation.
return;
- }
-
+ }
+
if (Math.abs(norm2 - 1) > PConstants.EPSILON) {
// The rotation vector is not normalized.
float norm = PApplet.sqrt(norm2);
v0 /= norm;
v1 /= norm;
v2 /= norm;
- }
+ }
float c = cos(angle);
float s = sin(angle);
@@ -776,19 +776,19 @@ public final class PMatrix3D implements PMatrix /*, PConstants*/ {
//////////////////////////////////////////////////////////////
- private final float max(float a, float b) {
+ static private final float max(float a, float b) {
return (a > b) ? a : b;
}
- private final float abs(float a) {
+ static private final float abs(float a) {
return (a < 0) ? -a : a;
}
- private final float sin(float angle) {
+ static private final float sin(float angle) {
return (float) Math.sin(angle);
}
- private final float cos(float angle) {
+ static private final float cos(float angle) {
return (float) Math.cos(angle);
}
}
diff --git a/core/src/processing/core/PShape.java b/core/src/processing/core/PShape.java
index 98a985e4e..5f8a42618 100644
--- a/core/src/processing/core/PShape.java
+++ b/core/src/processing/core/PShape.java
@@ -77,7 +77,6 @@ import processing.core.PApplet;
* @instanceName sh any variable of type PShape
*/
public class PShape implements PConstants {
-
protected String name;
protected HashMap nameTable;
@@ -398,13 +397,13 @@ public class PShape implements PConstants {
- // TODO: need to discuss about these two (four).
- public PVector getTop() {
+ // TODO unapproved
+ protected PVector getTop() {
return getTop(null);
}
- public PVector getTop(PVector top) {
+ protected PVector getTop(PVector top) {
if (top == null) {
top = new PVector();
}
@@ -412,12 +411,12 @@ public class PShape implements PConstants {
}
- public PVector getBottom() {
+ protected PVector getBottom() {
return getBottom(null);
}
- public PVector getBottom(PVector bottom) {
+ protected PVector getBottom(PVector bottom) {
if (bottom == null) {
bottom = new PVector();
}
@@ -444,6 +443,7 @@ public class PShape implements PConstants {
/**
* Return true if this shape requires rendering through OpenGL. Defaults to false.
*/
+ // TODO unapproved
public boolean isGL() {
return false;
}
@@ -461,7 +461,8 @@ public class PShape implements PConstants {
public void noTexture() {
}
- public void solid(boolean solid) {
+ // TODO unapproved
+ protected void solid(boolean solid) {
}
public void beginContour() {
@@ -491,6 +492,7 @@ public class PShape implements PConstants {
public void end(int mode) {
}
+
//////////////////////////////////////////////////////////////
// STROKE CAP/JOIN/WEIGHT
@@ -505,6 +507,7 @@ public class PShape implements PConstants {
public void strokeCap(int cap) {
}
+
//////////////////////////////////////////////////////////////
// FILL COLOR
@@ -778,7 +781,8 @@ public class PShape implements PConstants {
// Shape copy
- static public PShape createShape(PApplet parent, PShape src) {
+ // TODO unapproved
+ static protected PShape createShape(PApplet parent, PShape src) {
PShape dest = null;
if (src.family == GROUP) {
dest = parent.createShape(GROUP);
@@ -798,7 +802,8 @@ public class PShape implements PConstants {
}
- static public void copyGroup(PApplet parent, PShape src, PShape dest) {
+ // TODO unapproved
+ static protected void copyGroup(PApplet parent, PShape src, PShape dest) {
copyMatrix(src, dest);
copyStyles(src, dest);
copyImage(src, dest);
@@ -809,14 +814,16 @@ public class PShape implements PConstants {
}
- static public void copyPrimitive(PShape src, PShape dest) {
+ // TODO unapproved
+ static protected void copyPrimitive(PShape src, PShape dest) {
copyMatrix(src, dest);
copyStyles(src, dest);
copyImage(src, dest);
}
- static public void copyGeometry(PShape src, PShape dest) {
+ // TODO unapproved
+ static protected void copyGeometry(PShape src, PShape dest) {
copyMatrix(src, dest);
copyStyles(src, dest);
copyImage(src, dest);
@@ -831,13 +838,17 @@ public class PShape implements PConstants {
// s.emissive(vert[ER] * 255, vert[EG] * 255, vert[EB] * 255);
// s.shininess(vert[SHINE]);
- dest.normal(vert[NX], vert[NY], vert[NZ]);
- dest.vertex(vert[X], vert[Y], vert[Z], vert[U], vert[V]);
+ dest.normal(vert[PGraphics.NX],
+ vert[PGraphics.NY],
+ vert[PGraphics.NZ]);
+ dest.vertex(vert[X], vert[Y], vert[Z],
+ vert[PGraphics.U],
+ vert[PGraphics.V]);
}
} else {
for (int i = 0; i < src.vertexCount; i++) {
float[] vert = src.vertices[i];
- if (vert[PGraphics.Z] == 0) {
+ if (vert[Z] == 0) {
dest.vertex(vert[X], vert[Y]);
} else {
dest.vertex(vert[X], vert[Y], vert[Z]);
@@ -849,7 +860,8 @@ public class PShape implements PConstants {
}
- static public void copyPath(PShape src, PShape dest) {
+ // TODO unapproved
+ static protected void copyPath(PShape src, PShape dest) {
copyMatrix(src, dest);
copyStyles(src, dest);
copyImage(src, dest);
@@ -858,13 +870,16 @@ public class PShape implements PConstants {
}
- static public void copyMatrix(PShape src, PShape dest) {
+ // TODO unapproved
+ static protected void copyMatrix(PShape src, PShape dest) {
if (src.matrix != null) {
dest.applyMatrix(src.matrix);
}
}
- static public void copyStyles(PShape src, PShape dest) {
+
+ // TODO unapproved
+ static protected void copyStyles(PShape src, PShape dest) {
if (src.stroke) {
dest.stroke = true;
dest.strokeColor = src.strokeColor;
@@ -884,19 +899,21 @@ public class PShape implements PConstants {
}
- static public void copyImage(PShape src, PShape dest) {
+ // TODO unapproved
+ static protected void copyImage(PShape src, PShape dest) {
if (src.image != null) {
dest.texture(src.image);
}
}
+
////////////////////////////////////////////////////////////////////////
/**
* Called by the following (the shape() command adds the g)
- * PShape s = loadShapes("blah.svg");
+ * PShape s = loadShape("blah.svg");
* shape(s);
*/
public void draw(PGraphics g) {
@@ -988,8 +1005,6 @@ public class PShape implements PConstants {
protected void drawGeometry(PGraphics g) {
// get cache object using g.
-
-
g.beginShape(kind);
if (style) {
for (int i = 0; i < vertexCount; i++) {
@@ -998,7 +1013,7 @@ public class PShape implements PConstants {
} else {
for (int i = 0; i < vertexCount; i++) {
float[] vert = vertices[i];
- if (vert[PGraphics.Z] == 0) {
+ if (vert[Z] == 0) {
g.vertex(vert[X], vert[Y]);
} else {
g.vertex(vert[X], vert[Y], vert[Z]);
@@ -1124,6 +1139,7 @@ public class PShape implements PConstants {
case CURVE_VERTEX:
g.curveVertex(vertices[index][X], vertices[index][Y]);
index++;
+ break;
case BREAK:
if (insideContour) {
@@ -1162,6 +1178,7 @@ public class PShape implements PConstants {
case CURVE_VERTEX:
g.curveVertex(vertices[index][X], vertices[index][Y], vertices[index][Z]);
index++;
+ break;
case BREAK:
if (insideContour) {
@@ -1373,7 +1390,7 @@ public class PShape implements PConstants {
}
- public void setParams(float[] source) {
+ protected void setParams(float[] source) {
if (params == null) {
params = new float[source.length];
}
@@ -1390,7 +1407,7 @@ public class PShape implements PConstants {
}
- public void setPath(int vcount, float[][] verts, int ccount, int[] codes) {
+ protected void setPath(int vcount, float[][] verts, int ccount, int[] codes) {
if (verts == null || verts.length < vcount) return;
if (0 < ccount && (codes == null || codes.length < ccount)) return;
@@ -1447,7 +1464,8 @@ public class PShape implements PConstants {
public void setVertex(int index, float x, float y) {
- setVertex(index, x, y, 0);
+ vertices[index][X] = x;
+ vertices[index][Y] = y;
}
@@ -1474,146 +1492,146 @@ public class PShape implements PConstants {
if (vec == null) {
vec = new PVector();
}
- vec.x = vertices[index][NX];
- vec.y = vertices[index][NY];
- vec.z = vertices[index][NZ];
+ vec.x = vertices[index][PGraphics.NX];
+ vec.y = vertices[index][PGraphics.NY];
+ vec.z = vertices[index][PGraphics.NZ];
return vec;
}
public float getNormalX(int index) {
- return vertices[index][NX];
+ return vertices[index][PGraphics.NX];
}
public float getNormalY(int index) {
- return vertices[index][NY];
+ return vertices[index][PGraphics.NY];
}
public float getNormalZ(int index) {
- return vertices[index][NZ];
+ return vertices[index][PGraphics.NZ];
}
public void setNormal(int index, float nx, float ny, float nz) {
- vertices[index][NX] = nx;
- vertices[index][NY] = ny;
- vertices[index][NZ] = nz;
+ vertices[index][PGraphics.NX] = nx;
+ vertices[index][PGraphics.NY] = ny;
+ vertices[index][PGraphics.NZ] = nz;
}
public float getTextureU(int index) {
- return vertices[index][U];
+ return vertices[index][PGraphics.U];
}
public float getTextureV(int index) {
- return vertices[index][V];
+ return vertices[index][PGraphics.V];
}
public void setTextureUV(int index, float u, float v) {
- vertices[index][U] = u;
- vertices[index][V] = v;
+ vertices[index][PGraphics.U] = u;
+ vertices[index][PGraphics.V] = v;
}
public int getFill(int index) {
- int a = (int) (vertices[index][A] * 255);
- int r = (int) (vertices[index][R] * 255);
- int g = (int) (vertices[index][G] * 255);
- int b = (int) (vertices[index][B] * 255);
+ int a = (int) (vertices[index][PGraphics.A] * 255);
+ int r = (int) (vertices[index][PGraphics.R] * 255);
+ int g = (int) (vertices[index][PGraphics.G] * 255);
+ int b = (int) (vertices[index][PGraphics.B] * 255);
return (a << 24) | (r << 16) | (g << 8) | b;
}
public void setFill(int index, int fill) {
- vertices[index][A] = ((fill >> 24) & 0xFF) / 255.0f;
- vertices[index][R] = ((fill >> 16) & 0xFF) / 255.0f;
- vertices[index][G] = ((fill >> 8) & 0xFF) / 255.0f;
- vertices[index][B] = ((fill >> 0) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.A] = ((fill >> 24) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.R] = ((fill >> 16) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.G] = ((fill >> 8) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.B] = ((fill >> 0) & 0xFF) / 255.0f;
}
public int getStroke(int index) {
- int a = (int) (vertices[index][SA] * 255);
- int r = (int) (vertices[index][SR] * 255);
- int g = (int) (vertices[index][SG] * 255);
- int b = (int) (vertices[index][SB] * 255);
+ int a = (int) (vertices[index][PGraphics.SA] * 255);
+ int r = (int) (vertices[index][PGraphics.SR] * 255);
+ int g = (int) (vertices[index][PGraphics.SG] * 255);
+ int b = (int) (vertices[index][PGraphics.SB] * 255);
return (a << 24) | (r << 16) | (g << 8) | b;
}
public void setStroke(int index, int stroke) {
- vertices[index][SA] = ((stroke >> 24) & 0xFF) / 255.0f;
- vertices[index][SR] = ((stroke >> 16) & 0xFF) / 255.0f;
- vertices[index][SG] = ((stroke >> 8) & 0xFF) / 255.0f;
- vertices[index][SB] = ((stroke >> 0) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.SA] = ((stroke >> 24) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.SR] = ((stroke >> 16) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.SG] = ((stroke >> 8) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.SB] = ((stroke >> 0) & 0xFF) / 255.0f;
}
- public float getStrokeWeight(int index) {
- return vertices[index][SW];
+ protected float getStrokeWeight(int index) {
+ return vertices[index][PGraphics.SW];
}
- public void setStrokeWeight(int index, float weight) {
- vertices[index][SW] = weight;
+ protected void setStrokeWeight(int index, float weight) {
+ vertices[index][PGraphics.SW] = weight;
}
- public int getAmbient(int index) {
- int r = (int) (vertices[index][AR] * 255);
- int g = (int) (vertices[index][AG] * 255);
- int b = (int) (vertices[index][AB] * 255);
+ protected int getAmbient(int index) {
+ int r = (int) (vertices[index][PGraphics.AR] * 255);
+ int g = (int) (vertices[index][PGraphics.AG] * 255);
+ int b = (int) (vertices[index][PGraphics.AB] * 255);
return 0xff000000 | (r << 16) | (g << 8) | b;
}
- public void setAmbient(int index, int ambient) {
- vertices[index][AR] = ((ambient >> 16) & 0xFF) / 255.0f;
- vertices[index][AG] = ((ambient >> 8) & 0xFF) / 255.0f;
- vertices[index][AB] = ((ambient >> 0) & 0xFF) / 255.0f;
+ protected void setAmbient(int index, int ambient) {
+ vertices[index][PGraphics.AR] = ((ambient >> 16) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.AG] = ((ambient >> 8) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.AB] = ((ambient >> 0) & 0xFF) / 255.0f;
}
- public int getSpecular(int index) {
- int r = (int) (vertices[index][SPR] * 255);
- int g = (int) (vertices[index][SPG] * 255);
- int b = (int) (vertices[index][SPB] * 255);
+ protected int getSpecular(int index) {
+ int r = (int) (vertices[index][PGraphics.SPR] * 255);
+ int g = (int) (vertices[index][PGraphics.SPG] * 255);
+ int b = (int) (vertices[index][PGraphics.SPB] * 255);
return 0xff000000 | (r << 16) | (g << 8) | b;
}
- public void setSpecular(int index, int specular) {
- vertices[index][SPR] = ((specular >> 16) & 0xFF) / 255.0f;
- vertices[index][SPG] = ((specular >> 8) & 0xFF) / 255.0f;
- vertices[index][SPB] = ((specular >> 0) & 0xFF) / 255.0f;
+ protected void setSpecular(int index, int specular) {
+ vertices[index][PGraphics.SPR] = ((specular >> 16) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.SPG] = ((specular >> 8) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.SPB] = ((specular >> 0) & 0xFF) / 255.0f;
}
- public int getEmissive(int index) {
- int r = (int) (vertices[index][ER] * 255);
- int g = (int) (vertices[index][EG] * 255);
- int b = (int) (vertices[index][EB] * 255);
+ protected int getEmissive(int index) {
+ int r = (int) (vertices[index][PGraphics.ER] * 255);
+ int g = (int) (vertices[index][PGraphics.EG] * 255);
+ int b = (int) (vertices[index][PGraphics.EB] * 255);
return 0xff000000 | (r << 16) | (g << 8) | b;
}
- public void setEmissive(int index, int emissive) {
- vertices[index][ER] = ((emissive >> 16) & 0xFF) / 255.0f;
- vertices[index][EG] = ((emissive >> 8) & 0xFF) / 255.0f;
- vertices[index][EB] = ((emissive >> 0) & 0xFF) / 255.0f;
+ protected void setEmissive(int index, int emissive) {
+ vertices[index][PGraphics.ER] = ((emissive >> 16) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.EG] = ((emissive >> 8) & 0xFF) / 255.0f;
+ vertices[index][PGraphics.EB] = ((emissive >> 0) & 0xFF) / 255.0f;
}
- public float getShininess(int index) {
- return vertices[index][SHINE];
+ protected float getShininess(int index) {
+ return vertices[index][PGraphics.SHINE];
}
- public void setShininess(int index, float shine) {
- vertices[index][SHINE] = shine;
+ protected void setShininess(int index, float shine) {
+ vertices[index][PGraphics.SHINE] = shine;
}
diff --git a/core/src/processing/opengl/PGL.java b/core/src/processing/opengl/PGL.java
index 58c64f52d..006e35827 100644
--- a/core/src/processing/opengl/PGL.java
+++ b/core/src/processing/opengl/PGL.java
@@ -58,7 +58,10 @@ import com.jogamp.opengl.util.AnimatorBase;
/**
* Processing-OpenGL abstraction layer.
*
+ * Warnings are suppressed for static access because presumably on Android,
+ * the GL2 vs GL distinctions are necessary, whereas on desktop they are not.
*/
+@SuppressWarnings("static-access")
public class PGL {
// The two windowing toolkits available to use in JOGL:
protected static final int AWT = 0; // http://jogamp.org/wiki/index.php/Using_JOGL_in_AWT_SWT_and_Swing
diff --git a/core/src/processing/opengl/PGraphics2D.java b/core/src/processing/opengl/PGraphics2D.java
index 7522cf5d8..fb625ae7b 100644
--- a/core/src/processing/opengl/PGraphics2D.java
+++ b/core/src/processing/opengl/PGraphics2D.java
@@ -26,6 +26,7 @@ import java.io.InputStream;
import java.util.zip.GZIPInputStream;
import processing.core.PApplet;
+import processing.core.PConstants;
import processing.core.PGraphics;
import processing.core.PMatrix3D;
import processing.core.PShape;
@@ -300,8 +301,8 @@ public class PGraphics2D extends PGraphicsOpenGL {
static protected PShape2D createShapeImpl(PApplet parent, int type) {
PShape2D shape = null;
- if (type == PShape.GROUP) {
- shape = new PShape2D(parent, PShape.GROUP);
+ if (type == PConstants.GROUP) {
+ shape = new PShape2D(parent, PConstants.GROUP);
} else if (type == PShape.PATH) {
shape = new PShape2D(parent, PShape.PATH);
} else if (type == POINTS) {
diff --git a/core/src/processing/opengl/PGraphics3D.java b/core/src/processing/opengl/PGraphics3D.java
index 4dad25e78..ba24f1f10 100644
--- a/core/src/processing/opengl/PGraphics3D.java
+++ b/core/src/processing/opengl/PGraphics3D.java
@@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.Hashtable;
import processing.core.PApplet;
+import processing.core.PConstants;
import processing.core.PGraphics;
import processing.core.PImage;
import processing.core.PShape;
@@ -257,8 +258,8 @@ public class PGraphics3D extends PGraphicsOpenGL {
static protected PShape3D createShapeImpl(PApplet parent, int type) {
PShape3D shape = null;
- if (type == PShape.GROUP) {
- shape = new PShape3D(parent, PShape.GROUP);
+ if (type == PConstants.GROUP) {
+ shape = new PShape3D(parent, PConstants.GROUP);
} else if (type == PShape.PATH) {
shape = new PShape3D(parent, PShape.PATH);
} else if (type == POINTS) {
diff --git a/core/src/processing/opengl/PGraphicsOpenGL.java b/core/src/processing/opengl/PGraphicsOpenGL.java
index c8563f74c..8f4bd2299 100644
--- a/core/src/processing/opengl/PGraphicsOpenGL.java
+++ b/core/src/processing/opengl/PGraphicsOpenGL.java
@@ -8599,7 +8599,7 @@ public class PGraphicsOpenGL extends PGraphics {
PApplet.max(MIN_POINT_ACCURACY,
(int) (TWO_PI * PApplet.dist(sx1, sy1, sx2, sy2) /
POINT_ACCURACY_FACTOR));
- float inc = (float) PGraphicsOpenGL.SINCOS_LENGTH / accuracy;
+ float inc = (float) SINCOS_LENGTH / accuracy;
if (fill) {
addVertex(centerX, centerY, VERTEX);
@@ -8608,10 +8608,10 @@ public class PGraphicsOpenGL extends PGraphics {
idx0 = pidx = idx = 0;
float val = 0;
for (int i = 0; i < accuracy; i++) {
- idx = addVertex(centerX + PGraphicsOpenGL.cosLUT[(int) val] * radiusH,
- centerY + PGraphicsOpenGL.sinLUT[(int) val] * radiusV,
+ idx = addVertex(centerX + cosLUT[(int) val] * radiusH,
+ centerY + sinLUT[(int) val] * radiusV,
VERTEX);
- val = (val + inc) % PGraphicsOpenGL.SINCOS_LENGTH;
+ val = (val + inc) % SINCOS_LENGTH;
if (0 < i) {
if (stroke) addEdge(pidx, idx, i == 1, false);
@@ -8622,8 +8622,8 @@ public class PGraphicsOpenGL extends PGraphics {
pidx = idx;
}
// Back to the beginning
- addVertex(centerX + PGraphicsOpenGL.cosLUT[0] * radiusH,
- centerY + PGraphicsOpenGL.sinLUT[0] * radiusV,
+ addVertex(centerX + cosLUT[0] * radiusH,
+ centerY + sinLUT[0] * radiusV,
VERTEX);
if (stroke) addEdge(idx, idx0, false, true);
}
@@ -11432,6 +11432,7 @@ public class PGraphicsOpenGL extends PGraphics {
case LinePath.SEG_MOVETO:
gluTess.beginContour();
+ // $FALL-THROUGH$
case LinePath.SEG_LINETO:
sa = (strokeColor >> 24) & 0xFF;
sr = (strokeColor >> 16) & 0xFF;
diff --git a/core/src/processing/opengl/PShapeOpenGL.java b/core/src/processing/opengl/PShapeOpenGL.java
index 801cc53d4..20a4109da 100644
--- a/core/src/processing/opengl/PShapeOpenGL.java
+++ b/core/src/processing/opengl/PShapeOpenGL.java
@@ -2880,6 +2880,7 @@ public class PShapeOpenGL extends PShape {
fill, stroke, curveDetail, code);
code = VERTEX;
idx++;
+ break;
case BREAK:
code = BREAK;
@@ -2931,6 +2932,7 @@ public class PShapeOpenGL extends PShape {
fill, stroke, curveDetail, code);
code = VERTEX;
idx++;
+ break;
case BREAK:
code = BREAK;