Accidental rain – random() in the Khan Academy draw function

One of the Code Club members (6th grade) was using the draw function in Khan Academy to make a picture of a rainy day. She used ellipses to draw billowing clouds, and yellow triangles to make lightning. When she wanted to add the rain, she applied one of the most important computer programmer attributes – laziness – and ran into a little bit of serendipity.

You see, this young programmer wanted to draw a lot of tiny lines to represent the rain, but she did not want to manually enter parameters for each of those lines. So she tried to use the javascript random method to create lots of lines with different endpoints.

But the Khan academy program automatically calculates everything and redraws the picture as fast as the compute will let it. So instead of seeing lots of tiny lines, she saw a constantly changing line that looks like animated rainfall. Happy with that result, she replicated the process to fill the picture with rain.

Take a look at the final product:


Spin-off of “rainy day”

Made using: Khan Academy Computer Science.

Leave a Reply

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