# Anti-rotation command

**URL:** <https://discourse.processing.org/t/anti-rotation-command/5752>\
**Category:** Coding Questions\
**Created:** [November 20, 2018, 4:13am UTC](https://discourse.processing.org/t/anti-rotation-command/5752 "2018-11-20T04:13:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alk5603](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@alk5603](https://discourse.processing.org/u/alk5603)\
**Post date:** [November 20, 2018, 4:13am UTC](https://discourse.processing.org/t/anti-rotation-command/5752/1 "2018-11-20T04:13:24Z")

</div>

float angle = 0, radius = 300;  
int num = 6;

void setup() {  
size(800, 800);  
fill(255);  
}

void draw() {  
fill(0, 20);  
rect(-50, -50, width+100, height+100);

translate(width/2, height/2);  
rotate(angle);

if (mousePressed) {  
angle = angle + -0.05;  
radius = radius \* 0.975;  
} else {  
radius = radius + (300 - radius) \* 0.05;  
}

for (int i=0; i\< 8; i++) {  
fill(#214EFC);  
ellipse(100_cos(i_TWO\_PI / 8), 100_sin(i_TWO\_PI/ 8), 50, 50);  
}

for (int i=0; i\< 8; i++) {  
fill(#19F5E8);  
ellipse(300_cos(i_TWO\_PI / 8), 300_sin(i_TWO\_PI / 8), 150, 150);  
}  
}

I would like to ask how to make the outer ring rotate in the opposite direction.

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [November 20, 2018, 4:19am UTC](https://discourse.processing.org/t/anti-rotation-command/5752/2 "2018-11-20T04:19:15Z")

</div>

Please format your code. Also, you placed this code in p5.js but this is java. I have fixed the category of this post for you.

Kf

---

<div class="post-metadata">

**Author:** ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)\
**Post date:** [November 20, 2018, 4:27am UTC](https://discourse.processing.org/t/anti-rotation-command/5752/3 "2018-11-20T04:27:12Z")

</div>

You can counter the rotation using another rotate() before the outer ellipses are drawn. Just add a rotation(-angle) and using pushMatrix() and popMatrix() before and after the first and second rotation(). Or you could just use rotate(-angle-angle) right before the outer ellipses are drawn.
