fun drawVertices()

in skiko/src/commonMain/kotlin/org/jetbrains/skia/Canvas.kt [850:890]


    fun drawVertices(
        vertexMode: VertexMode,
        positions: FloatArray,
        colors: IntArray? = null,
        texCoords: FloatArray? = null,
        indices: ShortArray? = null,
        blendMode: BlendMode,
        paint: Paint
    ): Canvas {
        require(positions.size % 2 == 0) {
            "Expected even number of positions: ${positions.size}"
        }
        val points = positions.size / 2
        require(colors == null || colors.size == points) {
            "Expected colors.length == positions.length / 2, got: " + colors!!.size + " != " + points
        }
        require(texCoords == null || texCoords.size == positions.size) {
            "Expected texCoords.length == positions.length, got: " + texCoords!!.size + " != " + positions.size
        }
        Stats.onNativeCall()
        try {
            interopScope {
                _nDrawVertices(
                    _ptr,
                    vertexMode.ordinal,
                    points,
                    toInterop(positions),
                    toInterop(colors),
                    toInterop(texCoords),
                    indices?.size ?: 0,
                    toInterop(indices),
                    blendMode.ordinal,
                    getPtr(paint)
                )
            }
        } finally {
            reachabilityBarrier(this)
            reachabilityBarrier(paint)
        }
        return this
    }