Android Color Rendering (iii) shader color rendering

Source: Internet
Author: User

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

I believe that after reading the three articles mentioned in the previous article, we have a deeper understanding of color processing.

Before we talk about the effect of color gradients, how do you do that, you need to apply color rendering. Let's start with a few important classes about color rendering in the Android API:

Shader,bitmapshader,composeshader,lineargradient,radialgradient,sweepgradient

Look at the relationship between them:

public class Shader extends Object
The class is primarily a horizontal span that returns the color of the drawing when it is the base class. Its subclasses can function with Piant. by Paint.setshader (Shader Shader); To achieve some rendering effects. The function and graphics do not function and bitmap.
The constructor method is the default construction method.

Enumeration:
Emun Shader.tilemode


3 modes of tiling are defined:
static final Shader.tilemode CLAMP: Edge stretch.


static final Shader.tilemode MIRROR: Alternating between horizontal and vertical, there is no gap between the two adjacent images.


Static Final Shader.tillmode Repeta: Repeated in both horizontal and vertical directions, with gap gaps between two adjacent images.




Method:
1. boolean Getloaclmatrix (Matrix Localm); If shader has a non-native matrix, it returns TRUE.
Localm: If not null, the local matrix is set to shader.
2. void Setlocalmatrix (Matrix localm);

Sets the local matrix of the shader, if Localm is empty, resets the local matrix of the shader.

Direct subclasses of Shader:

bitmapshader : Bitmap Image rendering

lineargradient : Linear rendering

radialgradient : Ring Rendering

sweepgradient : Scanning gradient rendering/gradient rendering

Composeshader : Combined rendering, which can be combined with several other sub-classes

Is it much like the relationship between animation and its subclasses (Alphaanimation,rotateanimation,scaleanimation,translateanimation, Animationset)

Both specific rendering effects and a combination of rendering effects

Below are the steps to use shader:

1. Building Shader objects

2. Set the Render object through the Setshader method of paint

3. Set the Render object

4. Use this Paint object when drawing

Android Color Rendering (iii) shader color rendering

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.