Interfejsy Geometry API umożliwiają tworzenie interaktywnych narzędzi, takich jak mechanizmy wyboru i gumki.
W tej sekcji pokazujemy, jak używać interfejsów Geometry API do implementowania gumki.
private fun eraseIntersectingStrokes(
currentX: Float,
currentY: Float,
currentStrokes: MutableList<Stroke>,
): Unit {
val prev = previousPoint
previousPoint = MutableVec(currentX, currentY)
if (prev == null) return
val segment = MutableSegment(prev, MutableVec(currentX, currentY))
val parallelogram = MutableParallelogram().populateFromSegmentAndPadding(
segment,
eraserPadding
)
currentStrokes.removeAll {
it.shape.intersects(parallelogram, AffineTransform.IDENTITY)
}
}