[p5.js 2.0 Bug Report]: Not all primitive shape drawing goes through internal p5.Shape
Most appropriate sub-area of p5.js?
- [ ] Accessibility
- [ ] Color
- [x] Core/Environment/Rendering
- [ ] Data
- [ ] DOM
- [ ] Events
- [ ] Image
- [ ] IO
- [ ] Math
- [ ] Typography
- [ ] Utilities
- [ ] WebGL
- [ ] Build process
- [ ] Unit testing
- [ ] Internationalization
- [ ] Friendly errors
- [ ] Other (specify if possible)
p5.js version
2.x
Web browser and version
All
Operating system
All
Steps to reproduce this
Not exactly a bug, but, in debugging https://github.com/processing/p5.js/issues/7903, we noticed that while some drawing functions end up going through our internal p5.Shape representation, others manually apply drawing commands like ctx.ellipse(centerX, centerY, radiusX, radiusY, 0, 0, 2 * Math.PI). This works for now, but:
- we have more code paths to consider when we need to make changes to rendering, and more to maintain
- in the future, if we want to be able to expose p5.Shape to users (e.g. via a future
loadSVG()function), we won't have primitives ready to turn those shape components into
It would be great if we could add support for those primitives in p5.Shape, which involves:
- Making a subclass of
ShapePrimitivefor arcs and ellipses - Updating the
PrimitiveToPath2DVisitorto be able to convert those new primitives back into path drawing commands - Also updating the
PrimitiveToVerticesVisitorto be able to convert those to vertices in WebGL - Updating the code that renders arcs and ellipses to now use p5.Shape instead of manually issuing drawing commands
hi @davepagurek i would like to work on this issue please assign it to me
Hi @ayushman1210, I've checked your currently open PRs, and looks like there are already outstanding reviews and questions for your to address on your open issues. So please work on these before taking on new work.
Thanks for making this @davepagurek! For now, I'll mark this issue as reserved for CodeDay.org - so only volunteers from the CodeDay internship will be assigned.
Thank you everyone!
hey @davepagurek @ksen0 i would like to work on this issue can you please assign it to me?
Hi @ksen0,
I realise this issue is reserved for CodeDay.org, but I’ve been studying the relevant parts of the codebase — specifically ShapePrimitive, the PrimitiveToPath2DVisitor, and PrimitiveToVerticesVisitor, as well as how arcs/ellipses currently bypass p5.Shape and call canvas APIs directly. I’m a beginner, but I’m comfortable exploring these internals and would like to take on implementing the missing primitive classes and updating the visitors/rendering paths.
If the reservation is strict, no problem — I’ll look for another issue. Otherwise, I’d appreciate the opportunity to work on this. Thanks!
Hi @rounittxx ! Thanks for your interest. Since the next CodeDay round of work starts a bit later, we're happy to open this issue to you for work.
However, please create a PR by Dec 5th. If you're not finished by then, you can mark it as a "draft." So if it turns out you don't have time for it or if it needs a lot of additional work or iteration, we could reassign it. I hope that makes sense! (Typically, tasks do not have a specific time constraint, so you're welcome to look for other open work instead if Dec 5th is too soon.)
Please don't hesitate to ask for help form me or @davepagurek here or on Discord!
Yaa sure i m working on it.
As an update: this issue is not currently being worked on, but it is reserved for a CodeDay microinternship. Thank you for understanding!