Turning a simple grid into readable grid references?

So I have a small piece of code that I eventually would like to turn into something more advanced but for now I need to figure out how to make the computer understand that each of the squares shown is a specific grid reference (aka coordinate) on the screen.

This I do now know how to do, was wondering if I gave the code I have now if someone could help adapt it to what I need would be super awesome. Thanks

Code bellow:

`size(500,500); int cols = width; int rows = height;

// Declare 2D array int[][] myArray = new int[cols][rows]; // Initialize 2D array values for (int i = 0; i < cols; i+=50) { for (int j = 0; j < rows; j+=50) { myArray[i][j] = int(random(255)); } }

// Draw points for (int i = 0; i < cols; i+=50) { for (int j = 0; j < rows; j+=50) { stroke(myArray[i][j]); fill(myArray[i][j]); rect(i,j,50,50); } }`

Tagged:

Answers

Sign In or Register to comment.