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 processing/p5.js-website#493 would allow people like me to find constrain()
faster).