Giter Club home page Giter Club logo

u5.js's People

Contributors

ucodia avatar

Watchers

 avatar

u5.js's Issues

fill() style is overridden by background()

When calling background() after fill() the fill style is overridden with the background style.

Example to reproduce

<!DOCTYPE html>
<html>
  <body>
    <div id="container"></div>
    <script type="module">
      import u5 from "https://www.unpkg.com/[email protected]/index.js";

      const example = (sketch) => {
        sketch.setup = function () {
          sketch.createCanvas(sketch.windowWidth, sketch.windowHeight);
          sketch.fill("blue");
        };

        sketch.draw = function () {
          sketch.background("red");
          // sketch.fill("blue");
          sketch.rect(100, 100, sketch.width - 200, sketch.height - 200);
        };
      };

      new u5(example, document.getElementById("container"));
    </script>
  </body>
</html>
  • Actual result: The rectangle is filled red
  • Expected result: The rectangle should be filled blue

Sketches with low framerate flickers on resize

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/[email protected]/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

ellipse() are drawn twice larger in u5.js than in p5.js

Currently the ellipse function is using parameters as radiuses of X/Y instead of width/height as in p5.js.

this.ellipse = function (x, y, rx, ry)

This should be

this.ellipse = function (x, y, w, h)

As a result, ellipses are drawn twice larger with u5.js.

fill() and stroke() styles defined in setup() are overridden after canvas resize

When calling fill() and stroke() in the setup(), the fill and stroke styles are overridden after a canvas resize.

Example to reproduce

<!DOCTYPE html>
<html>
  <body>
    <div id="container"></div>
    <script type="module">
      import u5 from "https://www.unpkg.com/[email protected]/index.js";

      const example = (sketch) => {
        sketch.setup = function () {
          sketch.createCanvas(sketch.windowWidth, sketch.windowHeight);
          sketch.stroke("red");
          sketch.fill("blue");
        };

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

        sketch.draw = function () {
          sketch.rect(100, 100, sketch.width - 200, sketch.height - 200);
        };
      };

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

Actual result: After resize, the rectangle is filled black with a black stroke
Expected result: After resize, the rectangle should be filled filled blue with a red stroke

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.