Use the color in the development of the mobile phone program
Author: Chen yuefeng
From: http://blog.csdn.net/mailbomb
Color is often used for painting during the development process of the mobile phone program for enhancing the performance of the program. The following describes how to use color.
Due to the relatively simple technology, the special color class is not implemented, but the RGB concept is used to represent the color. Here we will briefly introduce the concept of RGB. colors are composed of three primary colors: Red, green, and blue, therefore, the combination of these three colors can be used to represent a specific color. Each value of R, G, and B is between 0 and. When expressing colors, you can use three numbers or a hexadecimal format, such as 0x00rrggbb. The following is a common expression of colors:
Red :( 255, 0, 0) or 0x00ff0000
Green: (0,255, 0) or 0x0000ff00
White: (255,255,255) or 0x00ffffff
Other colors can also be combined through the above method.
After learning about the color expression, we will introduce how to use the color in the j2s program. The methods involved are in the graphics class, including the following:
1. getcolor ():
Obtain the current color. The returned value is a number in 0x00rrggbb format. For example:
Int color = G. getcolor ();
Where G is a graphics type object.
2. setcolor (int rgb ):
Set the color used. For example:
G. setcolor (0x00ff0000 );
3. setcolor (INT red, int green, int blue)
It works the same way as the preceding method, for example:
G. setcolor (255, 0, 0 );
After the color used by graphics is set, you can draw the specified color.