Quantcast
Viewing all articles
Browse latest Browse all 40524

Skipping a single number in a for loop

If you want to skip every 3rd circle, you can use the modulo operator (%), it gives you the remainder of a division of two values:

for(i = 0 ; i < 12 ; i++){
    if (i % 3 == 0) { //3 divided by 3 has remainder 0, also 6, 9, etc.
        continue;
    } else {
        ofSetColor(200);
        ofCircle(blackLocX[i], blackLocY[i], pieceR);
    }
}

Viewing all articles
Browse latest Browse all 40524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>