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.
This pull request adds a
lineDash()
function to the p5 prototype which provides an easy way to draw dashed lines.The implementation is based on the native
CanvasRenderingContext2D.getLineDash()
/CanvasRenderingContext2D.setLineDash()
methods.The changes include:
lineDash()
method definition inp5.Renderer2D
classlineDash()
method definition inp5
classAs this is my first pull request to the p5 project, I had a few problems with the parameter validation system which I didn't manage to get to work, so I'm looking for some help on that. Furthermore, I have no idea how to write tests for the new functionality, so I'll need help on that as well.
There are a few things about the API which I'm not sure about that I'd leave to someone more experienced than me to decide:
lineDash()
function accepts an array as its only argument for now, while we might consider to use rest parameters insteadlineDash()
function always returns the current line dash settings, and is therefore not chainablelineDash()
function can be called with no parameters (it just returns the current settings)noLineDash()
function equivalent to callinglineDash([])
might be a good addition, since it would probably make the API more clearstrokeCap()
andstrokeJoin()
)Looking forward to receiving your suggestions.