Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The method should draw the 2D array of ints with the given Graphics object as a series filled 1x1 rectangles with the color set to

The method should draw the 2D array of ints with the given Graphics object as a series filled 1x1 rectangles with the color set to a grayscale value between white and black.

The shade of gray should be scaled to the elevation of the map. Recall, in RGB color, if each of RGB values are the same, youll get a shade of gray. Thus, there are 256 possible shades of gray from black (0,0,0) to middle gray (128,128,128), to white (255, 255, 255).

To make the shade of gray, you should use the min and max values in the 2D array (you just wrote helper methods to find these!) to scale each int to a value between 0 and 255 inclusive. (Note: this requires math! Think about it.) Once you have found your value between 0 and 255, call you need to set the fill color just before drawing the rectangle.

int c = //calculated grayscale value g.setColor(new Color(c, c, c)); g.fillRect(x,y,1,1);

Need help finding what c should be. Min and Max are int variables with the values 4400 (max) and 1300 (min).

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

What Is A Database And How Do I Use It

Authors: Matt Anniss

1st Edition

1622750799, 978-1622750795

More Books

Students also viewed these Databases questions

Question

5. Our efficiency focus eliminates free time for fresh thinking.

Answered: 1 week ago