# Computer-Generated Yarn Art

259

## Introduction: Computer-Generated Yarn Art

Hello again. Today I will be making a bit of a departure from my usual field of electronics. I will be making... art! Honestly, I don't really care about visual art. The only exposure I have had to art is when I was six and my mom gave us kids paint, brushes, and a canvas. The result was hideous. So no, I do not have what would be called "an artistic mind." The piece I will create is designed by a Python program. Before you get any ideas of a neural network making paintings that sell for millions, let me stop you. I do not have programming skills anywhere near that level. Still, I am fascinated by computer- generated art, so I am using a very simple Python program with a random number generator to decide what the art looks like. String art (using yarn to connect different points, forming a picture) like this is all over the internet, so I decided to do put my own personal spin on this cliche art project. The computer will randomly generate coordinates that fall within your parameters. However, the points will not only be determined by the computer, so will the color of each segment of yarn. Yes, it gets complicated.

## Step 1: Gather Materials

The Bill of Materials is as follows:

• Red, Green, and Blue Yarn- you need quite a bit, refer to picture above (Amazon, Amazon, Amazon)
• 4' x 2' Pegboard (Virtually Any Home Improvement Store)*
• Hot Glue Gun/ Plenty of Glue
• Scissors
• Computer, of which you obviously have
• Patience
• Sharpie

*The size of your pegboard depends on preference, but some of the code will have to be altered. See the next step for more information. Also, you don't really have to use a pegboard. Any large plane that can be clearly labeled with coordinates will work.

## Step 2: The Program

The easiest part of this project is the programming. The Python script is a mere 20 lines long, and really only took me three minutes to write. Here's the GitHub link: https://github.com/u92master/Yarn_Art. Basically, the code generates three random integers with different parameters- (1 , 24) for the X value, (1 , 48) for the Y value, and (1 , 3) for the three color options. Also, the value of the second argument on line 8 (in my case I used 80) is dependant on how much work you are willing to put into the project, as this value affects the number of segments of yarn there will be. The more segments you do, the more abstract your art will be (After working past 11:00 PM I decided to be satisfied with my 41 segments). Another value in the program depends on how large your pegboard is. My pegboard has 24 x 48 holes, so I used the parameters (1 , 24) and (1 , 48). The second number in the parenthesis depends on the width and height of your board to determine the X and Y axes, respectively. So make sure you count properly!

## Step 3: Glue on the Points

First, run the program. Open Python, then copy/paste the code from GitHub. Run the script, and Voila! The values in the terminal will appear with a 1/2 second delay. The code explains how the information is formatted. To make it easier to locate the coordinates before gluing on the yarn, I labeled numbers the X and Y axis with Sharpie, as shown above. Now you can start gluing. The first value that appears (eg: 10 , 20 | RED) will tell you where to go from the first point, which is (1 , 1). After gluing the 2 points of the segment, read the next line of the program to see where to go from there. Repeat this process until the program's data has ended (or your patience runs out, and you just want to stop). After you are finished gluing the intersecting points, hot glue the last point, and write "END", just in case you ever want to add on to your odd little art project. There is only one more step from here.

## Step 4: Step Back

Now it's time to just step back from your work and enjoy (or not) your string art. I'm sure many people will think they wasted two hours or so. For those that think art designed by chance is cool, I'm glad. Please vote for me in the Rainbow Contest if you enjoyed this Instructable in any capacity. Thanks for reading.

Participated in the
Colors of the Rainbow Contest

2 196
43 8.4K
10 945
30 1.8K