# Rotate problem with PGraphics

**URL:** <https://discourse.processing.org/t/rotate-problem-with-pgraphics/37753>\
**Category:** Coding Questions\
**Created:** [June 28, 2022, 11:16pm UTC](https://discourse.processing.org/t/rotate-problem-with-pgraphics/37753 "2022-06-28T23:16:08Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [June 29, 2022, 10:19pm UTC](https://discourse.processing.org/t/rotate-problem-with-pgraphics/37753/3 "2022-06-29T22:19:19Z")

</div>

Hello @druuupppa ,

Please format and post your code as per instructions here:  
[https://discourse.processing.org/faq#format-your-code](https://discourse.processing.org/faq#format-your-code)

See [Guidelines - Asking Questions](https://discourse.processing.org/t/guidelines-asking-questions/2147)

I suggest you take a look here:

> [@druuupppa](#):
>
> drawPetal(p, x, y, r, rt1, rt2 );

Did you include the necessary `p.` object prefix for all the elements you want in your PGraphics?

You are also passing your current PGraphics `p` to the function. Is that intended? Give that some consideration.

A working, minimal, formatted example in static mode:

```auto
PGraphics pg;

size(100, 100);

pg = createGraphics(100, 100);

for(int i = 0; i<=90; i+=9)
  {
  pg.beginDraw();
  pg.pushMatrix();
  pg.noFill();
  pg.rotate(radians(i));
  pg.ellipse(50, 0, random(5, 20), 5); // drawPetal()
  pg.popMatrix();
  pg.endDraw();
  }

image(pg, 0, 0);

```

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/e/7/e71ec788a53efa3674eed637ff61aa00696d74eb.png)

Start with a simple working example and build on that one step at a time.

References:

> **[PGraphics / Reference](https://processing.org/reference/PGraphics.html)**
>
> Main graphics and rendering context, as well as the base API implementation for processing "core". Use this class if you need to draw into an off-screen graphics buffer. A PGraphics object can be cons…

> **[Render Techniques](https://processing.org/tutorials/rendering/)**
>
> Tools for rendering geometries in Processing.

`:)`

---

_[View the full topic](https://discourse.processing.org/t/rotate-problem-with-pgraphics/37753)._
