Java Code Examples for android.graphics.Region#quickReject()
The following examples show how to use
android.graphics.Region#quickReject() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DrawElement.java From cidrawing with Apache License 2.0 | 6 votes |
@Override public boolean hitTestForSelection(Path path) { if (!isSelectionEnabled()) { return false; } RectF box = new RectF(); if (path.isRect(box)) { // Quick check if path is rectangle return box.contains(getOuterBoundingBox()); } else { path.transform(getInvertedDisplayMatrix()); Region r1 = ShapeUtils.createRegionFromPath(path); Region r2 = ShapeUtils.createRegionFromPath(getTouchableArea()); if (r1.quickReject(r2)) { // Quick check for not intersect case return false; } return !r2.op(r1, Region.Op.DIFFERENCE); } }
Example 2
Source File: FruitProjectileManager.java From FruitNinja with Apache License 2.0 | 6 votes |
@Override public int testForCollisions(List<TimedPath> allPaths) { int score = 0; for (TimedPath p : allPaths) { for (Projectile f : fruitProjectiles) { if(!f.isAlive()) continue; Region projectile = new Region(f.getLocation()); Region path = new Region(); path.setPath(p, clip); if (!projectile.quickReject(path) && projectile.op(path, Region.Op.INTERSECT)) { f.kill(); score++; } } } return score; }
Example 3
Source File: AccessibilityInteractionController.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void adjustIsVisibleToUserIfNeeded(AccessibilityNodeInfo info, Region interactiveRegion) { if (interactiveRegion == null || info == null) { return; } Rect boundsInScreen = mTempRect; info.getBoundsInScreen(boundsInScreen); if (interactiveRegion.quickReject(boundsInScreen)) { info.setVisibleToUser(false); } }
Example 4
Source File: DrawElement.java From cidrawing with Apache License 2.0 | 5 votes |
@Override public boolean hitTestForSelection(float x, float y) { if (!isSelectionEnabled()) { return false; } if (getBoundingBox() != null) { float[] points = new float[2]; getInvertedDisplayMatrix().mapPoints(points, new float[]{x, y}); Path path = getTouchableArea(); RectF box = new RectF(); if (path.isRect(box)) { // Quick check if path is rectangle return box.contains(points[0], points[1]); } else { Region region = ShapeUtils.createRegionFromPath(path); Rect touchSquare = DrawUtils.createTouchSquare(drawingView.getContext(), (int) points[0], (int) points[1]); if (region.quickReject(touchSquare)) { // Quick check for not intersect case return false; } Region pointRegion = new Region(touchSquare); return region.op(pointRegion, Region.Op.INTERSECT); } } return false; }