# Anyone can help me with scaling?

**URL:** <https://discourse.processing.org/t/anyone-can-help-me-with-scaling/28673>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [March 20, 2021, 5:42am UTC](https://discourse.processing.org/t/anyone-can-help-me-with-scaling/28673 "2021-03-20T05:42:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![olia](https://avatars.discourse-cdn.com/v4/letter/o/91b2a8/32.png) [@olia](https://discourse.processing.org/u/olia)\
**Post date:** [March 20, 2021, 5:42am UTC](https://discourse.processing.org/t/anyone-can-help-me-with-scaling/28673/1 "2021-03-20T05:42:40Z")

</div>

Sorry my eng not that good.  
So i created pattern with my own function and than used loop (i think u dont understand so just try my code)

```auto
float a=0.0;
int x = -20;
int y = -20;
int rad = 50;
int dod = 50;
void setup() {
  size(500, 500);
}
void draw() {
  noFill();

  while (x>520);
  {
    drawPattern(x, y, rad, rad);
    drawPattern(x, 30, rad, rad);
    drawPattern(x, 80, rad, rad);
    drawPattern(x, 130, rad, rad);
    drawPattern(x, 180, rad, rad);
    drawPattern(x, 230, rad, rad);
    drawPattern(x, 280, rad, rad);
    drawPattern(x, 330, rad, rad);
    drawPattern(x, 380, rad, rad);
    drawPattern(x, 430, rad, rad);
    drawPattern(x, 480, rad, rad);
    x=x+50;
  }
}
void drawPattern(int x, int y, int rad, int rad2) {
  strokeWeight(2);
  ellipseMode(CORNER);
  stroke(0, 0, 255);
  ellipse(x, y, rad, rad);
  ellipseMode(CENTER);
  stroke(255, 0, 0);
  rect(x, y, rad, rad);
  stroke(0, 255, 0);
  ellipse(x+50, y+50, rad/2, rad2/2);
}

```

SOOO now i need to Increase the initial size of the pattern until  
the radius will not be 4 times larger than the original

_ **this is an example of how my pettern should move** _

```auto
int x = -20;
int y = -20;
int rad = 50;
float a=0.0;
void setup() {
  size(500, 500);
}
void draw() {
  noFill();
  background(0);
  translate(0, 0);
  scale(sin(a) + 2);
  strokeWeight(2);
  ellipseMode(CORNER);
  stroke(0, 0, 255);
  ellipse(x, y, rad, rad);
  ellipseMode(CENTER);
  stroke(255, 0, 0);
  rect(x, y, rad, rad);
  stroke(0, 255, 0);
  ellipse(x+50, y+50, rad/2, 25);
  a += 0.1;
}

```

i hope u will help me

---

<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:** [March 20, 2021, 10:38am UTC](https://discourse.processing.org/t/anyone-can-help-me-with-scaling/28673/2 "2021-03-20T10:38:28Z")

</div>

Hello,

If you want to see what your original code is doing add this to setup():  
`frameRate(1);` // Slows things down for debugging or as needed

And add this to your while() loop:  
`println(frameCount, x);` //Prints to console

Consider:

- Adding background() to draw()
- Replacing the while() loop with a for() loop to increment x or a do while() loop
- Using a nested for() loop for x and y; see references and last example.
- map() and mouseX() are useful for interaction and I often use this for code development; move the mouse and change a value!  
See examples in references.

References:

- [for \ Language (API) \ Processing 3+](https://processing.org/reference/for.html)
- [frameRate() \ Language (API) \ Processing 3+](https://processing.org/reference/frameRate_.html)
- [map() \ Language (API) \ Processing 3+](https://processing.org/reference/map_.html)

You are a beginner so take it one step at a time.

`:)`

---

<div class="post-metadata">

**Author:** ![olia](https://avatars.discourse-cdn.com/v4/letter/o/91b2a8/32.png) [@olia](https://discourse.processing.org/u/olia)\
**Post date:** [March 25, 2021, 5:41am UTC](https://discourse.processing.org/t/anyone-can-help-me-with-scaling/28673/3 "2021-03-25T05:41:56Z")

</div>

Thanks, now i understand how i can make my pattern bigger, but i also need to **return it to its original position** (rad=50)

```auto

int x = -20;
int y = -20;
int rad = 50;
void setup() {
  frameRate(10);
  size(500, 500);
}
void draw() {
  background(200);
  noFill();
  stroke(random(500), random(500), random(500));
  if (rad<200) {
    rad= rad+1;
  }
  for (int x = -20; x<520; x=x+50)
  {
    println(frameCount, x);
    drawPattern(x, y, rad, rad);
    drawPattern(x, 30, rad, rad);
    drawPattern(x, 80, rad, rad);
    drawPattern(x, 130, rad, rad);
    drawPattern(x, 180, rad, rad);
    drawPattern(x, 230, rad, rad);
    drawPattern(x, 280, rad, rad);
    drawPattern(x, 330, rad, rad);
    drawPattern(x, 380, rad, rad);
    drawPattern(x, 430, rad, rad);
    drawPattern(x, 480, rad, rad);
  }
}
void drawPattern(int x, int y, int rad, int rad2) { 
  strokeWeight(2);
  ellipseMode(CORNER);
  ellipse(x, y, rad, rad);
  ellipseMode(CENTER);
  rect(x, y, rad, rad);
  ellipse(x+50, y+50, rad/2, rad2/2);
}

```

i was trying to do something else with **If** but it doesn’t help me 😢

---

<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:** [March 25, 2021, 10:23pm UTC](https://discourse.processing.org/t/anyone-can-help-me-with-scaling/28673/4 "2021-03-25T22:23:38Z")

</div>

Hello,

Consider an _if/else_ statement:

```auto
  if (rad<200) 
    {
    rad = rad+10; //Speed it up a bit
    }
  else
    rad = ?; // What should rad be set to?

```

Reference:  
_[else \ Language (API) \ Processing 3+](https://processing.org/reference/else.html)_

There are other ways to do this also…

`:)`
