processing / processing/p5.js

[p5.js 2.0+ Bug Report]: p5.Vector.x set doesn't work on 1D vector

Open Beginner friendly
#8,924 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area:Math p5.js 2.0+ Patch Reserved (CodeDay)
Dominant language
JavaScript
Stars
24k
Forks
3.8k
Avg merge
3d 16h
Merged PRs (30d)
25

Description

Most appropriate sub-area of p5.js?
  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • WebGPU
  • p5.strands
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)
p5.js version

2.3.0

Web browser and version

Brave 1.90.122

Operating system

Linux Mint 22.1

Steps to reproduce this
Steps:
  1. Create a 1D vector
  2. Set v.x to change the "x" value
  3. Show that setting v.x didn't work
Snippet:
function setup() {
  let v = createVector(1);
  v.x = 2;
  
  // This should print "vector[2]", but prints "vector[1]"
  print(v.toString());
}
Problem

The code contains a comparison if (this.values.length > 1); it doesn't work because the length is 1. The comparison should be if (this.values.length > 0).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the p5.Vector implementation and the comparison on this.values.length described in the issue. Reproduce the provided createVector(1) snippet, then verify that assigning v.x changes the printed vector from vector[1] to vector[2].

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
75/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.