JavaScript tutorial: Create a textured paper background with P5.js

Last week I introduced the concept of generative art, P5.js, and some of the setup woes with P5.js. I left you with a scaffolding repository that gets all the project setup headache out of the way, but we didn’t dig into making anything yet. This week, we’ll begin the process of actually making some art.

We’re going to start simple by introducing some basic API concepts and build in just the right amount of randomness while we create the “paper” for our watercolor effect. Getting the look and feel of the paper just right is important with any watercolor. It’s also going to help get us get into the mindset of emulating the real world in a digital space.

The goal of the rest of this post is to create the effect of real paper for the background of our watercolor. I’d like our paper to be an off-white, cream, or beige color, and it should have a little texture to it. Note that I’m calling our background “paper” (the thing I’m trying to mimic) and not “the canvas element” (the implementation terminology).

Thinking in terms of the real world rather than the digital space is a little mental trick to get me out of the implementation details and help guide my intuition.

Create a color background in P5.js

Our scaffolding already has a bit of P5 code in it, so we can use the existing setup function to get started.

Espruino Pico STM32 ARM Cortex M4 USB JavaScript On Board FETEspruino-Pico-SBC-STM32-ARM-Cortex-M4-USB-JavaScript-On-Board-FET-Espruino-ESPRUINO-PICO-PINNED-p-The-Espruino-Pico-is-a-revolutionary-tiny-single-board-computer-that-features-JavaScript-and-a-USB-connection-allowing-the-control-of-electronics-quickly-and-easily-The-Pico-has-an-STM32-ARM-Cortex-M4-microcontroller-pre-programmed-with-the-Espruino-IDE-so-it-easy-to-get-up-and-running-The-on-board-USB-Type-A-connector-makes-integration-easy-and-an-on-board-voltage-regulator-will-accept-input - More Info

Nano BreadBoard Kit w/ IO Board / Sensors / LCD Module / TutorialNano BreadBoard Kit w/ IO Board / Sensors / LCD Module / Tutorial - More Info

Franzis 65279 Arduino Tutorial KitFranzis-65279-Arduino-Tutorial-Kit-Franzis-9783645652797-P-The-Franzis-Arduino-Tutorial-kit-will-let-you-kick-start-your-Arduino-programming-with-the-components-and-the-instructions-you-need-to-get-familiar-with-this-popular-microcontroller-Whether-you-want-to-build-a-home-automation-system-or-an-LED-lamp-with-changing-colours-this-Arduino-kit-will-show-you-how-to-write-your-first-programs-and-implement-your-very-own-ideas-In-this-tutorial-kit-you-will-discover-the-basics-of-electronics-a - More Info

Blue LED Electronic Digital Clock Time Thermometer Microcontroller Digital Clock DIY Kit With Tutorial BlueBlue LED Electronic Digital Clock Time Thermometer Microcontroller Digital Clock DIY Kit With Tutorial Blue - More Info

White Color LED Electronic Clock Microcontroller Digital Clock Time Thermometer DIY Kit With PDF Tutorial BlackWhite Color LED Electronic Clock Microcontroller Digital Clock Time Thermometer DIY Kit With PDF Tutorial Black - More Info

You may also like...

       
Apps & Games Clothing Electronics & Photo Large Appliances
Baby Womens Apparel Garden Lighting
Beauty Mens Apparel Outdoors Luggage
Books Girls Apparel Health & Personal Care Pet Supplies
Car Boys Apparel Home Shoes & Bags
Motorbike Computers & Accessories Kitchen Equipment Sports & Outdoors
Fashion DIY & Tools Jewellery Toys & Games