Skip to content

Commit

Permalink
Adding assertion to warn about the situation in #196.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Mar 12, 2014
1 parent ecff992 commit 1dfb61b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions js/nodes/Path.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ define( function( require ) {
// add new ones if applicable
this.addSVGFillDef( svg, defs );
this.addSVGStrokeDef( svg, defs );

assert && assert( !this.requiresSVGBoundsWorkaround(), 'No workaround for https://github.com/phetsims/scenery/issues/196 is provided at this time, please add an epsilon' );
},

// cleans up references created with udpateSVGDefs()
Expand Down
10 changes: 10 additions & 0 deletions js/nodes/Strokable.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,16 @@ define( function( require ) {
return style;
};

// if we have to apply a transform workaround for https://github.com/phetsims/scenery/issues/196 (only when we have a pattern or gradient)
proto.requiresSVGBoundsWorkaround = function() {
if ( !this._stroke || !this._stroke.getSVGDefinition ) {
return false;
}

var bounds = this.computeShapeBounds( false ); // without stroke
return bounds.x * bounds.y === 0; // at least one of them was zero, so the bounding box has no area
};

proto.getSimpleCSSFill = function() {
// if it's a Color object, get the corresponding CSS
// 'transparent' will make us invisible if the fill is null
Expand Down

0 comments on commit 1dfb61b

Please sign in to comment.