Skip to content

Conversation

@dhowe
Copy link
Contributor

@dhowe dhowe commented Dec 9, 2025

Resolves #8323

Changes:

Changed (x && y && ...) to use typeof checks

Screenshots of the change:

old:
image

new:
image

@dhowe dhowe changed the base branch from main to dev-2.0 December 9, 2025 20:31
@dhowe dhowe requested review from davepagurek and limzykenneth and removed request for limzykenneth December 9, 2025 20:34
@limzykenneth limzykenneth requested review from davepagurek and removed request for davepagurek December 10, 2025 18:12
@limzykenneth limzykenneth merged commit ce3037d into processing:dev-2.0 Dec 11, 2025
2 checks passed
@Deepak-cell311
Copy link

Hi @limzykenneth @davepagurek,
While looking at the current implementation of p5.prototype.cursor, I noticed a couple of areas that could potentially be simplified or modernized.

  1. The regex used to detect image extensions currently enumerates both lowercase and uppercase variants:
    (/\.(cur|jpg|jpeg|gif|png|CUR|JPG|JPEG|GIF|PNG)$/.test(type)).
    This could be simplified and made more robust by using a case-insensitive flag instead:
    (/\.(cur|jpg|jpeg|gif|png)$/i.test(type))
    This would handle all casing variations (e.g. .PNG, .pNg) without needing to list them explicitly.

  2. For checking absolute URLs, the code currently uses substring comparisons:
    type.substring(0, 7) === 'http://' || type.substring(0, 8) === 'https://'
    This could be updated to a more modern and readable ES6 approach:
    type.startsWith('http://') || type.startsWith('https://')

I think these are small changes, but they might improve readability and maintainability without altering behavior. Just wanted to share in case it’s useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[p5.js 2.0 Bug Report]: position ignored on cursor(img, x, y) when either x or y are zero

3 participants