Skip to content

custom loading animations should automatically add a push()/pop() to match draw() behavior #9367

Open

Description

@ksen0

Topic

I've been trying out the custom loading animations in the new RC: https://openprocessing.org/@p5js/3047815 and I noticed that push(); and pop(); are always needed when there are any transforms.

For example:

function draw() {
  // This example is based on an example in
  // https://day.processing.org/activity-guide/a-coding-train-zine/
  // A Coding Train Zine by Dan Shiffman, Cy X
  background(51);
  translate(200, height);

  stroke(255, 0, 255);
  branch(100, map(sin(millis() / 1300), -1, 1, 0, PI));

  stroke(255, 255, 0);
  branch(100, map(sin(millis() / 1100), -1, 1, 0, PI));
}

...

Would be valid p5.js, that would reset state between draws. But using an existing valid p5.js sketch in a custom loading animation requires realizing that the reason it looks broken is that there's a missing implicit push/pop. Even fi not a "bug" I could imagine this could be confusing behavior

Activity

  1. ksen0 commented on Nov 2, 2026

    @ksen0
    MemberAuthor

    @Jextic @limzykenneth I don't think this should be blocking/urgent (or should it?), and I think there's a deeper perhaps question here of what we expect people to do with custom animation.

  2. limzykenneth commented on Nov 3, 2026

    @limzykenneth
    Member

    I think we can consider doing similar to draw and have automatic push pop later. It won't affect loading animations that already does their own push pop and for animations, and it is probably unusual for any animations to expect transformation to accumulate over time since that is contrary to what p5.js itself does.

    This don't need to be blocking 2.4 since loading animation itself is new and experimental (could be worth noting in release notes if not already), and putting in the default push pop is likely additive considering the above.

  3. changed the title [-]2.4.0-rc.3: custom Loading Animation requires push/pop when draw() wouldn't[/-] [+]custom loading animations should automatically add a push()/pop() to match draw() behavior[/+] on Nov 3, 2026
  4. added this to the 2.x Anytime milestone on Nov 3, 2026
  5. Deekshitha-089 commented on Nov 4, 2026

    @Deekshitha-089

    Hi! I'd be interested in working on this issue.
    I understand that the goal is to make custom loading animations automatically reset drawing state between frames, similar to the behavior of draw().
    Would it be okay if I investigated the current loading animation implementation and proposed a solution with appropriate tests?
    I'd also appreciate any pointers to the relevant implementation files.
    Thanks!

  6. ksen0 commented on Nov 4, 2026

    @ksen0
    MemberAuthor

    Sure @Deekshitha-089, welcome! the loading animation was introduced by Jextic in #9119 (this was building on previous work #8997) Those discussions may also be useful for thinking about how to both manually and automatically test this. If you spot any thing weird about the loading animation please do report bugs, it's a very new feature (for example, a recent edge case fix: #9365) so bug reporting is extra helpful.

    Here is an example usage: https://openprocessing.org/@p5js/3047815 (the sketch shared above)

    Please post your findings and ideas here so we can verify the approach, before making a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions