processing/p5.js

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

Chiusa

#8157 aperta il 15 ott 2025

 (16 commenti) (0 reazioni) (1 assegnatario)JavaScript (3178 fork)batch import
Area:MathEnhancementGood First IssueHelp Wantedp5.js 2.0+

Metriche repository

Star
 (20.784 stelle)
Metriche merge PR
 (Merge medio 8g 13h) (45 PR mergiate in 30 g)

Descrizione

[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

Guida contributor