Repository: Automattic/pocket-casts-android
File: modules/services/compose/src/main/java/au/com/shiftyjelly/pocketcasts/compose/components/Tooltip2.kt (Kotlin)

Code before:
        val anchorHeight = density.run { AnchorHeight.toPx() }
        val anchorWidth = density.run { CornerAnchorWidth.toPx() }

        moveTo(shapeSize.width - anchorWidth, shapeSize.height - anchorHeight)
        addCornerAnchor(scale, flipVertically = true)
    }

    private fun bottomLeftAnchor(
        shapeSize: Size,
        density: Density,
    ) = Path().apply {
        val scale = density.density
        val anchorHeight = density.run { AnchorHeight.toPx() }
        val anchorWidth = density.run { CornerAnchorWidth.toPx() }

        moveTo(anchorWidth, shapeSize.height - anchorHeight)
        addCornerAnchor(scale, flipHorizontally = true, flipVertically = true)
    }

    private fun Path.addEdgeAnchor(
        scale: Float,
        flipVertically: Boolean = false,
    ) {
        val hScale = scale
        val vScale = scale * (if (flipVertically) -1 else 1)

        relativeCubicTo(1.71f * hScale, 0f * vScale, 3.42f * hScale, 0.01f * vScale, 5.14f * hScale, -0.01f * vScale)
        relativeCubicTo(1.62f * hScale, -0.02f * vScale, 3.47f * hScale, -0.04f * vScale, 5.07f * hScale, -0.65f * vScale)
        relativeCubicTo(1.72f * hScale, -0.65f * vScale, 2.86f * hScale, -1.79f * vScale, 4.01f * hScale, -3.12f * vScale)
        relativeCubicTo(0.83f * hScale, -0.96f * vScale, 2.45f * hScale, -3.01f * vScale, 3.24f * hScale, -4.01f * vScale)
        relativeCubicTo(0.65f * hScale, -0.81f * vScale, 1.91f * hScale, -2.42f * vScale, 2.6f * hScale, -3.2f * vScale)
        relativeCubicTo(0.87f * hScale, -0.98f * vScale, 1.95f * hScale, -2.02f * vScale, 3.44f * hScale, -2.02f * vScale)
        relativeCubicTo(1.49f * hScale, 0f * vScale, 2.57f * hScale, 1.04f * vScale, 3.44f * hScale, 2.02f * vScale)
        relativeCubicTo(0.69f * hScale, 0.78f * vScale, 1.96f * hScale, 2.38f * vScale, 2.6f * hScale, 3.2f * vScale)
        relativeCubicTo(0.79f * hScale, 0.99f * vScale, 2.41f * hScale, 3.04f * vScale, 3.24f * hScale, 4.01f * vScale)
        relativeCubicTo(1.15f * hScale, 1.34f * vScale, 2.29f * hScale, 2.47f * vScale, 4.01f * hScale, 3.12f * vScale)
        relativeCubicTo(1.6f * hScale, 0.6f * vScale, 3.43f * hScale, 0.63f * vScale, 5.07f * hScale, 0.65f * vScale)
        relativeCubicTo(1.71f * hScale, 0.02f * vScale, 3.43f * hScale, 0.01f * vScale, 5.14f * hScale, 0.01f * vScale)
    }

    private fun Path.addCornerAnchor(
        scale: Float,
        flipHorizontally: Boolean = false,
        flipVertically: Boolean = false,
    ) {
        val hScale = scale * (if (flipHorizontally) -1 else 1)
        val vScale = scale * (if (flipVertically) -1 else 1)

        relativeCubicTo(1.71f * hScale, 0f * vScale, 3.42f * hScale, 0.01f * vScale, 5.14f * hScale, -0.01f * vScale)
        relativeCubicTo(1.62f * hScale, -0.02f * vScale, 3.47f * hScale, -0.04f * vScale, 5.07f * hScale, -0.65f * vScale)
        relativeCubicTo(1.72f * hScale, -0.65f * vScale, 2.86f * hScale, -1.79f * vScale, 4.01f * hScale, -3.12f * vScale)

Review comment (suggestion):
Wake up, Neo. The Matrix has you.
JK -- these numbers look a bit intimidating. Isn't there a better way to get the anchor path? 
It's just a wild idea, but can't we define a vector drawable resource and transform its path somehow? 🤔 

Code after:
        val tipWidth = density.run { CornerTipWidth.toPx() }

        moveTo(shapeSize.width - tipWidth, shapeSize.height - tipHeight)
        addCornerTip(scale, flipVertically = true)
    }

    private fun bottomLeftTip(
        shapeSize: Size,
        density: Density,
    ) = Path().apply {
        val scale = density.density
        val tipHeight = density.run { TipHeight.toPx() }
        val tipWidth = density.run { CornerTipWidth.toPx() }

        moveTo(tipWidth, shapeSize.height - tipHeight)
        addCornerTip(scale, flipHorizontally = true, flipVertically = true)
    }

    private fun Path.addEdgeTip(
        scale: Float,
        flipVertically: Boolean = false,
    ) {
        val hScale = scale
        val vScale = scale * (if (flipVertically) -1 else 1)

        relativeCubicTo(1.71f * hScale, 0f * vScale, 3.42f * hScale, 0.01f * vScale, 5.14f * hScale, -0.01f * vScale)
        relativeCubicTo(1.62f * hScale, -0.02f * vScale, 3.47f * hScale, -0.04f * vScale, 5.07f * hScale, -0.65f * vScale)
        relativeCubicTo(1.72f * hScale, -0.65f * vScale, 2.86f * hScale, -1.79f * vScale, 4.01f * hScale, -3.12f * vScale)
        relativeCubicTo(0.83f * hScale, -0.96f * vScale, 2.45f * hScale, -3.01f * vScale, 3.24f * hScale, -4.01f * vScale)
        relativeCubicTo(0.65f * hScale, -0.81f * vScale, 1.91f * hScale, -2.42f * vScale, 2.6f * hScale, -3.2f * vScale)
        relativeCubicTo(0.87f * hScale, -0.98f * vScale, 1.95f * hScale, -2.02f * vScale, 3.44f * hScale, -2.02f * vScale)
        relativeCubicTo(1.49f * hScale, 0f * vScale, 2.57f * hScale, 1.04f * vScale, 3.44f * hScale, 2.02f * vScale)
        relativeCubicTo(0.69f * hScale, 0.78f * vScale, 1.96f * hScale, 2.38f * vScale, 2.6f * hScale, 3.2f * vScale)
        relativeCubicTo(0.79f * hScale, 0.99f * vScale, 2.41f * hScale, 3.04f * vScale, 3.24f * hScale, 4.01f * vScale)
        relativeCubicTo(1.15f * hScale, 1.34f * vScale, 2.29f * hScale, 2.47f * vScale, 4.01f * hScale, 3.12f * vScale)
        relativeCubicTo(1.6f * hScale, 0.6f * vScale, 3.43f * hScale, 0.63f * vScale, 5.07f * hScale, 0.65f * vScale)
        relativeCubicTo(1.71f * hScale, 0.02f * vScale, 3.43f * hScale, 0.01f * vScale, 5.14f * hScale, 0.01f * vScale)
    }

    private fun Path.addCornerTip(
        scale: Float,
        flipHorizontally: Boolean = false,
        flipVertically: Boolean = false,
    ) {
        val hScale = scale * (if (flipHorizontally) -1 else 1)
        val vScale = scale * (if (flipVertically) -1 else 1)

        relativeCubicTo(1.71f * hScale, 0f * vScale, 3.42f * hScale, 0.01f * vScale, 5.14f * hScale, -0.01f * vScale)
        relativeCubicTo(1.62f * hScale, -0.02f * vScale, 3.47f * hScale, -0.04f * vScale, 5.07f * hScale, -0.65f * vScale)
        relativeCubicTo(1.72f * hScale, -0.65f * vScale, 2.86f * hScale, -1.79f * vScale, 4.01f * hScale, -3.12f * vScale)
        relativeCubicTo(0.83f * hScale, -0.96f * vScale, 2.45f * hScale, -3.01f * vScale, 3.24f * hScale, -4.01f * vScale)