Assign a variable from draw function to setup function


I just wanted to assign mouseX value to one of my parameters value in setup function. how should I assign something that needs to run continuously in setup function?

    for (let a = startA; a < 360; a += spacing) {
      if (a % 30 == 0) {
        radius = map(mouseX, 0, width, 89, 110);
      } else {
        radius = 100;
function setup() {
  morph = new Morph();


the setup can not read the mouse
and if you would have something running forever in setup, the draw would never start.

when the setup is finished the draw starts to run ( 60 times per second default )
and can read between its runs mouse and keyboard.


can you not just put your code in one of the many mouse functions already included in processing or simply create a function, which is called in draw?

Otherwise I would assume you can simply assign your variable globally outside of setup and call it within setup after. ie

float x = mouseX;

function setup(){
var a = x + somecode…;