processing/p5.js

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

クローズ

#8,157 opened on 2025/10/15

 (16 件のコメント) (0 件のリアクション) (1 人の担当者)JavaScript (3,178 件のフォーク)batch import
Area:MathEnhancementGood First IssueHelp Wantedp5.js 2.0+

Repository metrics

Stars
 (20,784 個のスター)
PR merge metrics
 (平均マージ 8d 13h) (30d で 45 merged PRs)

説明

[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

コントリビューターガイド