Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Path collision problems/solutions
    primarykey
    data
    text
    <p>I have a drawing application in Android that allows the user to draw with their finger, and then stores the resulting shapes as Android <code>Path</code>s. To allow the user to delete individual <code>Path</code>s they have drawn, I have implemented <a href="https://stackoverflow.com/questions/5914911/pixel-perfect-collision-detection-android">this solution</a> that uses a bounding <code>Rect</code> for each <code>Path</code>, and then uses an inner multi-dimensional binary array to represent the pixels inside the bounding <code>Rect</code>. I then populate the array by taking the Path's control points and track along it using the mathematical equation for a quadratic bezier curve, setting each element in the array that would have a pixel underneath it to 1. </p> <p>Using the above setup, when in erasing mode, I first check for collision between the users finger and the bounding <code>Rect</code>, and if that collides, I then check to see if the pixel being touched by the user is set to a 1 in the array.</p> <p>Now, when a user loads a note, I load all of the shapes into an <code>ArrayList</code> of 'stroke' objects so that I can then easily display them and can loop through them checking for collision when in erase mode. I also store the <code>Rect</code> and binary array with the strokes in the custom object. Everything is working as expected, but the memory footprint of storing all of this data, specifically the binary array for each Path's bounding <code>Rect</code>, is getting expensive, and when a user has a large number of strokes I am getting a <code>java.lang.OutOfMemoryError</code> on the portion of my code that is creating the array for each stroke.</p> <p>Any suggestions on a better way to accomplish this? Essentially, I am trying to determine collision between two Android Paths (the drawing Path, and then a Path that the user creates when in erase mode), and while the above works in theory, in practice it is not feasible.</p> <p>Thanks,</p> <p>Paul</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. 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