Conditional Statements in p5.js

Hey Fellas!

This week we were introduced to some cool things in p5.js: the conditional statements. These features allow the program to make decisions while it is running based on the condition written in the code. True and false. “If”, “while”, “and”, “or” are all boolean expressions.

And_OR_NOT_pics

Does that make any sense? Well for me it did not in the beginning. But after a lot little bit of practice, I started getting more comfortable with using these expressions and they become fun to play with. The conditional statements allows us to create such a greater number of things than the ones we we doing until past week.

So for our weekly challenge we had to create a button or a slide that would interact with an algorithmic design (all of that is created using conditional statements). And we should do it in pairs, collaborating with each-others design.

So I created a button that would turn day into night and also another sketch with a pattern that fills the canvas over and over again. Then I added my classmate’s, Serena Parr, button to my pattern and she made some modifications herself to my “day and night” sketch too!

Check out the results:

Day and night before:

http://techaboom.com/day_and_night/

My algorithmic design pattern:

http://techaboom.com/design_patterns/

Serena’s button:

http://techaboom.com/crazy_to_static/

My algorithmic design with Serena’s button:

http://techaboom.com/mixed_sketches/

One think I don’t know the reason why it is happening is the fact that once you click the button in the last sketch “mixed_sketches”, it may clear the canvas or just pause the pattern’s movement. Its seems that is happening in a random way and I cannot explain why.

Leave a Reply

Your email address will not be published. Required fields are marked *