gpt4 book ai didi

当绘制设置为 Stroke 时,Android Canvas.drawTextOnPath 看起来不正确

转载 作者:IT老高 更新时间:2023-10-28 22:03:45 27 4
gpt4 key购买 nike

我在扩展 View 中设置了一些代码,这些代码设置了一些易于缩放的图形(类似于矢量)。 (我的比例设置为 0-1.0)

我注意到,当我将油漆填充设置为 FILL 时,路径上绘制的文本看起来是正确的,但是当我将填充设置为描边时(我只想要文本的轮廓),图像看起来像是在某个LSD 之旅。这是我的示例代码:

    Paint yellowPaint = Paints.getFillTextPaint(0.01f, 0xFFffea3e, 0.065f);
canvas.drawTextOnPath(mContext.getString(R.string.building_a_partnership),
Paths.getRoundedTextPath(mOuterCircleRectF, 280f, 350f),
0, -0.025f, yellowPaint);

public static Paint getFillTextPaint(float f, int color, float textSize) {
Paint textPaint = new Paint();
textPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
textPaint.setStyle(Paint.Style.FILL);
textPaint.setColor(color);
textPaint.setTextSize(textSize);
textPaint.setStrokeWidth(f);
textPaint.setShadowLayer(0.002f, 0.0f, 0.0f, 0xFF000000);
textPaint.setTypeface(Typeface.SANS_SERIF);
return textPaint;
}

如果我将 Paint.Style 从 FILL 更改为 STROKE,我会得到下面的图像。我使用了 canvas.drawText(),它可以很好地显示描边的字母。只有当它应用于路径时,它才会变得很奇怪。

Fill Image

Stroke Image

最佳答案

显然这是因为我的比例因子是 0-1.. 似乎存在一个错误,即如何处理渲染大小 < 1.0 的笔划。建议的解决方案是使用 0-100 的比例。

关于当绘制设置为 Stroke 时,Android Canvas.drawTextOnPath 看起来不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9493627/

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