1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

Syncing with Processing 1.0.9 (revision 5766).

This commit is contained in:
David A. Mellis
2009-10-22 00:56:16 +00:00
parent 7f58e2213e
commit 2e26a2d994
38 changed files with 16818 additions and 901 deletions

View File

@ -1,3 +1,29 @@
0170 core (1.0.8)
X added some min/max functions that work with doubles
X not sure if those are staying in or not
X filter(RGB) supposed to be filter(OPAQUE)
X http://dev.processing.org/bugs/show_bug.cgi?id=1346
X implement non-power-of-2 textures
X fix get() when used with save() in OpenGL mode
X immediately update projection with OpenGL
X in the past, projection updates required a new frame
X also prevents camera/project from being reset with setSize() (regression?)
X which was a problem anyway because it made GL calls outside draw()
X partial fix for texture edge problems with opengl
o http://dev.processing.org/bugs/show_bug.cgi?id=602
X some camera problems may be coming from "cameraNear = -8" line
X this may cause other problems with drawing/clipping however
X opengl camera does not update on current frame (has to do a second frame)
X remove methods from PApplet that use doubles
0169 core (1.0.7)
X remove major try/catch block from PApplet.main()
X hopefully will allow some exception stuff to come through properly
X PVector.angleDistance() returns NaN
X http://dev.processing.org/bugs/show_bug.cgi?id=1316
0168 core (1.0.6)
X getImage() setting the wrong image type
X http://dev.processing.org/bugs/show_bug.cgi?id=1282

7
core/preproc/.classpath Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/usr/share/ant/lib/ant.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

17
core/preproc/.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>preproc</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

22
core/preproc/build.xml Normal file
View File

@ -0,0 +1,22 @@
<project name="preproc" default="task-lib">
<target name="compile">
<mkdir dir="bin" />
<!-- <javac target="1.5" srcdir="src" destdir="bin" classpath="../ant/ant.jar" debug="true"/>-->
<javac target="1.5" srcdir="src" destdir="bin" classpath="/usr/share/ant/ant.jar" debug="true"/>
</target>
<target name="task-lib" depends="compile">
<jar basedir="bin" destfile="preproc.jar" />
</target>
<target name="demo">
<taskdef name="preproc" classname="processing.build.PAppletMethods" classpath="preproc.jar" />
<preproc dir="demo"/>
</target>
<target name="clean">
<delete dir="bin" />
<delete file="preproc.jar" />
</target>
</project>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

BIN
core/preproc/preproc.jar Normal file

Binary file not shown.

View File

