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

Open
wants to merge 74 commits into
base: dev-2.0
Choose a base branch
from

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
…dd-thrly

docs: add thrly as a contributor for doc, and code
…dd-lirenjie95

docs: add lirenjie95 as a contributor for doc, and code
…dd-philyawj

docs: add philyawj as a contributor for doc
…dd-akkarn1689

docs: add akkarn1689 as a contributor for code
…dd-xinemata

docs: add xinemata as a contributor for eventOrganizing, tutorial, and 3 more
…dd-Vaivaswat2244

docs: add Vaivaswat2244 as a contributor for code
…dd-dkessner

docs: add dkessner as a contributor for example
…dd-AnimeshSinha1309

docs: add AnimeshSinha1309 as a contributor for example
ksen0 and others added 25 commits January 29, 2025 21:16
…dd-gabrielsroka

docs: add gabrielsroka as a contributor for example
…dd-kcconch

docs: add kcconch as a contributor for example
…dd-davidblitz

docs: add davidblitz as a contributor for example
…dd-crh82

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
…dd-seyko1

docs: add seyko1 as a contributor for code
…dd-thekinardist

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

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