/** * Specify all the Javascript methods that can be called from this sketch. */ interface JavaScript { } // interface JavaScript /** * This method is called from Javascript and gives * the link to the middle and right sketches. */ void setLinkSketch(Object[] pjs, JavaScript js) { pjsMiddle = pjs[1]; pjsRight = pjs[2]; } // setLinkSketch Object pjsMiddle, pjsRight; int xLine, yLine, xSquare, ySquare, xCircle, yCircle; /** * Initialize the sketch */ void setup() { size(250,300); background(0); smooth(); noLoop(); xLine = 500; // Initially draw items off screen yLine = 500; // to hide them. xSquare = 500; ySquare = 500; xCircle = 500; yCircle = 500; } // setup /** * Draw the sketch */ void draw() { fill(0,0,0,20); rect(-1,-1,width+2,height+2); // draw lines stroke(#FFFF00); line(xLine,-1,xLine,height+2); line(-1,yLine,width+2,yLine); // draw square fill(#00FF00); rect(xSquare-10, ySquare-10, 20, 20); // draw circle stroke(#FF00FF); fill(#FF00FF); ellipse(xCircle, yCircle, 20, 20); } // draw /** * Respond to mouse movement by updating the lines location and asking other * sketches to draw those line. */ void mouseMoved() { xLine = mouseX; yLine = mouseY; if (pjsMiddle != null) { pjsMiddle.drawLines(xLine, yLine);// } if (pjsRight != null) { pjsRight.drawLines(xLine, yLine); } redraw(); } // mouseMoved /** * Get coordinates of Square */ void drawSquare(int xCoor, int yCoor) { xSquare = xCoor; ySquare = yCoor; redraw(); } // drawSquare /** * Get cooredinates of circle */ void drawCircle(int xCoor, int yCoor) { xCircle = xCoor; yCircle = yCoor; redraw(); } // drawCircle