@ -0,0 +1,236 @@
package processing.build;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
/**
* Ant Task for copying the PImage and PGraphics methods into PApplet.
*/
public class PAppletMethods extends Task {
private File baseDir;
public PAppletMethods() {
}
public void setDir(String dir) {
baseDir = new File(dir);
}
public void execute() throws BuildException {
// Do a bunch of checks...
if (baseDir == null) {
throw new BuildException("dir parameter must be set!");
}
File graphicsFile = new File(baseDir, "PGraphics.java");
File appletFile = new File(baseDir, "PApplet.java");
File imageFile = new File(baseDir, "PImage.java");
if (!graphicsFile.exists() || !graphicsFile.canRead()) {
throw new BuildException("PGraphics file not readable: " +
graphicsFile.getAbsolutePath());
}
if (!appletFile.exists() || !appletFile.canRead() || !appletFile.canWrite()) {
throw new BuildException("PApplet file not read/writeable: " +
appletFile.getAbsolutePath());
}
if (!imageFile.exists() || !imageFile.canRead()) {
throw new BuildException("PImage file not readable: " +
imageFile.getAbsolutePath());
}
// Looking good, let's do this!
ByteArrayOutputStream outBytes = new ByteArrayOutputStream();
PrintStream out = new PrintStream(outBytes);
StringBuffer content = new StringBuffer();
try{
BufferedReader applet = createReader(appletFile);
String line;
while ((line = applet.readLine()) != null) {
out.println(line);
content.append(line + "\n");
if (line.indexOf("public functions for processing.core") >= 0) {
break;
}
}
// read the rest of the file and append it to the
while ((line = applet.readLine()) != null) {
content.append(line + "\n");
}
applet.close();
process(out, graphicsFile);
process(out, imageFile);
out.println("}");
} catch (IOException e) {
e.printStackTrace();
} catch(Exception ex) {
ex.printStackTrace();
}
out.flush();
if (content.toString().equals(outBytes.toString())) {
System.out.println("No changes to PApplet API.");
} else {
System.out.println("Updating PApplet with API changes from PImage or PGraphics.");
try {
PrintStream temp = new PrintStream(appletFile);
temp.print(outBytes.toString());
temp.flush();
temp.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
private void process(PrintStream out, File input) throws IOException {
BufferedReader in = createReader(input);
int comments = 0;
String line = null;
while ((line = in.readLine()) != null) {
String decl = "";
// Keep track of comments
if (line.matches(Pattern.quote("/*"))) {
comments ++;
}
if (line.matches(Pattern.quote("*/"))) {
comments --;
}
// Ignore everything inside comments
if (comments > 0) {
continue;
}
boolean gotSomething = false;
boolean gotStatic = false;
Matcher result;
if ((result = Pattern.compile("^\\s*public ([\\w\\[\\]]+) [a-zA-z_]+\\(.*$").matcher(line)).matches()) {
gotSomething = true;
}
else if ((result = Pattern.compile("^\\s*abstract public ([\\w\\[\\]]+) [a-zA-z_]+\\(.*$").matcher(line)).matches()) {
gotSomething = true;
}
else if ((result = Pattern.compile("^\\s*public final ([\\w\\[\\]]+) [a-zA-z_]+\\(.*$").matcher(line)).matches()) {
gotSomething = true;
}
else if ((result = Pattern.compile("^\\s*static public ([\\w\\[\\]]+) [a-zA-z_]+\\(.*$").matcher(line)).matches()) {
gotSomething = true;
gotStatic = true;
}
// if function is marked "// ignore" then, uh, ignore it.
if (gotSomething && line.indexOf("// ignore") >= 0) {
gotSomething = false;
}
String returns = "";
if (gotSomething) {
if (result.group(1).equals("void")) {
returns = "";
} else {
returns = "return ";
}
// remove the abstract modifier
line = line.replaceFirst(Pattern.quote("abstract"), " ");
// replace semicolons with a start def
line = line.replaceAll(Pattern.quote(";"), " {\n");
out.println("\n\n" + line);
decl += line;
while(line.indexOf(')') == -1) {
line = in.readLine();
decl += line;
line = line.replaceAll("\\;\\s*$", " {\n");
out.println(line);
}
result = Pattern.compile(".*?\\s(\\S+)\\(.*?").matcher(decl);
result.matches(); // try to match. DON't remove this or things will stop working!
String declName = result.group(1);
String gline = "";
String rline = "";
if (gotStatic) {
gline = " " + returns + "PGraphics." + declName + "(";
} else {
rline = " if (recorder != null) recorder." + declName + "(";
gline = " " + returns + "g." + declName + "(";
}
decl = decl.replaceAll("\\s+", " "); // smush onto a single line
decl = decl.replaceFirst("^.*\\(", "");
decl = decl.replaceFirst("\\).*$", "");
int prev = 0;
String parts[] = decl.split("\\, ");
for (String part : parts) {
if (!part.trim().equals("")) {
String blargh[] = part.split(" ");
String theArg = blargh[1].replaceAll("[\\[\\]]", "");
if (prev != 0) {
gline += ", ";
rline += ", ";
}
gline += theArg;
rline += theArg;
prev = 1;
}
}
gline += ");";
rline += ");";
if (!gotStatic && returns.equals("")) {
out.println(rline);
}
out.println(gline);
out.println(" }");
}
}
in.close();
}
private static BufferedReader createReader(File f) throws FileNotFoundException {
return new BufferedReader(new InputStreamReader(new FileInputStream(f)));
}
}

View File

@ -2687,6 +2687,12 @@ public class PApplet extends Applet
return (a > b) ? a : b;
}
/*
static public final double max(double a, double b) {
return (a > b) ? a : b;
}
*/
static public final int max(int a, int b, int c) {
return (a > b) ? ((a > c) ? a : c) : ((b > c) ? b : c);
@ -2732,6 +2738,26 @@ public class PApplet extends Applet
}
/**
* Find the maximum value in an array.
* Throws an ArrayIndexOutOfBoundsException if the array is length 0.
* @param list the source array
* @return The maximum value
*/
/*
static public final double max(double[] list) {
if (list.length == 0) {
throw new ArrayIndexOutOfBoundsException(ERROR_MIN_MAX);
}
double max = list[0];
for (int i = 1; i < list.length; i++) {
if (list[i] > max) max = list[i];
}
return max;
}
*/
static public final int min(int a, int b) {
return (a < b) ? a : b;
}
@ -2740,6 +2766,12 @@ public class PApplet extends Applet
return (a < b) ? a : b;
}
/*
static public final double min(double a, double b) {
return (a < b) ? a : b;
}
*/
static public final int min(int a, int b, int c) {
return (a < b) ? ((a < c) ? a : c) : ((b < c) ? b : c);
@ -2749,6 +2781,12 @@ public class PApplet extends Applet
return (a < b) ? ((a < c) ? a : c) : ((b < c) ? b : c);
}
/*
static public final double min(double a, double b, double c) {
return (a < b) ? ((a < c) ? a : c) : ((b < c) ? b : c);
}
*/
/**
* Find the minimum value in an array.
@ -2766,6 +2804,8 @@ public class PApplet extends Applet
}
return min;
}
/**
* Find the minimum value in an array.
* Throws an ArrayIndexOutOfBoundsException if the array is length 0.
@ -2784,6 +2824,25 @@ public class PApplet extends Applet
}
/**
* Find the minimum value in an array.
* Throws an ArrayIndexOutOfBoundsException if the array is length 0.
* @param list the source array
* @return The minimum value
*/
/*
static public final double min(double[] list) {
if (list.length == 0) {
throw new ArrayIndexOutOfBoundsException(ERROR_MIN_MAX);
}
double min = list[0];
for (int i = 1; i < list.length; i++) {
if (list[i] < min) min = list[i];
}
return min;
}
*/
static public final int constrain(int amt, int low, int high) {
return (amt < low) ? low : ((amt > high) ? high : amt);
}
@ -2888,11 +2947,13 @@ public class PApplet extends Applet
}
/*
static public final double map(double value,
double istart, double istop,
double ostart, double ostop) {
return ostart + (ostop - ostart) * ((value - istart) / (istop - istart));
}
*/
@ -4355,18 +4416,34 @@ public class PApplet extends Applet
* Saves bytes to a specific File location specified by the user.
*/
static public void saveBytes(File file, byte buffer[]) {
File tempFile = null;
try {
File parentDir = file.getParentFile();
tempFile = File.createTempFile(file.getName(), null, parentDir);
/*
String filename = file.getAbsolutePath();
createPath(filename);
OutputStream output = new FileOutputStream(file);
if (file.getName().toLowerCase().endsWith(".gz")) {
output = new GZIPOutputStream(output);
}
*/
OutputStream output = createOutput(tempFile);
saveBytes(output, buffer);
output.close();
output = null;
if (!tempFile.renameTo(file)) {
System.err.println("Could not rename temporary file " +
tempFile.getAbsolutePath());
}
} catch (IOException e) {
System.err.println("error saving bytes to " + file);
if (tempFile != null) {
tempFile.delete();
}
e.printStackTrace();
}
}
@ -4393,6 +4470,8 @@ public class PApplet extends Applet
static public void saveStrings(File file, String strings[]) {
saveStrings(createOutput(file), strings);
/*
try {
String location = file.getAbsolutePath();
createPath(location);
@ -4406,18 +4485,17 @@ public class PApplet extends Applet
} catch (IOException e) {
e.printStackTrace();
}
*/
}
static public void saveStrings(OutputStream output, String strings[]) {
try {
OutputStreamWriter osw = new OutputStreamWriter(output, "UTF-8");
PrintWriter writer = new PrintWriter(osw);
PrintWriter writer = createWriter(output);
for (int i = 0; i < strings.length; i++) {
writer.println(strings[i]);
}
writer.flush();
} catch (UnsupportedEncodingException e) { } // will not happen
writer.close();
}

