# Why? My class exists!

**URL:** <https://discourse.processing.org/t/why-my-class-exists/24269>\
**Category:** Beginners\
**Created:** [October 1, 2020, 1:27pm UTC](https://discourse.processing.org/t/why-my-class-exists/24269 "2020-10-01T13:27:31Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![HumanoidX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/humanoidx/32/8506_2.png) [@HumanoidX](https://discourse.processing.org/u/HumanoidX)\
**Post date:** [October 1, 2020, 1:27pm UTC](https://discourse.processing.org/t/why-my-class-exists/24269/1 "2020-10-01T13:27:31Z")

</div>

The compiler says…  
the class “Circle” does not exist  
…but it does.

Code:

```auto
Circle circle = new Circle(10,color(0),color(255,0,0),0,new PVector(400,400),new PVector(0,0),new PVector(0,0));

class Circle{
  float diameter;
  color colorStroke;
  color colorFill;
  float thickness;
  PVector position;
  PVector velocity;
  PVector acceleration;
  
  Circle(float d,color cs,color cf,float t,PVector p,PVector v,PVector a){
    diameter = d;
    colorStroke = cs;
    colorFill = cf;
    thickness = t;
    position = p;
    velocity = v;
    acceleration = a;
  }
  
  void update(){
    velocity.add(acceleration);
    position.add(velocity);
    if(thickness == 0){
      noStroke();
    }else{
      strokeWeight(thickness);
    }
    stroke(colorStroke);
    fill(colorFill);
    ellipse(position.x - (diameter / 2),position.y - (diameter / 2),position.x + (diameter / 2),position.y + (diameter / 2));
  }
}

```

---

<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:** [October 1, 2020, 1:37pm UTC](https://discourse.processing.org/t/why-my-class-exists/24269/2 "2020-10-01T13:37:31Z")

</div>

Is this your entire code?

But you have setup() and draw()?

---

<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:** [October 1, 2020, 1:44pm UTC](https://discourse.processing.org/t/why-my-class-exists/24269/3 "2020-10-01T13:44:58Z")

</div>

it is necessary

Chrisir

---

<div class="post-metadata">

**Author:** ![HumanoidX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/humanoidx/32/8506_2.png) [@HumanoidX](https://discourse.processing.org/u/HumanoidX)\
**Post date:** [October 1, 2020, 1:45pm UTC](https://discourse.processing.org/t/why-my-class-exists/24269/4 "2020-10-01T13:45:47Z")

</div>

Whoops…  
Adding setup and draw works…  
Thanks!

😁

---

<div class="post-metadata">

**Author:** ![HumanoidX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/humanoidx/32/8506_2.png) [@HumanoidX](https://discourse.processing.org/u/HumanoidX)\
**Post date:** [October 1, 2020, 1:46pm UTC](https://discourse.processing.org/t/why-my-class-exists/24269/5 "2020-10-01T13:46:31Z")

</div>

Arr… I told you I am a noob… 🙃

---

<div class="post-metadata">

**Author:** ![HumanoidX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/humanoidx/32/8506_2.png) [@HumanoidX](https://discourse.processing.org/u/HumanoidX)\
**Post date:** [October 1, 2020, 1:51pm UTC](https://discourse.processing.org/t/why-my-class-exists/24269/6 "2020-10-01T13:51:06Z")

</div>

Circle circle1 = new Circle(50,color(0),color(255,0,0),0,new PVector(400,400),new PVector(0,0),new PVector(0,0));

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

void draw(){  
background(0);  
circle1.update();  
circle1.position.x = mouseX;  
circle1.position.y = mouseY;  
}

class Circle{  
float diameter,thickness;  
color colorStroke,colorFill;  
PVector position,velocity,acceleration;

class Circle{  
float radius,thickness;  
color colorStroke,colorFill;  
PVector position,velocity,acceleration;

Circle(float r,color cs,color cf,float t,PVector p,PVector v,PVector a){  
radius = r;  
colorStroke = cs;  
colorFill = cf;  
thickness = t;  
position = p;  
velocity = v;  
acceleration = a;  
}

void update(){  
velocity.add(acceleration);  
position.add(velocity);  
if(thickness == 0){  
noStroke();  
}else{  
strokeWeight(thickness);  
}  
stroke(colorStroke);  
fill(colorFill);  
ellipse(position.x,position.y,radius,radius);  
}  
}

---

<div class="post-metadata">

**Author:** ![HumanoidX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/humanoidx/32/8506_2.png) [@HumanoidX](https://discourse.processing.org/u/HumanoidX)\
**Post date:** [October 1, 2020, 1:52pm UTC](https://discourse.processing.org/t/why-my-class-exists/24269/7 "2020-10-01T13:52:19Z")

</div>

Just for a test…

---

<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:** [October 1, 2020, 1:53pm UTC](https://discourse.processing.org/t/why-my-class-exists/24269/8 "2020-10-01T13:53:36Z")

</div>

> [@HumanoidX](#):
>
> ellipse(position.x - (diameter / 2),position.y - (diameter / 2),position.x + (diameter / 2),position.y + (diameter / 2));

instead of doing this `position.x - (diameter / 2),position.y - (diameter / 2),`

use `ellipseMode(CENTER); // Set ellipseMode to CENTER` previous to `ellipse()` command

see [ellipseMode() / Reference / Processing.org](https://www.processing.org/reference/ellipseMode_.html)

AND the last two parameters are wrong: just use `diameter` here

**Remarks**

- don’t use a Sketch name (on your hard drive) when it’s already a class name
- everything is case sensitive
- circle is a command, so maybe not a good idea to have an object with the same name (it works but…): Use circle1 or myCircle instead

Chrisir

---

<div class="post-metadata">

**Author:** ![HumanoidX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/humanoidx/32/8506_2.png) [@HumanoidX](https://discourse.processing.org/u/HumanoidX)\
**Post date:** [October 1, 2020, 1:54pm UTC](https://discourse.processing.org/t/why-my-class-exists/24269/9 "2020-10-01T13:54:42Z")

</div>

Yeah, I changed it. 😀

---

<div class="post-metadata">

**Author:** ![HumanoidX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/humanoidx/32/8506_2.png) [@HumanoidX](https://discourse.processing.org/u/HumanoidX)\
**Post date:** [October 1, 2020, 1:55pm UTC](https://discourse.processing.org/t/why-my-class-exists/24269/10 "2020-10-01T13:55:00Z")

</div>

Thanks Chrisir 😄
