# Creating a grid of dice representing an image

**URL:** <https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364>\
**Category:** Coding Questions\
**Created:** [August 15, 2022, 4:41pm UTC](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364 "2022-08-15T16:41:22Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![asymmetric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/asymmetric/32/16577_2.png) [@asymmetric](https://discourse.processing.org/u/asymmetric)\
**Post date:** [October 30, 2022, 12:51am UTC](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364/21 "2022-10-30T00:51:20Z")

</div>

Where do I insert the following code?

> [@Chrisir](#):
>
> dots=s;

This is what I have so far, but should I remove the random function from the class since the dots are referring to the brightness?

```auto
PImage img;

void setup(){
  size(700,700);
  img = loadImage("IMG_7741.jpeg");
  img.resize(800,800);
}

void draw(){
  background(#f1f1f1);
  //noSrtoke();
  
  float tilesX = 80;
  float tilesY = tilesX;
  
  float tileW = width / tilesX;
  float tileH = height/ tilesY;
 
  for (int x = 0; x < tilesX; x++){
    for (int y = 0; y < tilesY; y++){
     
      int px = int(x);
      int py = int(y);
      color c = img.get(px,py);
      
      fill(c);
      
      float b = brightness(c);

      float s = map(b, 0, 255, 1, 6); // 1-6 dice sides
      Die die = new Die(x*tileW, y*tileH );
      die.show(s);
      
      //rect(x*tileW, y*tileH, tilesX, tilesY);
      
        
      }
   }
}
class Die
{
  //variable declarations here
  int dots;
  int myX;
  int myY;

  Die(float x, float y) //constructor
  {
    roll();
    myX = x;
    myY= y;
  }
  void roll()
  {
    if (s(6) <= 1)
    {
      dots = 1;
    } else if (random(6) <= 2) // remove random?
    {
      dots = 2;
    } else if (random(6) <= 3) // remove random?
    {
      dots = 3;
    } else if (random(6) <= 4) // remove random?
    {
      dots = 4;
    } else if (random(6) <= 5) // remove random?
    {
      dots = 5;
    } else if (random(6) <= 6) // remove random?
    {
      dots = 6;
    }
  }
  void show(int s )
  {
    fill(255,255,255);
    rect(myX, myY, 50, 50);
    fill(0, 0, 0);

    if (dots == 1)
    {
      ellipse(myX+25, myY+25, 10, 10);
    } else if (dots == 2)
    {
      ellipse(myX+10, myY+40, 10, 10); 
      ellipse(myX+40, myY+10, 10, 10);
    } else if (dots == 3)
    { 
      ellipse(myX+10, myY+40, 10, 10); 
      ellipse(myX+25, myY+25, 10, 10); 
      ellipse(myX+40, myY+10, 10, 10);
    } else if (dots == 4)
    { 
      ellipse(myX+10, myY+40, 10, 10); 
      ellipse(myX+10, myY+10, 10, 10); 
      ellipse(myX+40, myY+40, 10, 10); 
      ellipse(myX+40, myY+10, 10, 10);
    } else if (dots == 5)
    { 
      ellipse(myX+10, myY+40, 10, 10); 
      ellipse(myX+10, myY+10, 10, 10); 
      ellipse(myX+40, myY+40, 10, 10); 
      ellipse(myX+40, myY+10, 10, 10); 
      ellipse(myX+25, myY+25, 10, 10);
    } else if (dots == 6)
    { 
      ellipse(myX+10, myY+40, 10, 10); 
      ellipse(myX+10, myY+25, 10, 10); 
      ellipse(myX+10, myY+10, 10, 10); 
      ellipse(myX+40, myY+10, 10, 10); 
      ellipse(myX+40, myY+25, 10, 10); 
      ellipse(myX+40, myY+40, 10, 10);
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![asymmetric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/asymmetric/32/16577_2.png) [@asymmetric](https://discourse.processing.org/u/asymmetric)\
**Post date:** [October 30, 2022, 12:52am UTC](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364/22 "2022-10-30T00:52:02Z")

</div>

> [@Chrisir](#):
>
> in the for loops, they must not exceed width and height of the image (is your image 80x80??)

My image is 800 pixels by 800 pixels.

---

<div class="post-metadata">

**Author:** ![asymmetric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/asymmetric/32/16577_2.png) [@asymmetric](https://discourse.processing.org/u/asymmetric)\
**Post date:** [October 30, 2022, 12:53am UTC](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364/23 "2022-10-30T00:53:19Z")

</div>

> [@Chrisir](#):
>
> Please tell us the errors you get

“The method show() in the type “sketch” Die is not applicable for the arguments (float)”

---

<div class="post-metadata">

**Author:** ![asymmetric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/asymmetric/32/16577_2.png) [@asymmetric](https://discourse.processing.org/u/asymmetric)\
**Post date:** [October 30, 2022, 12:58am UTC](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364/24 "2022-10-30T00:58:10Z")

</div>

Thank you for your help @Chrisir ! I’m learning slowly but surely!!

---

<div class="post-metadata">

**Author:** ![scudly](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/scudly/32/5597_2.png) [@scudly](https://discourse.processing.org/u/scudly)\
**Post date:** [October 30, 2022, 1:13am UTC](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364/25 "2022-10-30T01:13:07Z")

</div>

use `die.show( int(s) );`

Java is being picky about converting a float to an int so you have to tell it explicitly that that’s what you want to do.

But also in your `show()` function, you need `dots = s;` so that it uses that value to choose how many dots to show.

---

<div class="post-metadata">

**Author:** ![asymmetric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/asymmetric/32/16577_2.png) [@asymmetric](https://discourse.processing.org/u/asymmetric)\
**Post date:** [October 30, 2022, 1:19am UTC](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364/26 "2022-10-30T01:19:52Z")

</div>

I just fixed my code with your suggestions! I’m still recieving compiler erros… specifically line 47 says “cannot convert from float to int”.

```auto
myX = x;

```

```auto
PImage img;

void setup(){
  size(700,700);
  img = loadImage("IMG_7741.jpeg");
  img.resize(800,800);
}

void draw(){
  background(#f1f1f1);
  //noSrtoke();
  
  float tilesX = 80;
  float tilesY = tilesX;
  
  float tileW = width / tilesX;
  float tileH = height/ tilesY;
 
  for (int x = 0; x < tilesX; x++){
    for (int y = 0; y < tilesY; y++){
     
      int px = int(x);
      int py = int(y);
      color c = img.get(px,py);
      
      fill(c);
      
      float b = brightness(c);

      float s = map(b, 0, 255, 1, 6); // 1-6 dice sides
      Die die = new Die(x*tileW, y*tileH );
      die.show(int(s)); // or s?
       
      }
   }
}
class Die
{
  //variable declarations here
  int dots;
  int myX;
  int myY;

  Die(float x, float y) //constructor
  {
    roll();
    myX = x;
    myY= y;
  }
  void roll()
  {
    if (s(6) <= 1) 
    {
      dots = 1;
    } else if (random(6) <= 2)
    {
      dots = 2;
    } else if (random(6) <= 3)
    {
      dots = 3;
    } else if (random(6) <= 4)
    {
      dots = 4;
    } else if (random(6) <= 5)
    {
      dots = 5;
    } else if (random(6) <= 6)
    {
      dots = 6;
    }
  }
  void show(int s )
  {
    fill(255,255,255);
    dots = s;
    rect(myX, myY, 50, 50);
    fill(0, 0, 0);

    if (dots == 1)
    {
      ellipse(myX+25, myY+25, 10, 10);
    } else if (dots == 2)
    {
      ellipse(myX+10, myY+40, 10, 10); 
      ellipse(myX+40, myY+10, 10, 10);
    } else if (dots == 3)
    { 
      ellipse(myX+10, myY+40, 10, 10); 
      ellipse(myX+25, myY+25, 10, 10); 
      ellipse(myX+40, myY+10, 10, 10);
    } else if (dots == 4)
    { 
      ellipse(myX+10, myY+40, 10, 10); 
      ellipse(myX+10, myY+10, 10, 10); 
      ellipse(myX+40, myY+40, 10, 10); 
      ellipse(myX+40, myY+10, 10, 10);
    } else if (dots == 5)
    { 
      ellipse(myX+10, myY+40, 10, 10); 
      ellipse(myX+10, myY+10, 10, 10); 
      ellipse(myX+40, myY+40, 10, 10); 
      ellipse(myX+40, myY+10, 10, 10); 
      ellipse(myX+25, myY+25, 10, 10);
    } else if (dots == 6)
    { 
      ellipse(myX+10, myY+40, 10, 10); 
      ellipse(myX+10, myY+25, 10, 10); 
      ellipse(myX+10, myY+10, 10, 10); 
      ellipse(myX+40, myY+10, 10, 10); 
      ellipse(myX+40, myY+25, 10, 10); 
      ellipse(myX+40, myY+40, 10, 10);
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![scudly](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/scudly/32/5597_2.png) [@scudly](https://discourse.processing.org/u/scudly)\
**Post date:** [October 30, 2022, 1:30am UTC](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364/27 "2022-10-30T01:30:57Z")

</div>

In `class Die`, change `int myX;` to `float myX;` and same for `myY`.

---

<div class="post-metadata">

**Author:** ![asymmetric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/asymmetric/32/16577_2.png) [@asymmetric](https://discourse.processing.org/u/asymmetric)\
**Post date:** [October 30, 2022, 1:37am UTC](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364/28 "2022-10-30T01:37:41Z")

</div>

Okay! Now line 52 is creating a compiler error

“The function s(int) does not exist.”

```auto
    if (s(6) <= 1) 

```

---

<div class="post-metadata">

**Author:** ![asymmetric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/asymmetric/32/16577_2.png) [@asymmetric](https://discourse.processing.org/u/asymmetric)\
**Post date:** [October 30, 2022, 1:39am UTC](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364/29 "2022-10-30T01:39:21Z")

</div>

Should I change the random function to int s?

```auto
PImage img;

void setup(){
  size(700,700);
  img = loadImage("IMG_7741.jpeg");
  img.resize(800,800);
}

void draw(){
  background(#f1f1f1);
  //noSrtoke();
  
  float tilesX = 80;
  float tilesY = tilesX;
  
  float tileW = width / tilesX;
  float tileH = height/ tilesY;
 
  for (int x = 0; x < tilesX; x++){
    for (int y = 0; y < tilesY; y++){
     
      int px = int(x);
      int py = int(y);
      color c = img.get(px,py);
      
      fill(c);
      
      float b = brightness(c);

      float s = map(b, 0, 255, 1, 6); // 1-6 dice sides
      Die die = new Die(x*tileW, y*tileH );
      die.show(int(s)); // or s?
       
      }
   }
}
class Die
{
  //variable declarations here
  int dots;
  float myX;
  float myY;

  Die(float x, float y) //constructor
  {
    roll();
    myX = x;
    myY= y;
  }
  void roll()
  {
    if (s <= 1) 
    {
      dots = 1;
    } else if (random(6) <= 2) // Change random to s?
    {
      dots = 2;
    } else if (random(6) <= 3) // Change random to s?
    {
      dots = 3;
    } else if (random(6) <= 4) // Change random to s?
    {
      dots = 4;
    } else if (random(6) <= 5)// Change random to s?
    {
      dots = 5;
    } else if (random(6) <= 6)// Change random to s?
    {
      dots = 6;
    }
  }
  void show(int s )
  {
    fill(255,255,255);
    dots = s;
    rect(myX, myY, 50, 50);
    fill(0, 0, 0);

    if (dots == 1)
    {
      ellipse(myX+25, myY+25, 10, 10);
    } else if (dots == 2)
    {
      ellipse(myX+10, myY+40, 10, 10); 
      ellipse(myX+40, myY+10, 10, 10);
    } else if (dots == 3)
    { 
      ellipse(myX+10, myY+40, 10, 10); 
      ellipse(myX+25, myY+25, 10, 10); 
      ellipse(myX+40, myY+10, 10, 10);
    } else if (dots == 4)
    { 
      ellipse(myX+10, myY+40, 10, 10); 
      ellipse(myX+10, myY+10, 10, 10); 
      ellipse(myX+40, myY+40, 10, 10); 
      ellipse(myX+40, myY+10, 10, 10);
    } else if (dots == 5)
    { 
      ellipse(myX+10, myY+40, 10, 10); 
      ellipse(myX+10, myY+10, 10, 10); 
      ellipse(myX+40, myY+40, 10, 10); 
      ellipse(myX+40, myY+10, 10, 10); 
      ellipse(myX+25, myY+25, 10, 10);
    } else if (dots == 6)
    { 
      ellipse(myX+10, myY+40, 10, 10); 
      ellipse(myX+10, myY+25, 10, 10); 
      ellipse(myX+10, myY+10, 10, 10); 
      ellipse(myX+40, myY+10, 10, 10); 
      ellipse(myX+40, myY+25, 10, 10); 
      ellipse(myX+40, myY+40, 10, 10);
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![scudly](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/scudly/32/5597_2.png) [@scudly](https://discourse.processing.org/u/scudly)\
**Post date:** [October 30, 2022, 2:21am UTC](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364/30 "2022-10-30T02:21:49Z")

</div>

You’re not using `roll()`, are you? Seems like you could just delete it if all you want is just the dice images.

---

<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 30, 2022, 6:21am UTC](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364/31 "2022-10-30T06:21:29Z")

</div>

> [@asymmetric](#):
>
> The function s(int) does not exist.”
> 
> ```auto
> if (s(6) <= 1) 
> 
> ```

You really don’t need this.

Read your code and understand the concepts. s is a variable and not a function

---

<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:** [October 30, 2022, 11:17am UTC](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364/32 "2022-10-30T11:17:37Z")

</div>

Hello @asymmetric,

Consider just using this in your class or as a standalone function/method:

```auto
void show(float myX, float myY, float dots)
  {
 // Code here...
  }

```

You will also have to scale your die faces:

```auto
float sc = tileW/50; //50 is size of die face
println(sc, 1/sc);

push();
scale(sc, sc);
int s = int(random(0, 7)); // This will give 0 to 6! Use print() to see this before and after int()
die.show(1/sc*px, 10, s); //Class
//show(1/sc*px, 10, s); // Function
pop();

```

The above is just _ **one way to do it** _ using your _ **existing die class** _.

Scaled die faces:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/e/b/eb04946d3a0a70bcad7ba7f1b2433b26315d15d6.png)  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/9/1/9166a60243a13fc31959aedba346c248ed128011.png)

You should write separate working examples for each element of your code and then combine them; I did this with the class and scaling before adding it to the image tiling.

I was able to achieve this with above hints:

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

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/8/6/861677e7c62e661d926343025636a2b52dc67397.png)  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/6/3/631f3be9facaf0d9aea709832942edf25dd7329b.png)

Reference:

> **[Objects](https://processing.org/tutorials/objects/)**
>
> The basics of object-oriented programming.

`:)`

---

<div class="post-metadata">

**Author:** ![asymmetric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/asymmetric/32/16577_2.png) [@asymmetric](https://discourse.processing.org/u/asymmetric)\
**Post date:** [October 30, 2022, 5:24pm UTC](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364/33 "2022-10-30T17:24:03Z")

</div>

Thank you @glv ! I will re-read that chapter on Objects by Daniel Shiffman to get a stronger understanding!

Do I enter the following scaling code within the show() function or draw()? For now it is under the void draw(); block.

> [@glv](#):
>
> ```auto
> float sc = tileW/50; //50 is size of die face
> println(sc, 1/sc);
> 
> push();
> scale(sc, sc);
> int s = int(random(0, 7)); // This will give 0 to 6! Use print() to see this before and after int()
> die.show(1/sc*px, 10, s); //Class
> //show(1/sc*px, 10, s); // Function
> pop();
> 
> ```

---

<div class="post-metadata">

**Author:** ![asymmetric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/asymmetric/32/16577_2.png) [@asymmetric](https://discourse.processing.org/u/asymmetric)\
**Post date:** [October 30, 2022, 5:25pm UTC](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364/34 "2022-10-30T17:25:11Z")

</div>

I removed the roll() dice function block!

> [@glv](#):
>
> Consider just using this in your class or as a standalone function/method:
> 
> ```auto
> void show(float myX, float myY, float dots)
> {
> // Code here...
> }
> 
> ```

---

<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 30, 2022, 5:30pm UTC](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364/35 "2022-10-30T17:30:52Z")

</div>

> [@asymmetric](#):
>
> I enter the following scaling code within the show() function or draw()? For now it is under the void draw(); block.

Draw is correct

Replace random by map… brightness…

---

<div class="post-metadata">

**Author:** ![asymmetric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/asymmetric/32/16577_2.png) [@asymmetric](https://discourse.processing.org/u/asymmetric)\
**Post date:** [October 30, 2022, 5:49pm UTC](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364/36 "2022-10-30T17:49:16Z")

</div>

> [@Chrisir](#):
>
> Replace random by map… brightness…

Do you mean that I didn’t need to completely remove the roll() block? Do I need to change the roll block’s functionality from random to map the brightness? Like so? Or should I put the following conditional statements in the show() function?

```auto
  void brightness()
  {
    if (s <= 1) 
    {
      dots = 1;
    } else if (s <= 2) 
    {
      dots = 2;
    } else if (s <= 3)
    {
      dots = 3;
    } else if (s <= 4) 
    {
      dots = 4;
    } else if (s <= 5)
    {
      dots = 5;
    } else if (s <= 6)
    {
      dots = 6;
    }
  }

```

---

<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 30, 2022, 10:16pm UTC](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364/37 "2022-10-30T22:16:37Z")

</div>

You should really read my initial post, read your code and understand the idea we’re following.

You are making things far too complicated.

s=dots;

---

<div class="post-metadata">

**Author:** ![asymmetric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/asymmetric/32/16577_2.png) [@asymmetric](https://discourse.processing.org/u/asymmetric)\
**Post date:** [October 31, 2022, 6:41pm UTC](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364/38 "2022-10-31T18:41:15Z")

</div>

Hi @chrisir & @glv ! I read your code, as well as my code and I re-read the chapter on objects, yet I am still feeling confused as to how to connect the dice values to the value of the pixels… Can you steer me in the right direction?

```auto
PImage img;

void setup(){
  size(700,700);
  img = loadImage("IMG_7741.jpeg");
  img.resize(800,800);
}

void draw(){
  background(#f1f1f1);
  //noSrtoke();
  
  float tilesX = 80;
  float tilesY = tilesX;
  
  float tileW = width / tilesX;
  float tileH = height/ tilesY;
 
  for (int x = 0; x < tilesX; x++){
    for (int y = 0; y < tilesY; y++){
     
      int px = int(x);
      int py = int(y);
      color c = img.get(px,py);
      
      fill(c);
      
      float b = brightness(c);

      float s = map(b, 0, 255, 0, 7); // 1-6 dice sides
      Die die = new Die(x*tileW, y*tileH );
      
      float sc = tileW/50; //50 is size of die face
      println(sc, 1/sc);

      push();
      scale(sc, sc);
      //int s = int(random(0, 7)); // This will give 0 to 6! Use print() to see this before and after int()
      die.show(1/sc*px, 10, s); //Class
      //show(1/sc*px, 10, s); // Function
      pop();
      }
   }
}
class Die
{
  //variable declarations here
  int dots;
  float myX;
  float myY;

  Die(float x, float y) //constructor
  {
    int dots = s;
    float myX = x;
    float myY= y;
  }

  void show(float myX, float myY, float dots )
  {
    fill(255,255,255);
    dots = s;
    rect(myX, myY, 50, 50);
    fill(0, 0, 0);

    if (dots == 1)
    {
      ellipse(myX+25, myY+25, 10, 10);
    } else if (dots == 2)
    {
      ellipse(myX+10, myY+40, 10, 10); 
      ellipse(myX+40, myY+10, 10, 10);
    } else if (dots == 3)
    { 
      ellipse(myX+10, myY+40, 10, 10); 
      ellipse(myX+25, myY+25, 10, 10); 
      ellipse(myX+40, myY+10, 10, 10);
    } else if (dots == 4)
    { 
      ellipse(myX+10, myY+40, 10, 10); 
      ellipse(myX+10, myY+10, 10, 10); 
      ellipse(myX+40, myY+40, 10, 10); 
      ellipse(myX+40, myY+10, 10, 10);
    } else if (dots == 5)
    { 
      ellipse(myX+10, myY+40, 10, 10); 
      ellipse(myX+10, myY+10, 10, 10); 
      ellipse(myX+40, myY+40, 10, 10); 
      ellipse(myX+40, myY+10, 10, 10); 
      ellipse(myX+25, myY+25, 10, 10);
    } else if (dots == 6)
    { 
      ellipse(myX+10, myY+40, 10, 10); 
      ellipse(myX+10, myY+25, 10, 10); 
      ellipse(myX+10, myY+10, 10, 10); 
      ellipse(myX+40, myY+10, 10, 10); 
      ellipse(myX+40, myY+25, 10, 10); 
      ellipse(myX+40, myY+40, 10, 10);
    }
  }
}

```

---

<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 31, 2022, 6:45pm UTC](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364/39 "2022-10-31T18:45:46Z")

</div>

> [@asymmetric](#):
>
> `die.show(1/sc*px, 10, s); //Class`

maybe here you use the position parameters  
x_tileW , y_ tileH, s

Otherwise test it and debug it

---

<div class="post-metadata">

**Author:** ![asymmetric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/asymmetric/32/16577_2.png) [@asymmetric](https://discourse.processing.org/u/asymmetric)\
**Post date:** [October 31, 2022, 7:59pm UTC](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364/40 "2022-10-31T19:59:42Z")

</div>

> [@Chrisir](#):
>
> Otherwise test it and debug it

```auto
Die(float x, float y) //constructor
  {
    int dots = s;
    float myX = x;
    float myY= y;
  }

```

“s cannot be resolved to a variable”

[Previous page](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364.md?page=1)

[Next page](https://discourse.processing.org/t/creating-a-grid-of-dice-representing-an-image/38364.md?page=3)
