Skip to content

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

@davepagurek

Description

@davepagurek

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)

p5.js version

2.x

Web browser and version

All

Operating system

All

Steps to reproduce this

Not exactly a bug, but, in debugging #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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions