< BACK

TUTORIAL: Using a Wacom Board with Processing

This is based on Amit Pitaru's tutorial and source files.

For starting a new project, simply create a folder called 'code' within the sketchfolder (the empty sketch you have just created) and copy the .DLL and .JAR file Amit provides in there.

- - - -

This program draws draws a simple line trailing the mouse-cursor, using your Wacom-board you can control the thikness of the line with the pressure sensitivity of the board. A link to a zip-file containing the entire sketch-folder (including Amit's .DLL and .JAR files) can be found at the bottom of this page.

- - - -

// mikkel crone koser
// www.beyondthree.com
// october 29th 2003
// PROCE55ING rev. 0067
//
// implementing JwinTab_v2 by amit pitaru,
// more info: http://www.pitaru.com/jwintab_v2/
//
// ***** WORKS ONLY ON PC ******
//


BTablet t = new BTablet();

float tp; // preassure
float ang; // angle
int rx, ry, lx, ly; // right XY & left XY
int prx, pry, plx, ply; // previous --- " ----

void setup(){
size(500, 350);
background(0);
t.startTablet();
noStroke();
}

void loop(){
fill(0, 2);
rect(0, 0, width, height);

updateTablet();

fill(255, 200, 0, 55);
if(dist(mouseX, mouseY, pmouseX, pmouseY) >= 1){
beginShape(QUADS);
vertex(lx, ly);
vertex(plx, ply);
vertex(prx, pry);
vertex(rx, ry);
endShape();
}
}

void updateTablet(){
t.readTablet();

if(dist(prx, pry, rx, ry) >= 1){
prx = rx;
pry = ry;
}
if(dist(plx, ply, lx, ly) >= 1){
plx = lx;
ply = ly;
}

tp = t.pressure/25f;

ang = calcAngle(mouseX, mouseY, pmouseX, pmouseY);

rx = (int)(tp * cos(ang+90)) + mouseX;
ry = (int)(tp * sin(ang+90)) + mouseY;
lx = (int)(tp * cos(ang-90)) + mouseX;
ly = (int)(tp * sin(ang-90)) + mouseY;
}

float calcAngle(int ax, int ay, int bx, int by){
float a = atan2(ay-by, ax-bx);
return a;
}

 

download zipped Sketch-folder [29.10.2003]
Built with Processing by Mikkel Crone Koser of BEYONDTHREE