Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8191035

WebView Canvas Graphics2D arc renders incorrectly

XMLWordPrintable

    • web

        We have been attempting to use JavaFx WebView with canvas and 2d Graphics for
        trying to recreate a pie chart, but a simple arc does not draw correctly in WebView,
        Since our application requires use of drawing canvas arcs, we need this fixed.

        Here is codepen which you can use to recreate the problem:

        https://codepen.io/blueShell/pen/MENyRJ

        Here is the same source HTML
        {code}
        <html>
        <head>
          <title></title>
        </head>

        <body>
            <canvas id="myCanvas" width="578" height="250"></canvas>
            <script>
              var canvas = document.getElementById('myCanvas');
        var context = canvas.getContext('2d');
        var x = canvas.width / 2;
        var y = canvas.height / 2;
        var radius = 75;
        var startAngle = 0;
        startAngle = startAngle - (Math.PI / 2.0);
        var ratio = 0.59;
        var endAngle = ratio * Math.PI * 2.0;
        endAngle = endAngle - (Math.PI / 2.0);
        var counterClockwise = false;

        context.beginPath();
        context.arc(x, y, radius, startAngle, endAngle, counterClockwise);
        context.lineWidth = 15;

        // line color
        context.strokeStyle = 'black';
        context.stroke();
            </script>
        </body>
        </html>
        {code}

        Attached are screen shots comparing the arc in different browsers showing WebView is incorrect when compared in Chrome and IE11.

          1. arc.html
            0.7 kB
          2. arc1.html
            0.8 kB
          3. arc-simple-2.diff
            8 kB
          4. webViewArcNotWorking.png
            webViewArcNotWorking.png
            12 kB

              arajkumar Arunprasad Rajkumar
              shadowbug Shadow Bug
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: