Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could consider the 'feather effect' as a gradial gradient, with the <em>alpha</em> fading from 100% to 0%. </p> <p>Android offers the <a href="http://developer.android.com/reference/android/graphics/RadialGradient.html" rel="noreferrer">RadialGradient</a> class for this purpose. You'll want to use the constructor where you can specify the control points for the radient, as you'll want the fading to start near the edge, not in the middle.</p> <p>The one problem with Android's RadialGradient class is that it <em>only supports perfect circles</em>, not for ovals. To compensate for this, we'll just draw a perfect circle and scale afterwards.</p> <p>Example code:</p> <pre><code> private Bitmap makeFeatheredOval(int width, int height) { // Determine largest dimension, use for rectangle. int size = Math.max( width, height); RadialGradient gradient = new RadialGradient(size / 2, size / 2, size / 2, new int[] {0xFFFFFFFF, 0xFFFFFFFF, 0x00FFFFFF}, new float[] {0.0f, 0.8f, 1.0f}, android.graphics.Shader.TileMode.CLAMP); Paint paint = new Paint(); paint.setShader(gradient); Bitmap bitmap = Bitmap.createBitmap(size, size, Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); canvas.drawCircle(size / 2, size / 2, size / 2, paint); // Scale the bitmap, creating an oval bitmap = Bitmap.createScaledBitmap(bitmap, width, height, true); return bitmap; } </code></pre> <p>Example image (it's the oval "moon" in the upper left corner):</p> <p><img src="https://i.stack.imgur.com/PU0fX.png" alt="Oval circle overlayed on demoscene awesomeness"></p> <p><em>Bonus points for everyone who recognizes that backdrop image.</em></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload