# ¿Cómo rotar Colores?

**URL:** <https://discourse.processing.org/t/como-rotar-colores/35383>\
**Category:** Español\
**Created:** [February 22, 2022, 1:15pm UTC](https://discourse.processing.org/t/como-rotar-colores/35383 "2022-02-22T13:15:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![juan\_esteban](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@juan\_esteban](https://discourse.processing.org/u/juan_esteban)\
**Post date:** [February 22, 2022, 1:15pm UTC](https://discourse.processing.org/t/como-rotar-colores/35383/1 "2022-02-22T13:15:18Z")

</div>

Alguien me puede colaborar con este codigo ¿Qué tengo de malo? face\_with\_head\_bandage:  
Cada vez que se de clic Izquierdo en cualquiera de los cinco círculos, los colores de los círculo rotan una posición a la derecha y permanecen así hasta que se de clic de nuevo y vuelvan a girar.

```auto
boolean rote=true;
int[] x ={70, 180, 290, 400, 510};

int []y ={170, 170, 170, 170, 170};

int []la= {90, 90, 90, 90, 90};

int []an= {90, 90, 90, 90, 90};

int []fondo= {#F51936, #F0B41D, #209526, #203495, #8D2095};

void setup() {

  size(600, 400);
}

void draw() {
  background(245);
  textSize(18);
  fill(0);
  stroke(0);
  text("Juan Esteban L.S", 450, 360);

  for ( int i=0; i<x.length; i++) {
    fill(fondo[i]);
    ellipse(x[i], y[i], la[i], an[i]);

    if (mousePressed) {
      if (mouseButton==LEFT) {
        if (rote) {
          fill(#8D2095);
          ellipse(70, 170, 90, 90);
         fill(#0F0CF0);
          ellipse(180, 170, 90, 90);
           fill(#209526);
          ellipse(290, 170, 90, 90);
          
          
        }
      }
    }
  }
  if (mouseButton==LEFT &&
    mouseX>150 &&
    mouseX<150+80 &&
    mouseY>160 && mouseY<160+75) {
    rote = !rote;

  }
}

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [February 24, 2022, 3:22pm UTC](https://discourse.processing.org/t/como-rotar-colores/35383/2 "2022-02-24T15:22:25Z")

</div>

```auto

//

boolean rote=true;

int[] x ={70, 180, 290, 400, 510};

int []y ={170, 170, 170, 170, 170};

int []la= {90, 90, 90, 90, 90};

int []an= {90, 90, 90, 90, 90};

int []fondo= {#F51936, #F0B41D, #209526, #203495, #8D2095};

void setup() {
  size(600, 400);
}

void draw() {
  background(245);

  textSize(18);
  fill(0);
  stroke(0);
  text("<- Juan Esteban L.S", 450, 360);

  for ( int i=0; i<x.length; i++) {
    fill(fondo[i]);
    ellipse(x[i], y[i], la[i], an[i]);
  }
}

void mousePressed() {
  color a= fondo[0];

  for (int i=0; i<fondo.length-1; i++) {
    fondo[i] = fondo[i+1] ;
  }
  fondo[fondo.length-1] = a;
}
//

```

---

<div class="post-metadata">

**Author:** ![RichardDL](https://avatars.discourse-cdn.com/v4/letter/r/f475e1/32.png) [@RichardDL](https://discourse.processing.org/u/RichardDL)\
**Post date:** [February 25, 2022, 10:07am UTC](https://discourse.processing.org/t/como-rotar-colores/35383/3 "2022-02-25T10:07:14Z")

</div>

For those of us who don’t know Spanish, we have Google Translate:

Can someone help me with this code. What’s wrong with me? face\_with\_head\_bandage:  
Each time you Left click on any of the five circles, the colors of the circles rotate one position to the right and stay that way until you click again and rotate again.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [February 25, 2022, 10:43am UTC](https://discourse.processing.org/t/como-rotar-colores/35383/4 "2022-02-25T10:43:06Z")

</div>

Hello,

> [@RichardDL](#):
>
> For those of us who don’t know Spanish, we have Google Translate:

Also, when using Google Chrome (English language version) right click on the page and select “Translate to English”:

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/4/448ccf8789080909451e892ff8cb7ffe385d318f.png)

`:)`

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [February 25, 2022, 10:50am UTC](https://discourse.processing.org/t/como-rotar-colores/35383/5 "2022-02-25T10:50:40Z")

</div>

Thank you

My version is not correct and not complete then

I think it’s rotating left, not right

Also I don’t check whether we are clicking in a circle or not
