android - Line/Paths intersecting -


I am creating a simple eraser tool for a vector-based drawing program. example

I have a path in my list > Android.graphics.Path and then drag them into a loop with a canvas.drawpath (path, color) on a canvas. In this example there is a red line eraser and the green line should be erased.

I have tried to convert path to area and call redRegion.op (greenRegion, Region.OP.INTERSECT) < / Code>. I think the issue is that the paths have no area, because the paint has not yet been implemented, these are just simple lines.

I'm building API lvl 15.

If your background is always white, then if you have a path that is white then "eraser" It seems as if other lines are being erased

EDIT:

Maybe you can query all the points that are used to pull your way to your touch event And use it to create a custom square. After that there is a way to:

  // other code .... MyCustomClass class = new MyCustomClass (); If (class.contains (float x, float y)) {//...erase line} // other code  

the MyCustomClass

  public Class MyCustomClass {Private List & gt; Pathpoints & gt; PathPoints; Public MyCustomClass (list & lt; pathpoint & gt; digits) {this.pathPoints = points; } (In the public bullion (float x, float y) {pathpoint point: pathpoints} {if (x == point.getX () & amp; y == point.gateway ()) {back true; }        return false; }}}  

and the Path Points class

  Public class pathpoint {Private float x; Private float y; Private Ent article type; Public zero set x (float x) {this.x = x; } // // all other getters and setters }  

Then for each path in your on-touch event, add a new pathpack to the list of path paths that draw only one new point in Action.UP (user drawings has stopped).

EDIT 2: OK, so here's another idea. Why do not you make your own custom path class and then add that all logic to that class. So while you are portraying the path, you can add path points to the path. Then add a method "include ()" to your custom path class so that it will include every point present on the path, whether it goes forward, line, tractor or whatever:

  Public category extension of MyPath path (Private list & amp;;; PathPoint & gt; digits; Public MyPath (list & lt; pathpoints & gt; pathpoints) {this.points = pathpoints;} Public Zero addPathPoint (pathpoint Pathpoints) {if (points! = Null) {points.add (pathpoints);}} in public boolean (float x, float wa } {Pathpoints (pathpoints: points) {if (pathpoint.getX () == x & amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; / Code> 

Its drawing part should work fine because you are not touching it. If it's functional, then let me know.


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -