How can I use the input value as a variable with two arguments?

Hi kfrajer,

I used the console.log() as you suggested in the other forum. It shows the correct value, and the button also works fine.

My code is the following:

let lim = 2.5;

let button;

let inpRe;
let inpIm;

function setup() {
    createCanvas(400, 400);
    colorMode(HSB, 360, 100, 100);
    noLoop();
    
    inpRe = createInput('x');
    inpIm = createInput('y');
    
    inpRe.position(60, 420);
    inpIm.position(60, 445);
    
    button = createButton('Submit');
    button.position(inpIm.x + inpIm.width+10, inpIm.y);
    button.mousePressed(redraw);
    
    realImput = createElement('h2', 'Re:');
    realImput.position(20, 395);
    
    imaginaryImput = createElement('h2', 'Im:');
    imaginaryImput.position(20, 420);
}

function Re(x, y){
    return inpRe.value(); // Here I had: x*x-y*y;
}

function Im(x, y){
    return inpIm.value(); // Here I had: x*y;
}

function draw() {

    loadPixels();
    
    for (let xp = 0; xp < width; xp++) {
        for (let yp = 0; yp < height; yp++) {
            let x, y;
            
            x = map(xp, 0, width, -lim, lim);
            y = map(yp, height, 0, -lim, lim);
            
            let z = new p5.Vector(0,0);
            
            let nextz = new p5.Vector();
            nextz.x = Re(,x, y); 
            nextz.y = Im(x, y); 
            
            z = new p5.Vector(z.x + nextz.x, z.y + nextz.y);
            
            let h = map(atan2(-z.y, -z.x), -PI, PI, 0, 360);
            let s = sqrt(abs( 3*sin( 2* PI * (log(sqrt( z.x*z.x + z.y*z.y ))/log(2) - floor( log(sqrt( z.x*z.x + z.y*z.y ))/log(2) )) )));
            let s2 = map(s, 0, 1, 0, 100);
            let b = sqrt(sqrt(abs( sin(2 * PI * z.y) * sin(2 * PI * z.x) )));
            let b2 = 0.5 * ((1 - s) + b + sqrt((1 - s - b) * (1 - s - b) + 0.01));
            let b3 = map(b2, 0, 1, 0, 100);
            
            set(xp, yp, color(h, s2, b3));
        }
    }
    updatePixels();
    
    console.log(inpRe.value());
}

Regards