Trouble With While Function

var x = 0;
while(x < 390)
fill(0, 119, 255);
x = x + 50;

the above code is supposed to be a shorthand for the code you see below and it is supposed to give me the same result as you see in the diagram on the right side of the image - a row of numbers across the top of the window - but I get nothing - any idea where I am going wrong?

I don’t see an image here so I’m not sure it got uploaded.

You have a bunch of things that don’t match up, such as fill() being different (you only need to call this once outside of the loop), textSize() is being used which wasn’t before, and you’re not passing in 10 (which should be 20 to match the new text size now) to bring the text down. The last one is probably why you’re not seeing anything. Text is drawn from the bottom up, more or less, so with using 0 for the 3rd argument of text() is going to cause the text to be drawn off screen. Changing that to a 20 should help.

Yes indeed that did help - very nice analysis of the problem - in fact it did solve the issue - thanks !

1 Like