Skip to content

Conversation

@VANSH3104
Copy link
Contributor

Resolves #2984

Changes:

Screenshots of the change:

Before vs After Comparison

Before After
image image
image image
image image
image image
image image
image image
image image

PR Checklist

@VANSH3104
Copy link
Contributor Author

@ksen0 @davepagurek I've implemented the fix for set() to support p5.Graphics objects. The solution adds a check for Graphics instances in p5.Renderer2D.prototype.set() and uses drawImage() with the graphics canvas directly (avoiding .get() as suggested).

@VANSH3104
Copy link
Contributor Author

@ksen0, is this change satisfactory or is there anything further that needs to be done?

@VANSH3104
Copy link
Contributor Author

Hi @ksen0 and @davepagurek,
Just following up on this PR. All checks are passing, and the implementation aligns with the approach discussed earlier by handling p5.Graphics directly via drawImage and avoiding .get() for performance and WebGPU compatibility.
Whenever you have time to review, please let me know if any changes, refinements, or additional tests are needed. I’m happy to continue working on this.
Thanks for your time.

@VANSH3104
Copy link
Contributor Author

@ksen0 or @davepagurek , could you please review this so that I can continue working on it?.

Copy link
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good so far, just one code style comment. The other suggestion I have is to add a visual test so that we can automatically catch it if this breaks in the future.

y = Math.floor(y);
if (imgOrCol instanceof Image) {
if (imgOrCol instanceof Graphics) {
this.drawingContext.save();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, is the code in this branch the same as in the Image branch though? if so maybe we can simplify this by using an || condition and just having it be one branch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they are the same. I will update it.

@VANSH3104
Copy link
Contributor Author

@davepagurek I have added your recommendation and also test cases. Should I also add manual test examples?

Copy link
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is looking almost ready to go! I think tests for just this feature don't need to be in their own file, can we move them into maybe https://github.com/processing/p5.js/blob/dev-2.0/test/unit/core/rendering.js ?

@VANSH3104
Copy link
Contributor Author

@davepagurek I have added the test to your preferred location. Please let me know if anything else is required.

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.

2 participants