the pixels of PImage can not be modified in browsers
in
Processing with Other Languages
•
1 year ago
My codes can be running as expected in processing app. However it does not work in browsers (e.g firefox, IE, google chrome etc.) if I use them as JS in HTML.
<p><canvas id="canvas1" width="200" height="200"></canvas></p>
<script type="application/processing" data-processing-target="canvas1">
/* @pjs preload="../images/im.jpg"; */
PImage img = loadImage("../images/im.jpg");
int dimension = (img.width*img.height);
img.loadPixels();
for (int i=0; i < dimension; i+=2) {
img.pixels[i] = color(80, 80, 80);
}
img.updatePixels();
image(img, 0, 0);
/*color pink = color(255, 102, 204);
loadPixels();
for (int i = 0; i < (width*height/2)-width/2; i++) {
//println(pixels[i]);
pixels[i] = pink;
}
updatePixels();*/ // this parts of code can be worked in browsers
</script>
1