Add a clamp() alias for constrain() or mention clamp in the docs
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 24k
- Forks
- 3.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 25
Description
Increasing access
People who come from other frameworks and languages will have an easier time finding the relevant function for clamping numbers in p5.js.
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
Feature enhancement details
The typical name for the constrain(x, min, max) function in p5.js, used across the math and computing world, is clamp. E.g. see OpenGL, Godot/Unity, C#, Java, CSS, and C++.
In comparision, less popular names include clip, used by Numpy and Octave/Mathematica/Wolphram, and, well, constrain, used by Processing/Arduino/P5.js and MakeCode.
Hence I think that it would make sense to either have clamp() as an alias to constrain() (ideal for me, as I always end up reaching for "clamp" before realizing it's different in p5), or to add a note in constrain()'s documentation that explains it's also known as clamp() elsewhere (which, together with https://github.com/processing/p5.js-website/issues/493 would allow people like me to find constrain() faster).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the p5.js constrain() reference and the Math area identified in the issue. Determine whether the contribution should provide a clamp() alias or document clamp as an alternate name; done means the chosen option is available or discoverable through the constrain() documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, documentation
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100