Use AI and Python to make *.svg graphics
Use AI and Python to make *.svg graphics

Use AI and Python to make *.svg graphics

Tags
illustratorpythonai
Date
January 11, 2024
Class
Author
Z
Zach
Class Section
Documentation Type
tutorial

Introduction

AI image generation using tools like DALL-E is cool. But what about using AI text tools to generate code which produces graphics? The difference is subtle but useful for those of us in the digital fabrication realm; using these methods, we can directly produce vector graphics! No more image tracing! As an added bonus, we can also modify the code used to generate the graphics. Very nice.

Prerequisites

A basic familiarity with Python is helpful but not required for this tutorial. You can pick it up as you go by examining code snippets, just know that it may be more time-efficient to run through an introductory Python tutorial first. You will need access to a computer with sufficient permission to install software; note that once this part is completed you can continue as a normal user, so perhaps a proximate IT professional can assist with the initial set-up.

drawsvg setup

Wrangling Python

Setting up the library

First shapes

Programs

Generating code with AI chatbots

From here, you could manually write routines which call the drawsvg library. This is a terrific exercise; head over to the documentation and run through a few examples, and then start building. But using AI tools is also fun! For this we use Playlab, which gives us easy access to state-of-the-art language models like GPT-4 Turbo.

Vector Graphics from GPT-4 Turbo