Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Preserve canvas position when calling noSmooth() in WEBGL #7553

Closed

Conversation

ImRAJAS-SAMSE
Copy link
Contributor

Resolves #7548

Changes:

  • Prevent unnecessary canvas recreation: Modified _resetContext() in p5.RendererGL.js to check if antialias is already false, avoiding redundant resets.
  • Preserve canvas positioning: Before recreating the canvas, store position, top, and left attributes, then restore them after recreation.
  • Update documentation: Clarified in src/core/shape/attributes.js that noSmooth() may recreate the canvas when called in draw().

Before (Bug Occurs)

  • Running noSmooth() in draw() caused the canvas to reset to (0,0) instead of staying in its assigned position.

After Fix

  • The canvas remains in position even when noSmooth() is called.
  • WebGL rendering works as expected, with jagged edges applied.

(Attach is the screenshot of test file running correctly: The sphere should be rendered inside a blue canvas at position (150,50).)
p5 js-error


✅ PR Checklist

allcontributors bot and others added 30 commits January 20, 2025 15:48
docs: add thrly as a contributor for doc, and code
docs: add lirenjie95 as a contributor for doc, and code
docs: add philyawj as a contributor for doc
docs: add akkarn1689 as a contributor for code
docs: add xinemata as a contributor for eventOrganizing, tutorial, and 3 more
…at2244

docs: add Vaivaswat2244 as a contributor for code
docs: add dkessner as a contributor for example
…Sinha1309

docs: add AnimeshSinha1309 as a contributor for example
allcontributors bot and others added 23 commits January 30, 2025 02:16
docs: add kcconch as a contributor for example
docs: add davidblitz as a contributor for example
docs: add crh82 as a contributor for example
docs: add Aaron Welles as a contributor for example
docs: add example emoji to all example contributors using emoji key
docs: add seyko1 as a contributor for code
…rdist

docs: add thekinardist as a contributor for example, and design
@davepagurek
Copy link
Contributor

Thanks for making a PR! Two things to help make this more reviewable:

  • We're currently working on developing p5 2.0, which is in the dev-2.0 branch and not the main branch, and have temporarily frozen merges into main. Could you base your changes off of that branch and make your PR's base branch dev-2.0?
  • It looks like an auto formatter got run on the codebase, so the Files Changed tab of the PR has lots of unrelated changes. Could you make your changes without that turned on so it's easier to see what changes relate to the issue at hand?

@ImRAJAS-SAMSE ImRAJAS-SAMSE changed the base branch from main to dev-2.0 February 18, 2025 06:31
@ImRAJAS-SAMSE
Copy link
Contributor Author

Hi @davepagurek, thanks for your patience!

I tried rebasing my branch onto dev-2.0 as requested, but I ran into a lot of conflicts and unintended changes from previous commits that were already in main.

Would it be better if I reset my branch and recreated the PR with only the necessary changes? That way, the PR will be clean and contain only the actual fix for noSmooth() in p5.RendererGL.js and the documentation update.

Let me know the best way to proceed! Thanks.

@davepagurek
Copy link
Contributor

Agreed, I think it's probably easiest to just manually re-apply the changes on top of dev-2.0. We've added a lot of changes between dev-2.0 and main so rebasing is unfortunately pretty difficult.

@ImRAJAS-SAMSE
Copy link
Contributor Author

I have created a new clean PR based on dev-2.0 as suggested: #7568

@ImRAJAS-SAMSE
Copy link
Contributor Author

This issues has been resolved #7568

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.

noSmooth() breaks positioned WEBGL canvas
4 participants