Skip to content

gr.setlinewidth is broken in Javascript #194

@EmDash00

Description

@EmDash00

I've been playing around a bit with the Javascript package and this function appears to be broken. Setting different line widths doesn't appear to change the linewidth. I was planning on using this for a visualization and running an experiment, so if anyone could help that'd be great. Here's a sample script. Just compile the webassembly and try to run this html file (it's just the example in the docs but I set a different line width).

<!doctype html>
<html lang="en-us">

<head>
    <meta charset="utf-8">
    <title>gr.js example</title>
</head>

<body>
    <canvas id="example-canvas" width="500" height="500"></canvas>
    <script type="text/javascript" src="gr.js"></script>

    <script type="text/javascript">
      // Set up x and y values
      var x = new Array(201);
      var y = new Array(201);
      for (var i = 0; i < 201; i++) {
        x[i] = 2 * i / 200;
      }
      y[0] = 0;
      for (var i = 1; i < 201; i++) {
        y[i] = 0.9*y[i-1] + 0.4 * Math.random() - 0.2;
      }

      GR.ready(function() {
        var gr = new GR('example-canvas');

        function onFrame() {
          // Update x and y values
          for (var i = 0; i < 200; i++) {
            y[i] = y[i+1];
            x[i] = x[i+1];
          }
          y[200] = 0.9*y[200] + 0.4* Math.random() - 0.2;
          x[200] = x[199] + 0.01;

          // Draw new frame
          gr.clearws();
          gr.setviewport(0.1, 0.95, 0.1, 0.95);
          gr.setwindow(x[0], x[200], -1, 1);
          gr.grid(0.25, 0.25, 0, 0, 2, 2);
          gr.axes(0.25, 0.25, x[0], -1, 2, 2, 0.005);
          gr.axes(0.25, 0.25, x[200], 1, -2, -2, -0.005);
          gr.setlinewidth(20);  // Does nothing???
          gr.polyline(200, x, y);
          gr.textext(0.37, 0.97, "Plot Animation Demo");
          gr.textext(0.5, 0.01, "x");
          gr.textext(0.01, 0.525, "y");

          // Request to be called for the next frame
          window.requestAnimationFrame(onFrame);
        };
        window.requestAnimationFrame(onFrame);
      });
    </script>
</body>

</html>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions