By bug, I mean I would like to relax the restriction, and allow you to pass null. I don't know yet when the could get in. Thus you should always (for now) pass in a region as the clip. It can be something large with no downside (i.e. -10,000, .... 10,000)
On Fri, Feb 20, 2009 at 3:57 PM, David Hu <vistoda...@gmail.com> wrote: > Thanks for your explanation, Mike. So, if there is not a bug, I can pass > the outer rect as clip region to attain my aim, and: > Region rgn = new Region(); > (1) //----- actual result: The application will crash here with an > exception here > //------expect result : ? > rgn.setPath(p, null); > (2) //----- actual result: The region is the rect area which encircle > the rotated > rect, not the rotated rect itself > //-------expect result :? > rgn.setPath(p, rgn); > (3) //----- actual result: The region is the rect area which encircle > the rotated > rect, not the rotated rect itself > //------- expect result: The region should be a complicate > area, inclined rect clipped by the original rect > Region clipRgn = new Region(top, bottom, left, right); > mRgn2.setPath(p, clipRgn); > I'll try to use outer rect region as the clip region later, see what's > happen currently. Would you please tell me when this region bug can be > fixed? I need try to check if my project can catch up the schedule, > otherwise, I have to try to calculate this region by ourselves, it would > take more efforts. > > BR, > -David > On Fri, Feb 20, 2009 at 10:49 PM, Mike Reed <r...@google.com> wrote: >> >> Ah, that's a bug, null should be allowed. I'll see what can be done >> there for the future. >> >> The clip parameter is mean to be a hint to speedup turning the path >> into a region by restricting the result to a clipped subset of the >> path. For your purposes, you can just make a big rectangular region >> for the clip. The bounds of the path or larger. >> >> On Thu, Feb 19, 2009 at 10:22 PM, David Hu <vistoda...@gmail.com> wrote: >> > Thanks for your reply, Mike. I've tried your method, seems still >> > not >> > work yet. The second parameter of Region.setPath (clip) can't be null. >> > >> > >> > If we use null, there will be an exception happen. So I've tried to >> > use >> > the region I've just constructed or the original rect region, the area >> > is >> > still the ourter standard rect area, not the inclined rect which rotated >> > from a standard rect. Here is my code tip and possible result: >> > >> > //Calculate region >> > top = 150; >> > bottom = top + bmp.getHeight(); //bmp is a bitmap instance >> > left = 200; >> > right = left + bmp.getWidth(); >> > Path p = new Path(); >> > p.addRect(left, top, right, bottom, Path.Direction.CCW); >> > >> > // use Matrix to rotate 30 degrees >> > Matrix mtx = new Matrix(); >> > mtx.setRotate(30); >> > p.transform(mtx); >> > >> > Region rgn = new Region(); >> > (1) //----- The application will crash here with an exception here >> > rgn.setPath(p, null); >> > (2) //----- The region is the rect area which encircle the rotated >> > rect, not the rotated rect itself >> > rgn.setPath(p, rgn); >> > (3) //----- The region is the rect area which encircle the rotated >> > rect, not the rotated rect itself >> > Region clipRgn = new Region(top, bottom, left, right); >> > mRgn2.setPath(p, clipRgn); >> > BTW, I searched in android source code and www.google.com, can't find >> > any >> > usage of this API: >> > >> > public boolean setPath(Path path, Region clip) >> > >> > So now, my question is which clip region should I pass or any other way >> > in >> > order to attain my aim? Hope I've made my aim clearly. >> > >> > BR, >> > -David >> > >> > On Thu, Feb 19, 2009 at 11:27 PM, Mike Reed <r...@google.com> wrote: >> >> >> >> You could possibly un-rotate your touch-point by 30 degrees, and then >> >> just use the rectangle. >> >> >> >> However, you can make complex regions by first constructing a Path, >> >> and then calling region.setPath(...), which converts the path into a >> >> region. Below is pseudo sample code: >> >> >> >> Path p = new Path(); >> >> p.addRect(rect); // this is your rect >> >> p.transform(matrix); // construct a matrix and then rotate as you wish >> >> region.setPath(p, null); >> >> >> >> On Thu, Feb 19, 2009 at 5:01 AM, <vistoda...@gmail.com> wrote: >> >> > >> >> > I want to judge whether the touch point(x, y) is in a region or >> >> > not, the region is from a stardard rect by rotating specified >> >> > degrees, >> >> > from example, rotate 30 degrees. There is a class named Region in >> >> > Android, but as I researched, it just supports standard rect, is >> >> > there >> >> > any other way to judge whether a point is in an acclivitous rect? >> >> > How >> >> > to do it? >> >> > >> >> > Br, >> >> > -David >> >> > > >> >> > >> >> >> >> > >> >> > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---