diff --git a/.editorconfig b/.editorconfig index f7afd4e8..01dab7ee 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,6 +2,9 @@ ij_kotlin_allow_trailing_comma = true ij_kotlin_allow_trailing_comma_on_call_site = true +ktlint_standard_chain-method-continuation = disabled +ktlint_standard_class-signature = disabled +ktlint_standard_function-literal = disabled ktlint_standard_function-naming = disabled ktlint_standard_function-signature = disabled ktlint_standard_no-blank-line-in-list = disabled diff --git a/kanvas/src/appleMain/kotlin/IsPointInCGPath.kt b/kanvas/src/appleMain/kotlin/IsPointInCGPath.kt index b0a60b52..5039267a 100644 --- a/kanvas/src/appleMain/kotlin/IsPointInCGPath.kt +++ b/kanvas/src/appleMain/kotlin/IsPointInCGPath.kt @@ -6,18 +6,16 @@ import platform.CoreGraphics.CGPointMake public object IsPointInCGPath : IsPointInPath { - override fun isPointInPath(transform: Transform, path: Path, x: Float, y: Float): Boolean { - return path.withCGPath { cgPath -> - // Krayon passes the path transformation here, but CGPathContainsPoint can transform - // just the point and it's actually cheaper than transforming a whole path. - // TODO: Investigate propagating this optimization to other platforms. - val pointTransform = CGAffineTransformInvert(transform.asCGAffineTransform()) - CGPathContainsPoint( - cgPath, - m = pointTransform, - point = CGPointMake(x.toDouble(), y.toDouble()), - eoFill = false, - ) - } + override fun isPointInPath(transform: Transform, path: Path, x: Float, y: Float): Boolean = path.withCGPath { cgPath -> + // Krayon passes the path transformation here, but CGPathContainsPoint can transform + // just the point and it's actually cheaper than transforming a whole path. + // TODO: Investigate propagating this optimization to other platforms. + val pointTransform = CGAffineTransformInvert(transform.asCGAffineTransform()) + CGPathContainsPoint( + cgPath, + m = pointTransform, + point = CGPointMake(x.toDouble(), y.toDouble()), + eoFill = false, + ) } } diff --git a/kanvas/src/commonMain/kotlin/SegmentedPath.kt b/kanvas/src/commonMain/kotlin/SegmentedPath.kt index a4d97d6d..7e9a507c 100644 --- a/kanvas/src/commonMain/kotlin/SegmentedPath.kt +++ b/kanvas/src/commonMain/kotlin/SegmentedPath.kt @@ -156,19 +156,21 @@ internal data class SegmentedPath( ) { fun

rebuildWith(builder: PathBuilder

): P { builder.reset() - for (segment in segments) with(segment) { - when (this) { - is MoveTo -> builder.moveTo(x, y) - is RelativeMoveTo -> builder.relativeMoveTo(x, y) - is LineTo -> builder.lineTo(x, y) - is RelativeLineTo -> builder.relativeLineTo(x, y) - is ArcTo -> builder.arcTo(left, top, right, bottom, startAngle, sweepAngle, forceMoveTo) - is QuadraticTo -> builder.quadraticTo(controlX, controlY, endX, endY) - is RelativeQuadraticTo -> builder.relativeQuadraticTo(controlX, controlY, endX, endY) - is CubicTo -> builder.cubicTo(beginControlX, beginControlY, endControlX, endControlY, endX, endY) - is RelativeCubicTo -> builder.relativeCubicTo(beginControlX, beginControlY, endControlX, endControlY, endX, endY) - is Close -> builder.close() - else -> error("Unreachable.") + for (segment in segments) { + with(segment) { + when (this) { + is MoveTo -> builder.moveTo(x, y) + is RelativeMoveTo -> builder.relativeMoveTo(x, y) + is LineTo -> builder.lineTo(x, y) + is RelativeLineTo -> builder.relativeLineTo(x, y) + is ArcTo -> builder.arcTo(left, top, right, bottom, startAngle, sweepAngle, forceMoveTo) + is QuadraticTo -> builder.quadraticTo(controlX, controlY, endX, endY) + is RelativeQuadraticTo -> builder.relativeQuadraticTo(controlX, controlY, endX, endY) + is CubicTo -> builder.cubicTo(beginControlX, beginControlY, endControlX, endControlY, endX, endY) + is RelativeCubicTo -> builder.relativeCubicTo(beginControlX, beginControlY, endControlX, endControlY, endX, endY) + is Close -> builder.close() + else -> error("Unreachable.") + } } } return builder.build()