# How to manipulate one shape or other p5 objects in another place

**URL:** <https://discourse.processing.org/t/how-to-manipulate-one-shape-or-other-p5-objects-in-another-place/29396>\
**Category:** Beginners\
**Tags:** homework\
**Created:** [April 16, 2021, 1:00am UTC](https://discourse.processing.org/t/how-to-manipulate-one-shape-or-other-p5-objects-in-another-place/29396 "2021-04-16T01:00:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![turtle](https://avatars.discourse-cdn.com/v4/letter/t/ecb155/32.png) [@turtle](https://discourse.processing.org/u/turtle)\
**Post date:** [April 16, 2021, 1:00am UTC](https://discourse.processing.org/t/how-to-manipulate-one-shape-or-other-p5-objects-in-another-place/29396/1 "2021-04-16T01:00:26Z")

</div>

I have checked out the Reference and Examples roundly, now I find that it is difficult to manipulate p5 objects in another place(only can manipulate them in where they are be defined).  
For example:

```javascript
function draw() {
  stroke("red");
  fill("blue");
  ellipse(100,100,100,100);
}

```

after 1000 rows codes, I want to change the fillColor and strokeColor of the ellipse, how can I do that? And another question is that if the ellipse is defined in the `setup()` function, how can I manipulate it in other functions?

Looking forward reply.

---

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [April 16, 2021, 2:01am UTC](https://discourse.processing.org/t/how-to-manipulate-one-shape-or-other-p5-objects-in-another-place/29396/2 "2021-04-16T02:01:35Z")

</div>

You’re not defining anything. You’re simply drawing one.

You could define them by using some variables. Consider:

```auto
color ellipse_0_stroke_color = color(255,0,0);
color ellipse_0_fill_color = color(0,0,255);
int ellipse_0_size = 100;

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

void draw(){
  background(0);
  stroke(ellipse_0_stroke_color);
  fill(ellipse_0_fill_color);
  ellipse(100,100,ellipse_0_size,ellipse_0_size);
}

```

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [April 16, 2021, 2:10am UTC](https://discourse.processing.org/t/how-to-manipulate-one-shape-or-other-p5-objects-in-another-place/29396/3 "2021-04-16T02:10:23Z")

</div>

> [@turtle](#):
>
> , I want to change the fillColor and strokeColor of the ellipse, how can I do that?

You can make a class to represent it, so you can easily change its properties:

```auto
class ColorBall {
  constructor(x = 100, y = 100, diam = 100, border = 'red', paint = 'blue') {
    this.x = x, this.y = y, this.diam = diam;
    this.border = border, this.paint = paint;
  }

  display() {
    const { x, y, diam, border, paint } = this;
    stroke(border).fill(paint).circle(x, y, diam);
  }
}

```
