I am currently coding a java applet to visual a modified version of breadth first search.
My problem is I am trying to convert a number coordinated to a pixel on a 2d array to a color.
Code : map is a 2d array of values that should be increasing by 1 as they go away from the starting location except for walls which are set to 0 and will appear as black.
String colorhex1 = Integer.toHexString(map[i][j]+100);
g.setColor(Color.decode("#"+colorhex1));
if (map[i][j]==1)
g.setColor(Color.white);
else if (map[i][j]==0)
g.setColor(Color.Black);
g.fillRect(i*10,j*10+40,10,10);
How the main search works is it increases the number of each cell next to it one unless it has been touched so in my visualization it should show a increase in vibrancy as we get farther away from the starting location. However with this design I have currently it will one start off as "black" which is the color of my walls. To which then two it will slowly head towards purple then randomly change color then again and again having it look quite weird.
Question : Is there a way for me to code a more gradual way of increasing this color by using the number value of the map array?