Add drawStar() function to draw customizable star shapes #7816
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes:
star(x, y, radius1, radius2, npoints)
top5.prototype
insrc/core/shape/2d_primitives.js
.test-star.html
andtest-star-interactive.html
to illustrate basic and interactive usage.Description:
I found that the project didn’t have a clearly documented or easily accessible star-drawing function, so I contributed
p5.prototype.star
, located around line 1490-1517 insrc/core/shape/2d_primitives.js
.Implementation details:
x
,y
— center position of the starradius1
— outer radiusradius2
— inner radiusnpoints
— number of star points (default 5)beginShape()
.radius1
andradius2
.endShape(CLOSE)
to complete the star.This function enhances the creative capabilities of p5.js, especially for users working in visual arts and design.
Screenshots of the change:
(Add screenshots here if available, e.g. result of test-star.html)
PR Checklist
npm run lint
passes