HarmonyOS 鸿蒙Next canvas绘制时开启了抗锯齿 无效

发布于 1周前 作者 sinazl 来自 鸿蒙OS

HarmonyOS 鸿蒙Next canvas绘制时开启了抗锯齿 无效

settings: RenderingContextSettings = new RenderingContextSettings(true)
context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)

开启后毛边,锯齿依旧明显

3 回复

一样我也遇到这个问题 画布面积大没事,设置小点,图形不仅有锯齿,还虚的不行呀。咋整。

private settings: RenderingContextSettings = new RenderingContextSettings(true)
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)

// 绘制打勾
private drawSuccess() {
if (this.context.width === 0 || this.context.height === 0) {
return
}
this.context.clearRect(0, 0, this.context.width, this.context.height);

let centerX = this.context.width / 2;
let centerY = this.context.height / 2;

this.context.beginPath();
//
let radius = Math.min(centerX, centerY) - 5
this.context.arc(centerX, centerY, radius, this.DEGREES_TO_RADIANS(-90),
this.DEGREES_TO_RADIANS(360), false)
this.context.strokeStyle = this.drawColor.toString();
this.context.lineCap = 'round';
this.context.lineWidth = 2
this.context.stroke()
}

WechatIMG358.jpg

楼主您好,该问题需要demo代码进行分析,建议通过在线提单提交问题。

支持 - 在线提单 - 华为开发者联盟 (huawei.com)

HarmonyOS鸿蒙Next在Canvas绘制时开启抗锯齿无效的问题,可能是由于多种因素导致的。首先,确保在创建CanvasRenderingContext2D对象时正确设置了抗锯齿属性。其次,检查绘制的图形尺寸和画布尺寸是否匹配,因为小尺寸图形在较大画布上可能会显得锯齿明显。如果问题依旧,请检查绘制的具体代码是否有误,或者尝试更新HarmonyOS到最新版本。如果问题依旧没法解决,请加我微信,我的微信是itying888。

回到顶部