Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
frameBuffer.pixelDensity example added
  • Loading branch information
deveshidwivedi authored Jan 19, 2024
commit b8b784b6f061187e308fef3fa3e4100a84ceeb22
26 changes: 26 additions & 0 deletions src/webgl/p5.Framebuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,32 @@ class Framebuffer {
* @method pixelDensity
* @param {Number} [density] A scaling factor for the number of pixels per
* side of the framebuffer
* @example
* <div>
* <code>
* let pg;
*
* function setup() {
* createCanvas(150, 150);
* pixelDensity(4);
* pg = createGraphics(75, 75);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm uncertain about whether we should include examples in all files containing the same method, such as pixelDensity, which is present in three files. If it's advisable, we could consider adding relevant examples in each corresponding file. What are your thoughts on this matter? for the example (pixelDensity), I believe we're referring to the method created on p5.framebuffer. Could we include an example related to using framebuffer instead of createGraphics? This might provide more relevant examples. What you think?

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, for p5.Framebuffer.pixelDensity it would indeed be more relevant to add an example using framebuffer instead of createGraphics.

* pg.pixelDensity(1);
* }
*
* function draw() {
* background(220);
* fill(255, 0, 0);
* ellipse(25, 25, 40, 40);
* pg.background(255);
* pg.fill(0, 0, 255);
* pg.ellipse(50, 50, 40, 40);
* image(pg, 75, 75);
* }
* </code>
* </div>
*
* @alt
* A red and a blue ellipse on a canvas.
*/
pixelDensity(density) {
if (density) {
Expand Down