Tinier Numbers
|
|
Tinier Numbers: These numbers are all 3X5 images. You will
also notice that a number of colors are used. There are three strategies
which could be used to set colors. These strategies are described below.
|
Strategy One: Create an arrays like this:
int[] a1={0,1,0,
0,1,0,
0,1,0,
0,1,0,
0,1,0};
Then when setting pixel color multiply by Color.red.getRGB().
Strategy Two: Create arrays as before, but this time multiply
by raw numbers like this:
pix[i]=(255<<24)|(255<<16)|(255<<8)|255; //white
or
pix[i]=(255<<24)|(255<<8); //blue
Strategy Three: Create arrays using different numbers for
different colors like this:
int[] a1={0,1,0,
0,1,0,
0,1,0,
0,1,0,
0,1,0};
int[] a2={2,2,2,
0,0,2,
2,2,2,
2,0,0,
2,2,2 };
Then simply use these numbers when assigning colors like this:
if(arr[i]==0) pix[i]=Color.black.getRGB();
else if(arr[i]==1) pix[i]=Color.red.getRGB();
etc.