Leaflet.buffer
Leaflet.buffer copied to clipboard
Figure out a different reference point for buffering
Right now, this is essentially the algorithm:
- User mousedowns on a shape. Calculate (rough) centroid of shape, and distance (d1) of mouse location to the centroid.
- As mouse moves, calculate distance of mouse position to centroid (d2)
- d2-d1 is the amount to adjust the buffering radius
Some things happen with this:
- If you shrink far enough, the centroid will often wind up completely outside the convex hull of the shape. This makes further shrinkage awkward, since you are dragging to some point outside of the shape but it still shrinks.
- If you drag from near the end of a long, skinny shape, you can produce a very negative radius (consider a 500x5 rectangle; if you start dragging from (0,3) you can wind up with a -250 radius once you reach the centroid, which of course is way more than you need for the shape to completely disappear)
Perhaps scaling motion relative to the bounding rectangle? Should solve 2 at least.