Skip to content

Add dashed lines to the core API #5670

@ianstormtaylor

Description

@ianstormtaylor

Increasing Access

Unsure. But I believe it would reduce the mental barriers to a very common goal, which feels like increasing access for people with less math-heavy or programming-heavy backgrounds.

Most appropriate sub-area of p5.js?

  • Accessibility (Web Accessibility)
  • Build tools and processes
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Friendly error system
  • Image
  • IO (Input/Output)
  • Localization
  • Math
  • Unit Testing
  • Typography
  • Utilities
  • WebGL
  • Other (specify if possible)

Feature request details

P5.js should add dashed lines as a core construct. Dashed lines are really common when working in sketches... either for hierarchical reasons (eg. a less important line) or just pure aesthetics reasons (eg. in generative art).

This has been brought up before in #3016 and #3336, but it was waived off then.

There is a "workaround" that involves dipping into the Canvas API's own setLineDash method, but the problem with that is that you can't rely on dashing across rendering contexts... so if you want to switch to rendering with SVG or WebGL you have to find a new approach. And because of this, downstream plugins and addons can't rely on it.

To have a rendering-agnostic approach right now you'd have to do some very heavy math to be able to convert any potential lines, curves, shapes, etc. to a ton of individual segments, which is not only very complex to write, but likely less performant.

I think this is such common functionality—evidenced by both Canvas and SVG (stroke-dasharray) having implemented this natively—that it should be handled in core so that rendering contexts (and external plugins) can build on top of a predictable target.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Open for Discussion

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions