Android Path collision problems/solutions -
Android Path collision problems/solutions -
i have drawing application in android allows user draw finger, , stores resulting shapes android paths. allow user delete individual paths have drawn, have implemented this solution uses bounding rect each path, , uses inner multi-dimensional binary array represent pixels within bounding rect. populate array taking path's command points , track along using mathematical equation quadratic bezier curve, setting each element in array have pixel underneath 1.
using above setup, when in erasing mode, first check collision between users finger , bounding rect, , if collides, check see if pixel beingness touched user set 1 in array.
now, when user loads note, load of shapes arraylist of 'stroke' objects can display them , can loop through them checking collision when in erase mode. store rect , binary array strokes in custom object. working expected, memory footprint of storing of data, binary array each path's bounding rect, getting expensive, , when user has big number of strokes getting java.lang.outofmemoryerror on portion of code creating array each stroke.
any suggestions on improve way accomplish this? essentially, trying determine collision between 2 android paths (the drawing path, , path user creates when in erase mode), , while above works in theory, in practice not feasible.
thanks,
paul
what actual representation of "binary array"? think if tweak representation reflect actual info need store (for illustration rle encode bits: @ y starting @ x , z pixels) able store need without excessive size.
storing actual array of bytes 1 byte per pixel, or per 8 pixels (if doing) isn't necessary use.
another alternative not store bitmap @ all, command points , bounding boxes. if touch intersects bounding box, calculate bitmap on fly command points.
android path collision-detection
Comments
Post a Comment