-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Added Example on p5.Framebuffer.get method #7166
base: main
Are you sure you want to change the base?
Changes from 1 commit
bb4dde0
aea7d41
170894d
d46a582
7b1cba7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1489,16 +1489,17 @@ class Framebuffer { | |
* createCanvas(400, 400, WEBGL); | ||
* | ||
* // Create an off-screen WebGL graphics buffer | ||
* let myBuffer = createGraphics(200, 200, WEBGL); | ||
* | ||
* let myBuffer = createFramebuffer({ width: 200, height: 200 }); | ||
* // Draw a red box on the off-screen buffer | ||
* myBuffer.background(0); // Set the background to black | ||
* myBuffer.noStroke(); | ||
* myBuffer.fill(255, 0, 0); // Set the fill color to red | ||
* myBuffer.push(); | ||
* myBuffer.translate(0, 0, 0); | ||
* myBuffer.box(100); // Draw a red box at the center | ||
* myBuffer.pop(); | ||
* myBuffer.draw(() => { | ||
* background(0); // Set the background to black | ||
* noStroke(); | ||
* fill(255, 0, 0); // Set the fill color to red | ||
* push(); | ||
* translate(0, 0, 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We maybe don't need the push/translate/pop since the translation is 0 here, but otherwise this is looking good! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thank you |
||
* box(100); // Draw a red box at the center | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we make the size of the box to be 50 i.e. |
||
* pop(); | ||
* }) | ||
* | ||
* // Get the color of a pixel at the center of the box (in 2D coordinates) | ||
* myBuffer.loadPixels(); // Load the pixel data for myBuffer | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry one last thing, 400x400 will be rather large for the reference, where examples are typically use 100x100 for pages like https://p5js.org/reference/p5/createFilterShader/. Could we maybe do the same here? There's also nothing wrong with a framebuffer larger than the main canvas, but it may be helpful for illustration purposes to also make
myBuffer
fit in that size too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries