-
-
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
Made a new method to return Geometry with no internal colors. #6498
Conversation
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.
Nice work on this! I think we just want to add some documentation to the new method now.
src/webgl/3d_primitives.js
Outdated
* Clears the internal Color of the Geometry. | ||
* @method clearColors | ||
*/ | ||
p5.prototype.clearColors = function () { |
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.
I think maybe we can take out this method now that we have one on p5.Geometry
.
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.
Okay
@@ -88,6 +88,10 @@ p5.Geometry = class Geometry { | |||
this.dirtyFlags = {}; | |||
} | |||
|
|||
clearColors() { |
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.
Do you think you can add a doc comment around this one? It would be nice to add your example in the video in your PR description. Maybe we can add two examples: one showing the behaviour without clearColors()
, and one showing the behaviour with clearColors()
?
Here's an example of a doc comment with an example sketch on another class. Adding one here would look similar:
p5.js/src/webgl/p5.Framebuffer.js
Lines 750 to 794 in 716554f
/** | |
* Removes the framebuffer and frees its resources. | |
* | |
* @method remove | |
* | |
* @example | |
* <div> | |
* <code> | |
* let framebuffer; | |
* function setup() { | |
* createCanvas(100, 100, WEBGL); | |
* } | |
* | |
* function draw() { | |
* const useFramebuffer = (frameCount % 120) > 60; | |
* if (useFramebuffer && !framebuffer) { | |
* // Create a new framebuffer for us to use | |
* framebuffer = createFramebuffer(); | |
* } else if (!useFramebuffer && framebuffer) { | |
* // Free the old framebuffer's resources | |
* framebuffer.remove(); | |
* framebuffer = undefined; | |
* } | |
* | |
* background(255); | |
* if (useFramebuffer) { | |
* // Draw to the framebuffer | |
* framebuffer.begin(); | |
* background(255); | |
* rotateX(frameCount * 0.01); | |
* rotateY(frameCount * 0.01); | |
* fill(255, 0, 0); | |
* box(30); | |
* framebuffer.end(); | |
* | |
* image(framebuffer, -width/2, -height/2); | |
* } | |
* } | |
* </code> | |
* </div> | |
* | |
* @alt | |
* A rotating red cube blinks on and off every second. | |
*/ | |
remove() { |
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.
Okay, I will add a doc comment around this one.
@davepagurek , I have added a doc comment with two examples. Can you check and suggest what else we need? |
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.
Nice work so far, and great comments in the example! I just have a few more comments to clean up the example a bit.
src/webgl/p5.Geometry.js
Outdated
* for (let vec of points) vertex(vec.x * 200, vec.y * 200, vec.z * 200); | ||
* endShape(CLOSE); | ||
* shape02 = endGeometry(); | ||
* // You can also call shape02.clearColors() here. |
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.
How do you feel about putting the clearColors()
here? It also works having it in draw
, but it only needs to be called once, so it feels like only doing it once when building the shape fits more cleanly.
src/webgl/p5.Geometry.js
Outdated
* let points = []; | ||
* | ||
* function setup() { | ||
* renderer = createCanvas(600, 600, WEBGL); |
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.
I think we can take out the renderer =
because we don't use it elsewhere.
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 yess... I will take out that.
src/webgl/p5.Geometry.js
Outdated
@@ -87,7 +87,59 @@ p5.Geometry = class Geometry { | |||
|
|||
this.dirtyFlags = {}; | |||
} | |||
|
|||
/** | |||
* Removes the internal Colors of p5.Geometry |
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.
Maybe we can add one more sentence after this explaining that this lets you supply new colors with fill()
before drawing it? And otherwise, fill()
gets ignored?
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.
Yes. I was also thinking of that... Okay going to add this.
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.
One other small request: could we add a period at the end of the sentence so it fits with the style of the next bit of text? other than that I think everything looks good!
src/webgl/p5.Geometry.js
Outdated
@@ -90,7 +90,7 @@ p5.Geometry = class Geometry { | |||
/** | |||
* Removes the internal Colors of p5.Geometry | |||
* Using clearColors, you can use 'fill()' to supply new colors before drawing each shape. | |||
* If clearColors() is not used, the shapes will use their internal colors. | |||
* If clearColors() is not used, the shapes will use their internal colors by ignoring 'fill()'. |
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.
If you use backticks around the function names, they'll get rendered like code:
by ignoring `fill()`.
...becomes:
by ignoring fill()
.
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.
Okay...gonna do it.
@davepagurek Does it looks good now? |
Any other change you want @davepagurek ? |
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.
Found two tiny things, and after that we're good to merge!
src/webgl/p5.Geometry.js
Outdated
/** | ||
* Removes the internal Colors of p5.Geometry. | ||
* Using clearColors, you can use `fill()` to supply new colors before drawing each shape. | ||
* If clearColors() is not used, the shapes will use their internal colors by ignoring `fill()`. |
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.
One more spot where we can use backticks:
* If clearColors() is not used, the shapes will use their internal colors by ignoring `fill()`. | |
* If `clearColors()` is not used, the shapes will use their internal colors by ignoring `fill()`. |
src/webgl/p5.Geometry.js
Outdated
@@ -87,7 +87,60 @@ p5.Geometry = class Geometry { | |||
|
|||
this.dirtyFlags = {}; | |||
} | |||
|
|||
/** | |||
* Removes the internal Colors of p5.Geometry. |
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 also, we have an extra capital in here:
* Removes the internal Colors of p5.Geometry. | |
* Removes the internal colors of p5.Geometry. |
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.
Ok gonna do ASAP, wait
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.
Btw nice observation 😅
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.
Everything looks good to go now, thanks! 😁
Sorry @davepagurek for these all mistakes. And thankyou so much for the constant support. |
No worries! Don't think of it so much as finding mistakes, rather it's just always helpful having an editor/reviewer to catch things that slip by. Hopefully it relieves some of the pressure knowing you don't have to get everything right yourself the first time because someone else is also helping to check! |
Yes, Thankyou so much. Love to contribute more like this. |
Resolves #6384
Changes:
PR.mp4
Description:
let shap01;
function setup() {
renderer = createCanvas(600, 600, WEBGL);
buildShape02();
}
function draw() {
background(0);
fill("yellow");
model(shape02);
}
function buildShape02() {
beginGeometry();
fill("red"); //The box is red
box(50);
shape02 = endGeometry();
shape02.clearColors(); //After calling this the box becomes yellow as it removes internal colors.
}
PR Checklist
npm run lint
passes