# How about the code when the ball is retracted and returned to its original position?

**URL:** <https://discourse.processing.org/t/how-about-the-code-when-the-ball-is-retracted-and-returned-to-its-original-position/5507>\
**Category:** Coding Questions\
**Created:** [November 13, 2018, 6:54pm UTC](https://discourse.processing.org/t/how-about-the-code-when-the-ball-is-retracted-and-returned-to-its-original-position/5507 "2018-11-13T18:54:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alk5603](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@alk5603](https://discourse.processing.org/u/alk5603)\
**Post date:** [November 13, 2018, 6:54pm UTC](https://discourse.processing.org/t/how-about-the-code-when-the-ball-is-retracted-and-returned-to-its-original-position/5507/1 "2018-11-13T18:54:37Z")

</div>

[![](https://img.youtube.com/vi/yvaAZ7-Qi-M/hqdefault.jpg "mov3") ](https://www.youtube.com/watch?v=yvaAZ7-Qi-M&t=7)

float rot = PI;  
float d\_rot = 0.05;  
float xoff = 0.0;  
float xincrement = 0.01;  
//float xoff\_xincrement = 0.05;

void setup() {  
size(800, 800);  
noStroke();  
fill(255);  
}

void draw() {  
background(0);  
translate(width/2, height/2);

rot += d\_rot;  
rotate( rot );

ellipse(0, 200, 40, 40);

rotate(radians(120));  
ellipse(0, 200, 40, 40);

rotate(radians(120));  
ellipse(0, 200, 40, 40);  
// With each cycle, increment xoff

// Create an alpha blended background  
fill(0, 10);  
rect(0,0,width,height);

//float n = random(0,width); // Try this line instead of noise

// Get a noise value based on xoff and scale it according to the window’s width  
float n = noise(xoff)\*width;

// With each cycle, increment xoff  
xoff += xincrement;

// Draw the ellipse at the value produced by perlin noise  
fill(200);  
ellipse(n,height/2, 64, 64);  
}

// When the mouse is pressed,  
void mousePressed(){  
// If there is no rotation right now,  
if( d\_rot == 0 ){  
// Start doing rotation.  
d\_rot = 0.03;  
} else { // Or if there was some,  
// Stop doing rotation.  
d\_rot = 0;  
}  
}

---

<div class="post-metadata">

**Author:** ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)\
**Post date:** [November 13, 2018, 7:29pm UTC](https://discourse.processing.org/t/how-about-the-code-when-the-ball-is-retracted-and-returned-to-its-original-position/5507/2 "2018-11-13T19:29:57Z")

</div>

You expect us to do that for you?

You did not even format your code which means you haven’t even read the pin thread on how to ask question which you are suppose to read before posting something. I’m speaking of this one in case you are interested: [Guidelines—Tips on Asking Questions](https://discourse.processing.org/t/guidelines-tips-on-asking-questions/2147)

And most importantly you don’t even write a sentence in your post… I’m not even speaking of politeness words like “hello” or “please” or “thanks”… I’m just speaking of the fact that there is not a single word… just a video and your code…

So please edit your post and be more friendly, maybe someone will consider helping you then.

And trust me, I’m taking on me to not be rude!

---

<div class="post-metadata">

**Author:** ![alk5603](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@alk5603](https://discourse.processing.org/u/alk5603)\
**Post date:** [November 14, 2018, 1:21am UTC](https://discourse.processing.org/t/how-about-the-code-when-the-ball-is-retracted-and-returned-to-its-original-position/5507/3 "2018-11-14T01:21:34Z")

</div>

Sorry Poor english 😓😓

When the mouse is pressed, it turns around the circle and retracts at the same time. When the mouse is released, it returns to the original radius.
