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

Hi everyone,

I was able to plot complex functions using the method of domain coloring

https://openprocessing.org/sketch/569018

and now I have been trying to add two inputs for changing the real and imaginary components of the function after clicking a button, but it seems I am doing something wrong

https://openprocessing.org/sketch/569019

How can I use those inputs to update two variables each one with two arguments? Do I need to parse the text somehow?

Any help or advice would be appreciated. Thanks in advanced.

Answers

  • Answer ✓

    There is a new forum, maybe ask there

  • thanks for that, I did not know there is a new forum

  • Nice avatar image by the way. Looks like a recursive function, like a menger sponge

  • Unfortunately I cannot run your code atm. How do you use your inputs to modify the main function?

    Just double checking: did you include the p5js.dom js library in your html? If you check this lib documentation, you will find functions to retrieve the values of your text boxes' content. Something along the lines of mytextbox.innerHTML.

    Check if your click event associated to your submit button is working. For this, use console.log().

    Don't forget to include an empty draw(). I think you needed if you want to have a responsive interface.

    See you in the new forum.

    Kf

  • @kfrajer

    Thanks for the advice. I checked to include the p5.dom.js library. I did.

    I tried the other suggestions, but it did not work.

    In the original code I have two variables with two arguments:

    See the Pen Domain coloring by Juan Carlos Ponce Campuzano (@carlosponce) on CodePen.

    I would like to replace these two with the inputs that I defined, but it does not work. Let's forget about the button for a second, if I replace these two variables and have a pre-defined value using the inputs such as

    let inputRe; let inputIm;

    function setup{ inputRe = createInput(); inputIm = createInput(); }

    function draw{ inputRe.value('x-y') inputIm.value('x+y') }

    I should be able to run the same code. But it does not work. :(

    See the Pen Domain coloring with input by Juan Carlos Ponce Campuzano (@carlosponce) on CodePen.

    I am not sure if I am calling back the correct values or do I need to parse them somehow?

    @Chrisir

    The avatar pic is indeed a recursive function made with paper, similar to a Spierpinski triangle... Cheers!

    Thanks

  • Thanks!

Sign In or Register to comment.