From 41f5c22ed1108601513948221a6979af5337ee8f Mon Sep 17 00:00:00 2001 From: Jonathan Olson Date: Wed, 17 Jul 2019 23:04:24 -0600 Subject: [PATCH] Omit an ending line segment (when writing a shape to a Canvas context) if our path is closed, see https://github.com/phetsims/ph-scale/issues/83 --- js/util/Subpath.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/js/util/Subpath.js b/js/util/Subpath.js index 944bbc0..a6a5871 100644 --- a/js/util/Subpath.js +++ b/js/util/Subpath.js @@ -346,6 +346,13 @@ define( function( require ) { context.moveTo( startPoint.x, startPoint.y ); // the segments assume the current context position is at their start var len = this.segments.length; + + // Omit an ending line segment if our path is closed. + // see https://github.com/phetsims/ph-scale/issues/83#issuecomment-512663949 + if ( this.closed && len >= 2 && this.segments[ len - 1 ] instanceof Line ) { + len--; + } + for ( var i = 0; i < len; i++ ) { this.segments[ i ].writeToContext( context ); }