processing/p5.js

[2.0] Add array, vector overloads to `createVector()` for consistency

Closed

#8,157 opened on Oct 15, 2025

 (16 comments) (0 reactions) (1 assignee)JavaScript (3,178 forks)batch import
Area:MathEnhancementGood First IssueHelp Wantedp5.js 2.0+

Repository metrics

Stars
 (20,784 stars)
PR merge metrics
 (Avg merge 8d 13h) (45 merged PRs in 30d)

Description

[2.0] Add array, vector overloads to createVector() for consistency

Currently, vector operations often allow vectors to be specified in three ways: separate number arguments, a number array, or a vector instance. For example, add(), sub(), mult(), div(), and rem() all work this way. Ideally, we would always allow users to specify vectors in the same ways, so they don't need to guess which vector features accept which overloads. We already do this with color features like fill() and stroke(), which have a consistent set of overloads for specifying colors.

If adding array and vector overloads to createVector() sounds good, then we might also consider deprecating the copy() method, as it would no longer be needed: v.copy() could be replaced by createVector(v).

Edit: We don't plan to deprecate copy(). See this comment.

Tasks:

  • Reach consensus on adding overloads
  • Implement and document

Contributor guide