phetsims / kite

A library for creating, manipulating and displaying 2D shapes in JavaScript.
MIT License
12 stars 6 forks source link

Some font awesome shapes fail to render #88

Open samreid opened 3 years ago

samreid commented 3 years ago

From https://github.com/phetsims/sherpa/issues/81.

These icons throw errors during Shape construction:

Amazon
Aviato
Bitcoin
CanadianMapleLeaf
CcAmex
CcJcb
CcVisa
Confluence
DAndDBeyond
Discord
Discourse
DumpsterFire
Ember
Evernote
FilePdf
FireAlt
FirefoxBrowser
FreeCodeCamp
Frog
GithubSquare
Grav
Gripfire
Grunt
Hooli
Hornbill
ItchIo
ItunesNote
Java
JediOrder
Jira
Keycdn
KissWinkHeart
Language
Lastfm
Lyft
Mdb
Napster
Odnoklassniki
Pagelines
Paypal
Phabricator
PinterestSquare
Playstation
Pushed
PuzzlePiece
RProject
Rebel
Ribbon
Rockrms
Salesforce
Sass
Shopify
Studiovinari
StumbleuponCircle
Usps
Viber
Vnv
WatchmanMonitoring
Wix
WizardsOfTheCoast
Wordpress
Yarn
YoutubeSquare
Zhihu

For instance, Amazon throws this error (when asserts are enabled):

Vector2.js:256 Uncaught Error: Cannot normalize a zero-magnitude vector
    at Vector2.normalized (Vector2.js:256)
    at Cubic.getEndTangent (Cubic.js:361)
    at Cubic.get endTangent [as endTangent] (Cubic.js:365)
    at Subpath.addSegmentDirectly (Subpath.js:165)
    at Subpath.addSegment (Subpath.js:187)
    at Shape.addSegmentAndBounds (Shape.js:1744)
    at Shape.js:596
    at u (lodash-4.17.4.min.js:5)
    at Function.ru (lodash-4.17.4.min.js:67)
    at Shape.cubicCurveToPoint (Shape.js:595)

I saw another failure mode with assertions disabled, but cannot figure out which icon(s) it was for, where NaN are leaking into the path commands.

samreid commented 3 years ago

If I disable assertions, Amazon seems to render OK, add this line to any screenView:

this.addChild( new Amazon( { fill: 'black' } ) );

image