Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sketches with low framerate flickers on resize #4

Open
Ucodia opened this issue Feb 25, 2023 · 0 comments
Open

Sketches with low framerate flickers on resize #4

Ucodia opened this issue Feb 25, 2023 · 0 comments

Comments

@Ucodia
Copy link
Owner

Ucodia commented Feb 25, 2023

Sketches which have a low framerate defined and resize the canvas when the window id resized, show some flickering behaviour.
Here is an example:

<!DOCTYPE html>
<html>
  <body>
    <div id="container"></div>
    <script type="module">
      import u5 from "https://www.unpkg.com/u5js@0.4.2/index.js";

      const example = (sketch) => {
        sketch.setup = function () {
          sketch.createCanvas(sketch.windowWidth, sketch.windowHeight);
          sketch.frameRate(25);
        };

        sketch.draw = function () {
          sketch.background("white");
          sketch.fill("black");
          sketch.noStroke();
          const d = Math.min(sketch.width, sketch.height) / 2;
          sketch.ellipse(sketch.width / 2, sketch.height / 2, d, d);
        };

        sketch.windowResized = () => {
          sketch.resizeCanvas(sketch.windowWidth, sketch.windowHeight);
        };
      };

      new u5(example, document.getElementById("container"));
    </script>
  </body>
</html>

Actual result: Canvas flickers when resized
Expected result: Canvas should not flicker when resized

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant