Make Digital Art With JavaScript

Make Digital Art With JavaScript

Learn the basics of p5.js

Full disclosure — you won’t be an expert at creating digital art by the end of this article. However, you will learn the basics of it, and have a starting point to venture onto much bigger projects.

We will be working on creating a canvas filled with random geometric shapes. Is it possible to make something much more exciting with p5? Absolutely. Check out the example projects in the docs.

In this article, however, we’ll be sticking to simple geometries. This is to ensure that the complexity of the project does not deter us from learning the essentials. Let’s save the exciting pieces for the future, and dive into this one for now.

Set up the HTML

We’ll setup a backbone for the web page, and then never touch the HTML again. Our HTML needs to do two things. First it needs to link all the files necessary for our project — the p5.js library, our JS script, and the style-sheet. Then, it also needs to set up a division onto which we’ll later mount the canvas (remember the id of “shapes” for later).

Note : I’ve decided to import p5.js using the CDN, but please feel free to download it to your machine, and use it locally.

<!DOCTYPE html>
<html>
    <head>
        <title>Shapes</title>
        <link rel="stylesheet" href="shapes.css">
    </head>
    <body>
        <div class="frame">
            <h1>Familiar Shapes</h1>
            <div id="shapes" class="art"></div>
        </div>
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.js"></script>
        <script src="shapes.js"></script>
    </body>
</html>

javascript beginner art

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

JavaScript Shopping Cart - Javascript Project for Beginners

JavaScript Shopping Cart - javascript shopping cart tutorial for beginnersBuy me a coffee 🍺 https://www.paypal.com/paypalme/ziddahSource Code: https://bit....

JavaScript Game Tutorial for Beginners

In this JavaScript game tutorial for beginners I will take you step by step though a complete game development process. We will improve our front end web development coding skills and learn about ES6 syntax, event listeners, how to control CSS styles and classes with JavaScript, what's the difference between setTimeout and setInterval, how to use clearInterval, difference between const and let variables and between regular JavaScript functions and ES6 arrow functions and much more.

Introduction With Basic JavaScript

Introduction With Basic JavaScript - Unlike most programming languages, the JavaScript language has no concept of input or output. It is designed to run as a scripting language in a host environment, and it is up to the host environment to provide mechanisms for communicating with the outside world.

JavaScript Guide For Beginners

Making JavaScript to be learned within a week. It can be difficult when you start learning a new language if you’re a beginner in programming. Here, I’ll give you a guide for learning JavaScript.

The essential JavaScript concepts that you should understand

The essential JavaScript concepts that you should understand - For successful developing and to pass a work interview