# Slider and box rotation

**URL:** <https://discourse.processing.org/t/slider-and-box-rotation/28071>\
**Category:** Gallery\
**Created:** [February 25, 2021, 2:43am UTC](https://discourse.processing.org/t/slider-and-box-rotation/28071 "2021-02-25T02:43:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [February 25, 2021, 2:43am UTC](https://discourse.processing.org/t/slider-and-box-rotation/28071/1 "2021-02-25T02:43:48Z")

</div>

```auto
import controlP5.*;

ControlP5 cp5;

Slider boxSize; 
Slider2D rotate;
ColorWheel col; 
Toggle start; 

void setup() {
  
  size(800, 600, P3D);
  
  cp5 = new ControlP5(this);
  
 
  boxSize = cp5.addSlider("BOX SIZE")
    .setPosition(20, 20)
    .setRange(0, 400)
    .setValue(200);
 
  rotate = cp5.addSlider2D("ROTATION")
    .setPosition(20, 40)
    .setSize(100, 100)
    .setMinMax(1.0, 1.0, 10.0, 10.0)
    .setValue(2.0, 2.0);
  
  start = cp5.addToggle("START/STOP")
    .setPosition(20, 160)
    .setSize(20, 20);
  
  col = cp5.addColorWheel("COLOR")
    .setPosition(20, 220)
    .setRGB(color(31, 128, 255));
}

void draw() {
  background(0);
  pushMatrix();
  
  lights();

  translate(width/2, height/2, 0);
  
  if (start.getState()) {
    
    rotateX(millis()/1000.0 * rotate.getArrayValue()[0]);
    
    rotateY(millis()/1000.0 * rotate.getArrayValue()[0]);
  }
  
  fill(col.getRGB());
  noStroke();
 
  box(boxSize.getValue());
  popMatrix();
}

```

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [February 25, 2021, 2:44am UTC](https://discourse.processing.org/t/slider-and-box-rotation/28071/2 "2021-02-25T02:44:29Z")

</div>

![3d](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/b/b3ae711bbd17a24e9511337b5d325ff060288aa0.jpeg)
