Color gradient and transparency processing of j2-based ECs

Source: Internet
Author: User

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;
}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.