Currently you are writing lots of top-level functions in order to create flow controls that will do what you want.
@GoToLoop is suggesting that at some point in the future you may want to use Object Oriented Programming to organize your function into classes. See for example the tutorial “Objects”:
https://processing.org/tutorials/objects/
As @kll has hinted, you will get much better help if you say more about what, specifically, you want to accomplish with this sketch. Are you trying to write your own paint program? Are you trying to create a model for a generative art work involving rectangles? Are rectangles all just an excuse to learn more about how functions work? Is sending the output to a breadboard (e.g. with an Arduino) the goal?
Some of your code looks like you are trying to develop the basic functions of a programming language, rather than use those functions that already exist. This is a great way to learn programming, if learning is your only goal – but if you have some other goal for your sketch, it is much easier to use the existing Processing API. The function “lesser”, for example, looks like you are writing your own min(), which is a standard part of Processing.
https://processing.org/reference/min_.html
“greater” is max().
I would suggest spending a bit of time browsing through the reference – looking at things in Math and Data, for example.