code works in Java mode but not JS mode, cant figure out why
in
Processing with Other Languages
•
1 year ago
Hi,
Im using Processing 2.0b2 so that I can use Javascript mode to run the below code. The code works fine in Java mode but not JS mode. I cant figure out why, can anyone help?
The sketch is based on a post over at
openprocessing which also does not work in JS mode.
Thanks for any help in advance. The folder can be
downloaded here.
- /* @pjs preload="baseimg.png,colormap.png,0.png,1.png"; */
- PImage prospMap; //map image
- PImage colorMap; //colormap of the buttons (hidden)
- PImage[] png; //array of images to correspond to colormap
- color[] regionColor= {
- 0xFFC4C4C4, 0xFF595959
- };
- color testcolor=0xFFFFFFFF;
- void setup ()
- {
- size(600, 300);
- smooth();
- prospMap=loadImage("baseimg.png");
- colorMap=loadImage("colormap.png");
- png = new PImage[2];
- for (int i = 0; i< png.length; i++) {
- png[i] = loadImage(i + ".png");
- }
- }
- void draw(){
- background(prospMap);
- fill(0);
- mouseOver();
- }
- void mouseOver() {
- testcolor = colorMap.get(mouseX, mouseY); //get the color in the colormap
- println("0x"+hex(testcolor));
- for (int i=0; i<png.length; i++) { //if the color has a match in the color array,
- //show the corresponding png and data
- if (testcolor==regionColor[i]) {
- image(png[i], 0, 0);
- }
- }
- }
1