[Bug]: p5.Image.prototype.copy and blend do not scale destination coordinates for high pixel density
维护者通常 2 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript
调研方向
从 p5.Image.prototype._copyHelper 的第 920-960 行附近开始,使用提供的 high-DPI copy() 示例重现该问题。检查传递给 dstImage.drawingContext.drawImage() 的目标值,然后验证在使用 pixelDensity(2) 时,copy() 和 blend() 是否都覆盖了预期的逻辑区域。
由索引模型根据 Issue 内容生成。
描述
Most appropriate component
Image (p5.Image, image, etc.)
Describe the bug
When calling copy() or blend() on a p5.Image instance that has pixelDensity > 1 (e.g., Retina / high-DPI displays), the destination coordinates (dx, dy, dw, dh) are not scaled by the destination image's pixel density.
In p5.Image.prototype._copyHelper (lines 920-960), the source coordinates are scaled by s = srcImage.canvas.width / srcImage.width, but the destination parameters are passed directly as raw logical values to dstImage.drawingContext.drawImage().
Because dstImage.drawingContext operates directly on the physical canvas of dstImage without an automated DPI transformation matrix, drawImage() draws into only [dx, dy, dw, dh] physical canvas pixels instead of [d*dx, d*dy, d*dw, d*dh].
For pixelDensity(2), this results in the copied image covering only 1/4th of the intended area in the top-left corner, leaving the remaining 75% of the intended target area completely untouched (transparent / blank). Because p5.Image.prototype.blend() delegates to copy(), it suffers from the identical issue.
Steps to reproduce
let src = createImage(50, 50);
src.loadPixels();
for (let i = 0; i < src.pixels.length; i += 4) {
src.pixels[i] = 255; // Red
src.pixels[i + 3] = 255; // Alpha
}
src.updatePixels();
let dst = createImage(100, 100);
dst.pixelDensity(2); // canvas backing store is 200x200
dst.copy(src, 0, 0, 50, 50, 0, 0, 50, 50);
// Sample a point in the bottom-right quadrant of the logical image
let col = dst.get(35, 35);
console.log(col); // [0, 0, 0, 0] instead of [255, 0, 0, 255]
Expected behavior
The destination coordinates should be scaled by d = dstImage.canvas.width / dstImage.width so that copy() and blend() properly fill the intended logical region on high-DPI images.
- 主要语言
- JavaScript
- 星标
- 24.1k
- 派生
- 3.9k
- 平均合并
- 3 天 17 小时
- 30 天内合并 PR
- 33
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
processing/p5.js 的其他 Issue
-
[p5.js 2.0+ Bug Report]: SVG importer does not respect preserveAspectRatio="none" for <symbol>/<use>可能已有人在做 @Danyccsf 于 1 天前认领。 未关闭Area:Core p5.js 2.0+
难度 2/5 1-3 小时 新手友好度 83/100
processing/p5.js#9257 · 2 条评论 · 已指派 1 人 ·
维护者通常 2 天内回复
-
Add unit tests for noiseDetail()可能已有人在做 @Pcmhacker-piro 于 3 天前认领。 未关闭Area:Math Enhancement
难度 2/5 1-3 小时 新手友好度 75/100
processing/p5.js#9253 ·
维护者通常 2 天内回复
-
[p5.js 2.0+ Bug Report]: storeItem() validation branches are missing `return`, so bad input throws a TypeError or is stored anyway可能已有人在做 @iUjjwalRaj 于 3 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 85/100
processing/p5.js#9242 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
processing/p5.js#9241 ·
维护者通常 2 天内回复
-
[p5.js 2.0+ Bug Report]: Typo in Spanish reference documentation for ellipseMode()可能已有人在做 @cgutierrezval 于 6 天前认领。 未关闭Internationalization p5.js 2.0+
难度 1/5 1 小时以内 新手友好度 95/100
processing/p5.js#9231 · 3 条评论 ·
维护者通常 2 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
documentation good first issue help wanted
难度 1/5 1-3 小时 新手友好度 85/100
zmo2s/agent-toolbox#23 ·
-
[Bug]: [MCP/CLI] Bare loopback IP addresses (127.0.0.1:port) and hosts with ports fail to navigate due to erroneous scheme inference可能已有人在做 @alok-108 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/playwright#43263 ·
维护者通常 1 天内回复