Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

The String Art Machine General description You will create a “Programmable String Art Machine”, which is actually a program like we discussed in class on 11/23. Your program will read a file and use...

1 answer below »

The String Art Machine

General description

You will create a “Programmable String Art Machine”, which is actually a program like we discussed in class on 11/23. Your program will read a file and use the information in the file to render a piece of string art in the turtle graphics window. Each line of the input file is really a coded instruction, telling your program where to create a point or how to connect the points to create the artwork.

The tasks

Your program will start by asking the user for the name of an input file. The program then reads each line of the input file and uses the information on that line to do one of two things. If the first character on the line is a ‘p’, the rest of the line will represent the x- and y-coordinates of a point. Your program will place those two numbers into a tuple and add the tuple to an ordered collection of points. The first point described in the file will be the first point in the list of points, the second ‘p’ instruction in the file will create the second point in the list, and so on.

If the first character on a line in the file is a ‘c’, the rest of the line consists of four numbers describing a “connection pattern”. The first of the numbers is a ‘stride’ value, and the last three numbers represent an RGB color code. If the stride is 4 and the color code is (255,0,0), that means that each point in the list of points should be connected, using a red line to the point that is 4 farther down the list – point 0 has a red line connecting it to point 4, point 1 has a red line connecting it to point 5, and so on. Remember that we consider the list of points to be “circular”, so the point after the last point in the list is the first point in the list.

Once the program has read and recorded the information from the entire input file, it should put a 3-pixel black dot at each of the points and then draw all the connecting lines in their proper colors

Example data file

Below is an example data file. The instructions in this file would result in a string art drawing with 40 points. Each point would be connected to 5 points:

· a point 9 farther down by a red line,

· a point 19 farther down by an orange line

· a point 29 farther down by a green line

· a point 39 farther down by a blue line

· a point 49 farther down by a purple line

You can assume that all of the ‘c’ lines would come before any of the ‘p’ lines in the file.

A copy of this data file is attached to the assignment link in Module 9 in Blackboard.

c XXXXXXXXXX

c XXXXXXXXXX

c XXXXXXXXXX

c XXXXXXXXXX

c XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX -6.394884621840902e-14

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p 1.5987211554602254e XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX -5.329070518200751e-15

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p XXXXXXXXXX XXXXXXXXXX

p 2.327027459614328e XXXXXXXXXX XXXXXXXXXX


Answered 4 days After Nov 29, 2021

Solution

Arun Shankar answered on Dec 03 2021
128 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here