How to rotate text drawn in a straight line (without radius) when using drawTextOnPath?

一个人想着一个人 提交于 2020-03-03 10:10:32

问题


I want to rotate the numbers in canvas,

This is what I have tried:

override fun onDraw(canvas: Canvas) {    
var i = 0
while (i < rulerHeightInInch) {
val markingPositionYaxis =
            screenHeightInPx - (ydpinch * i + topThreshold)
paint.textSize = getPixelValueForDp(18.0f)
                    val path = Path()
                    path.reset()
                    path.moveTo(
                        (getPixelValueForDp(30f) + paint.textSize),
                        markingPositionYaxis +17
                    )
                    path.lineTo(
                        (getPixelValueForDp(30f) + paint.textSize),
                        markingPositionYaxis - (paint.textSize)
                    )
                    canvas.drawTextOnPath(nf.format(i / 32), path, 0f, 0f, paint)
}
i++
}
}

First image is what I have right now

Second image is what I want

I don't want to draw in circular path or by using radius I want from top to bottom in a straight line

来源:https://stackoverflow.com/questions/60396437/how-to-rotate-text-drawn-in-a-straight-line-without-radius-when-using-drawtext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!