I have a .pde file will detect user mouse click, and there are few object in it, if the user click on the first one, I will get '1' as output and so on. And I will use this value to decided a <div> content in the html file("targetDiv" in the demo code below), so I need to pass the value to javascript, and let javascript control the next step. The problem is I don't know how to pass the value("outcome" in the demo code below) to javascript(or jquery is also ok).
Below is demo code, cannot run because it is simplify code.
Please help me!!It is an important part has to be come across in my work!!!Thank you very much!
<!doctype html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="processing-1.3.6.js"></script>
<body>
<div id="targetDiv"></div>
<canvas data-processing-sources="testing.pde"></canvas>
<script type="text/javascript">
//below is something I want to do, but still don't know the details
//if (outcome == 1){
//load 1.txt in the targetDiv
//}else if(outcome == 2){
//load 2.txt in the targetDiv
//}and so on.....
</body>
</html>
and in the testing pde. ::
int outcome;
void setup() {
//sth happend
}
void draw() {
//draw some object
}
void mousePressed() {
//when user click on some obj
//output the number of the object
for (int i = 0; i < num; i++) {
//isOver is a processing function to check the mouse click on the object or not
if (isOver(mouseX, mouseY, i)==true) {
outcome = i;
}
}
}
I am very new in processing js, the following question is stupid but I don't know why when it happend...
It is a simplify code to show my problem, the translate function are not working when I run this code as html file using processing js. (Start from the comment line //****). I have tested it in processing and it is works fine, those rectangles should go to next row if they are out of the screen. But I just see the first row of rects when I running as html file.
Can anyone tell me what's wrong? Thank you very much!!!!!!
<script src="processing-1.3.6.min.js"></script>
<script type="text/processing" data-processing-target="mycanvas">
</script>
<canvas id="mycanvas"></canvas>