# Unexpected void error

**URL:** <https://discourse.processing.org/t/unexpected-void-error/25640>\
**Category:** Beginners\
**Created:** [November 23, 2020, 6:13pm UTC](https://discourse.processing.org/t/unexpected-void-error/25640 "2020-11-23T18:13:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![type.gaurav](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@type.gaurav](https://discourse.processing.org/u/type.gaurav)\
**Post date:** [November 23, 2020, 6:13pm UTC](https://discourse.processing.org/t/unexpected-void-error/25640/1 "2020-11-23T18:13:24Z")

</div>

void setup(){  
size(900,900);  
background(255);  
}

void draw(){  
for(int x = 0; x \< height; x = x+90){  
for (int y = 0; ABy \< width; y = y+90){  
shapeX(x, y, 90, 90, random(255));  
}  
}

void shapeX(float x, float y, float z, float a, float c){  
beginShape();  
noStroke();  
fill©;  
ellipse(x, y, z+40, a+40);  
translate(-58,-58);  
noStroke();  
fill©;  
rect(x, y, z+25, a+25);  
endShape(CLOSE);  
}

```auto
type or paste code here

```

---

<div class="post-metadata">

**Author:** ![type.gaurav](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@type.gaurav](https://discourse.processing.org/u/type.gaurav)\
**Post date:** [November 23, 2020, 6:14pm UTC](https://discourse.processing.org/t/unexpected-void-error/25640/2 "2020-11-23T18:14:29Z")

</div>

© = ( c )

.

.  
.  
…  
.  
.

.  
.  
.  
.  
.  
.  
.  
.  
.  
.  
.

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [November 23, 2020, 6:17pm UTC](https://discourse.processing.org/t/unexpected-void-error/25640/3 "2020-11-23T18:17:22Z")

</div>

Hi,

Welcome to the forum!

It seems that there’s a strange character in your code! It’s probably due to `fill©` twice.

In Java, you the grammar of the language doesn’t include the copyright sign except for strings of course 😉

_PS : remember to format your code by using the `</>` button in the message editor on the forum_

---

<div class="post-metadata">

**Author:** ![type.gaurav](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@type.gaurav](https://discourse.processing.org/u/type.gaurav)\
**Post date:** [November 23, 2020, 6:19pm UTC](https://discourse.processing.org/t/unexpected-void-error/25640/4 "2020-11-23T18:19:39Z")

</div>

hey, thankyou but © is ( c ) within the code.  
i am beginner to processing so i am clueless rightnow as to what do to.

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [November 23, 2020, 6:21pm UTC](https://discourse.processing.org/t/unexpected-void-error/25640/5 "2020-11-23T18:21:35Z")

</div>

> [@type.gaurav](#):
>
> hey, thankyou but © is ( c ) within the code.

I don’t understand, where does your code come from? You would never have `©` character in your code but rather `fill(c);`

---

<div class="post-metadata">

**Author:** ![type.gaurav](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@type.gaurav](https://discourse.processing.org/u/type.gaurav)\
**Post date:** [November 23, 2020, 6:25pm UTC](https://discourse.processing.org/t/unexpected-void-error/25640/6 "2020-11-23T18:25:09Z")

</div>

i get you,  
actually in my code its ( c ) without the spaces within the bracket but in this website when we type and upload ( c ) it becomes ©.  
this is not the problem tho.

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [November 23, 2020, 6:31pm UTC](https://discourse.processing.org/t/unexpected-void-error/25640/7 "2020-11-23T18:31:00Z")

</div>

Ok well anyway it’s strange 😉

Changing the corresponding lines and pressing `Ctrl+T` in the Processing editor to auto format the code (handy tip!), I get an error at line 10 saying that there’s a missing curly bracket.

In fact you forgot to close the `draw()` function block. (in general when you open a bracket, you need to close it)

This is the corrected code :

```auto
void setup() {
  size(900, 900);
  background(255);
}

void draw() {
  for (int x = 0; x < height; x = x+90) {
    for (int y = 0; y < width; y = y+90) {
      shapeX(x, y, 90, 90, random(255));
    }
  }
}

void shapeX(float x, float y, float z, float a, float c) {
  beginShape();
  noStroke();
  fill(c);
  ellipse(x, y, z+40, a+40);
  translate(-58, -58);
  noStroke();
  fill(c);
  rect(x, y, z+25, a+25);
  endShape(CLOSE);
}

```

I don’t think that it’s the result that you want but this is a starting point

---

<div class="post-metadata">

**Author:** ![type.gaurav](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@type.gaurav](https://discourse.processing.org/u/type.gaurav)\
**Post date:** [November 23, 2020, 6:35pm UTC](https://discourse.processing.org/t/unexpected-void-error/25640/8 "2020-11-23T18:35:01Z")

</div>

Thanks and you are right, this is not the result i am looking for XD.  
if you can and if you want.  
please help me with this code.  
what I want to do is to fill the sketch area with shapeX(with i made within the code) in checker box manner

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [November 23, 2020, 6:47pm UTC](https://discourse.processing.org/t/unexpected-void-error/25640/9 "2020-11-23T18:47:19Z")

</div>

Ok let’s go over this 😉 :

- I suppose that you don’t want to animate your sketch based on your description so you can use [`noLoop()`](https://processing.org/reference/noLoop_.html) at the end of the draw function to break the loop. We want to only draw once.

- Also you are misleading with the usage of [`beginShape()`](https://processing.org/reference/beginShape_.html) / `endShape()`, they are used when you want to draw a shape using custom points (not a rectangle or an ellipse since those shapes already have their own pre defined functions)

- Using [`translate()`](https://processing.org/reference/translate_.html) will move the whole coordinate system, in this case you rather want to display your rect with an offset of -58.

- When using `fill()` or `noStroke()`, it’s like a state machine. Unless you call again `fill()` with another color, it’s going to stay the same. So you can call them once before drawing your shapes

- When your pattern is working properly, you can see that the last column and row are not drawn. Can you find what to change in order to display the whole pattern correctly?

- Also try to put spaces in your code as it increases readability

Try to change your code to make it work and then I can post the full solution! 🙂
