Skip to main content

About this free course

Download this course

Share this free course

Algorithmic Design
Algorithmic Design

Start this free course now. Just create an account and sign in. Enrol and complete the course for a free statement of participation or digital badge if available.

3 Playing with code

The aim of this course is to Design algorithmic wallpaper for a place in your home. You will be playing with code to make algorithmic tiles and then arrange those tiles into a larger wallpaper pattern (see Figure 5).

Described image
Figure 5  Six algorithmically generated wallpaper designs created using code

In this project, you will be using p5.js, which is a programming library that uses the JavaScript programming language and syntax. There are many different programming languages available; for example, you may have heard of Python, Java, or C++. Every language has different strengths and limitations and they have a slightly different syntax – meaning the grammar of commands that they use.

Described image
Figure 6  The logo of the p5.js programming language

We have chosen to use p5.js because it is based on Processing [Tip: hold Ctrl and click a link to open it in a new tab. (Hide tip)] , an open-source software, which was developed for artists and designers for its ease of use and its ability to quickly get visual output onto the screen.

Here is a talk by Lauren McCarthy, one of the founders of p5.js, about the origins and spirit of the p5.js language. It is a lovely video, but you only need to watch the first 14 minutes or so.

Download this video clip.Video player: Video 2
Copy this transcript to the clipboard
Print this transcript
Show transcript | Hide transcript
Video 2  Lauren McCarthy discusses the making of p5.js
Interactive feature not available in single page view (see it in standard view).

P5.js allows us to embed a code editor into the module website, so you don’t need to install any software on your computer to put your learning into practice. Any p5.js code you create can be embedded in any website, so anything you create in this topic can be shown on your personal website for the whole world to see.

There are many useful p5.js resources online, and the best place to start is the p5.js website. The website has many examples and tutorials, as well as a detailed reference section that lists all the syntax of the language.

There is also a very good p5.js web editor, which gives you lots of space to see and edit your code. You might find it useful to use this editor to work on the code that has been provided for you as part of the learning material, rather than using the embedded code editor.

Throughout this topic, there are some conventions used in the example code which aren’t strictly necessary, but are good coding practice and will help with translation into other coding languages. For example, you will notice that code is indented and that semicolons are frequently used at the end of a line of code, but there are only a few occasions where this is strictly necessary in JavaScript.