Use the color in the development of the mobile phone program

Source: Internet
Author: User
Tags getcolor

Use the color in the development of the mobile phone program

Author: Chen yuefeng



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.

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: 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.