Skip to content

Add Interactive Support for p5.Shapes #9405

Open

Description

@VANSH3104

Context

The existing p5.Shape system provides a way to create and render custom shapes using primitives such as vertices, curves, ellipses and rectangles.

A possible next step is to extend this infrastructure so that Shapes can also respond to user interactions, allowing developers to use custom Shapes as buttons and other interactive UI elements.

Rather than introducing a completely separate system, we could explore building on the existing Shape geometry and path conversion infrastructure.

Goals

  • Support pointer-based interactions with Shapes.
  • Enable hit-testing for existing Shape primitives.
  • Consider both filled and stroked regions during hit-testing.
  • Support hover, press, release and click interactions.
  • Allow multiple interactive Shapes to work together.
  • Explore interaction support for ShapeCollections.

Expected Outcome

Developers should be able to make p5.Shape objects interactive and use custom Shapes as buttons or other interactive elements.

Activity

  1. welcome commented on Nov 15, 2026

    @welcome

    Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, please make sure to fill out the inputs in the issue forms.

    For guidance on contributing, check out our contributing guidelines and other resources for contributors.
    💬 If you have questions or need support, feel free to join the Processing Foundation Forum or visit our Community page.
    📜 Please also review our Code of Conduct to understand our community standards.
    Thank You!

  2. VANSH3104 commented on Nov 15, 2026

    @VANSH3104
    MemberAuthor

    Hey @ksen0, @diyaayay, @davepagurek, tagging you all here to get your thoughts on the initial approach.

    I was thinking that instead of introducing a completely new approach, we could explore extending the existing p5.Shape functionality.

    We already have PrimitiveToPath2DConverter in `custom_shapes.js, which converts Shape primitives into Canvas Path2D objects. and the existing geometry infrastructure. One possibility is to build on these for hit-testing using Canvas APIs like isPointInPath() and isPointInStroke(). Do you think this would be a good direction, or should we explore other approaches?

    I think we could start with hit-testing for the existing primitives, validate that approach, and then build pointer interactions on top of it. I'm open to alternatives if there's a better fit for the Shape system.

    Bounding-box calculations could also be useful as the number of interactive Shapes grows. Do you think they're needed initially, or can we start with a simpler approach?

    These are just my initial thoughts. I'd love to hear your perspectives!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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