Calling Processing code

Can you do it from within Arduino. I mean if I have a section of code to blink a light if I mouseOver a processing drawn square, can I just leave the processing code section inside the arduino environment, executing a function, calling it from there.

or is it always necessary to write it seperately into processing?

Do you have a mouse attached to the Arduino? If not, how are you going to detect that the mouse is over a square? Where are you drawing the square? With what?

Can you do it from within Arduino.

No, while the language looks superficially the same they are different and run in different environments.

As pointed out Processing has access to all your computer peripherals where as the arduino only has access to what is connected to it.

I have yet to see that done, but it can certainly work the other way around: Arduino-like code inside Processing. Use the Firmata library (in Processing) for this.