gpt4 book ai didi

android - 在android中的圆形路径上绘制文本

转载 作者:行者123 更新时间:2023-12-03 17:40:00 26 4
gpt4 key购买 nike

我需要在圆形路径上绘制文本。
我试过 drawTextOnPath()方法。但是对于所附图像中的“肥沃窗口”之类的文本,文本会旋转并且不可读。

This is the way I need

The text "Fertile window" isnt readable

我用过的代码:

customPath2.addArc(mCircleRectF, 30F, 64.28F);
customPaint2.setAntiAlias(true);
customPaint2.setDither(true);
customPaint2.setStrokeWidth(mCircleStrokeWidth);
customPaint2.setColor(Color.parseColor("#93BE66"));
customPaint2.setStyle(Paint.Style.STROKE);
customPaint2.setStrokeCap(Paint.Cap.ROUND);
canvas.drawPath(customPath2, customPaint2);

titlePaint.setColor(Color.parseColor("#ffffff"));
titlePaint.setAntiAlias(true);
titlePaint.setTypeface(Typeface.MONOSPACE); titlePaint.setLetterSpacing(0.07F);
titlePaint.setTextAlign(Paint.Align.CENTER);
titlePaint.setTextSize(35f);

canvas.drawTextOnPath("FERTILE WINDOW", customPath2, 0, 8, titlePaint);

最佳答案

感谢评论的帮助,将文字“向外”绘制,制作弧线逆时针 .
在您的示例中, startAngle 变为 94.28并且sweepAngle 变为-64.28 .
Kotlin :

val enclosingRect = RectF(0f, 0f, 200f, 200f)
val path = Path()
path.addArc(enclosingRect, 94.28f, -64.28f)
canvas.drawTextOnPath("FERTILE WINDOW", path, 0f, 0f, myPaint)
java :
RectF enclosingRect = new RectF(0f, 0f, 200f, 200f);
Path path = new Path();
path.addArc(enclosingRect, 94.28f, -64.28f);
canvas.drawTextOnPath("FERTILE WINDOW", path, 0f, 0f, myPaint);
这适用于圆圈底部的文本(从 0180 或从 -180-360 度)。
对于 180 之间的角度和 3600-180您要绘制弧线的度数 顺时针 .

关于android - 在android中的圆形路径上绘制文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38657335/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com