APIهای هندسه
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
{% setvar compose_or_views "نوشتن" %}
{% شامل "/develop/ui/compose/touch-input/stylus-input/includes/___ink-api-geometry-apis" %}
،
{% setvar compose_or_views "نوشتن" %}
{% شامل "/develop/ui/compose/touch-input/stylus-input/includes/___ink-api-geometry-apis" %}
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Geometry APIs\n\nThe Geometry APIs allow you to create interactive tools such as erasers and\nselection mechanisms.\n\nTo illustrate practical application of the Geometry APIs, explore the following\neraser implementation example.\n\n### Whole stroke eraser\n\n fun eraseWholeStrokes(\n eraserBox: ImmutableBox,\n finishedStrokesState: MutableState\u003cSet\u003cStroke\u003e\u003e,\n ) {\n val threshold = 0.1f\n\n val strokesToErase = finishedStrokesState.value.filter { stroke -\u003e\n stroke.shape.computeCoverageIsGreaterThan(\n box = eraserBox,\n coverageThreshold = threshold,\n )\n }\n if (strokesToErase.isNotEmpty()) {\n Snapshot.withMutableSnapshot {\n finishedStrokesState.value -= strokesToErase\n }\n }\n }\n\nFor a Compose implementation, make sure to trigger a recomposition, so the\nstrokes are effectively removed. For example, an approach would be to use\n`rememberCoroutineScope` in your composable and pass the coroutine scope to your\ntouch listener, allowing you to modify `finishedStrokesState` within the scope\nof Compose.\n| **Note:** An eraser that only removes the parts of the strokes it touches can be implemented by seeing if a stroke intersects with individual line segments of a [`StrokeInputBatch`](/reference/kotlin/androidx/ink/strokes/StrokeInputBatch) and creating new [`StrokeInputBatch`](/reference/kotlin/androidx/ink/strokes/StrokeInputBatch) and [`Stroke`](/reference/kotlin/androidx/ink/strokes/Stroke) objects out of the line segments that aren't intersected."]]