Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The <code>android.graphics.Path</code> class doesn't have such a method. The Canvas class does have a clipping region that can be set to a path, there is no way to test it against a point. You might try Canvas.quickReject, testing against a single point rectangle (or a 1x1 <code>Rect</code>). I don't know if that would really check against the path or just the enclosing rectangle, though.</p> <p>The Region class clearly only keeps track of the containing rectangle. </p> <p>You might consider drawing each of your regions into an 8-bit alpha layer Bitmap with each <code>Path</code> filled in it's own 'color' value (make sure anti-aliasing is turned off in your <code>Paint</code>). This creates kind of a mask for each path filled with an index to the path that filled it. Then you could just use the pixel value as an index into your list of paths.</p> <pre><code>Bitmap lookup = Bitmap.createBitmap(width, height, Bitmap.Config.ALPHA_8); //do this so that regions outside any path have a default //path index of 255 lookup.eraseColor(0xFF000000); Canvas canvas = new Canvas(lookup); Paint paint = new Paint(); //these are defaults, you only need them if reusing a Paint paint.setAntiAlias(false); paint.setStyle(Paint.Style.FILL); for(int i=0;i&lt;paths.size();i++) { paint.setColor(i&lt;&lt;24); // use only alpha value for color 0xXX000000 canvas.drawPath(paths.get(i), paint); } </code></pre> <p>Then look up points,</p> <pre><code>int pathIndex = lookup.getPixel(x, y); pathIndex &gt;&gt;&gt;= 24; </code></pre> <p>Be sure to check for 255 (no path) if there are unfilled points.</p>
 

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