JSFiddle - React, Tailwind, and code Playground

by demso

HTML

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

int counter;
int moduleSize = 10;
// limiter
int limiter = moduleSize;
int limiterStore = moduleSize;

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,  100);
 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,  80);
 mods[7] = new Module(8*30,  70);
 mods[8] = new Module(9*30,  90);
 mods[9] = new Module(10*30, 10);  
 }

void draw() { 
  background(50);
   buttonUpdate();  
  for (Module mod : mods) {  mod.display();  }  
   // paddle
  rect (slider*30, 85, 20, 5);  
  rect (limiter*30, 75, 20, 5);
  
  textSize(25);
  text(counter,300,350);
  // 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 mousePressed() {
 if(boolButton)
 {  
 counter++;
 if(limiter!=moduleSize) 
  {
   limiter++;
   slider++;
  }
   if(slider==limiter) 
   {
     slider=1;
     limiter=1;
   }  
  }
}

void mouseReleased() {
 if(boolButton)
  {
     if(mods[slider-1].rectHight > mods[limiter-1].rectHight)  
    {     
     vTemp= mods[slider-1].rectHight;
     mods[slider-1].rectHight=mods[limiter-1].rectHight;
     mods[limiter-1].rectHight=vTemp;
    } 
  if(limiter==moduleSize)
   {
    limiter =...