# Oppositional Rotations

**URL:** https://discourse.processing.org/t/oppositional-rotations/33364
**Category:** Gallery
**Created:** [November 6, 2021, 2:27pm UTC](https://discourse.processing.org/t/oppositional-rotations/33364 "2021-11-06T14:27:59Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![javagar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/javagar/32/11434_2.png) [@javagar](https://discourse.processing.org/u/javagar)
#### Post date: [November 6, 2021, 2:28pm UTC](https://discourse.processing.org/t/oppositional-rotations/33364/1 "2021-11-06T14:28:00Z")

</div>

The forms rotate clockwise, while the colors rotate counterclockwise.

![OppositionalRotations](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/3a3cb5a4c519537a270bb884b2c8d4a059d1de3c.png)

p5.js code:

```auto
/* Oppositional Rotations
The forms rotate clockwise,
while the colors rotate counterclockwise.
November 6, 2021 */
let ang = 0;
function setup() {
  createCanvas(377, 377);
  noStroke();
  rectMode(CENTER);
  colorMode(HSB, 360, 100, 100, 1);
}

function draw() {
  background(0);
  fill(0);
  // rect(width / 2, height * 3 / 4, 25, height / 2);
  for (let n = 0; n < 360; n += 10) {
    petal(width / 2, height / 2, 144, 34, TWO_PI * n / 360 + frameCount / 60, color((frameCount * 3 + n) % 360, 100, 100, 0.5));
  }
}

function petal(x, y, w, h, angle, f) {
  push();
  translate(x, y);
  rotate(angle);
  fill(f);
  ellipse(w / 2, 0, w, h);
  pop();
}

```

This sketch was composed subsequent to this discussion:

> [@New rotated ellipse function help and suggestions](https://discourse.processing.org/t/new-rotated-ellipse-function-help-and-suggestions/33281):
>
> Hello! I finally figured out how to make an ellipse that will rotate without having to use the rotate function on it. I had had no luck getting solutions using rotate() and push()/pop() to generalize to making multiple copies that are resizable or relocatable. For instance, trying to make a flower function with tilted petals. It just won’t relocate without messing up. Here’s a link to the function I created to try to fix that issue. It uses angle of rotation as an argument. Feel free to use/mo…
