processing/p5.js

Add dashed lines to the core API

Open

#5,670 创建于 2022年5月7日

在 GitHub 查看
 (29 评论) (3 反应) (0 负责人)JavaScript (3,178 fork)batch import
Area:CoreDiscussionFeature RequestHelp Wanted

仓库指标

Star
 (20,784 star)
PR 合并指标
 (平均合并 8天 13小时) (30 天内合并 45 个 PR)

描述

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 https://github.com/processing/p5.js/issues/3016 and https://github.com/processing/p5.js/issues/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.

贡献者指南