My First Feedback (and a suggestion for a standard function for p5.js)

Hi to the community, I have begun making p5.js sketches recently to help instruct math and science at my university, and it’s perfect for our applications. So first of all, thanks to all the contributors and our friends at the Processing Foundation.

Anyways - it occurred to me that there is no 2D primitive for arrows. I will be drawing my arrows using a series of three line() functions (or maybe a line and triangle), but it would be super convenient if we added a standard 2D primitive for that, along with some function to control the size of the arrowhead and/or whether it is a 2-sided arrow or not.

I hope this is the right place to send my suggestions? Input appreciated :slight_smile:

3 Likes

Great to hear about your use of p5.js! Sounds like a useful feature to me. But actually the best place to ask for features is over on the GitHub page by making an issue. It’s fairly self explanatory from then on. If you don’t have a GitHub account I’d be happy to make the request for you just let me know.

An arrow isn’t a geometric drawing primitive, like a line or a rect. To me it doesn’t make sense to configure one with global settings (like stroke) --each arrow is a complex object with multiple configuration settings for its head, tail, and line, and many uses of arrow would have different setting for each instance.

For that reason I would be surprised if this became a built-in to the core library, even though drawing arrows is really useful. Instead, drawing arrows strikes me as a perfect example of a p5.js library – for example, like a diagramming library.

https://modeling-languages.com/javascript-drawing-libraries-diagrams/

Then all the things people want – single head, double head, hollow or filled, UML-style, ball-caps, curved line, orthogonal-line, etc. – could all be included as features of that library.

In the meantime, I would suggest creating a simple arrow class rather than a function.

3 Likes

This makes a lot of sense, actually! If I ever feel ambitious, I might just build that :slight_smile:
FYI I ended up doing a line+triangle, with a couple conditionals to make it scale correctly. Works great, but won’t work in all applications unfortunately