Skip to content

Commit a023d54

Browse files
authored
Merge pull request #7626 from himanshuukholiya/fix-7259-offscreen-shapes
Fix #7259 TypeError for Offscreen Shapes
2 parents 4496a4d + e30b51b commit a023d54

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/accessibility/outputs.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,13 @@ p5.prototype._getPos = function (x, y) {
579579
function _canvasLocator(args, canvasWidth, canvasHeight) {
580580
const noRows = 10;
581581
const noCols = 10;
582-
let locX = Math.floor(args[0] / canvasWidth * noRows);
583-
let locY = Math.floor(args[1] / canvasHeight * noCols);
582+
let x = args[0];
583+
let y = args[1];
584+
if (x < 0 || x >= canvasWidth || y < 0 || y >= canvasHeight) {
585+
return null;
586+
}
587+
let locX = Math.floor(x / canvasWidth * noRows);
588+
let locY = Math.floor(y / canvasHeight * noCols);
584589
if (locX === noRows) {
585590
locX = locX - 1;
586591
}

0 commit comments

Comments
 (0)