Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Working with for loops. String art is a form of art made by wrapping the colored string around a pattern of nails. First, you are

Working with for loops.

image text in transcribed

image text in transcribed

String art is a form of art made by wrapping the colored string around a pattern of nails. First, you are going to calculate the x, y coordinates of the nails. You will be using a Drawing Panel of size 401 by 401 (coordinate value are 0 - 400). Write a for loop counting from 0 to 20. Your first task is to calculate and print the coordinates of the A points as shown in the diagram above. The coordinates are A0 = (0, 400), A1 = (0, 380), A2 = (0, 360) ... A20 = (0, 0). Print out the result just like this. Next write loops to calculate and print the B, C, and D coordinates. Now create a 401 by 401 Drawing Panel and draw all of the edge nails as 1-pixel ovals. Write a new for loop from 0 to 20 and draw the lines connecting A0 to BO, A1 to B1, etc. You can choose the colors. You will be using the same formulas to calculate the points that you used to draw the nails. Once you get the previous part working perfectly, copy and paste It, and then modify it to draw the C-D corner gusset. Next, you are going to calculate and draw the circle nails. The nail locations are every 10 degree around a circle centered at (200, 200) and with radius 140. Remember your trigonometry: x = center X + radius * cos (angle) y = center Y + radius * sin (angle) We like to think about angles in degrees, but Java's Math package uses radians. Before you call Math. cos () and Math. sin (), use Math to Radians () to convert an angle from degrees to radians. Print your results. You should get E0 = (340.0, 200.0), E1 = (337.8, 224.3), E2 = (331.5, 247.8)... Once you have the formulas correct, draw the nails. Draw Oval (int x, int y, int w, int h) accepts only integer parameters. Use casting (int) to convert your coordinates to integers. There are two circle patterns drawn using the same nail points. The bottom circle pattern is drawn in cyan (light blue) has a line from each nail to the nail 140 degrees further around the circle. Calculate both points and draw the circle pattern. Draw the top circle in a different color. It connects nails to points 100 degrees further around the circle. If you need inspiration, search the web for "String Art

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions

Question

Knowledge of project management (PMI) teachings

Answered: 1 week ago