gpt4 book ai didi

android - Arc on canvas 没有抗锯齿

转载 作者:行者123 更新时间:2023-11-29 00:25:55 27 4
gpt4 key购买 nike

我想在 Canvas 上画两个彩色圆圈。一切正常,但圆圈并不光滑。这是效果:

This is the effect

这是代码:

private void drawCircle(Canvas c)
{
RectF oval = new RectF(20, 20, 100, 100);

c.drawArc(oval, -90, 180, false, getPaintWithColor(R.color.background));
c.drawArc(oval, 90, 180, false, getPaintWithColor(R.color.font_grey));
}

private Paint getPaintWithColor(int colorId){
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setDither(true);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(4);
paint.setColor(getResources().getColor(colorId));

return paint;
}

最佳答案

paint.setFlags(Paint.ANTI_ALIAS_FLAG)

参见Can I draw with antialiasing on canvas?

关于android - Arc on canvas 没有抗锯齿,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19496377/

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