Skip to content

Commit

Permalink
fix 1d render of 2d matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
YeonV committed Feb 17, 2025
1 parent 380104f commit 5a1cee2
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/components/PixelGraph/PixelGraphCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,19 @@ const PixelGraphCanvas = ({
const realPixelCount = virtuals[virtId]?.pixel_count || totalPixels
const realCols = Math.ceil(realPixelCount / rows)
const aspectRatio = realCols / rows
const displayRows =
(shape && shape[0]) ||
(realPixelCount > 4096 ? Math.sqrt(4096 / aspectRatio) : rows)

const displayCols =
(shape && shape[1]) ||
(realPixelCount > 4096 ? 4096 / displayRows : realCols)
let displayRows, displayCols
if (showMatrix) {
displayRows =
(shape && shape[0]) ||
(realPixelCount > 4096 ? Math.sqrt(4096 / aspectRatio) : rows)
displayCols =
(shape && shape[1]) ||
(realPixelCount > 4096 ? 4096 / displayRows : realCols)
} else {
displayRows = 1
displayCols = totalPixels
}

canvas.width = displayCols
canvas.height = displayRows
Expand Down

0 comments on commit 5a1cee2

Please sign in to comment.