Android color rendering (3) Shader color rendering

Source: Internet
Author: User

Application Color Rendering. First, we need to introduce several important classes about color rendering in the Android Api:
Shader, BitmapShader, ComposeShader, LinearGradient, RadialGradient, and SweepGradient:
Public class Shader extends Object
This class is used as the base class to return the horizontal span of the color during painting. Its subclass can be used with Piant. Use piant. setShader (Shader shader); to achieve some rendering effects. The role of the image does not work with bitmap.
The constructor is the default constructor. Enumeration:
Emun Shader. TileMode
Three tile modes are defined:
Static final Shader. TileMode CLAMP: edge stretch.
Static final Shader. TileMode MIRROR: alternate between the horizontal and vertical directions. there is no gap between the two adjacent images.
Static final Shader. TillMode REPETA: it is repeatedly placed in the horizontal and vertical directions, and there is a gap between the two adjacent images.
 
Method:
1. boolean getLoaclMatrix (Matrix localM); returns true if the shader has a non-local Matrix.
LocalM: if it is not null, It is set as the local matrix of the shader.
2. void setLocalMatrix (Matrix localM); set the local Matrix of the shader. If localM is empty, the local Matrix of the shader is reset. Direct subclass of Shader: BitmapShader: bitmap image rendering LinearGradient: Linear rendering RadialGradient: Annular rendering SweepGradient: Scan gradient rendering/gradient rendering ComposeShader: ComposeShader, it can be combined with several other sub-classes to see if it is similar to the relationship between Animation and its sub-classes (AlphaAnimation, RotateAnimation, ScaleAnimation, TranslateAnimation, and AnimationSet) with specific rendering effects, there are also a combination of rendering effects. The following describes how to use the Shader: 1. build a Shader object 2. set the rendering object through the setShader method of Paint 3. set the rendering object 4. this Paint object is used for painting.
 

Related Article

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.