Digital art, visualizations & interactive web animations
...without plugins!
A JavaScript port of the Processing Visualization Language.
vs.
D3.js - CanvasJS HTML5 Charts - JavaScript InfoViz Toolkit - Kinetic.JS - Raphael - SWFObject - Three.JS - Two.JS - FrameEngine - PhiloGB - ChartJS - iio engine
<canvas data-processing-sources="hello.pde"></canvas>
Let's try!
float radius = 50.0;
int X, Y, nX, nY;
int delay = 16;
void setup() {
size ( 200, 200 );
strokeWeight( 10 );
frameRate( 15 );
X = width / 2;
Y = height / 2;
nX = X;
nY = Y;
}
void draw() {
radius = radius + sin( frameCount / 4 );
X += (nX-X)/delay;
Y += (nY-Y)/delay;
background( 100 );
fill( 0, 121, 184 );
stroke(255);
ellipse( X, Y, radius, radius );
}
void mouseMoved() {
nX = mouseX;
nY = mouseY;
}
videos.pde
void addVideo(String hostname, int length) {
// Do something very clever in Processing!
}
index.html
function addVideo(name, length) {
// Get Processing
var pjs = Processing.getInstanceById('mysketch');
// Call a method
pjs.addVideo(name, length);
};
node.js express.js socket.io processing.js
// modules
var io = require('socket.io').listen(app),
var spawn = require('child_process').spawn,
// tail logs
var tailer = spawn('./loggrep2.sh');
// handle socket connection
io.sockets.on('connection', function(socket) {
tailer.stdout.on('data', function (data){
console.log(data.toString('utf8'));
socket.emit('log', "["+data.toString('utf8')+"]");
});
});
<canvas id="mysketch" data-processing-sources="videos.pde">
</canvas>
// Listen to the server.
var socket = io.connect("http://localhost:3003");
// Do something when we get data.
socket.on('log', function (data) {
var req = JSON.parse(data);
var tld = req['URL'];
var len = req['Content-length'];
addVideo(tld, len);
});
// Pass data to Processing.
function addVideo(name, length) {
var pjs = Processing.getInstanceById('mysketch');
pjs.addVideo(name, length);
};
// Draw some circles.
class Bubble {
int x, y;
// ...
void draw() {
ellipse(x, y, height, width);
}
}
// Draw the rest of the $#%^ing owl.
void addVideo(String hostname, int length) {
tld = (TLD) websites.get(hostname.toString());
tld.points.add(
new Bubble((20 + 20*tld.size()), tld.height)
);
}