{"id":357294,"date":"2021-11-24T07:49:08","date_gmt":"2021-11-24T15:49:08","guid":{"rendered":"https:\/\/css-tricks.com\/?p=357294"},"modified":"2021-11-24T07:49:11","modified_gmt":"2021-11-24T15:49:11","slug":"creating-generative-patterns-with-the-css-paint-api","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/creating-generative-patterns-with-the-css-paint-api\/","title":{"rendered":"Creating Generative Patterns with The CSS Paint API"},"content":{"rendered":"\n
The browser has long been a medium for art and design. From Lynn Fisher’s joyful A Single Div<\/a> creations to Diana Smith’s staggeringly detailed CSS paintings<\/a>, wildly creative, highly skilled developers have \u2014 over the years \u2014 continuously pushed web technologies to their limits and crafted innovative, inspiring visuals.<\/p>\n\n\n\n CSS, however, has never really had an API dedicated to\u2026 well, just<\/em> drawing stuff! As demonstrated by the talented folks above, it certainly can<\/em> render most things, but it’s not always easy, and it’s not always practical for production sites\/applications.<\/p>\n\n\n\n Recently, though, CSS was gifted an exciting new set of APIs known as Houdini<\/a>, and one of them \u2014 the Paint API<\/a> \u2014 is specifically<\/em> designed for rendering 2D graphics. For us web folk, this is incredibly exciting. For the first time, we have a section of CSS that exists for the sole purpose of programmatically creating images. The doors to a mystical new world are well and truly open!<\/p>\n\n\n\n In this tutorial, we will be using the Paint API to create three (hopefully!) beautiful, generative patterns that could be used to add a delicious spoonful of character to a range of websites\/applications.<\/p>\n\n\n\n\n\n\n\n Spellbooks\/text editors at the ready, friends, let’s do some magic!<\/p>\n\n\n This tutorial is perfect for folks who are comfortable writing HTML, CSS, and JavaScript. A little familiarity with generative art and some knowledge of the Paint API\/HTML canvas will be handy but not essential. We will do a quick overview before we get started. Speaking of which…<\/p>\n\n\n For a comprehensive introduction to both the Paint API and generative art\/design, I recommend popping over to the first entry in this series<\/a>. If you are new to either subject, this will be a great place to start. If you don’t feel like navigating another article, however, here are a couple of key concepts to be familiar with before moving on.<\/p>\n\n\n\nIntended audience<\/h3>\n\n\n
Before we start<\/h3>\n\n\n