# Need help for this task

**URL:** <https://discourse.processing.org/t/need-help-for-this-task/20771>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [May 12, 2020, 6:18am UTC](https://discourse.processing.org/t/need-help-for-this-task/20771 "2020-05-12T06:18:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jones](https://avatars.discourse-cdn.com/v4/letter/j/6de8d8/32.png) [@jones](https://discourse.processing.org/u/jones)\
**Post date:** [May 12, 2020, 6:18am UTC](https://discourse.processing.org/t/need-help-for-this-task/20771/1 "2020-05-12T06:18:50Z")

</div>

![sample output 03](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/6/6fad48273ea8cd778c73a9e647c616cf4f577cee.jpeg)

```auto
int cellSize = 30;
int radius = cellSize/2;
int ellipseSize = cellSize;
int ellipseSizeMini = 5;
int gap = 0;

void setup()
{
  size (300, 300);
  background(255);
  noStroke();
  
  for (int j=0; j<height; j=j+cellSize)  
    for (int i=0; i<width; i=i+cellSize)  
      fill(0);
      ellipse(i+radius, j+radius, ellipseSize, ellipseSize);   
      
     
     ellipseSizeMini = calculateSizeMini(i, j);
      
      gap = radius-(ellipseSizeMini/2);// [10%] to write an equation which calculates the length of gap between the smaller white circle and the bigger black circle. Hard coding value does not receive any mark
      float shiftX = random(-gap, gap);
      float shiftY = random(-gap, gap);
      fill(255);
      ellipse(i+radius+shiftX,j+radius+shiftY,ellipseSizeMini,ellipseSizeMini); // [10%] fill in the four parameters (each takes 2.5% mark) for this ellipse() so that it draw a white circle on top of its corresponding black circle with size of ellipseSizeMini
    }
}

int calculateSizeMini(int i, int j)
{
  int sizeMax = (int)0.8*ellipseSize;// [5%] to write an equation which generates a value of 80% of ellipseSize to be the maximum possible size of the small white circle. Hard coding value does not receive any mark
  int sizeMin = (int) 0.1*ellipseSize;// [5%] to write an equation which generates a value of 10% of ellipseSize to be the minimum possible size of the small white circle. Hard coding value does not receive any mark
  int answer = ellipseSizeMini;
  

  // [20%] to develop equation(s) and write lines of code here to calculate a value for ellipseSizeMini. This value changes according to i and j. 
  // The value is closed to sizeMax if i and j are closed to the center of the application window, and it closed to sizeMin if i and j are 
  // closed to the edge of the application window. This value will be assigned to the variable of answer as a returning value of this function.
  // The simpler the approach, the higher is the mark.

  return answer;
}

```

---

<div class="post-metadata">

**Author:** ![jones](https://avatars.discourse-cdn.com/v4/letter/j/6de8d8/32.png) [@jones](https://discourse.processing.org/u/jones)\
**Post date:** [May 12, 2020, 6:21am UTC](https://discourse.processing.org/t/need-help-for-this-task/20771/2 "2020-05-12T06:21:47Z")

</div>

i finshed the previous part and the last part just make me crazy. i can’t work this out.

Can someone help me ? The closer a white dot locates toward the center, the bigger it is and vice versa. You should try to solve this problem by simply coding.

---

<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:** [May 12, 2020, 10:22am UTC](https://discourse.processing.org/t/need-help-for-this-task/20771/3 "2020-05-12T10:22:11Z")

</div>

Hello and welcome to the forum!

You can find the distance with `dist()`

See reference please [https://www.processing.org/reference/dist\_.html](https://www.processing.org/reference/dist_.html)

Store the distance in a float variable `distC`

Next step: use map() to get the size of a circle:

`float sizeC= map( distC, 0, width/3, 3, 30);`

to get the size of the circle (between 3 and 30 in the line above)

Warmest regards,

Chrisir