View File

@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2004-08 Ben Fry and Casey Reas
Copyright (c) 2004-09 Ben Fry and Casey Reas
Copyright (c) 2001-04 Massachusetts Institute of Technology
This library is free software; you can redistribute it and/or

View File

@ -358,12 +358,12 @@ public class PGraphics3D extends PGraphics {
cameraInv = new PMatrix3D();
// set up the default camera
camera();
// camera();
// defaults to perspective, if the user has setup up their
// own projection, they'll need to fix it after resize anyway.
// this helps the people who haven't set up their own projection.
perspective();
// perspective();
}
@ -478,6 +478,12 @@ public class PGraphics3D extends PGraphics {
forwardTransform = modelview;
reverseTransform = modelviewInv;
// set up the default camera
camera();
// defaults to perspective, if the user has setup up their
// own projection, they'll need to fix it after resize anyway.
// this helps the people who haven't set up their own projection.
perspective();
// easiest for beginners
@ -1344,7 +1350,7 @@ public class PGraphics3D extends PGraphics {
boolean bClipped = false;
int clippedCount = 0;
cameraNear = -8;
// cameraNear = -8;
if (vertices[a][VZ] > cameraNear) {
aClipped = true;
clippedCount++;
@ -1358,8 +1364,15 @@ public class PGraphics3D extends PGraphics {
clippedCount++;
}
if (clippedCount == 0) {
// if (vertices[a][VZ] < cameraFar &&
// vertices[b][VZ] < cameraFar &&
// vertices[c][VZ] < cameraFar) {
addTriangleWithoutClip(a, b, c);
// }
// } else if (true) {
// return;
} else if (clippedCount == 3) {
// In this case there is only one visible point. |/|
// So we'll have to make two new points on the clip line <| |
@ -3502,6 +3515,7 @@ public class PGraphics3D extends PGraphics {
0, y, 0, ty,
0, 0, z, tz,
0, 0, 0, 1);
updateProjection();
frustumMode = false;
}
@ -3569,6 +3583,12 @@ public class PGraphics3D extends PGraphics {
0, (2*znear)/(top-bottom), (top+bottom)/(top-bottom), 0,
0, 0, -(zfar+znear)/(zfar-znear),-(2*zfar*znear)/(zfar-znear),
0, 0, -1, 0);
updateProjection();
}
/** Called after the 'projection' PMatrix3D has changed. */
protected void updateProjection() {
}

View File

@ -182,6 +182,7 @@ public class PImage implements PConstants, Cloneable {
raster.getDataElements(0, 0, width, height, pixels);
} else { // go the old school java 1.0 route
// System.out.println(img.getClass().getName());
width = img.getWidth(null);
height = img.getHeight(null);
pixels = new int[width * height];
@ -690,7 +691,7 @@ public class PImage implements PConstants, Cloneable {
throw new RuntimeException("Use filter(POSTERIZE, int levels) " +
"instead of filter(POSTERIZE)");
case RGB:
case OPAQUE:
for (int i = 0; i < pixels.length; i++) {
pixels[i] |= 0xff000000;
}

View File

@ -430,6 +430,11 @@ public class PVector {
}
static public float dot(PVector v1, PVector v2) {
return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
}
/**
* Return a vector composed of the cross product between this and another.
*/

View File

@ -1,8 +1,30 @@
0169 core
X remove major try/catch block from PApplet.main()
X hopefully will allow some exception stuff to come through properly
X PVector.angleDistance() returns NaN
X http://dev.processing.org/bugs/show_bug.cgi?id=1316
0171 core
X Blurred PImages in OPENGL sketches
X removed NPOT texture support (for further testing)
X http://dev.processing.org/bugs/show_bug.cgi?id=1352
_ open up the pdf library more (philho)
_ http://dev.processing.org/bugs/show_bug.cgi?id=1343
_ changing vertex alpha in P3D in a QUAD_STRIP is ignored
_ with smoothing, it works fine, but with PTriangle, it's not
_ smooth() not working with applets an createGraphics(JAVA2D)
_ but works fine with applications
_ get() with OPENGL is grabbing the wrong coords
_ http://dev.processing.org/bugs/show_bug.cgi?id=1349
_ No textures render with hint(ENABLE_ACCURATE_TEXTURES)
_ http://dev.processing.org/bugs/show_bug.cgi?id=985
_ need to remove the hint from the reference
_ need to throw an error when it's used
_ deal with issue of single pixel seam at the edge of textures
_ http://dev.processing.org/bugs/show_bug.cgi?id=602
_ should vertexTexture() divide by width/height or width-1/height-1?
_ key and mouse events delivered out of order
_ http://dev.processing.org/bugs/show_bug.cgi?id=638
_ key/mouse events have concurrency problems with noLoop()
_ http://dev.processing.org/bugs/show_bug.cgi?id=1323
_ need to say "no drawing inside mouse/key events w/ noLoop"
_ make the index lookup use numbers up to 256?
@ -170,12 +192,6 @@ _ smooth in P3D has zbuffer glitches
_ http://dev.processing.org/bugs/show_bug.cgi?id=1000
_ smoothing is slow
_ http://dev.processing.org/bugs/show_bug.cgi?id=1001
_ No textures render with hint(ENABLE_ACCURATE_TEXTURES)
_ http://dev.processing.org/bugs/show_bug.cgi?id=985
_ need to remove the hint from the reference
_ need to throw an error when it's used
_ deal with issue of single pixel seam at the edge of textures
_ ??? what is the bug # for this one?
_ textured sphere example needs to set normals
_ also needs fix for last edge and the seam
@ -235,8 +251,6 @@ _ PApplet.main(new String[] { "classname" }) won't pass in args
_ this means that no args are after passed to the class
_ the fix would be to use the following as the call to main()
_ PApplet.main(append(new String[] { "classname }, args));
_ key and mouse events delivered out of order
_ http://dev.processing.org/bugs/show_bug.cgi?id=638
_ figure out why 1024x768 image takes 3.5 seconds to load
_ would using a BufferedImage work better?
_ is the image actually a BufferedImage so PixelGrabber is a waste?