Suppose that I have the given array:
int[] array = {
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0
};
Would there be a way to draw graphics into that array? For example assume that we have a way to access the data in this array by an x and y coordinate could we make a method that would put a line through this array dependant on 2 coordinates. The code would look something like this:
public void drawLine(int x1, int y1, int x2, int y2) {
...
}
And would transfer something like this:
int[] array = {
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0
};
Into this:
int[] array = {
1, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
0, 0, 0, 1, 0,
0, 0, 0, 0, 1
};
You would have to be able to pass in any set of coordinates and have a calculated line placed through the array. How would I implement this?
Calling drawLine(1,0,3,4) would create something like:
int[] array = {
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
0, 0, 1, 0, 0,
0, 0, 0, 1, 0,
0, 0, 0, 1, 0
};
Also if your up to it is there a way I could specify any number of points and have them all connected and then filled in? (No I don't want to use any libraries).