Skip to content

[p5.js 2.0 Bug Report]: frameCount stops updating if set to any value #8281

@juaogeneroso

Description

@juaogeneroso

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.5

Web browser and version

142.0.7444.163 (Official Build) (64-bit) (cohort: Stable)

Operating system

Windows 10

Steps to reproduce this

Steps:

  1. At any moment, set the frameCount to any value.
  2. The frameCount will stop updating and the console will log "You just changed the value of "frameCount", which was a p5 global value. This could cause problems later if you're not careful."

Snippet:

function setup() {
  createCanvas(400, 400);
}

function draw() {
  background(0);
  circle(frameCount % width, height * 0.5, 50);
  
  // frameCount stops updating at frame 30, after it gets changed
  if (frameCount > 30) frameCount = 0;

  // the draw() continues looping
  print("I'm running!");
}

I couldn’t find any information on whether this is an intentional change or a bug.
In any case, this behavior limits the possibilities of the frameCount variable. In p5.js 1.x it could be freely manipulated, allowing for looping or resetting animations and other time manipulations.

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