Hello.
I am trying to display one of my processing sketches in the browser with processing.js and it works fine both from processing “Run” and the browser when I am using size(1900,1200), but when I add P3D to size(), then the program works from processing with run, but not in the browser giving me this error:
Uncaught TypeError: drawing.$ensureContext(…).getImageData is not a function processing.js:19173
I tried digging into the processing.js code, but quickly got lost and I don’t know what to do now. It seems that P3D render mode does not support getImageData.
Code:
/* @pjs preload="Logo.jpg"; */
ArrayList<PVector> points = new ArrayList<PVector>();
float o;
void setup() {
size(1088,156,P3D);
points = JpgToPVec(0,0);
}
ArrayList<PVector> JpgToPVec(float extraX, float extraY) {
PVector location;
ArrayList<PVector> pointsTemp= new ArrayList<PVector>();
PImage img = loadImage("Logo.jpg");
loadPixels();
for(float x = 0; x < width; x++){
for(float y = 0; y < height; y++) {
location = new PVector(x,y,0);
int loc = (int)x+(int)y*width;
float r = red(img.pixels[loc]);
float g = green(img.pixels[loc]);
float b = blue(img.pixels[loc]);
if(r >= 250 && g >= 250 && b >= 250) {
x+=extraX;
y+=extraY;
pointsTemp.add(location);
}
}
}
return pointsTemp;
}
void draw() {
background(0);
points = JpgToPVec(random(0.05,0.3),random(0.2,3.9));
for(o = 0; o < points.size(); o++) {
float x = points.get((int)o).x;
float y = points.get((int)o).y;
stroke(255,200,60);
ellipse(x,y,1,1);
}
}