I know how to setup and display an oval shape. I know how to apply a gradient to this shape. What I cant figure out is how I can get an oval gradient to match the shape.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<gradient
android:startColor="#66FFFFFF"
android:endColor="#00FFFFFF"
android:gradientRadius="100"
android:type="radial" />
</shape>
If you can imagine, this gradient has a semi transparent white glow in the middle, then fades to alpha zero at the edges. I need to get it to go out in an oval shape, not just a circular gradient. How can I achieve this?
Best Answer
I would suggest more 'direct' drawing approach. If you can draw gradient pixel-by-pixel, then you need just to remember that for
r
r1+r2
Here:
r - distance to circle center
r1,r2 - distances to two foci of ellipse
EDIT: Consider this Pixel Shader code:
You will get oval something like that:
good luck