home logo

It is day – under one condition

This p5js sketch uses conditional statements in order to draw a bright sun on a daylight sky or a full moon and shining stars in a dark blue night sky.

The particular code looks like this:

if (isNight === true) {
sketch.drawNight();
} else {
sketch.drawDay();
}


The initial varibale let isNight = true; is set manually eather to day or night time. It is set with the boolean method of "true" or "false".

The user can alter the sketch by clicking on a button.

You can find the code for this particualt sketch in the following GitHub repository.