From 0c0b272ccc209ce86cb70142071ace4627eaee86 Mon Sep 17 00:00:00 2001 From: Twilrom Date: Tue, 13 Feb 2018 15:49:38 +0100 Subject: [PATCH] Update WebGL Graphics.arc to work more like on Canvas --- .../webgl/pipelines/FlatTintPipeline.js | 49 +++++++++++++------ 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/src/renderer/webgl/pipelines/FlatTintPipeline.js b/src/renderer/webgl/pipelines/FlatTintPipeline.js index c56b04db4..3f60182cf 100644 --- a/src/renderer/webgl/pipelines/FlatTintPipeline.js +++ b/src/renderer/webgl/pipelines/FlatTintPipeline.js @@ -796,6 +796,7 @@ var FlatTintPipeline = new Class({ var path = null; var sin = Math.sin; var cos = Math.cos; + var PI2 = Math.PI * 2; var sr = sin(srcRotation); var cr = cos(srcRotation); var sra = cr * srcScaleX; @@ -835,31 +836,51 @@ var FlatTintPipeline = new Class({ endAngle = commands[cmdIndex + 5]; anticlockwise = commands[cmdIndex + 6]; + if (lastPath === null) + { + lastPath = new Path(x + cos(startAngle) * radius, y + sin(startAngle) * radius, lineWidth, lineColor, lineAlpha); + pathArray.push(lastPath); + iteration += iterStep; + } + + endAngle -= startAngle; if (anticlockwise) { - ta = endAngle; - endAngle = startAngle; - startAngle = -ta; + if (endAngle < -PI2) + { + endAngle = -PI2; + } + else if (endAngle > 0) + { + endAngle = -PI2 + endAngle % PI2; + } } - + else if (endAngle > PI2) + { + endAngle = PI2; + } + else if (endAngle < 0) + { + endAngle = PI2 + endAngle % PI2; + } + while (iteration < 1) { - ta = (endAngle - startAngle) * iteration + startAngle; + ta = endAngle * iteration + startAngle; tx = x + cos(ta) * radius; ty = y + sin(ta) * radius; - if (iteration === 0) - { - lastPath = new Path(tx, ty, lineWidth, lineColor, lineAlpha); - pathArray.push(lastPath); - } - else - { - lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha)); - } + lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha)); iteration += iterStep; } + + ta = endAngle + startAngle; + tx = x + cos(ta) * radius; + ty = y + sin(ta) * radius; + + lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha)); + cmdIndex += 6; break;