Skip to content

[p5.js 2.0 Beta Bug Report]: vertexProperty with single number arguments throws error #7518

@davepagurek

Description

@davepagurek

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

p5.js version

2.0 beta 1

Web browser and version

Firefox

Operating system

MacOS

Steps to reproduce this

Steps:

  1. Draw a shape with vertexProperty between each vertex
  2. Make sure you pass a single value as the property (e.g. 0) as opposed to an array (e.g. [0])

This throws the error Error: Can't convert 0 to array!. If you use an array, there is no error. It should be converting to an array under the hood, but I must have messed that up in the shapes refactor.

Snippet:

function setup() {
  createCanvas(400, 400, WEBGL);
  
  const pts = []
  for (let i = 0; i < 50; i++) {
      pts.push(createVector(random(width), random(height)))
  }
  
  const snake = buildGeometry(() => {
    noFill()
    beginShape()
    for (const [i, { x, y }] of pts.entries()) {
        vertexProperty('length', i/(pts.length-1))
        splineVertex(x, y)
    }
    endShape()
  })
}

Live: https://editor.p5js.org/davepagurek/sketches/YPu6ixNV5

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions