Skip to content

Commit

Permalink
Update to latest 2.0 beta. 50% of tests pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Feinberg committed Oct 22, 2012
1 parent a938b66 commit 7d1ce74
Show file tree
Hide file tree
Showing 873 changed files with 4,253 additions and 32 deletions.
2 changes: 1 addition & 1 deletion build.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@


<target name="generate-driver" <target name="generate-driver"
description="Generate DriverImpl class"> description="Generate DriverImpl class">
<java classpath="buildtime/lib/jython/jython.jar:buildtime/lib/processing/core.jar" <java classpath="buildtime/lib/jython/jython.jar:buildtime/lib/processing/core.jar:libraries/processing/opengl/jogl-all.jar:libraries/processing/opengl/gluegen-rt.jar"
classname="org.python.util.jython" classname="org.python.util.jython"
fork="true"> fork="true">
<arg value="buildtime/py/cog.py"/> <arg value="buildtime/py/cog.py"/>
Expand Down
Binary file modified buildtime/lib/processing/core.jar
Binary file not shown.
14 changes: 10 additions & 4 deletions buildtime/py/processing_parser.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
^( ^(
screen|args|recorder|frame|g|selectedFile|keyEvent|mouseEvent screen|args|recorder|frame|g|selectedFile|keyEvent|mouseEvent
|sketchPath|screen(Width|Height)|defaultSize|firstMouse|finished |sketchPath|screen(Width|Height)|defaultSize|firstMouse|finished
|requestImageMax |requestImageMax|online
)$ )$
''', re.X) ''', re.X)


Expand All @@ -31,7 +31,8 @@
|(get|set|remove)Cache|update|destroy|main|flush|addListeners|dataFile |(get|set|remove)Cache|update|destroy|main|flush|addListeners|dataFile
|die|setup|mouseE(ntered|xited)|paint|sketch[A-Z].*|stop|save(File|Path) |die|setup|mouseE(ntered|xited)|paint|sketch[A-Z].*|stop|save(File|Path)
|displayable|method|runSketch|start|focus(Lost|Gained)|(data|create)Path |displayable|method|runSketch|start|focus(Lost|Gained)|(data|create)Path
|round|abs|max|min|open|append|splice|expand|contract|set|exit |round|abs|max|min|open|append|splice|expand|contract|set|exit|link|param
|status
)$ )$
''', re.X) ''', re.X)


Expand All @@ -58,10 +59,11 @@ def prim(type_name):
We want to create Jython wrappers for all public methods of PApplet except We want to create Jython wrappers for all public methods of PApplet except
those in "BAD_METHOD". Also, if we have both foo(int) and foo(char), we throw those in "BAD_METHOD". Also, if we have both foo(int) and foo(char), we throw
away the char variant, and always call the int variant. Same with foo(byte). away the char variant, and always call the int variant. Same with foo(byte).
Sadly, Java has no unisgned types, so the distinction is weird. Sadly, Java has no unsigned types, so the distinction is weird.
""" """
WANTED_METHODS = [m for m in Class.getDeclaredMethods(PApplet) WANTED_METHODS = [m for m in Class.getDeclaredMethods(PApplet)
if Modifier.isPublic(m.getModifiers()) if Modifier.isPublic(m.getModifiers())
and not m.getExceptionTypes()
and not BAD_METHOD.match(m.getName()) and not BAD_METHOD.match(m.getName())
and not any(k in USELESS_TYPES for k in m.getParameterTypes())] and not any(k in USELESS_TYPES for k in m.getParameterTypes())]


