processing/p5.js

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

Fermée

#8 157 ouverte le 15 oct. 2025

 (16 commentaires) (0 réaction) (1 personne assignée)JavaScript (3 178 forks)batch import
Area:MathEnhancementGood First IssueHelp Wantedp5.js 2.0+

Métriques du dépôt

Stars
 (20 784 étoiles)
Métriques de merge PR
 (Merge moyen 8j 13h) (45 PRs mergées en 30 j)

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

Guide contributeur