Skip to content

Commit 53c10af

Browse files
pjt222claude
andcommitted
fix(snic): normalize canvas_size to c(width, height) convention
SNIC returned canvas_size as c(height, width) while build_svg_header() expects c(width, height), causing the SVG viewBox to swap dimensions and the image to appear cropped. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9b40dd0 commit 53c10af

2 files changed

Lines changed: 2 additions & 8 deletions

File tree

R/image_fill_rendering.R

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,9 @@ render_image_filled_pieces <- function(pieces, image_data_uri, canvas_size,
9393
colors <- rep(colors, length(pieces))
9494
}
9595

96-
# Image dimensions in canvas mm units
96+
# Image dimensions in canvas mm units — canvas_size is always c(width, height)
9797
img_w <- canvas_size[1] # width
9898
img_h <- canvas_size[2] # height
99-
# If canvas_size is c(height, width), swap
100-
if (!is.null(image_width) && !is.null(image_height)) {
101-
# Use actual canvas_size values (already in mm from generate_puzzle)
102-
img_w <- canvas_size[2] # width is second element
103-
img_h <- canvas_size[1] # height is first element
104-
}
10599

106100
sapply(seq_along(pieces), function(i) {
107101
piece <- pieces[[i]]

R/snic_puzzle.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ generate_snic_pieces_internal <- function(seed, grid, size, image_path,
222222

223223
list(
224224
pieces = pieces,
225-
canvas_size = size,
225+
canvas_size = c(size[2], size[1]), # Convert from c(height, width) to c(width, height)
226226
canvas_offset = c(0, 0),
227227
type = "snic",
228228
parameters = parameters,

0 commit comments

Comments
 (0)