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 9 255 0 0


c 19 255 165 0


c 29 0 128 0


c 39 0 0 255


c 49 255 0 255


p 31.286893008046174 -197.53766811902756


p 61.80339887498949 -190.21130325903073


p 90.79809994790936 -178.20130483767358


p 117.55705045849463 -161.80339887498948


p 141.4213562373095 -141.4213562373095


p 161.80339887498948 -117.55705045849463


p 178.20130483767355 -90.79809994790936


p 190.21130325903067 -61.803398874989504


p 197.5376681190275 -31.286893008046214


p 199.99999999999994 -6.394884621840902e-14


p 197.5376681190275 31.286893008046086


p 190.21130325903067 61.80339887498938


p 178.20130483767352 90.79809994790924


p 161.80339887498945 117.55705045849447


p 141.42135623730948 141.42135623730934


p 117.55705045849464 161.8033988749893


p 90.7980999479094 178.20130483767338


p 61.80339887498957 190.2113032590305


p 31.28689300804629 197.5376681190273


p 1.5987211554602254e-13 199.99999999999974


p -31.286893008045972 197.5376681190273


p -61.80339887498924 190.21130325903047


p -90.79809994790908 178.20130483767332


p -117.55705045849432 161.80339887498926


p -141.42135623730914 141.42135623730928


p -161.80339887498906 117.55705045849444


p -178.20130483767312 90.79809994790921


p -190.21130325903022 61.80339887498938


p -197.53766811902702 31.286893008046114


p -199.99999999999946 -5.329070518200751e-15


p -197.53766811902702 -31.286893008046125


p -190.2113032590302 -61.803398874989384


p -178.20130483767304 -90.7980999479092


p -161.80339887498897 -117.5570504584944


p -141.421356237309 -141.42135623730923


p -117.55705045849416 -161.80339887498914


p -90.79809994790895 -178.20130483767318


p -61.80339887498913 -190.21130325903027


p -31.286893008045876 -197.53766811902707


p 2.327027459614328e-13 -199.99999999999952





Answered 4 days AfterNov 29, 2021

Answer To: The String Art Machine General description You will create a “Programmable String Art Machine”,...

Arun Shankar answered on Dec 03 2021
127 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