Learning For Loops: Code

///////////////////
// Hello! This is a for loop tutorial!
// You can copy and paste this on to a new processing sketch!
// By: aisencc
///////////////////
/*
In a for loop you have 3 portions: (init; test; update){ stuff }
The value is first initiated, then tested, then the loop does “stuff”, and then it is updated.

INIT:
An initiating value happens only once the first time the loop runs and it looks like:
int i= 0;
This initiating value is what your number count will start from. Usually we start counting from 0.
We use “i” because in math i is used sometimes in place for an intereger.
If we are using nested forloops we will initiate the value with “j” then “k” and so forth.
We could use “int ilovethisnumber = 0;” but that is just too long.

TEST:
The test is much like the comparator tests we use in if statements, it looks like:
i < height;
i < 100;
This means that once i grows bigger than the height of our sketch the loop will stop.

UPDATE:
The update is the opperation that allows the i to grow or shrink, it looks like:
i–; will subtract 1.
The update is last command to run after each turn of the loop,
and it will stop once the number is to high or too low and fails the test.

Run this sketch and see what happens.
Comment stuff out below, and run one forloop at a time to see which loop is drawing the lines you see
*/

// remember that “//” allows you to comment things out, and not affect the code
// you can also use /* stuff */ to comment stuff out

void setup() {
size(600, 900); //window size
background(255); // white background
stroke(125, 125, 255); // color of our lines

for (int i = 0; i < height; i+=10) {
line(0, i, width, i);
}
for (int i = 0; i < width; i+=10) {
line(i, 0, i, height);
}

stroke(255, 30, 30);

for (int i = height/2; i < height; i = i+5) {
line(0, i, width, i);
}

for (int i = 40; i < 80; i = i+5) {
line(30, i, 80, i);
}
}
//// run this later! 🙂
//void draw() {
// stroke(0);
// for (int i = 0; i < height; i = i+90) {
// line(mouseX, i, mouseY, i);
// }
// for (int i = 0; i < width; i = i+90) {
// line(i, mouseX, i, mouseY);
// }
//}

This entry was posted in Assignment, Uncategorized on by .

Hello! I'm Aisen Caro Chacin, my curiosity led me to research the intersecting fields of art, science, and technology driven by conceptual forms of inquiry and design thinking resulting in functional prototypes. I'm looking forward to seeing your ideas materialize. My inbox is always open.. so say "Hello!".

353 thoughts on “Learning For Loops: Code”

1. Pingback: loli sex games

2. Ruthie

My spouse and I stumbled over here from a different website and thought I might as well check things
out. I like what I see so i am just following you.
Look forward to looking over your web page repeatedly.

3. Tania

Admiring the dedication you put into your blog and in depth information you offer.
It’s nice to come across a blog every once in a while that isn’t the
same outdated rehashed information. Wonderful read!

4. Alma

Heya! I’m at work surfing around your blog from my new iphone!
look forward to all your posts! Carry on the great work!

5. Riley

I simply could not go away your site before suggesting that I extremely loved the standard information a person supply for your
guests? Is gonna be back steadily to investigate cross-check new posts

6. Maxwell

always i used to read smaller posts that as well
clear their motive, and that is also happening with this post which I am reading at this time.

7. Shantae

Hey superb blog! Does running a blog like this take a great
deal of work? I have absolutely no expertise in coding however I had been hoping to start my own blog in the near future.
Anyways, should you have any recommendations or techniques for new blog owners please share.

I understand this is off subject however I simply needed

8. Claudia

Just wish to say your article is as astounding. The clarity in your post is just excellent and i could assume you are an expert on this subject.
Fine with your permission allow me to grab your feed to keep up to date with forthcoming post.
Thanks a million and please keep up the rewarding work.

9. Christian

Hey just wanted to give you a quick heads up and let you know a few of the

I’ve tried it in two different internet browsers and both show the same results.

10. Jermaine

Thanks

11. Whitney

Admiring the time and effort you put into your blog and detailed information you offer.

It’s awesome to come across a blog every once in a while that isn’t
the same old rehashed information. Fantastic read!

12. Leif

Link exchange is nothing else however it is just
place and other person will also do same in support of
you.

13. hi

Hello! I just wanted to ask if you ever have any trouble with hackers? My last blog (wordpress) was hacked and I ended up losing many months of hard work due to no backup. Do you have any solutions to prevent hackers?|

14. Bryan

What’s up Dear, are you genuinely visiting this web page daily,
if so afterward you will definitely get pleasant knowledge.

15. Oren

Great beat ! I wish to apprentice whilst you amend your
site, how can i subscribe for a weblog website?
The account aided me a applicable deal. I had been a little bit familiar of this your broadcast offered brilliant
transparent idea

16. Larhonda

After exploring a few of the articles on your site, I seriously like your technique of writing a
blog. I book marked it to my bookmark webpage list and will be checking back soon. Take a look at my web site as well and tell me
how you feel.

17. Opal

Hi this is somewhat of off topic but I was wondering if blogs use WYSIWYG editors or if you have
to manually code with HTML. I’m starting a blog soon but have no coding skills so I wanted to get advice from someone with experience.
Any help would be enormously appreciated!

18. Pingback: bahis siteleri

19. Pingback: 1floating