---
# System prepended metadata

title: Grease Pencil Eraser

---

![](https://hackmd.io/_uploads/SkDyg2FFn.jpg)
![](https://hackmd.io/_uploads/SJP1gntY3.jpg)



# Current approach

(Find the curves that intersect the bounding box of the brush in screen space)

1. Go through all the curves and check each segment for intersections with the eraser (circle)
    1.1. Per segment: Store the intersections (t-values, 0 to 1) and the number of cuts
    1.2. Calculate how many points are added and how many are removed
2. Create a new `CurvesGeometry` with the right number of target points
    2.1. Fill the curves' offsets with the accumulated number of cuts
    2.2. Copy/interpolate all the attributes of the points in the destination. To do so, we are looping through the source segment, getting the index range of the corresponding destination points (should be between 0 to 3 points), and then fill the points in the destination with interpolated versions of the source segment. For points that are removed in the destination, we get an `IndexRange` of size 0 and skip it.
3. Replace the old geometry with the new one, tag it for changes, and done :) .  