mcfly soft
mcfly soft

Reputation: 11655

Filled Path with fadeout effect with drawpath

I draw a filled path ( shape ) with

canvas.drawPath(mypath, paint);

This works fine. Now my Question: I would like to have a special effect that the opacity of the color decreases to the border of the path ( shape ). So in the center of the shape the opacity will be 100% and to the borders the colors fade out to 0% ( 0 opacity )

Does anyone have a hint for me how to do this?

Upvotes: 1

Views: 1273

Answers (1)

user1410657
user1410657

Reputation: 1294

This isn't doable unless path is a simple ellipse-like shape (in which case you can fill it with RadialGradient).

Another option is to set an inner blur MaskFilter to the paint like so:

float blurRadius = 10;
paint.setMaskFilter(new BlurMaskFilter(blurRadius,
                                       BlurMaskFilter.Blur.NORMAL));

In case of blur, results also highly depend on the path shape.

Upvotes: 4

Related Questions