Final class magiccolorsutiles
{
// Grain = is the gradient Granularity
Public static final void drawstatebar (Graphics g, int RGB, int X, int y, int WID, int HIG, int grain)
{
Int [] rgb1 = {(RGB & 0xff0000) >>> 16, (RGB & 0x00ff00) >>> 8, RGB & 0x0000ff };
Int [] xyz = new int [3];
For (Int J = 0, K = 0; j <= HIG/2; j ++, K + = grain)
{
If (rgb1 [0] + k) <0xff)
XYZ [0] = rgb1 [0] + K;
Else
XYZ [0] = 0xff;
If (rgb1 [1] + k) <0xff)
XYZ [1] = rgb1 [1] + K;
Else
XYZ [1] = 0xff;
If (rgb1 [2] + k) <0xff)
XYZ [2] = rgb1 [2] + K;
Else
XYZ [2] = 0xff;
G. setcolor (XYZ [0], XYZ [1], XYZ [2]);
G. drawline (X, Y + J, x + WID, Y + J );
G. drawline (X, Y + hig-J, x + WID, Y + hig-j );
}
}
Public final static void drawshaderect (Graphics g, int color, int X, int y, int width, int height)
{
Int [] RGB = getshadecolor (color, width );
For (INT by = y; by <Y + height; by + = 4)
{
Int ntemp = Y + height-(by-y );
Ntemp = ntemp> 4? 4: ntemp;
G. drawrgb (RGB, 0, width, X, by, width, ntemp, true );
}
}
Public final static int [] getshadecolor (INT color, int width)
{
Int [] RGB;
Int shadewidth = width;
Int nrgbdata = shadewidth <2; // shadewidth * 4
RGB = new int [nrgbdata];
Intalpha =-127;
For (INT I = 0; I <shadewidth; I ++)
{
Alpha =-127 + I;
// The main algorithm is here.
Int Col = color | (128-Alpha <24 );
RGB [I] = Col;
RGB [I + shadewidth] = Col;
RGB [I + shadewidth * 2] = Col;
RGB [I + shadewidth * 3] = Col;
}
Return RGB;
}
}