JSFiddle - React, Tailwind, and code Playground

by demso

HTML

<script src="processing.js"></script>
<script type="text/processing" data-processing-target="mycanvas">

int min; 
int counter;
int moduleSize = 10;
int limiterL = 1;

int slider=1;

 int vTemp;
//button
int buttonX=25, buttonY=325; 
int buttonSize = 50;     
boolean boolButton = false;

int count;
Module[] mods;

void setup() {
  size(400, 400);
 mods = new Module[moduleSize];
 mods[0] = new Module(1*30,  80);
 mods[1] = new Module(2*30,  50);
 mods[2] = new Module(3*30,  30);
 mods[3] = new Module(4*30,  60);
 mods[4] = new Module(5*30,  20);
 mods[5] = new Module(6*30,  40);
 mods[6] = new Module(7*30,  100);
 mods[7] = new Module(8*30,  70);
 mods[8] = new Module(9*30,  90);
 mods[9] = new Module(10*30, 10);
 min =  mods[0].rectHight;
}

void draw() { 
  background(50);
   buttonUpdate();  
   for (Module mod : mods) {  mod.display();  }
  
   // paddle
  rect (slider*30, 85, 20, 5);  
  rect (limiterL*30, 75, 20, 5);
  
  textSize(25);
  text(counter,300,350);
  text(min,30,30);
  // draw button
  fill(150);
  rect(buttonX,buttonY,buttonSize,buttonSize);
   if(boolButton && mousePressed){ 
    fill(200);
    rect(buttonX,buttonY,buttonSize,buttonSize);
    }
}

class Module {
 int xOffset; 
 int rectHight;
  
// Contructor
   Module(int xOffsetTemp, int rectHightTemp) {
    xOffset = xOffsetTemp;  
    rectHight=rectHightTemp;
  }  
  // Custom method for drawing the object
  void display() {
   fill(255);
   rect(xOffset , 100, 20, rectHight);
   }
}

// button
void mouseReleased() {
 if(boolButton)
  {
    if (mods[limiterL-1].rectHight>min)
     {     
     vTemp= mods[limiterL-1].rectHight;
     mods[limiterL-1].rectHight=mods[slider-1].rectHight;
     mods[slider-1].rectHight=vTemp;
    }    
    
     //if(slider==moduleSize){       
     if(slider==moduleSize-1){
      //if(limiterL<moduleSize) limiterL++;
      limiterL++;      
      min=mods[limiterL-1].rectHight;
      slider=limiterL-1; 
      }
     // slider++;
   ...