* Sets the value at the specified index of the vector. * * This method allows you to change a specific component of the vector by providing its index and the new value you want to set. * Think of the vector as a list of numbers, where each number represents a different direction (like x, y,
(index, value)
| 179 | * @throws Will throw an error if the index is outside the bounds of the vector, meaning if you try to set a value at a position that doesn't exist in the vector. |
| 180 | */ |
| 181 | setValue(index, value) { |
| 182 | if (index < this.values.length) { |
| 183 | this.values[index] = value; |
| 184 | } else { |
| 185 | this._friendlyError( |
| 186 | 'The index parameter is trying to set a value outside the bounds of the vector', |
| 187 | 'p5.Vector.setValue' |
| 188 | ); |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * Gets the y component of the vector. |
nothing calls this directly
no test coverage detected