从android.graphics.Path中取出Point点,Kotlin

从android.graphics.Path中取出Point点,Kotlin

    /**
     * 从一条Path中获取多少个Point点
     */
    private fun getPoints(path: Path, pointCount: Int): Array {
        val points = arrayOfNulls(pointCount)

        val pm = PathMeasure(path, false)
        val length = pm.length
        var distance = 0f
        val speed = length / pointCount
        var counter = 0
        val aCoordinates = FloatArray(2)
        while (distance < length && counter < pointCount) {
            // 从path中取出点Point
            pm.getPosTan(distance, aCoordinates, null)
            points[counter] = FloatPoint(
                aCoordinates[0],
                aCoordinates[1]
            )

            counter++

            distance += speed
        }

        return points
    }

    class FloatPoint(var x: Float, var y: Float)

Android图形图像处理:添加涂鸦文字_android 在图片上涂鸦-CSDN博客文章浏览阅读2k次。先看运行效果: 关键的PaintView:package com.zhangphil;import android.content.Context;import android.graphics.Canvas;import android.graphics.Color;import android.graphics.Paint;import android.graph..._android 在图片上涂鸦https://blog.csdn.net/zhangphil/article/details/87810653

你可能感兴趣的:(kotlin,Android,android,kotlin)