Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement a custom Shader in Android

Tags:

android

I would like to draw a circle filled with blended color with gradient. However, the existing android.graphics.Shader subclasses cannot meet my need. In short, I would like to control the color of each pixel in the circle myself. Is it possible to implement a custom Shadar object by extending android.graphics.Shader?

like image 227
Mason Fong Avatar asked Dec 26 '11 16:12

Mason Fong


People also ask

What is shader in Android?

In Android, Shader defines the color(s) or the texture with which the Paint object should draw (other than a bitmap). Android defines several subclasses of Shader for Paint to use, such as BitmapShader , ComposeShader , LinearGradient , RadialGradient , and SweepGradient .


1 Answers

I am not sure about subclassing android.graphics.Shader

But if you are using OpenGl ES 2.0 you can write your own Shader using GLSL which gives you very high flexibilty.

Maybe have a look at this question.

like image 93
micha Avatar answered Nov 10 '22 08:11

micha