Expand Down Expand Up @@ -104,10 +106,14 @@ def __init__(self, to_python_prefix, to_java_format, typecheck_format):
'(%(name)s == PyFloat.TYPE ' '(%(name)s == PyFloat.TYPE '
'|| %(name)s == PyInteger.TYPE ' '|| %(name)s == PyInteger.TYPE '
'|| %(name)s == PyLong.TYPE)'), '|| %(name)s == PyLong.TYPE)'),
PRIMITIVES['double']:
ClassConversionInfo('new PyFloat',
'%s.asDouble()',
'%(name)s == PyFloat.TYPE'),
PRIMITIVES['long']: PRIMITIVES['long']:
ClassConversionInfo('new PyLong', ClassConversionInfo('new PyLong',
'%s.asLong()', '%s.asLong()',
None), '%(name)s == PyLong.TYPE'),
Class.forName("java.lang.String"): Class.forName("java.lang.String"):
ClassConversionInfo('new PyUnicode', ClassConversionInfo('new PyUnicode',
'%s.asString()', '%s.asString()',
Expand Down
1 change: 1 addition & 0 deletions buildtime/template/DriverImpl.java.cog
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package jycessing;
import org.python.util.InteractiveConsole; import org.python.util.InteractiveConsole;
import org.python.core.*; import org.python.core.*;
import processing.core.*; import processing.core.*;
import processing.opengl.*;
import java.io.*; import java.io.*;


@SuppressWarnings("serial") @SuppressWarnings("serial")
Expand Down
Binary file modified libraries/processing/dxf.jar
Binary file not shown.
Binary file modified libraries/processing/minim/jsminim.jar
Binary file not shown.
Binary file removed libraries/processing/minim/minim-spi.jar
Binary file not shown.
Binary file modified libraries/processing/minim/minim.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion libraries/processing/minim/version.txt
Original file line number Original file line Diff line number Diff line change
@@ -1 +1 @@
2.0.2 3.0 BETA
Binary file modified libraries/processing/net.jar
Binary file not shown.
19 changes: 0 additions & 19 deletions libraries/processing/opengl/export.txt

This file was deleted.

Binary file not shown.
Binary file modified libraries/processing/opengl/gluegen-rt-natives-linux-i586.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified libraries/processing/opengl/gluegen-rt-natives-windows-amd64.jar
Binary file not shown.
Binary file modified libraries/processing/opengl/gluegen-rt-natives-windows-i586.jar
Binary file not shown.
Binary file modified libraries/processing/opengl/gluegen-rt.jar
Binary file not shown.
Binary file removed libraries/processing/opengl/gluegen-rt.jar.pack.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added libraries/processing/opengl/jogl-all.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed libraries/processing/opengl/jogl.dll
Binary file not shown.
Binary file removed libraries/processing/opengl/jogl.jar
Binary file not shown.
Binary file removed libraries/processing/opengl/jogl.jar.pack.gz
Binary file not shown.
Binary file removed libraries/processing/opengl/jogl_cg.dll
Binary file not shown.
Binary file removed libraries/processing/opengl/libgluegen-rt.so
Binary file not shown.
Binary file removed libraries/processing/opengl/libjogl.jnilib
Binary file not shown.
Binary file removed libraries/processing/opengl/libjogl.so
Binary file not shown.
Binary file removed libraries/processing/opengl/libjogl_awt.so
Binary file not shown.
Binary file removed libraries/processing/opengl/libjogl_cg.jnilib
Binary file not shown.
Binary file removed libraries/processing/opengl/libjogl_cg.so
Binary file not shown.
Binary file removed libraries/processing/opengl/opengl.jar
Binary file not shown.
Binary file modified libraries/processing/pdf/pdf.jar
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions libraries/processing/serial/library/export.txt
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1 @@
name = Serial I/O
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added libraries/processing/serial/library/serial.jar
Binary file not shown.
File renamed without changes.
Binary file removed libraries/processing/serial/librxtxSerial.jnilib
Binary file not shown.
Binary file removed libraries/processing/serial/librxtxSerial.so
Binary file not shown.
Binary file removed libraries/processing/serial/serial.jar
Binary file not shown.
Binary file removed libraries/processing/video.jar
Binary file not shown.
27 changes: 27 additions & 0 deletions libraries/processing/video/build.xml
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<project name="Processing Video Library" default="build">

<target name="clean" description="Clean the build directories">
<delete dir="bin" />
<delete file="library/video.jar" />
</target>

<target name="compile" description="Compile sources">
<condition property="core-built">
<available file="../../../core/library/core.jar" />
</condition>
<fail unless="core-built" message="Please build the core library first and make sure it sits in ../../../core/library/core.jar" />

<mkdir dir="bin" />
<javac source="1.6"
target="1.6"
srcdir="src" destdir="bin"
encoding="UTF-8"
includeAntRuntime="false"
classpath="../../../core/library/core.jar; library/gstreamer-java.jar; library/jna.jar" />
</target>

<target name="build" depends="compile" description="Build video library">
<jar basedir="bin" destfile="library/video.jar" />
</target>
</project>
136 changes: 136 additions & 0 deletions libraries/processing/video/examples/Capture/AsciiVideo/AsciiVideo.pde
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,136 @@
/**
* ASCII Video
* by Ben Fry.
*
*
* Text characters have been used to represent images since the earliest computers.
* This sketch is a simple homage that re-interprets live video as ASCII text.
* See the keyPressed function for more options, like changing the font size.
*/

import processing.video.*;

Capture video;
boolean cheatScreen;

// All ASCII characters, sorted according to their visual density
String letterOrder =
" .`-_':,;^=+/\"|)\\<>)iv%xclrs{*}I?!][1taeo7zjLu" +
"nT#JCwfy325Fp6mqSghVd4EgXPGZbYkOA&8U$@KHDBWNMR0Q";
char[] letters;

float[] bright;
char[] chars;

PFont font;
float fontSize = 1.5;


void setup() {
size(640, 480, P2D);

// Uses the default video input, see the reference if this causes an error
video = new Capture(this, 160, 120);
video.start();
int count = video.width * video.height;
println(count);

font = loadFont("UniversLTStd-Light-48.vlw");

// for the 256 levels of brightness, distribute the letters across
// the an array of 256 elements to use for the lookup
letters = new char[256];
for (int i = 0; i < 256; i++) {
int index = int(map(i, 0, 256, 0, letterOrder.length()));
letters[i] = letterOrder.charAt(index);
}

// current characters for each position in the video
chars = new char[count];

// current brightness for each point
bright = new float[count];
for (int i = 0; i < count; i++) {
// set each brightness at the midpoint to start
bright[i] = 128;
}
}


void captureEvent(Capture c) {
c.read();
}


void draw() {
background(0);

pushMatrix();

float hgap = width / float(video.width);
float vgap = height / float(video.height);

scale(max(hgap, vgap) * fontSize);
textFont(font, fontSize);

int index = 0;
video.loadPixels();
for (int y = 1; y < video.height; y++) {

// Move down for next line
translate(0, 1.0 / fontSize);

pushMatrix();
for (int x = 0; x < video.width; x++) {
int pixelColor = video.pixels[index];
// Faster method of calculating r, g, b than red(), green(), blue()
int r = (pixelColor >> 16) & 0xff;
int g = (pixelColor >> 8) & 0xff;
int b = pixelColor & 0xff;

// Another option would be to properly calculate brightness as luminance:
// luminance = 0.3*red + 0.59*green + 0.11*blue
// Or you could instead red + green + blue, and make the the values[] array
// 256*3 elements long instead of just 256.
int pixelBright = max(r, g, b);

// The 0.1 value is used to damp the changes so that letters flicker less
float diff = pixelBright - bright[index];
bright[index] += diff * 0.1;

fill(pixelColor);
int num = int(bright[index]);
text(letters[num], 0, 0);

// Move to the next pixel
index++;

// Move over for next character
translate(1.0 / fontSize, 0);
}
popMatrix();
}
popMatrix();

if (cheatScreen) {
//image(video, 0, height - video.height);
// set() is faster than image() when drawing untransformed images
set(0, height - video.height, video);
}
}


/**
* Handle key presses:
* 'c' toggles the cheat screen that shows the original image in the corner
* 'g' grabs an image and saves the frame to a tiff image
* 'f' and 'F' increase and decrease the font size
*/
void keyPressed() {
switch (key) {
case 'g': saveFrame(); break;
case 'c': cheatScreen = !cheatScreen; break;
case 'f': fontSize *= 1.1; break;
case 'F': fontSize *= 0.9; break;
}
}
Binary file not shown.
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* Background Subtraction
* by Golan Levin.
*
* Detect the presence of people and objects in the frame using a simple
* background-subtraction technique. To initialize the background, press a key.
*/


import processing.video.*;

int numPixels;
int[] backgroundPixels;
Capture video;

void setup() {
// Change size to 320 x 240 if too slow at 640 x 480
size(640, 480, P2D);

video = new Capture(this, width, height);
video.start();
numPixels = video.width * video.height;
// Create array to store the background image
backgroundPixels = new int[numPixels];
// Make the pixels[] array available for direct manipulation
loadPixels();
}

void draw() {
if (video.available()) {
video.read(); // Read a new video frame
video.loadPixels(); // Make the pixels of video available
// Difference between the current frame and the stored background
int presenceSum = 0;
for (int i = 0; i < numPixels; i++) { // For each pixel in the video frame...
// Fetch the current color in that location, and also the color
// of the background in that spot
color currColor = video.pixels[i];
color bkgdColor = backgroundPixels[i];
// Extract the red, green, and blue components of the current pixel�s color
int currR = (currColor >> 16) & 0xFF;
int currG = (currColor >> 8) & 0xFF;
int currB = currColor & 0xFF;
// Extract the red, green, and blue components of the background pixel�s color
int bkgdR = (bkgdColor >> 16) & 0xFF;
int bkgdG = (bkgdColor >> 8) & 0xFF;
int bkgdB = bkgdColor & 0xFF;
// Compute the difference of the red, green, and blue values
int diffR = abs(currR - bkgdR);
int diffG = abs(currG - bkgdG);
int diffB = abs(currB - bkgdB);
// Add these differences to the running tally
presenceSum += diffR + diffG + diffB;
// Render the difference image to the screen
pixels[i] = color(diffR, diffG, diffB);
// The following line does the same thing much faster, but is more technical
//pixels[i] = 0xFF000000 | (diffR << 16) | (diffG << 8) | diffB;
}
updatePixels(); // Notify that the pixels[] array has changed
println(presenceSum); // Print out the total amount of movement
}
}

// When a key is pressed, capture the background image into the backgroundPixels
// buffer, by copying each of the current frame�s pixels into it.
void keyPressed() {
video.loadPixels();
arraycopy(video.pixels, backgroundPixels);
}
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Brightness Thresholding
* by Golan Levin.
*
* Determines whether a test location (such as the cursor) is contained within
* the silhouette of a dark object.
*/


import processing.video.*;

color black = color(0);
color white = color(255);
int numPixels;
Capture video;

void setup() {
size(640, 480, P2D); // Change size to 320 x 240 if too slow at 640 x 480
strokeWeight(5);
// Uses the default video input, see the reference if this causes an error
video = new Capture(this, width, height);
video.start();
numPixels = video.width * video.height;
noCursor();
smooth();
}

void draw() {
if (video.available()) {
video.read();
video.loadPixels();
int threshold = 127; // Set the threshold value
float pixelBrightness; // Declare variable to store a pixel's color
// Turn each pixel in the video frame black or white depending on its brightness
loadPixels();
for (int i = 0; i < numPixels; i++) {
pixelBrightness = brightness(video.pixels[i]);
if (pixelBrightness > threshold) { // If the pixel is brighter than the
pixels[i] = white; // threshold value, make it white
}
else { // Otherwise,
pixels[i] = black; // make it black
}
}
updatePixels();
// Test a location to see where it is contained. Fetch the pixel at the test
// location (the cursor), and compute its brightness
int testValue = get(mouseX, mouseY);
float testBrightness = brightness(testValue);
if (testBrightness > threshold) { // If the test location is brighter than
fill(black); // the threshold set the fill to black
}
else { // Otherwise,
fill(white); // set the fill to white
}
ellipse(mouseX, mouseY, 20, 20);
}
}
Loading

0 comments on commit 7d1ce74

Please sign in to comment.