continuing the graphics madness

This commit is contained in:
benfry
2005-02-14 18:28:10 +00:00
parent e3456e2f49
commit 504f10b761
5 changed files with 37 additions and 746 deletions
+1 -10
View File
@@ -64,6 +64,7 @@ echo Building processing.core...
CLASSPATH=/System/Library/Frameworks/JavaVM.framework/Classes/classes.jar:/System/Library/Frameworks/JavaVM.framework/Classes/ui.jar:/System/Library/Java/Extensions/QTJava.zip:/System/Library/Java/Extensions/MRJToolkit.jar
export CLASSPATH
perl preproc.pl
../build/macosx/work/jikes -d . +D -target 1.1 *.java
zip -r0q ../build/macosx/work/lib/core.jar processing
@@ -74,18 +75,8 @@ cd ../app
### -- BUILD PARSER ---------------------------------------------
# add code here later to conditionally build the parser.
# but for now, the parser is only built when the work dir
# is created, to speed the build process.
#echo Removing preproc code so it will regenerate
#rm preprocessor/expandedpde.g
if $BUILD_PREPROC
#if test -f preprocessor/expandedpde.g
then
echo
else
cd preprocessor
# build classes/grammar for preprocessor
echo Building antlr grammar code...
+30 -482
View File
@@ -4500,6 +4500,21 @@ v PApplet.this.stop();
}
public void modified(int x, int y) {
g.modified(x, y);
}
public void modified(int x1, int y1, int x2, int y2) {
g.modified(x1, y1, x2, y2);
}
public void resetModified() {
g.resetModified();
}
public void alpha(int alpha[]) {
g.alpha(alpha);
}
@@ -4647,31 +4662,11 @@ v PApplet.this.stop();
}
public void beginShape() {
g.beginShape();
}
public void beginShape(int kind) {
g.beginShape(kind);
}
public void normal(float nx, float ny, float nz) {
g.normal(nx, ny, nz);
}
public void textureMode(int mode) {
g.textureMode(mode);
}
public void texture(PImage image) {
g.texture(image);
}
public void vertex(float x, float y) {
g.vertex(x, y);
}
@@ -4713,134 +4708,26 @@ v PApplet.this.stop();
}
public void normal(float nx, float ny, float nz) {
g.normal(nx, ny, nz);
}
public void textureMode(int mode) {
g.textureMode(mode);
}
public void texture(PImage image) {
g.texture(image);
}
public void endShape() {
g.endShape();
}
public void point(float x, float y) {
g.point(x, y);
}
public void point(float x, float y, float z) {
g.point(x, y, z);
}
public void line(float x1, float y1, float x2, float y2) {
g.line(x1, y1, x2, y2);
}
public void line(float x1, float y1, float z1,
float x2, float y2, float z2) {
g.line(x1, y1, z1, x2, y2, z2);
}
public void triangle(float x1, float y1, float x2, float y2,
float x3, float y3) {
g.triangle(x1, y1, x2, y2, x3, y3);
}
public void rectMode(int mode) {
g.rectMode(mode);
}
public void rect(float x1, float y1, float x2, float y2) {
g.rect(x1, y1, x2, y2);
}
public void quad(float x1, float y1, float x2, float y2,
float x3, float y3, float x4, float y4) {
g.quad(x1, y1, x2, y2, x3, y3, x4, y4);
}
public void image(PImage image, float x1, float y1) {
g.image(image, x1, y1);
}
public void image(PImage image,
float x1, float y1, float x2, float y2) {
g.image(image, x1, y1, x2, y2);
}
public void image(PImage image,
float x1, float y1, float x2, float y2,
float u1, float v1, float u2, float v2) {
g.image(image, x1, y1, x2, y2, u1, v1, u2, v2);
}
public void cache(PImage image) {
g.cache(image);
}
public void cache(PImage images[]) {
g.cache(images);
}
public void arcMode(int mode) {
g.arcMode(mode);
}
public void arc(float start, float stop,
float x, float y, float radius) {
g.arc(start, stop, x, y, radius);
}
public void arc(float start, float stop,
float x, float y, float hr, float vr) {
g.arc(start, stop, x, y, hr, vr);
}
public void ellipseMode(int mode) {
g.ellipseMode(mode);
}
public void ellipse(float x, float y, float hradius, float vradius) {
g.ellipse(x, y, hradius, vradius);
}
public void circle(float x, float y, float radius) {
g.circle(x, y, radius);
}
public float bezierPoint(float a, float b, float c, float d,
float t) {
return g.bezierPoint(a, b, c, d, t);
}
public float bezierTangent(float a, float b, float c, float d,
float t) {
return g.bezierTangent(a, b, c, d, t);
}
public void bezier(float x1, float y1,
float x2, float y2,
float x3, float y3,
float x4, float y4) {
g.bezier(x1, y1, x2, y2, x3, y3, x4, y4);
}
public void bezier(float x1, float y1, float z1,
float x2, float y2, float z2,
float x3, float y3, float z3,
@@ -4849,49 +4736,6 @@ v PApplet.this.stop();
}
public void bezierDetail(int detail) {
g.bezierDetail(detail);
}
public void curveDetail(int detail) {
g.curveDetail(detail);
}
public void curveTightness(float tightness) {
g.curveTightness(tightness);
}
public float curvePoint(float a, float b, float c, float d,
float t) {
return g.curvePoint(a, b, c, d, t);
}
public float curveTangent(float a, float b, float c, float d,
float t) {
return g.curveTangent(a, b, c, d, t);
}
public void curve(float x1, float y1,
float x2, float y2,
float x3, float y3,
float x4, float y4) {
g.curve(x1, y1, x2, y2, x3, y3, x4, y4);
}
public void curve(float x1, float y1, float z1,
float x2, float y2, float z2,
float x3, float y3, float z3,
float x4, float y4, float z4) {
g.curve(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4);
}
public void box(float size) {
g.box(size);
}
@@ -4917,91 +4761,6 @@ v PApplet.this.stop();
}
public void textFont(PFont which) {
g.textFont(which);
}
public void textSize(float size) {
g.textSize(size);
}
public void textFont(PFont which, float size) {
g.textFont(which, size);
}
public void textLeading(float leading) {
g.textLeading(leading);
}
public void textMode(int mode) {
g.textMode(mode);
}
public void textSpace(int space) {
g.textSpace(space);
}
public void text(char c, float x, float y) {
g.text(c, x, y);
}
public void text(char c, float x, float y, float z) {
g.text(c, x, y, z);
}
public void text(String s, float x, float y) {
g.text(s, x, y);
}
public void text(String s, float x, float y, float z) {
g.text(s, x, y, z);
}
public void text(String s, float x, float y, float w, float h) {
g.text(s, x, y, w, h);
}
public void text(String s, float x1, float y1, float z, float x2, float y2) {
g.text(s, x1, y1, z, x2, y2);
}
public void text(int num, float x, float y) {
g.text(num, x, y);
}
public void text(int num, float x, float y, float z) {
g.text(num, x, y, z);
}
public void text(float num, float x, float y) {
g.text(num, x, y);
}
public void text(float num, float x, float y, float z) {
g.text(num, x, y, z);
}
public void angleMode(int mode) {
g.angleMode(mode);
}
public void translate(float tx, float ty) {
g.translate(tx, ty);
}
@@ -5052,14 +4811,6 @@ v PApplet.this.stop();
}
public void transform(float n00, float n01, float n02, float n03,
float n10, float n11, float n12, float n13,
float n20, float n21, float n22, float n23,
float n30, float n31, float n32, float n33) {
g.transform(n00, n01, n02, n03, n10, n11, n12, n13, n20, n21, n22, n23, n30, n31, n32, n33);
}
public void push() {
g.push();
}
@@ -5083,12 +4834,6 @@ v PApplet.this.stop();
}
public void applyMatrix(float n00, float n01, float n02,
float n10, float n11, float n12) {
g.applyMatrix(n00, n01, n02, n10, n11, n12);
}
public void printMatrix() {
g.printMatrix();
}
@@ -5179,148 +4924,6 @@ v PApplet.this.stop();
}
public void colorMode(int mode) {
g.colorMode(mode);
}
public void colorMode(int mode, float max) {
g.colorMode(mode, max);
}
public void colorMode(int mode,
float maxX, float maxY, float maxZ) {
g.colorMode(mode, maxX, maxY, maxZ);
}
public void colorMode(int mode,
float maxX, float maxY, float maxZ, float maxA) {
g.colorMode(mode, maxX, maxY, maxZ, maxA);
}
public void noTint() {
g.noTint();
}
public void tint(int rgb) {
g.tint(rgb);
}
public void tint(float gray) {
g.tint(gray);
}
public void tint(float gray, float alpha) {
g.tint(gray, alpha);
}
public void tint(float x, float y, float z) {
g.tint(x, y, z);
}
public void tint(float x, float y, float z, float a) {
g.tint(x, y, z, a);
}
public void noFill() {
g.noFill();
}
public void fill(int rgb) {
g.fill(rgb);
}
public void fill(float gray) {
g.fill(gray);
}
public void fill(float gray, float alpha) {
g.fill(gray, alpha);
}
public void fill(float x, float y, float z) {
g.fill(x, y, z);
}
public void fill(float x, float y, float z, float a) {
g.fill(x, y, z, a);
}
public void strokeWeight(float weight) {
g.strokeWeight(weight);
}
public void strokeJoin(int join) {
g.strokeJoin(join);
}
public void strokeCap(int cap) {
g.strokeCap(cap);
}
public void noStroke() {
g.noStroke();
}
public void stroke(int rgb) {
g.stroke(rgb);
}
public void stroke(float gray) {
g.stroke(gray);
}
public void stroke(float gray, float alpha) {
g.stroke(gray, alpha);
}
public void stroke(float x, float y, float z) {
g.stroke(x, y, z);
}
public void stroke(float x, float y, float z, float a) {
g.stroke(x, y, z, a);
}
public void background(int rgb) {
g.background(rgb);
}
public void background(float gray) {
g.background(gray);
}
public void background(float x, float y, float z) {
g.background(x, y, z);
}
public void background(PImage image) {
g.background(image);
}
@@ -5331,16 +4934,6 @@ v PApplet.this.stop();
}
public void depth() {
g.depth();
}
public void noDepth() {
g.noDepth();
}
public void lights() {
g.lights();
}
@@ -5385,49 +4978,4 @@ v PApplet.this.stop();
public void lightSpecular(int num, float x, float y, float z) {
g.lightSpecular(num, x, y, z);
}
public void hint(int which) {
g.hint(which);
}
public void unhint(int which) {
g.unhint(which);
}
public final float alpha(int what) {
return g.alpha(what);
}
public final float red(int what) {
return g.red(what);
}
public final float green(int what) {
return g.green(what);
}
public final float blue(int what) {
return g.blue(what);
}
public final float hue(int what) {
return g.hue(what);
}
public final float saturation(int what) {
return g.saturation(what);
}
public final float brightness(int what) {
return g.brightness(what);
}
}
+1 -1
View File
@@ -195,7 +195,7 @@ public interface PConstants {
static final int CAP_MASK = SQUARE | ROUND | PROJECTED;
static final int MITERED = 1 << 3;
static final int ROUND = 1 << 4;
//static final int ROUND = 1 << 4;
static final int BEVELED = 1 << 5;
static final int JOIN_MASK = MITERED | ROUND | BEVELED;
+3 -251
View File
@@ -44,7 +44,7 @@ public class PGraphics2 extends PGraphics {
new AffineTransform[MATRIX_STACK_DEPTH];
double transform[] = new double[6];
Elipse2D.Float ellipse = new Ellipse2D.Float();
Ellipse2D.Float ellipse = new Ellipse2D.Float();
Rectangle2D.Float rect = new Rectangle2D.Float();
Arc2D.Float arc = new Arc2D.Float();
@@ -125,255 +125,6 @@ public class PGraphics2 extends PGraphics {
// SHAPES
public void endShape() {
// don't try to draw if there are no vertices
// (fixes a bug in LINE_LOOP that re-adds a nonexistent vertex)
if (vertexCount == 0) {
shape = 0;
return;
}
// ------------------------------------------------------------------
// CREATE LINES
int increment = 1;
int stop = 0;
int counter = 0;
if (stroke) {
switch (shape) {
case POINTS:
{
for (int i = 0; i < vertexCount; i++) {
point(vertices[i][VX], vertices[i][VY]);
}
stop = vertex_end;
for (int i = vertex_start; i < stop; i++) {
add_path(); // total overkill for points
add_line(i, i);
}
}
break;
case LINES:
case LINE_STRIP:
case LINE_LOOP:
{
// store index of first vertex
int first = lineCount;
stop = vertex_end - 1;
increment = (shape == LINES) ? 2 : 1;
// for LINE_STRIP and LINE_LOOP, make this all one path
if (shape != LINES) add_path();
for (int i = vertex_start; i < stop; i+=increment) {
// for LINES, make a new path for each segment
if (shape == LINES) add_path();
add_line(i, i+1);
}
// for LINE_LOOP, close the loop with a final segment
if (shape == LINE_LOOP) {
add_line(stop, lines[first][VERTEX1]);
}
}
break;
case TRIANGLES:
{
for (int i = vertex_start; i < vertex_end; i += 3) {
add_path();
counter = i - vertex_start;
add_line(i+0, i+1);
add_line(i+1, i+2);
add_line(i+2, i+0);
}
}
break;
case TRIANGLE_STRIP:
{
// first draw all vertices as a line strip
stop = vertex_end-1;
add_path();
for (int i = vertex_start; i < stop; i++) {
counter = i - vertex_start;
add_line(i,i+1);
}
// then draw from vertex (n) to (n+2)
stop = vertex_end-2;
for (int i = vertex_start; i < stop; i++) {
add_path();
add_line(i,i+2);
}
}
break;
case TRIANGLE_FAN:
{
// this just draws a series of line segments
// from the center to each exterior point
for (int i = vertex_start + 1; i < vertex_end; i++) {
add_path();
add_line(vertex_start, i);
}
// then a single line loop around the outside.
add_path();
for (int i = vertex_start + 1; i < vertex_end-1; i++) {
add_line(i, i+1);
}
// closing the loop
add_line(vertex_end-1, vertex_start + 1);
}
break;
case QUADS:
{
for (int i = vertex_start; i < vertex_end; i += 4) {
add_path();
counter = i - vertex_start;
add_line(i+0, i+1);
add_line(i+1, i+2);
add_line(i+2, i+3);
add_line(i+3, i+0);
}
}
break;
case QUAD_STRIP:
{
// first draw all vertices as a line strip
stop = vertex_end - 1;
add_path();
for (int i = vertex_start; i < stop; i++) {
counter = i - vertex_start;
add_line(i, i+1);
}
// then draw from vertex (n) to (n+3)
stop = vertex_end-2;
increment = 2;
add_path();
for (int i = vertex_start; i < stop; i += increment) {
add_line(i, i+3);
}
}
break;
case POLYGON:
case CONCAVE_POLYGON:
case CONVEX_POLYGON:
{
// store index of first vertex
int first = lineCount;
stop = vertex_end - 1;
add_path();
for (int i = vertex_start; i < stop; i++) {
add_line(i, i+1);
}
// draw the last line connecting back to the first point in poly
add_line(stop, lines[first][VERTEX1]);
}
break;
}
}
// ------------------------------------------------------------------
// CREATE TRIANGLES
if (fill) {
switch (shape) {
case TRIANGLES:
case TRIANGLE_STRIP:
{
stop = vertex_end - 2;
increment = (shape == TRIANGLES) ? 3 : 1;
for (int i = vertex_start; i < stop; i += increment) {
add_triangle(i, i+1, i+2);
}
}
break;
case QUADS:
case QUAD_STRIP:
{
stop = vertex_count-3;
increment = (shape == QUADS) ? 4 : 2;
for (int i = vertex_start; i < stop; i += increment) {
// first triangle
add_triangle(i, i+1, i+2);
// second triangle
add_triangle(i, i+2, i+3);
}
}
break;
case POLYGON:
case CONCAVE_POLYGON:
case CONVEX_POLYGON:
{
triangulate_polygon();
}
break;
}
}
// ------------------------------------------------------------------
// 2D or 3D POINTS FROM MODEL (MX, MY, MZ) TO VIEW SPACE (X, Y, Z)
if (depth) {
for (int i = vertex_start; i < vertex_end; i++) {
float vertex[] = vertices[i];
vertex[VX] = m00*vertex[MX] + m01*vertex[MY] + m02*vertex[MZ] + m03;
vertex[VY] = m10*vertex[MX] + m11*vertex[MY] + m12*vertex[MZ] + m13;
vertex[VZ] = m20*vertex[MX] + m21*vertex[MY] + m22*vertex[MZ] + m23;
vertex[VW] = m30*vertex[MX] + m31*vertex[MY] + m32*vertex[MZ] + m33;
}
} else {
// if no depth in use, then the points can be transformed simpler
for (int i = vertex_start; i < vertex_end; i++) {
vertices[i][X] = m00*vertices[i][MX] + m01*vertices[i][MY] + m03;
vertices[i][Y] = m10*vertices[i][MX] + m11*vertices[i][MY] + m13;
}
}
// ------------------------------------------------------------------
// TRANSFORM / LIGHT / CLIP
light_and_transform();
// ------------------------------------------------------------------
// RENDER SHAPES FILLS HERE WHEN NOT DEPTH SORTING
// if true, the shapes will be rendered on endFrame
if (hints[DEPTH_SORT]) {
shape = 0;
return;
}
if (fill) render_triangles();
if (stroke) render_lines();
shape = 0;
}
public void vertex(float x, float y) {
splineVertexCount = 0;
float vertex[];
@@ -557,8 +308,9 @@ public class PGraphics2 extends PGraphics {
public void endShape() {
switch (shape) {
shape = 0;
switch (shape) {
case LINE_STRIP:
stroke_shape(path);
break;
+2 -2
View File
@@ -171,7 +171,7 @@ public class PGraphics3 extends PGraphics {
* This prototype only exists because of annoying
* java compilers, and should not be used.
*/
public PGraphics2() { }
public PGraphics3() { }
/**
@@ -2297,4 +2297,4 @@ public class PGraphics3 extends PGraphics {
lightSpecularG[num] = calcG;
lightSpecularB[num] = calcB;
}
}
}