# Trying to create a shape/load image in a class and call it in my draw (not working)

**URL:** <https://discourse.processing.org/t/trying-to-create-a-shape-load-image-in-a-class-and-call-it-in-my-draw-not-working/13638>\
**Category:** Coding Questions\
**Created:** [August 27, 2019, 12:13am UTC](https://discourse.processing.org/t/trying-to-create-a-shape-load-image-in-a-class-and-call-it-in-my-draw-not-working/13638 "2019-08-27T00:13:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bobboibob](https://avatars.discourse-cdn.com/v4/letter/b/96bed5/32.png) [@bobboibob](https://discourse.processing.org/u/bobboibob)\
**Post date:** [August 27, 2019, 12:13am UTC](https://discourse.processing.org/t/trying-to-create-a-shape-load-image-in-a-class-and-call-it-in-my-draw-not-working/13638/1 "2019-08-27T00:13:35Z")

</div>

Sorry this is a two part question but it is kind of the same question, I taught myself processing so hence I am not sure how to figure this out myself.

1. So, I made a drawBird() function in my bird class and then in my Main I tried calling it using b.drawbird().  
This works if my code is a simple shape like:

```auto
   stroke(255);
    noFill();
    strokeWeight(2);
    ellipse(xPos, yPos, 20, 20);

```

But once I try doing complex that requires me adding different shapes together, ex. if I had lines and arc in that function. Something like:

```auto
  ellipse(250, 400, 20, 20);
  line(240, 400, 260, 400);
  line(240, 403, 260, 403);
  arc(263, 375, 50, 50, 0, HALF_PI);
  arc(250, 372, 60, 60, HALF_PI + QUARTER_PI/2, PI);

```

and then call this in my main, it doesn’t work the same. I tried grouping the shape using createShape(), but was having the same problem.

1. Also would it be possible use an image in my drawBird() and then use that in my Main draw function. I tried loadImage(), but it didnt work out like I thought.

if you need any explanations feel free to ask, thanks a lot 🙂

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [August 27, 2019, 12:55am UTC](https://discourse.processing.org/t/trying-to-create-a-shape-load-image-in-a-class-and-call-it-in-my-draw-not-working/13638/2 "2019-08-27T00:55:01Z")

</div>

> [@bobboibob](#):
>
> it doesn’t work the same

please we need more error description,

what i see is that in the first code part you use variables xPos yPos  
but not in the second part? why ?

* * *

try to learn about image load and display first outside your project and class… structure.  
/File/Examples/Basics/Image/LoadDisplayImage/

---

<div class="post-metadata">

**Author:** ![bobboibob](https://avatars.discourse-cdn.com/v4/letter/b/96bed5/32.png) [@bobboibob](https://discourse.processing.org/u/bobboibob)\
**Post date:** [August 27, 2019, 1:27am UTC](https://discourse.processing.org/t/trying-to-create-a-shape-load-image-in-a-class-and-call-it-in-my-draw-not-working/13638/3 "2019-08-27T01:27:07Z")

</div>

Oh my, I feel so stupid. I forgot to use xPos and yPos for my new shape. Thanks so much for pointing that out!! 😃
