@ray-js/pencil-flow貌似存在bug

小程序开发相关产品技术讨论,包括面板、智能小程序、React Native、Ray跨端框架、Panel SDK、微信小程序、小程序开发工具(IDE)及其他开发技术相关等话题


Post Reply
MwM-Mai
Posts: 173

@ray-js/pencil-flow 在绘制canvas的时候渲染了两个灯珠,当我update更新成一个灯珠的时候会多一个灯珠的边框出来,实际上是只执行一次方法,demo中的smearLightColorMaps数据类型和https://developer.tuya.com/material/library_oHEKLjj0/component?code=ComponentsTyLamp&subCode=LampStripLightSmear组件的一样

Attachments
demo.zip
(34.28 KiB) Downloaded 19 times

Tags:
MwM-Mai
Posts: 173

Re: @ray-js/pencil-flow貌似存在bug

这个是出现的bug

Attachments
68ee4509be797c5577e1fac70362178.png
bf681398987ed649136e8e351f79b14.png
crisiron
Posts: 164

Re: @ray-js/pencil-flow貌似存在bug

renderRoundLights(stage, ctx, data) { 在这里下面打印看看 data 的个数和数据结构

MwM-Mai
Posts: 173

Re: @ray-js/pencil-flow貌似存在bug

crisiron 2025年 Jun 23日 19:44

renderRoundLights(stage, ctx, data) { 在这里下面打印看看 data 的个数和数据结构

1个改成N个没问题,N改成1就会有问题, N改成2不会,具体是什么原因分析不出来,data长度也对

Attachments
815d507bb55232e332bd575195a0f90.png
crisiron
Posts: 164

Re: @ray-js/pencil-flow貌似存在bug

在 Line.js 存在多余的 ctx.stroke(); 需要将这个放在if 中, 代码如下 draw() {
this.clear();
const { data: data } = this;
if (!
data) {
return;
}
const { y, idx, endX, col, radius, isEvenRow, lightNum } = _data;
const ctx = this;
if ((idx === 0 || idx % col < col - 1) && lightNum !== idx + 1) {
if (isEvenRow) {
ctx.beginPath();
ctx.strokeStyle(LINE_COLOR);
ctx.lineWidth(2);
ctx.moveTo(endX + radius, y);
ctx.lineTo(endX + radius + offsetDistance, y);
ctx.stroke();
} else {
ctx.beginPath();
ctx.strokeStyle(LINE_COLOR);
ctx.lineWidth(2);
ctx.moveTo(endX - radius, y);
ctx.lineTo(endX - (radius + offsetDistance), y);
ctx.stroke();
}
}
if (((idx + 1) / col) % 2 === 1 && lightNum !== idx + 1) {
ctx.beginPath();
ctx.strokeStyle(LINE_COLOR);
ctx.beginPath();
ctx.lineWidth(2);
const arcRadius = (radius * 2.5) / 2;
ctx.arc(endX + radius, y + (radius * 2.5) / 2, arcRadius, Math.PI * 1.5, Math.PI * 0.5);
ctx.stroke();
}
if (((idx + 1) / col) % 2 === 0 && lightNum !== idx + 1) {
ctx.beginPath();
ctx.strokeStyle(LINE_COLOR);
ctx.beginPath();
ctx.lineWidth(2);
const arcRadius = (radius * 2.5) / 2;
ctx.arc(endX - radius, y + (radius * 2.5) / 2, arcRadius, Math.PI * 0.5, Math.PI * 1.5);
ctx.stroke();
}
}

MwM-Mai
Posts: 173

Re: @ray-js/pencil-flow貌似存在bug

Line类应该不会影响到Round类,只要绘制圆形的时候才会出现这个问题,Slider中有一个圆形按钮我显示后动态隐藏,更新canvas,哪个圆形按钮还是存在边框

crisiron
Posts: 164

Re: @ray-js/pencil-flow貌似存在bug

多余绘制一次 ctx.stroke(); 你按照我说的先试试

MwM-Mai
Posts: 173

Re: @ray-js/pencil-flow貌似存在bug

还真是被干扰到了,谢谢了

Post Reply