[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日 19時間
- マージ済み PR(30日)
- 33
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
processing/p5.js のほかの issue
-
[p5.js 2.0+ Bug Report]: SVG importer does not respect preserveAspectRatio="none" for <symbol>/<use>対応中かも @Danyccsf が今日担当しました。 オープン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 が 2 日前に担当しました。 オープン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 が 2 日前に担当しました。 オープン
難易度 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 が 5 日前に担当しました。 オープンInternationalization p5.js 2.0+
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
processing/p5.js#9231 · コメント 3 件 ·
メンテナーはふだん 2 日以内に返信
processing/p5.js の issue をすべて見る
似ている issue
-
component:sight
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
agentic-os-org/ANOLISA#6738 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
bug Durable Agents Observability (AI Telemetry) status: needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
mastra-ai/mastra#26470 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
feature/cohorts feature/feature-flags team/feature-flags
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
documentation good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Orbit-xyz/orbit-docs#11 ·
-
area/build area/tech debt
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 2 日以内に返信