p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

[p5.js 2.0 Bug Report]: Not all primitive shape drawing goes through internal p5.Shape

Open davepagurek opened this issue 1 month ago • 7 comments

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 ShapePrimitive for arcs and ellipses
  • Updating the PrimitiveToPath2DVisitor to be able to convert those new primitives back into path drawing commands
  • Also updating the PrimitiveToVerticesVisitor to 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

davepagurek avatar Nov 18 '25 18:11 davepagurek

hi @davepagurek i would like to work on this issue please assign it to me

ayushman1210 avatar Nov 18 '25 23:11 ayushman1210

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!

ksen0 avatar Nov 19 '25 08:11 ksen0

hey @davepagurek @ksen0 i would like to work on this issue can you please assign it to me?

rounittxx avatar Nov 19 '25 10:11 rounittxx

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!

rounittxx avatar Nov 19 '25 12:11 rounittxx

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!

ksen0 avatar Nov 25 '25 19:11 ksen0

Yaa sure i m working on it.

rounittxx avatar Nov 26 '25 06:11 rounittxx

As an update: this issue is not currently being worked on, but it is reserved for a CodeDay microinternship. Thank you for understanding!

ksen0 avatar Dec 05 '25 16:12 ksen0