raphael_uncompressed.js 216 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815
  1. // ┌────────────────────────────────────────────────────────────────────┐ \\
  2. // │ Raphaël 2.1.0 - JavaScript Vector Library │ \\
  3. // ├────────────────────────────────────────────────────────────────────┤ \\
  4. // │ Copyright © 2008-2012 Dmitry Baranovskiy (http://raphaeljs.com) │ \\
  5. // │ Copyright © 2008-2012 Sencha Labs (http://sencha.com) │ \\
  6. // ├────────────────────────────────────────────────────────────────────┤ \\
  7. // │ Licensed under the MIT (http://raphaeljs.com/license.html) license.│ \\
  8. // └────────────────────────────────────────────────────────────────────┘ \\
  9. // ┌──────────────────────────────────────────────────────────────────────────────────────┐ \\
  10. // │ Eve 0.3.4 - JavaScript Events Library │ \\
  11. // ├──────────────────────────────────────────────────────────────────────────────────────┤ \\
  12. // │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://dmitry.baranovskiy.com/) │ \\
  13. // │ Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. │ \\
  14. // └──────────────────────────────────────────────────────────────────────────────────────┘ \\
  15. (function (glob) {
  16. var version = "0.3.4",
  17. has = "hasOwnProperty",
  18. separator = /[\.\/]/,
  19. wildcard = "*",
  20. fun = function () {},
  21. numsort = function (a, b) {
  22. return a - b;
  23. },
  24. current_event,
  25. stop,
  26. events = {n: {}},
  27. eve = function (name, scope) {
  28. var e = events,
  29. oldstop = stop,
  30. args = Array.prototype.slice.call(arguments, 2),
  31. listeners = eve.listeners(name),
  32. z = 0,
  33. f = false,
  34. l,
  35. indexed = [],
  36. queue = {},
  37. out = [],
  38. ce = current_event,
  39. errors = [];
  40. current_event = name;
  41. stop = 0;
  42. for (var i = 0, ii = listeners.length; i < ii; i++) if ("zIndex" in listeners[i]) {
  43. indexed.push(listeners[i].zIndex);
  44. if (listeners[i].zIndex < 0) {
  45. queue[listeners[i].zIndex] = listeners[i];
  46. }
  47. }
  48. indexed.sort(numsort);
  49. while (indexed[z] < 0) {
  50. l = queue[indexed[z++]];
  51. out.push(l.apply(scope, args));
  52. if (stop) {
  53. stop = oldstop;
  54. return out;
  55. }
  56. }
  57. for (i = 0; i < ii; i++) {
  58. l = listeners[i];
  59. if ("zIndex" in l) {
  60. if (l.zIndex == indexed[z]) {
  61. out.push(l.apply(scope, args));
  62. if (stop) {
  63. break;
  64. }
  65. do {
  66. z++;
  67. l = queue[indexed[z]];
  68. l && out.push(l.apply(scope, args));
  69. if (stop) {
  70. break;
  71. }
  72. } while (l)
  73. } else {
  74. queue[l.zIndex] = l;
  75. }
  76. } else {
  77. out.push(l.apply(scope, args));
  78. if (stop) {
  79. break;
  80. }
  81. }
  82. }
  83. stop = oldstop;
  84. current_event = ce;
  85. return out.length ? out : null;
  86. };
  87. eve.listeners = function (name) {
  88. var names = name.split(separator),
  89. e = events,
  90. item,
  91. items,
  92. k,
  93. i,
  94. ii,
  95. j,
  96. jj,
  97. nes,
  98. es = [e],
  99. out = [];
  100. for (i = 0, ii = names.length; i < ii; i++) {
  101. nes = [];
  102. for (j = 0, jj = es.length; j < jj; j++) {
  103. e = es[j].n;
  104. items = [e[names[i]], e[wildcard]];
  105. k = 2;
  106. while (k--) {
  107. item = items[k];
  108. if (item) {
  109. nes.push(item);
  110. out = out.concat(item.f || []);
  111. }
  112. }
  113. }
  114. es = nes;
  115. }
  116. return out;
  117. };
  118. eve.on = function (name, f) {
  119. var names = name.split(separator),
  120. e = events;
  121. for (var i = 0, ii = names.length; i < ii; i++) {
  122. e = e.n;
  123. !e[names[i]] && (e[names[i]] = {n: {}});
  124. e = e[names[i]];
  125. }
  126. e.f = e.f || [];
  127. for (i = 0, ii = e.f.length; i < ii; i++) if (e.f[i] == f) {
  128. return fun;
  129. }
  130. e.f.push(f);
  131. return function (zIndex) {
  132. if (+zIndex == +zIndex) {
  133. f.zIndex = +zIndex;
  134. }
  135. };
  136. };
  137. eve.stop = function () {
  138. stop = 1;
  139. };
  140. eve.nt = function (subname) {
  141. if (subname) {
  142. return new RegExp("(?:\\.|\\/|^)" + subname + "(?:\\.|\\/|$)").test(current_event);
  143. }
  144. return current_event;
  145. };
  146. eve.off = eve.unbind = function (name, f) {
  147. var names = name.split(separator),
  148. e,
  149. key,
  150. splice,
  151. i, ii, j, jj,
  152. cur = [events];
  153. for (i = 0, ii = names.length; i < ii; i++) {
  154. for (j = 0; j < cur.length; j += splice.length - 2) {
  155. splice = [j, 1];
  156. e = cur[j].n;
  157. if (names[i] != wildcard) {
  158. if (e[names[i]]) {
  159. splice.push(e[names[i]]);
  160. }
  161. } else {
  162. for (key in e) if (e[has](key)) {
  163. splice.push(e[key]);
  164. }
  165. }
  166. cur.splice.apply(cur, splice);
  167. }
  168. }
  169. for (i = 0, ii = cur.length; i < ii; i++) {
  170. e = cur[i];
  171. while (e.n) {
  172. if (f) {
  173. if (e.f) {
  174. for (j = 0, jj = e.f.length; j < jj; j++) if (e.f[j] == f) {
  175. e.f.splice(j, 1);
  176. break;
  177. }
  178. !e.f.length && delete e.f;
  179. }
  180. for (key in e.n) if (e.n[has](key) && e.n[key].f) {
  181. var funcs = e.n[key].f;
  182. for (j = 0, jj = funcs.length; j < jj; j++) if (funcs[j] == f) {
  183. funcs.splice(j, 1);
  184. break;
  185. }
  186. !funcs.length && delete e.n[key].f;
  187. }
  188. } else {
  189. delete e.f;
  190. for (key in e.n) if (e.n[has](key) && e.n[key].f) {
  191. delete e.n[key].f;
  192. }
  193. }
  194. e = e.n;
  195. }
  196. }
  197. };
  198. eve.once = function (name, f) {
  199. var f2 = function () {
  200. var res = f.apply(this, arguments);
  201. eve.unbind(name, f2);
  202. return res;
  203. };
  204. return eve.on(name, f2);
  205. };
  206. eve.version = version;
  207. eve.toString = function () {
  208. return "You are running Eve " + version;
  209. };
  210. (typeof module != "undefined" && module.exports) ? (module.exports = eve) : (typeof define != "undefined" ? (define("eve", [], function() { return eve; })) : (glob.eve = eve));
  211. })(this);
  212. // ┌─────────────────────────────────────────────────────────────────────┐ \\
  213. // │ "Raphaël 2.1.0" - JavaScript Vector Library │ \\
  214. // ├─────────────────────────────────────────────────────────────────────┤ \\
  215. // │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\
  216. // │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\
  217. // │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\
  218. // └─────────────────────────────────────────────────────────────────────┘ \\
  219. (function () {
  220. function R(first) {
  221. if (R.is(first, "function")) {
  222. return loaded ? first() : eve.on("raphael.DOMload", first);
  223. } else if (R.is(first, array)) {
  224. return R._engine.create[apply](R, first.splice(0, 3 + R.is(first[0], nu))).add(first);
  225. } else {
  226. var args = Array.prototype.slice.call(arguments, 0);
  227. if (R.is(args[args.length - 1], "function")) {
  228. var f = args.pop();
  229. return loaded ? f.call(R._engine.create[apply](R, args)) : eve.on("raphael.DOMload", function () {
  230. f.call(R._engine.create[apply](R, args));
  231. });
  232. } else {
  233. return R._engine.create[apply](R, arguments);
  234. }
  235. }
  236. }
  237. R.version = "2.1.0";
  238. R.eve = eve;
  239. var loaded,
  240. separator = /[, ]+/,
  241. elements = {circle: 1, rect: 1, path: 1, ellipse: 1, text: 1, image: 1},
  242. formatrg = /\{(\d+)\}/g,
  243. proto = "prototype",
  244. has = "hasOwnProperty",
  245. g = {
  246. doc: document,
  247. win: window
  248. },
  249. oldRaphael = {
  250. was: Object.prototype[has].call(g.win, "Raphael"),
  251. is: g.win.Raphael
  252. },
  253. Paper = function () {
  254. this.ca = this.customAttributes = {};
  255. },
  256. paperproto,
  257. appendChild = "appendChild",
  258. apply = "apply",
  259. concat = "concat",
  260. supportsTouch = "createTouch" in g.doc,
  261. E = "",
  262. S = " ",
  263. Str = String,
  264. split = "split",
  265. events = "click dblclick mousedown mousemove mouseout mouseover mouseup touchstart touchmove touchend touchcancel"[split](S),
  266. touchMap = {
  267. mousedown: "touchstart",
  268. mousemove: "touchmove",
  269. mouseup: "touchend"
  270. },
  271. lowerCase = Str.prototype.toLowerCase,
  272. math = Math,
  273. mmax = math.max,
  274. mmin = math.min,
  275. abs = math.abs,
  276. pow = math.pow,
  277. PI = math.PI,
  278. nu = "number",
  279. string = "string",
  280. array = "array",
  281. toString = "toString",
  282. fillString = "fill",
  283. objectToString = Object.prototype.toString,
  284. paper = {},
  285. push = "push",
  286. ISURL = R._ISURL = /^url\(['"]?([^\)]+?)['"]?\)$/i,
  287. colourRegExp = /^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+%?)?)\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\))\s*$/i,
  288. isnan = {"NaN": 1, "Infinity": 1, "-Infinity": 1},
  289. bezierrg = /^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,
  290. round = math.round,
  291. setAttribute = "setAttribute",
  292. toFloat = parseFloat,
  293. toInt = parseInt,
  294. upperCase = Str.prototype.toUpperCase,
  295. availableAttrs = R._availableAttrs = {
  296. "arrow-end": "none",
  297. "arrow-start": "none",
  298. blur: 0,
  299. "clip-rect": "0 0 1e9 1e9",
  300. cursor: "default",
  301. cx: 0,
  302. cy: 0,
  303. fill: "#fff",
  304. "fill-opacity": 1,
  305. font: '10px "Arial"',
  306. "font-family": '"Arial"',
  307. "font-size": "10",
  308. "font-style": "normal",
  309. "font-weight": 400,
  310. gradient: 0,
  311. height: 0,
  312. href: "http://raphaeljs.com/",
  313. "letter-spacing": 0,
  314. opacity: 1,
  315. path: "M0,0",
  316. r: 0,
  317. rx: 0,
  318. ry: 0,
  319. src: "",
  320. stroke: "#000",
  321. "stroke-dasharray": "",
  322. "stroke-linecap": "butt",
  323. "stroke-linejoin": "butt",
  324. "stroke-miterlimit": 0,
  325. "stroke-opacity": 1,
  326. "stroke-width": 1,
  327. target: "_blank",
  328. "text-anchor": "middle",
  329. title: "Raphael",
  330. transform: "",
  331. width: 0,
  332. x: 0,
  333. y: 0
  334. },
  335. availableAnimAttrs = R._availableAnimAttrs = {
  336. blur: nu,
  337. "clip-rect": "csv",
  338. cx: nu,
  339. cy: nu,
  340. fill: "colour",
  341. "fill-opacity": nu,
  342. "font-size": nu,
  343. height: nu,
  344. opacity: nu,
  345. path: "path",
  346. r: nu,
  347. rx: nu,
  348. ry: nu,
  349. stroke: "colour",
  350. "stroke-opacity": nu,
  351. "stroke-width": nu,
  352. transform: "transform",
  353. width: nu,
  354. x: nu,
  355. y: nu
  356. },
  357. whitespace = /[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]/g,
  358. commaSpaces = /[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*/,
  359. hsrg = {hs: 1, rg: 1},
  360. p2s = /,?([achlmqrstvxz]),?/gi,
  361. pathCommand = /([achlmrqstvz])[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*)+)/ig,
  362. tCommand = /([rstm])[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*)+)/ig,
  363. pathValues = /(-?\d*\.?\d*(?:e[\-+]?\d+)?)[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*/ig,
  364. radial_gradient = R._radial_gradient = /^r(?:\(([^,]+?)[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*([^\)]+?)\))?/,
  365. eldata = {},
  366. sortByKey = function (a, b) {
  367. return a.key - b.key;
  368. },
  369. sortByNumber = function (a, b) {
  370. return toFloat(a) - toFloat(b);
  371. },
  372. fun = function () {},
  373. pipe = function (x) {
  374. return x;
  375. },
  376. rectPath = R._rectPath = function (x, y, w, h, r) {
  377. if (r) {
  378. return [["M", x + r, y], ["l", w - r * 2, 0], ["a", r, r, 0, 0, 1, r, r], ["l", 0, h - r * 2], ["a", r, r, 0, 0, 1, -r, r], ["l", r * 2 - w, 0], ["a", r, r, 0, 0, 1, -r, -r], ["l", 0, r * 2 - h], ["a", r, r, 0, 0, 1, r, -r], ["z"]];
  379. }
  380. return [["M", x, y], ["l", w, 0], ["l", 0, h], ["l", -w, 0], ["z"]];
  381. },
  382. ellipsePath = function (x, y, rx, ry) {
  383. if (ry == null) {
  384. ry = rx;
  385. }
  386. return [["M", x, y], ["m", 0, -ry], ["a", rx, ry, 0, 1, 1, 0, 2 * ry], ["a", rx, ry, 0, 1, 1, 0, -2 * ry], ["z"]];
  387. },
  388. getPath = R._getPath = {
  389. path: function (el) {
  390. return el.attr("path");
  391. },
  392. circle: function (el) {
  393. var a = el.attrs;
  394. return ellipsePath(a.cx, a.cy, a.r);
  395. },
  396. ellipse: function (el) {
  397. var a = el.attrs;
  398. return ellipsePath(a.cx, a.cy, a.rx, a.ry);
  399. },
  400. rect: function (el) {
  401. var a = el.attrs;
  402. return rectPath(a.x, a.y, a.width, a.height, a.r);
  403. },
  404. image: function (el) {
  405. var a = el.attrs;
  406. return rectPath(a.x, a.y, a.width, a.height);
  407. },
  408. text: function (el) {
  409. var bbox = el._getBBox();
  410. return rectPath(bbox.x, bbox.y, bbox.width, bbox.height);
  411. }
  412. },
  413. mapPath = R.mapPath = function (path, matrix) {
  414. if (!matrix) {
  415. return path;
  416. }
  417. var x, y, i, j, ii, jj, pathi;
  418. path = path2curve(path);
  419. for (i = 0, ii = path.length; i < ii; i++) {
  420. pathi = path[i];
  421. for (j = 1, jj = pathi.length; j < jj; j += 2) {
  422. x = matrix.x(pathi[j], pathi[j + 1]);
  423. y = matrix.y(pathi[j], pathi[j + 1]);
  424. pathi[j] = x;
  425. pathi[j + 1] = y;
  426. }
  427. }
  428. return path;
  429. };
  430. R._g = g;
  431. R.type = (g.win.SVGAngle || g.doc.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") ? "SVG" : "VML");
  432. if (R.type == "VML") {
  433. var d = g.doc.createElement("div"),
  434. b;
  435. d.innerHTML = '<v:shape adj="1"/>';
  436. b = d.firstChild;
  437. b.style.behavior = "url(#default#VML)";
  438. if (!(b && typeof b.adj == "object")) {
  439. return (R.type = E);
  440. }
  441. d = null;
  442. }
  443. R.svg = !(R.vml = R.type == "VML");
  444. R._Paper = Paper;
  445. R.fn = paperproto = Paper.prototype = R.prototype;
  446. R._id = 0;
  447. R._oid = 0;
  448. R.is = function (o, type) {
  449. type = lowerCase.call(type);
  450. if (type == "finite") {
  451. return !isnan[has](+o);
  452. }
  453. if (type == "array") {
  454. return o instanceof Array;
  455. }
  456. return (type == "null" && o === null) ||
  457. (type == typeof o && o !== null) ||
  458. (type == "object" && o === Object(o)) ||
  459. (type == "array" && Array.isArray && Array.isArray(o)) ||
  460. objectToString.call(o).slice(8, -1).toLowerCase() == type;
  461. };
  462. function clone(obj) {
  463. if (Object(obj) !== obj) {
  464. return obj;
  465. }
  466. var res = new obj.constructor;
  467. for (var key in obj) if (obj[has](key)) {
  468. res[key] = clone(obj[key]);
  469. }
  470. return res;
  471. }
  472. R.angle = function (x1, y1, x2, y2, x3, y3) {
  473. if (x3 == null) {
  474. var x = x1 - x2,
  475. y = y1 - y2;
  476. if (!x && !y) {
  477. return 0;
  478. }
  479. return (180 + math.atan2(-y, -x) * 180 / PI + 360) % 360;
  480. } else {
  481. return R.angle(x1, y1, x3, y3) - R.angle(x2, y2, x3, y3);
  482. }
  483. };
  484. R.rad = function (deg) {
  485. return deg % 360 * PI / 180;
  486. };
  487. R.deg = function (rad) {
  488. return rad * 180 / PI % 360;
  489. };
  490. R.snapTo = function (values, value, tolerance) {
  491. tolerance = R.is(tolerance, "finite") ? tolerance : 10;
  492. if (R.is(values, array)) {
  493. var i = values.length;
  494. while (i--) if (abs(values[i] - value) <= tolerance) {
  495. return values[i];
  496. }
  497. } else {
  498. values = +values;
  499. var rem = value % values;
  500. if (rem < tolerance) {
  501. return value - rem;
  502. }
  503. if (rem > values - tolerance) {
  504. return value - rem + values;
  505. }
  506. }
  507. return value;
  508. };
  509. var createUUID = R.createUUID = (function (uuidRegEx, uuidReplacer) {
  510. return function () {
  511. return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(uuidRegEx, uuidReplacer).toUpperCase();
  512. };
  513. })(/[xy]/g, function (c) {
  514. var r = math.random() * 16 | 0,
  515. v = c == "x" ? r : (r & 3 | 8);
  516. return v.toString(16);
  517. });
  518. R.setWindow = function (newwin) {
  519. eve("raphael.setWindow", R, g.win, newwin);
  520. g.win = newwin;
  521. g.doc = g.win.document;
  522. if (R._engine.initWin) {
  523. R._engine.initWin(g.win);
  524. }
  525. };
  526. var toHex = function (color) {
  527. if (R.vml) {
  528. // http://dean.edwards.name/weblog/2009/10/convert-any-colour-value-to-hex-in-msie/
  529. var trim = /^\s+|\s+$/g;
  530. var bod;
  531. try {
  532. var docum = new ActiveXObject("htmlfile");
  533. docum.write("<body>");
  534. docum.close();
  535. bod = docum.body;
  536. } catch(e) {
  537. bod = createPopup().document.body;
  538. }
  539. var range = bod.createTextRange();
  540. toHex = cacher(function (color) {
  541. try {
  542. bod.style.color = Str(color).replace(trim, E);
  543. var value = range.queryCommandValue("ForeColor");
  544. value = ((value & 255) << 16) | (value & 65280) | ((value & 16711680) >>> 16);
  545. return "#" + ("000000" + value.toString(16)).slice(-6);
  546. } catch(e) {
  547. return "none";
  548. }
  549. });
  550. } else {
  551. var i = g.doc.createElement("i");
  552. i.title = "Rapha\xebl Colour Picker";
  553. i.style.display = "none";
  554. g.doc.body.appendChild(i);
  555. toHex = cacher(function (color) {
  556. i.style.color = color;
  557. return g.doc.defaultView.getComputedStyle(i, E).getPropertyValue("color");
  558. });
  559. }
  560. return toHex(color);
  561. },
  562. hsbtoString = function () {
  563. return "hsb(" + [this.h, this.s, this.b] + ")";
  564. },
  565. hsltoString = function () {
  566. return "hsl(" + [this.h, this.s, this.l] + ")";
  567. },
  568. rgbtoString = function () {
  569. return this.hex;
  570. },
  571. prepareRGB = function (r, g, b) {
  572. if (g == null && R.is(r, "object") && "r" in r && "g" in r && "b" in r) {
  573. b = r.b;
  574. g = r.g;
  575. r = r.r;
  576. }
  577. if (g == null && R.is(r, string)) {
  578. var clr = R.getRGB(r);
  579. r = clr.r;
  580. g = clr.g;
  581. b = clr.b;
  582. }
  583. if (r > 1 || g > 1 || b > 1) {
  584. r /= 255;
  585. g /= 255;
  586. b /= 255;
  587. }
  588. return [r, g, b];
  589. },
  590. packageRGB = function (r, g, b, o) {
  591. r *= 255;
  592. g *= 255;
  593. b *= 255;
  594. var rgb = {
  595. r: r,
  596. g: g,
  597. b: b,
  598. hex: R.rgb(r, g, b),
  599. toString: rgbtoString
  600. };
  601. R.is(o, "finite") && (rgb.opacity = o);
  602. return rgb;
  603. };
  604. R.color = function (clr) {
  605. var rgb;
  606. if (R.is(clr, "object") && "h" in clr && "s" in clr && "b" in clr) {
  607. rgb = R.hsb2rgb(clr);
  608. clr.r = rgb.r;
  609. clr.g = rgb.g;
  610. clr.b = rgb.b;
  611. clr.hex = rgb.hex;
  612. } else if (R.is(clr, "object") && "h" in clr && "s" in clr && "l" in clr) {
  613. rgb = R.hsl2rgb(clr);
  614. clr.r = rgb.r;
  615. clr.g = rgb.g;
  616. clr.b = rgb.b;
  617. clr.hex = rgb.hex;
  618. } else {
  619. if (R.is(clr, "string")) {
  620. clr = R.getRGB(clr);
  621. }
  622. if (R.is(clr, "object") && "r" in clr && "g" in clr && "b" in clr) {
  623. rgb = R.rgb2hsl(clr);
  624. clr.h = rgb.h;
  625. clr.s = rgb.s;
  626. clr.l = rgb.l;
  627. rgb = R.rgb2hsb(clr);
  628. clr.v = rgb.b;
  629. } else {
  630. clr = {hex: "none"};
  631. clr.r = clr.g = clr.b = clr.h = clr.s = clr.v = clr.l = -1;
  632. }
  633. }
  634. clr.toString = rgbtoString;
  635. return clr;
  636. };
  637. R.hsb2rgb = function (h, s, v, o) {
  638. if (this.is(h, "object") && "h" in h && "s" in h && "b" in h) {
  639. v = h.b;
  640. s = h.s;
  641. h = h.h;
  642. o = h.o;
  643. }
  644. h *= 360;
  645. var R, G, B, X, C;
  646. h = (h % 360) / 60;
  647. C = v * s;
  648. X = C * (1 - abs(h % 2 - 1));
  649. R = G = B = v - C;
  650. h = ~~h;
  651. R += [C, X, 0, 0, X, C][h];
  652. G += [X, C, C, X, 0, 0][h];
  653. B += [0, 0, X, C, C, X][h];
  654. return packageRGB(R, G, B, o);
  655. };
  656. R.hsl2rgb = function (h, s, l, o) {
  657. if (this.is(h, "object") && "h" in h && "s" in h && "l" in h) {
  658. l = h.l;
  659. s = h.s;
  660. h = h.h;
  661. }
  662. if (h > 1 || s > 1 || l > 1) {
  663. h /= 360;
  664. s /= 100;
  665. l /= 100;
  666. }
  667. h *= 360;
  668. var R, G, B, X, C;
  669. h = (h % 360) / 60;
  670. C = 2 * s * (l < .5 ? l : 1 - l);
  671. X = C * (1 - abs(h % 2 - 1));
  672. R = G = B = l - C / 2;
  673. h = ~~h;
  674. R += [C, X, 0, 0, X, C][h];
  675. G += [X, C, C, X, 0, 0][h];
  676. B += [0, 0, X, C, C, X][h];
  677. return packageRGB(R, G, B, o);
  678. };
  679. R.rgb2hsb = function (r, g, b) {
  680. b = prepareRGB(r, g, b);
  681. r = b[0];
  682. g = b[1];
  683. b = b[2];
  684. var H, S, V, C;
  685. V = mmax(r, g, b);
  686. C = V - mmin(r, g, b);
  687. H = (C == 0 ? null :
  688. V == r ? (g - b) / C :
  689. V == g ? (b - r) / C + 2 :
  690. (r - g) / C + 4
  691. );
  692. H = ((H + 360) % 6) * 60 / 360;
  693. S = C == 0 ? 0 : C / V;
  694. return {h: H, s: S, b: V, toString: hsbtoString};
  695. };
  696. R.rgb2hsl = function (r, g, b) {
  697. b = prepareRGB(r, g, b);
  698. r = b[0];
  699. g = b[1];
  700. b = b[2];
  701. var H, S, L, M, m, C;
  702. M = mmax(r, g, b);
  703. m = mmin(r, g, b);
  704. C = M - m;
  705. H = (C == 0 ? null :
  706. M == r ? (g - b) / C :
  707. M == g ? (b - r) / C + 2 :
  708. (r - g) / C + 4);
  709. H = ((H + 360) % 6) * 60 / 360;
  710. L = (M + m) / 2;
  711. S = (C == 0 ? 0 :
  712. L < .5 ? C / (2 * L) :
  713. C / (2 - 2 * L));
  714. return {h: H, s: S, l: L, toString: hsltoString};
  715. };
  716. R._path2string = function () {
  717. return this.join(",").replace(p2s, "$1");
  718. };
  719. function repush(array, item) {
  720. for (var i = 0, ii = array.length; i < ii; i++) if (array[i] === item) {
  721. return array.push(array.splice(i, 1)[0]);
  722. }
  723. }
  724. function cacher(f, scope, postprocessor) {
  725. function newf() {
  726. var arg = Array.prototype.slice.call(arguments, 0),
  727. args = arg.join("\u2400"),
  728. cache = newf.cache = newf.cache || {},
  729. count = newf.count = newf.count || [];
  730. if (cache[has](args)) {
  731. repush(count, args);
  732. return postprocessor ? postprocessor(cache[args]) : cache[args];
  733. }
  734. count.length >= 1e3 && delete cache[count.shift()];
  735. count.push(args);
  736. cache[args] = f[apply](scope, arg);
  737. return postprocessor ? postprocessor(cache[args]) : cache[args];
  738. }
  739. return newf;
  740. }
  741. var preload = R._preload = function (src, f) {
  742. var img = g.doc.createElement("img");
  743. img.style.cssText = "position:absolute;left:-9999em;top:-9999em";
  744. img.onload = function () {
  745. f.call(this);
  746. this.onload = null;
  747. g.doc.body.removeChild(this);
  748. };
  749. img.onerror = function () {
  750. g.doc.body.removeChild(this);
  751. };
  752. g.doc.body.appendChild(img);
  753. img.src = src;
  754. };
  755. function clrToString() {
  756. return this.hex;
  757. }
  758. R.getRGB = cacher(function (colour) {
  759. if (!colour || !!((colour = Str(colour)).indexOf("-") + 1)) {
  760. return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: clrToString};
  761. }
  762. if (colour == "none") {
  763. return {r: -1, g: -1, b: -1, hex: "none", toString: clrToString};
  764. }
  765. !(hsrg[has](colour.toLowerCase().substring(0, 2)) || colour.charAt() == "#") && (colour = toHex(colour));
  766. var res,
  767. red,
  768. green,
  769. blue,
  770. opacity,
  771. t,
  772. values,
  773. rgb = colour.match(colourRegExp);
  774. if (rgb) {
  775. if (rgb[2]) {
  776. blue = toInt(rgb[2].substring(5), 16);
  777. green = toInt(rgb[2].substring(3, 5), 16);
  778. red = toInt(rgb[2].substring(1, 3), 16);
  779. }
  780. if (rgb[3]) {
  781. blue = toInt((t = rgb[3].charAt(3)) + t, 16);
  782. green = toInt((t = rgb[3].charAt(2)) + t, 16);
  783. red = toInt((t = rgb[3].charAt(1)) + t, 16);
  784. }
  785. if (rgb[4]) {
  786. values = rgb[4][split](commaSpaces);
  787. red = toFloat(values[0]);
  788. values[0].slice(-1) == "%" && (red *= 2.55);
  789. green = toFloat(values[1]);
  790. values[1].slice(-1) == "%" && (green *= 2.55);
  791. blue = toFloat(values[2]);
  792. values[2].slice(-1) == "%" && (blue *= 2.55);
  793. rgb[1].toLowerCase().slice(0, 4) == "rgba" && (opacity = toFloat(values[3]));
  794. values[3] && values[3].slice(-1) == "%" && (opacity /= 100);
  795. }
  796. if (rgb[5]) {
  797. values = rgb[5][split](commaSpaces);
  798. red = toFloat(values[0]);
  799. values[0].slice(-1) == "%" && (red *= 2.55);
  800. green = toFloat(values[1]);
  801. values[1].slice(-1) == "%" && (green *= 2.55);
  802. blue = toFloat(values[2]);
  803. values[2].slice(-1) == "%" && (blue *= 2.55);
  804. (values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") && (red /= 360);
  805. rgb[1].toLowerCase().slice(0, 4) == "hsba" && (opacity = toFloat(values[3]));
  806. values[3] && values[3].slice(-1) == "%" && (opacity /= 100);
  807. return R.hsb2rgb(red, green, blue, opacity);
  808. }
  809. if (rgb[6]) {
  810. values = rgb[6][split](commaSpaces);
  811. red = toFloat(values[0]);
  812. values[0].slice(-1) == "%" && (red *= 2.55);
  813. green = toFloat(values[1]);
  814. values[1].slice(-1) == "%" && (green *= 2.55);
  815. blue = toFloat(values[2]);
  816. values[2].slice(-1) == "%" && (blue *= 2.55);
  817. (values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") && (red /= 360);
  818. rgb[1].toLowerCase().slice(0, 4) == "hsla" && (opacity = toFloat(values[3]));
  819. values[3] && values[3].slice(-1) == "%" && (opacity /= 100);
  820. return R.hsl2rgb(red, green, blue, opacity);
  821. }
  822. rgb = {r: red, g: green, b: blue, toString: clrToString};
  823. rgb.hex = "#" + (16777216 | blue | (green << 8) | (red << 16)).toString(16).slice(1);
  824. R.is(opacity, "finite") && (rgb.opacity = opacity);
  825. return rgb;
  826. }
  827. return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: clrToString};
  828. }, R);
  829. R.hsb = cacher(function (h, s, b) {
  830. return R.hsb2rgb(h, s, b).hex;
  831. });
  832. R.hsl = cacher(function (h, s, l) {
  833. return R.hsl2rgb(h, s, l).hex;
  834. });
  835. R.rgb = cacher(function (r, g, b) {
  836. return "#" + (16777216 | b | (g << 8) | (r << 16)).toString(16).slice(1);
  837. });
  838. R.getColor = function (value) {
  839. var start = this.getColor.start = this.getColor.start || {h: 0, s: 1, b: value || .75},
  840. rgb = this.hsb2rgb(start.h, start.s, start.b);
  841. start.h += .075;
  842. if (start.h > 1) {
  843. start.h = 0;
  844. start.s -= .2;
  845. start.s <= 0 && (this.getColor.start = {h: 0, s: 1, b: start.b});
  846. }
  847. return rgb.hex;
  848. };
  849. R.getColor.reset = function () {
  850. delete this.start;
  851. };
  852. // http://schepers.cc/getting-to-the-point
  853. function catmullRom2bezier(crp, z) {
  854. var d = [];
  855. for (var i = 0, iLen = crp.length; iLen - 2 * !z > i; i += 2) {
  856. var p = [
  857. {x: +crp[i - 2], y: +crp[i - 1]},
  858. {x: +crp[i], y: +crp[i + 1]},
  859. {x: +crp[i + 2], y: +crp[i + 3]},
  860. {x: +crp[i + 4], y: +crp[i + 5]}
  861. ];
  862. if (z) {
  863. if (!i) {
  864. p[0] = {x: +crp[iLen - 2], y: +crp[iLen - 1]};
  865. } else if (iLen - 4 == i) {
  866. p[3] = {x: +crp[0], y: +crp[1]};
  867. } else if (iLen - 2 == i) {
  868. p[2] = {x: +crp[0], y: +crp[1]};
  869. p[3] = {x: +crp[2], y: +crp[3]};
  870. }
  871. } else {
  872. if (iLen - 4 == i) {
  873. p[3] = p[2];
  874. } else if (!i) {
  875. p[0] = {x: +crp[i], y: +crp[i + 1]};
  876. }
  877. }
  878. d.push(["C",
  879. (-p[0].x + 6 * p[1].x + p[2].x) / 6,
  880. (-p[0].y + 6 * p[1].y + p[2].y) / 6,
  881. (p[1].x + 6 * p[2].x - p[3].x) / 6,
  882. (p[1].y + 6*p[2].y - p[3].y) / 6,
  883. p[2].x,
  884. p[2].y
  885. ]);
  886. }
  887. return d;
  888. }
  889. R.parsePathString = function (pathString) {
  890. if (!pathString) {
  891. return null;
  892. }
  893. var pth = paths(pathString);
  894. if (pth.arr) {
  895. return pathClone(pth.arr);
  896. }
  897. var paramCounts = {a: 7, c: 6, h: 1, l: 2, m: 2, r: 4, q: 4, s: 4, t: 2, v: 1, z: 0},
  898. data = [];
  899. if (R.is(pathString, array) && R.is(pathString[0], array)) { // rough assumption
  900. data = pathClone(pathString);
  901. }
  902. if (!data.length) {
  903. Str(pathString).replace(pathCommand, function (a, b, c) {
  904. var params = [],
  905. name = b.toLowerCase();
  906. c.replace(pathValues, function (a, b) {
  907. b && params.push(+b);
  908. });
  909. if (name == "m" && params.length > 2) {
  910. data.push([b][concat](params.splice(0, 2)));
  911. name = "l";
  912. b = b == "m" ? "l" : "L";
  913. }
  914. if (name == "r") {
  915. data.push([b][concat](params));
  916. } else while (params.length >= paramCounts[name]) {
  917. data.push([b][concat](params.splice(0, paramCounts[name])));
  918. if (!paramCounts[name]) {
  919. break;
  920. }
  921. }
  922. });
  923. }
  924. data.toString = R._path2string;
  925. pth.arr = pathClone(data);
  926. return data;
  927. };
  928. R.parseTransformString = cacher(function (TString) {
  929. if (!TString) {
  930. return null;
  931. }
  932. var paramCounts = {r: 3, s: 4, t: 2, m: 6},
  933. data = [];
  934. if (R.is(TString, array) && R.is(TString[0], array)) { // rough assumption
  935. data = pathClone(TString);
  936. }
  937. if (!data.length) {
  938. Str(TString).replace(tCommand, function (a, b, c) {
  939. var params = [],
  940. name = lowerCase.call(b);
  941. c.replace(pathValues, function (a, b) {
  942. b && params.push(+b);
  943. });
  944. data.push([b][concat](params));
  945. });
  946. }
  947. data.toString = R._path2string;
  948. return data;
  949. });
  950. // PATHS
  951. var paths = function (ps) {
  952. var p = paths.ps = paths.ps || {};
  953. if (p[ps]) {
  954. p[ps].sleep = 100;
  955. } else {
  956. p[ps] = {
  957. sleep: 100
  958. };
  959. }
  960. setTimeout(function () {
  961. for (var key in p) if (p[has](key) && key != ps) {
  962. p[key].sleep--;
  963. !p[key].sleep && delete p[key];
  964. }
  965. });
  966. return p[ps];
  967. };
  968. R.findDotsAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {
  969. var t1 = 1 - t,
  970. t13 = pow(t1, 3),
  971. t12 = pow(t1, 2),
  972. t2 = t * t,
  973. t3 = t2 * t,
  974. x = t13 * p1x + t12 * 3 * t * c1x + t1 * 3 * t * t * c2x + t3 * p2x,
  975. y = t13 * p1y + t12 * 3 * t * c1y + t1 * 3 * t * t * c2y + t3 * p2y,
  976. mx = p1x + 2 * t * (c1x - p1x) + t2 * (c2x - 2 * c1x + p1x),
  977. my = p1y + 2 * t * (c1y - p1y) + t2 * (c2y - 2 * c1y + p1y),
  978. nx = c1x + 2 * t * (c2x - c1x) + t2 * (p2x - 2 * c2x + c1x),
  979. ny = c1y + 2 * t * (c2y - c1y) + t2 * (p2y - 2 * c2y + c1y),
  980. ax = t1 * p1x + t * c1x,
  981. ay = t1 * p1y + t * c1y,
  982. cx = t1 * c2x + t * p2x,
  983. cy = t1 * c2y + t * p2y,
  984. alpha = (90 - math.atan2(mx - nx, my - ny) * 180 / PI);
  985. (mx > nx || my < ny) && (alpha += 180);
  986. return {
  987. x: x,
  988. y: y,
  989. m: {x: mx, y: my},
  990. n: {x: nx, y: ny},
  991. start: {x: ax, y: ay},
  992. end: {x: cx, y: cy},
  993. alpha: alpha
  994. };
  995. };
  996. R.bezierBBox = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {
  997. if (!R.is(p1x, "array")) {
  998. p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y];
  999. }
  1000. var bbox = curveDim.apply(null, p1x);
  1001. return {
  1002. x: bbox.min.x,
  1003. y: bbox.min.y,
  1004. x2: bbox.max.x,
  1005. y2: bbox.max.y,
  1006. width: bbox.max.x - bbox.min.x,
  1007. height: bbox.max.y - bbox.min.y
  1008. };
  1009. };
  1010. R.isPointInsideBBox = function (bbox, x, y) {
  1011. return x >= bbox.x && x <= bbox.x2 && y >= bbox.y && y <= bbox.y2;
  1012. };
  1013. R.isBBoxIntersect = function (bbox1, bbox2) {
  1014. var i = R.isPointInsideBBox;
  1015. return i(bbox2, bbox1.x, bbox1.y)
  1016. || i(bbox2, bbox1.x2, bbox1.y)
  1017. || i(bbox2, bbox1.x, bbox1.y2)
  1018. || i(bbox2, bbox1.x2, bbox1.y2)
  1019. || i(bbox1, bbox2.x, bbox2.y)
  1020. || i(bbox1, bbox2.x2, bbox2.y)
  1021. || i(bbox1, bbox2.x, bbox2.y2)
  1022. || i(bbox1, bbox2.x2, bbox2.y2)
  1023. || (bbox1.x < bbox2.x2 && bbox1.x > bbox2.x || bbox2.x < bbox1.x2 && bbox2.x > bbox1.x)
  1024. && (bbox1.y < bbox2.y2 && bbox1.y > bbox2.y || bbox2.y < bbox1.y2 && bbox2.y > bbox1.y);
  1025. };
  1026. function base3(t, p1, p2, p3, p4) {
  1027. var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4,
  1028. t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3;
  1029. return t * t2 - 3 * p1 + 3 * p2;
  1030. }
  1031. function bezlen(x1, y1, x2, y2, x3, y3, x4, y4, z) {
  1032. if (z == null) {
  1033. z = 1;
  1034. }
  1035. z = z > 1 ? 1 : z < 0 ? 0 : z;
  1036. var z2 = z / 2,
  1037. n = 12,
  1038. Tvalues = [-0.1252,0.1252,-0.3678,0.3678,-0.5873,0.5873,-0.7699,0.7699,-0.9041,0.9041,-0.9816,0.9816],
  1039. Cvalues = [0.2491,0.2491,0.2335,0.2335,0.2032,0.2032,0.1601,0.1601,0.1069,0.1069,0.0472,0.0472],
  1040. sum = 0;
  1041. for (var i = 0; i < n; i++) {
  1042. var ct = z2 * Tvalues[i] + z2,
  1043. xbase = base3(ct, x1, x2, x3, x4),
  1044. ybase = base3(ct, y1, y2, y3, y4),
  1045. comb = xbase * xbase + ybase * ybase;
  1046. sum += Cvalues[i] * math.sqrt(comb);
  1047. }
  1048. return z2 * sum;
  1049. }
  1050. function getTatLen(x1, y1, x2, y2, x3, y3, x4, y4, ll) {
  1051. if (ll < 0 || bezlen(x1, y1, x2, y2, x3, y3, x4, y4) < ll) {
  1052. return;
  1053. }
  1054. var t = 1,
  1055. step = t / 2,
  1056. t2 = t - step,
  1057. l,
  1058. e = .01;
  1059. l = bezlen(x1, y1, x2, y2, x3, y3, x4, y4, t2);
  1060. while (abs(l - ll) > e) {
  1061. step /= 2;
  1062. t2 += (l < ll ? 1 : -1) * step;
  1063. l = bezlen(x1, y1, x2, y2, x3, y3, x4, y4, t2);
  1064. }
  1065. return t2;
  1066. }
  1067. function intersect(x1, y1, x2, y2, x3, y3, x4, y4) {
  1068. if (
  1069. mmax(x1, x2) < mmin(x3, x4) ||
  1070. mmin(x1, x2) > mmax(x3, x4) ||
  1071. mmax(y1, y2) < mmin(y3, y4) ||
  1072. mmin(y1, y2) > mmax(y3, y4)
  1073. ) {
  1074. return;
  1075. }
  1076. var nx = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4),
  1077. ny = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4),
  1078. denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
  1079. if (!denominator) {
  1080. return;
  1081. }
  1082. var px = nx / denominator,
  1083. py = ny / denominator,
  1084. px2 = +px.toFixed(2),
  1085. py2 = +py.toFixed(2);
  1086. if (
  1087. px2 < +mmin(x1, x2).toFixed(2) ||
  1088. px2 > +mmax(x1, x2).toFixed(2) ||
  1089. px2 < +mmin(x3, x4).toFixed(2) ||
  1090. px2 > +mmax(x3, x4).toFixed(2) ||
  1091. py2 < +mmin(y1, y2).toFixed(2) ||
  1092. py2 > +mmax(y1, y2).toFixed(2) ||
  1093. py2 < +mmin(y3, y4).toFixed(2) ||
  1094. py2 > +mmax(y3, y4).toFixed(2)
  1095. ) {
  1096. return;
  1097. }
  1098. return {x: px, y: py};
  1099. }
  1100. function inter(bez1, bez2) {
  1101. return interHelper(bez1, bez2);
  1102. }
  1103. function interCount(bez1, bez2) {
  1104. return interHelper(bez1, bez2, 1);
  1105. }
  1106. function interHelper(bez1, bez2, justCount) {
  1107. var bbox1 = R.bezierBBox(bez1),
  1108. bbox2 = R.bezierBBox(bez2);
  1109. if (!R.isBBoxIntersect(bbox1, bbox2)) {
  1110. return justCount ? 0 : [];
  1111. }
  1112. var l1 = bezlen.apply(0, bez1),
  1113. l2 = bezlen.apply(0, bez2),
  1114. n1 = ~~(l1 / 5),
  1115. n2 = ~~(l2 / 5),
  1116. dots1 = [],
  1117. dots2 = [],
  1118. xy = {},
  1119. res = justCount ? 0 : [];
  1120. for (var i = 0; i < n1 + 1; i++) {
  1121. var p = R.findDotsAtSegment.apply(R, bez1.concat(i / n1));
  1122. dots1.push({x: p.x, y: p.y, t: i / n1});
  1123. }
  1124. for (i = 0; i < n2 + 1; i++) {
  1125. p = R.findDotsAtSegment.apply(R, bez2.concat(i / n2));
  1126. dots2.push({x: p.x, y: p.y, t: i / n2});
  1127. }
  1128. for (i = 0; i < n1; i++) {
  1129. for (var j = 0; j < n2; j++) {
  1130. var di = dots1[i],
  1131. di1 = dots1[i + 1],
  1132. dj = dots2[j],
  1133. dj1 = dots2[j + 1],
  1134. ci = abs(di1.x - di.x) < .001 ? "y" : "x",
  1135. cj = abs(dj1.x - dj.x) < .001 ? "y" : "x",
  1136. is = intersect(di.x, di.y, di1.x, di1.y, dj.x, dj.y, dj1.x, dj1.y);
  1137. if (is) {
  1138. if (xy[is.x.toFixed(4)] == is.y.toFixed(4)) {
  1139. continue;
  1140. }
  1141. xy[is.x.toFixed(4)] = is.y.toFixed(4);
  1142. var t1 = di.t + abs((is[ci] - di[ci]) / (di1[ci] - di[ci])) * (di1.t - di.t),
  1143. t2 = dj.t + abs((is[cj] - dj[cj]) / (dj1[cj] - dj[cj])) * (dj1.t - dj.t);
  1144. if (t1 >= 0 && t1 <= 1 && t2 >= 0 && t2 <= 1) {
  1145. if (justCount) {
  1146. res++;
  1147. } else {
  1148. res.push({
  1149. x: is.x,
  1150. y: is.y,
  1151. t1: t1,
  1152. t2: t2
  1153. });
  1154. }
  1155. }
  1156. }
  1157. }
  1158. }
  1159. return res;
  1160. }
  1161. R.pathIntersection = function (path1, path2) {
  1162. return interPathHelper(path1, path2);
  1163. };
  1164. R.pathIntersectionNumber = function (path1, path2) {
  1165. return interPathHelper(path1, path2, 1);
  1166. };
  1167. function interPathHelper(path1, path2, justCount) {
  1168. path1 = R._path2curve(path1);
  1169. path2 = R._path2curve(path2);
  1170. var x1, y1, x2, y2, x1m, y1m, x2m, y2m, bez1, bez2,
  1171. res = justCount ? 0 : [];
  1172. for (var i = 0, ii = path1.length; i < ii; i++) {
  1173. var pi = path1[i];
  1174. if (pi[0] == "M") {
  1175. x1 = x1m = pi[1];
  1176. y1 = y1m = pi[2];
  1177. } else {
  1178. if (pi[0] == "C") {
  1179. bez1 = [x1, y1].concat(pi.slice(1));
  1180. x1 = bez1[6];
  1181. y1 = bez1[7];
  1182. } else {
  1183. bez1 = [x1, y1, x1, y1, x1m, y1m, x1m, y1m];
  1184. x1 = x1m;
  1185. y1 = y1m;
  1186. }
  1187. for (var j = 0, jj = path2.length; j < jj; j++) {
  1188. var pj = path2[j];
  1189. if (pj[0] == "M") {
  1190. x2 = x2m = pj[1];
  1191. y2 = y2m = pj[2];
  1192. } else {
  1193. if (pj[0] == "C") {
  1194. bez2 = [x2, y2].concat(pj.slice(1));
  1195. x2 = bez2[6];
  1196. y2 = bez2[7];
  1197. } else {
  1198. bez2 = [x2, y2, x2, y2, x2m, y2m, x2m, y2m];
  1199. x2 = x2m;
  1200. y2 = y2m;
  1201. }
  1202. var intr = interHelper(bez1, bez2, justCount);
  1203. if (justCount) {
  1204. res += intr;
  1205. } else {
  1206. for (var k = 0, kk = intr.length; k < kk; k++) {
  1207. intr[k].segment1 = i;
  1208. intr[k].segment2 = j;
  1209. intr[k].bez1 = bez1;
  1210. intr[k].bez2 = bez2;
  1211. }
  1212. res = res.concat(intr);
  1213. }
  1214. }
  1215. }
  1216. }
  1217. }
  1218. return res;
  1219. }
  1220. R.isPointInsidePath = function (path, x, y) {
  1221. var bbox = R.pathBBox(path);
  1222. return R.isPointInsideBBox(bbox, x, y) &&
  1223. interPathHelper(path, [["M", x, y], ["H", bbox.x2 + 10]], 1) % 2 == 1;
  1224. };
  1225. R._removedFactory = function (methodname) {
  1226. return function () {
  1227. eve("raphael.log", null, "Rapha\xebl: you are calling to method \u201c" + methodname + "\u201d of removed object", methodname);
  1228. };
  1229. };
  1230. var pathDimensions = R.pathBBox = function (path) {
  1231. var pth = paths(path);
  1232. if (pth.bbox) {
  1233. return pth.bbox;
  1234. }
  1235. if (!path) {
  1236. return {x: 0, y: 0, width: 0, height: 0, x2: 0, y2: 0};
  1237. }
  1238. path = path2curve(path);
  1239. var x = 0,
  1240. y = 0,
  1241. X = [],
  1242. Y = [],
  1243. p;
  1244. for (var i = 0, ii = path.length; i < ii; i++) {
  1245. p = path[i];
  1246. if (p[0] == "M") {
  1247. x = p[1];
  1248. y = p[2];
  1249. X.push(x);
  1250. Y.push(y);
  1251. } else {
  1252. var dim = curveDim(x, y, p[1], p[2], p[3], p[4], p[5], p[6]);
  1253. X = X[concat](dim.min.x, dim.max.x);
  1254. Y = Y[concat](dim.min.y, dim.max.y);
  1255. x = p[5];
  1256. y = p[6];
  1257. }
  1258. }
  1259. var xmin = mmin[apply](0, X),
  1260. ymin = mmin[apply](0, Y),
  1261. xmax = mmax[apply](0, X),
  1262. ymax = mmax[apply](0, Y),
  1263. bb = {
  1264. x: xmin,
  1265. y: ymin,
  1266. x2: xmax,
  1267. y2: ymax,
  1268. width: xmax - xmin,
  1269. height: ymax - ymin
  1270. };
  1271. pth.bbox = clone(bb);
  1272. return bb;
  1273. },
  1274. pathClone = function (pathArray) {
  1275. var res = clone(pathArray);
  1276. res.toString = R._path2string;
  1277. return res;
  1278. },
  1279. pathToRelative = R._pathToRelative = function (pathArray) {
  1280. var pth = paths(pathArray);
  1281. if (pth.rel) {
  1282. return pathClone(pth.rel);
  1283. }
  1284. if (!R.is(pathArray, array) || !R.is(pathArray && pathArray[0], array)) { // rough assumption
  1285. pathArray = R.parsePathString(pathArray);
  1286. }
  1287. var res = [],
  1288. x = 0,
  1289. y = 0,
  1290. mx = 0,
  1291. my = 0,
  1292. start = 0;
  1293. if (pathArray[0][0] == "M") {
  1294. x = pathArray[0][1];
  1295. y = pathArray[0][2];
  1296. mx = x;
  1297. my = y;
  1298. start++;
  1299. res.push(["M", x, y]);
  1300. }
  1301. for (var i = start, ii = pathArray.length; i < ii; i++) {
  1302. var r = res[i] = [],
  1303. pa = pathArray[i];
  1304. if (pa[0] != lowerCase.call(pa[0])) {
  1305. r[0] = lowerCase.call(pa[0]);
  1306. switch (r[0]) {
  1307. case "a":
  1308. r[1] = pa[1];
  1309. r[2] = pa[2];
  1310. r[3] = pa[3];
  1311. r[4] = pa[4];
  1312. r[5] = pa[5];
  1313. r[6] = +(pa[6] - x).toFixed(3);
  1314. r[7] = +(pa[7] - y).toFixed(3);
  1315. break;
  1316. case "v":
  1317. r[1] = +(pa[1] - y).toFixed(3);
  1318. break;
  1319. case "m":
  1320. mx = pa[1];
  1321. my = pa[2];
  1322. default:
  1323. for (var j = 1, jj = pa.length; j < jj; j++) {
  1324. r[j] = +(pa[j] - ((j % 2) ? x : y)).toFixed(3);
  1325. }
  1326. }
  1327. } else {
  1328. r = res[i] = [];
  1329. if (pa[0] == "m") {
  1330. mx = pa[1] + x;
  1331. my = pa[2] + y;
  1332. }
  1333. for (var k = 0, kk = pa.length; k < kk; k++) {
  1334. res[i][k] = pa[k];
  1335. }
  1336. }
  1337. var len = res[i].length;
  1338. switch (res[i][0]) {
  1339. case "z":
  1340. x = mx;
  1341. y = my;
  1342. break;
  1343. case "h":
  1344. x += +res[i][len - 1];
  1345. break;
  1346. case "v":
  1347. y += +res[i][len - 1];
  1348. break;
  1349. default:
  1350. x += +res[i][len - 2];
  1351. y += +res[i][len - 1];
  1352. }
  1353. }
  1354. res.toString = R._path2string;
  1355. pth.rel = pathClone(res);
  1356. return res;
  1357. },
  1358. pathToAbsolute = R._pathToAbsolute = function (pathArray) {
  1359. var pth = paths(pathArray);
  1360. if (pth.abs) {
  1361. return pathClone(pth.abs);
  1362. }
  1363. if (!R.is(pathArray, array) || !R.is(pathArray && pathArray[0], array)) { // rough assumption
  1364. pathArray = R.parsePathString(pathArray);
  1365. }
  1366. if (!pathArray || !pathArray.length) {
  1367. return [["M", 0, 0]];
  1368. }
  1369. var res = [],
  1370. x = 0,
  1371. y = 0,
  1372. mx = 0,
  1373. my = 0,
  1374. start = 0;
  1375. if (pathArray[0][0] == "M") {
  1376. x = +pathArray[0][1];
  1377. y = +pathArray[0][2];
  1378. mx = x;
  1379. my = y;
  1380. start++;
  1381. res[0] = ["M", x, y];
  1382. }
  1383. var crz = pathArray.length == 3 && pathArray[0][0] == "M" && pathArray[1][0].toUpperCase() == "R" && pathArray[2][0].toUpperCase() == "Z";
  1384. for (var r, pa, i = start, ii = pathArray.length; i < ii; i++) {
  1385. res.push(r = []);
  1386. pa = pathArray[i];
  1387. if (pa[0] != upperCase.call(pa[0])) {
  1388. r[0] = upperCase.call(pa[0]);
  1389. switch (r[0]) {
  1390. case "A":
  1391. r[1] = pa[1];
  1392. r[2] = pa[2];
  1393. r[3] = pa[3];
  1394. r[4] = pa[4];
  1395. r[5] = pa[5];
  1396. r[6] = +(pa[6] + x);
  1397. r[7] = +(pa[7] + y);
  1398. break;
  1399. case "V":
  1400. r[1] = +pa[1] + y;
  1401. break;
  1402. case "H":
  1403. r[1] = +pa[1] + x;
  1404. break;
  1405. case "R":
  1406. var dots = [x, y][concat](pa.slice(1));
  1407. for (var j = 2, jj = dots.length; j < jj; j++) {
  1408. dots[j] = +dots[j] + x;
  1409. dots[++j] = +dots[j] + y;
  1410. }
  1411. res.pop();
  1412. res = res[concat](catmullRom2bezier(dots, crz));
  1413. break;
  1414. case "M":
  1415. mx = +pa[1] + x;
  1416. my = +pa[2] + y;
  1417. default:
  1418. for (j = 1, jj = pa.length; j < jj; j++) {
  1419. r[j] = +pa[j] + ((j % 2) ? x : y);
  1420. }
  1421. }
  1422. } else if (pa[0] == "R") {
  1423. dots = [x, y][concat](pa.slice(1));
  1424. res.pop();
  1425. res = res[concat](catmullRom2bezier(dots, crz));
  1426. r = ["R"][concat](pa.slice(-2));
  1427. } else {
  1428. for (var k = 0, kk = pa.length; k < kk; k++) {
  1429. r[k] = pa[k];
  1430. }
  1431. }
  1432. switch (r[0]) {
  1433. case "Z":
  1434. x = mx;
  1435. y = my;
  1436. break;
  1437. case "H":
  1438. x = r[1];
  1439. break;
  1440. case "V":
  1441. y = r[1];
  1442. break;
  1443. case "M":
  1444. mx = r[r.length - 2];
  1445. my = r[r.length - 1];
  1446. default:
  1447. x = r[r.length - 2];
  1448. y = r[r.length - 1];
  1449. }
  1450. }
  1451. res.toString = R._path2string;
  1452. pth.abs = pathClone(res);
  1453. return res;
  1454. },
  1455. l2c = function (x1, y1, x2, y2) {
  1456. return [x1, y1, x2, y2, x2, y2];
  1457. },
  1458. q2c = function (x1, y1, ax, ay, x2, y2) {
  1459. var _13 = 1 / 3,
  1460. _23 = 2 / 3;
  1461. return [
  1462. _13 * x1 + _23 * ax,
  1463. _13 * y1 + _23 * ay,
  1464. _13 * x2 + _23 * ax,
  1465. _13 * y2 + _23 * ay,
  1466. x2,
  1467. y2
  1468. ];
  1469. },
  1470. a2c = function (x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) {
  1471. // for more information of where this math came from visit:
  1472. // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
  1473. var _120 = PI * 120 / 180,
  1474. rad = PI / 180 * (+angle || 0),
  1475. res = [],
  1476. xy,
  1477. rotate = cacher(function (x, y, rad) {
  1478. var X = x * math.cos(rad) - y * math.sin(rad),
  1479. Y = x * math.sin(rad) + y * math.cos(rad);
  1480. return {x: X, y: Y};
  1481. });
  1482. if (!recursive) {
  1483. xy = rotate(x1, y1, -rad);
  1484. x1 = xy.x;
  1485. y1 = xy.y;
  1486. xy = rotate(x2, y2, -rad);
  1487. x2 = xy.x;
  1488. y2 = xy.y;
  1489. var cos = math.cos(PI / 180 * angle),
  1490. sin = math.sin(PI / 180 * angle),
  1491. x = (x1 - x2) / 2,
  1492. y = (y1 - y2) / 2;
  1493. var h = (x * x) / (rx * rx) + (y * y) / (ry * ry);
  1494. if (h > 1) {
  1495. h = math.sqrt(h);
  1496. rx = h * rx;
  1497. ry = h * ry;
  1498. }
  1499. var rx2 = rx * rx,
  1500. ry2 = ry * ry,
  1501. k = (large_arc_flag == sweep_flag ? -1 : 1) *
  1502. math.sqrt(abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x))),
  1503. cx = k * rx * y / ry + (x1 + x2) / 2,
  1504. cy = k * -ry * x / rx + (y1 + y2) / 2,
  1505. f1 = math.asin(((y1 - cy) / ry).toFixed(9)),
  1506. f2 = math.asin(((y2 - cy) / ry).toFixed(9));
  1507. f1 = x1 < cx ? PI - f1 : f1;
  1508. f2 = x2 < cx ? PI - f2 : f2;
  1509. f1 < 0 && (f1 = PI * 2 + f1);
  1510. f2 < 0 && (f2 = PI * 2 + f2);
  1511. if (sweep_flag && f1 > f2) {
  1512. f1 = f1 - PI * 2;
  1513. }
  1514. if (!sweep_flag && f2 > f1) {
  1515. f2 = f2 - PI * 2;
  1516. }
  1517. } else {
  1518. f1 = recursive[0];
  1519. f2 = recursive[1];
  1520. cx = recursive[2];
  1521. cy = recursive[3];
  1522. }
  1523. var df = f2 - f1;
  1524. if (abs(df) > _120) {
  1525. var f2old = f2,
  1526. x2old = x2,
  1527. y2old = y2;
  1528. f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1);
  1529. x2 = cx + rx * math.cos(f2);
  1530. y2 = cy + ry * math.sin(f2);
  1531. res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]);
  1532. }
  1533. df = f2 - f1;
  1534. var c1 = math.cos(f1),
  1535. s1 = math.sin(f1),
  1536. c2 = math.cos(f2),
  1537. s2 = math.sin(f2),
  1538. t = math.tan(df / 4),
  1539. hx = 4 / 3 * rx * t,
  1540. hy = 4 / 3 * ry * t,
  1541. m1 = [x1, y1],
  1542. m2 = [x1 + hx * s1, y1 - hy * c1],
  1543. m3 = [x2 + hx * s2, y2 - hy * c2],
  1544. m4 = [x2, y2];
  1545. m2[0] = 2 * m1[0] - m2[0];
  1546. m2[1] = 2 * m1[1] - m2[1];
  1547. if (recursive) {
  1548. return [m2, m3, m4][concat](res);
  1549. } else {
  1550. res = [m2, m3, m4][concat](res).join()[split](",");
  1551. var newres = [];
  1552. for (var i = 0, ii = res.length; i < ii; i++) {
  1553. newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x;
  1554. }
  1555. return newres;
  1556. }
  1557. },
  1558. findDotAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {
  1559. var t1 = 1 - t;
  1560. return {
  1561. x: pow(t1, 3) * p1x + pow(t1, 2) * 3 * t * c1x + t1 * 3 * t * t * c2x + pow(t, 3) * p2x,
  1562. y: pow(t1, 3) * p1y + pow(t1, 2) * 3 * t * c1y + t1 * 3 * t * t * c2y + pow(t, 3) * p2y
  1563. };
  1564. },
  1565. curveDim = cacher(function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {
  1566. var a = (c2x - 2 * c1x + p1x) - (p2x - 2 * c2x + c1x),
  1567. b = 2 * (c1x - p1x) - 2 * (c2x - c1x),
  1568. c = p1x - c1x,
  1569. t1 = (-b + math.sqrt(b * b - 4 * a * c)) / 2 / a,
  1570. t2 = (-b - math.sqrt(b * b - 4 * a * c)) / 2 / a,
  1571. y = [p1y, p2y],
  1572. x = [p1x, p2x],
  1573. dot;
  1574. abs(t1) > "1e12" && (t1 = .5);
  1575. abs(t2) > "1e12" && (t2 = .5);
  1576. if (t1 > 0 && t1 < 1) {
  1577. dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1);
  1578. x.push(dot.x);
  1579. y.push(dot.y);
  1580. }
  1581. if (t2 > 0 && t2 < 1) {
  1582. dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t2);
  1583. x.push(dot.x);
  1584. y.push(dot.y);
  1585. }
  1586. a = (c2y - 2 * c1y + p1y) - (p2y - 2 * c2y + c1y);
  1587. b = 2 * (c1y - p1y) - 2 * (c2y - c1y);
  1588. c = p1y - c1y;
  1589. t1 = (-b + math.sqrt(b * b - 4 * a * c)) / 2 / a;
  1590. t2 = (-b - math.sqrt(b * b - 4 * a * c)) / 2 / a;
  1591. abs(t1) > "1e12" && (t1 = .5);
  1592. abs(t2) > "1e12" && (t2 = .5);
  1593. if (t1 > 0 && t1 < 1) {
  1594. dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1);
  1595. x.push(dot.x);
  1596. y.push(dot.y);
  1597. }
  1598. if (t2 > 0 && t2 < 1) {
  1599. dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t2);
  1600. x.push(dot.x);
  1601. y.push(dot.y);
  1602. }
  1603. return {
  1604. min: {x: mmin[apply](0, x), y: mmin[apply](0, y)},
  1605. max: {x: mmax[apply](0, x), y: mmax[apply](0, y)}
  1606. };
  1607. }),
  1608. path2curve = R._path2curve = cacher(function (path, path2) {
  1609. var pth = !path2 && paths(path);
  1610. if (!path2 && pth.curve) {
  1611. return pathClone(pth.curve);
  1612. }
  1613. var p = pathToAbsolute(path),
  1614. p2 = path2 && pathToAbsolute(path2),
  1615. attrs = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},
  1616. attrs2 = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},
  1617. processPath = function (path, d) {
  1618. var nx, ny;
  1619. if (!path) {
  1620. return ["C", d.x, d.y, d.x, d.y, d.x, d.y];
  1621. }
  1622. !(path[0] in {T:1, Q:1}) && (d.qx = d.qy = null);
  1623. switch (path[0]) {
  1624. case "M":
  1625. d.X = path[1];
  1626. d.Y = path[2];
  1627. break;
  1628. case "A":
  1629. path = ["C"][concat](a2c[apply](0, [d.x, d.y][concat](path.slice(1))));
  1630. break;
  1631. case "S":
  1632. nx = d.x + (d.x - (d.bx || d.x));
  1633. ny = d.y + (d.y - (d.by || d.y));
  1634. path = ["C", nx, ny][concat](path.slice(1));
  1635. break;
  1636. case "T":
  1637. d.qx = d.x + (d.x - (d.qx || d.x));
  1638. d.qy = d.y + (d.y - (d.qy || d.y));
  1639. path = ["C"][concat](q2c(d.x, d.y, d.qx, d.qy, path[1], path[2]));
  1640. break;
  1641. case "Q":
  1642. d.qx = path[1];
  1643. d.qy = path[2];
  1644. path = ["C"][concat](q2c(d.x, d.y, path[1], path[2], path[3], path[4]));
  1645. break;
  1646. case "L":
  1647. path = ["C"][concat](l2c(d.x, d.y, path[1], path[2]));
  1648. break;
  1649. case "H":
  1650. path = ["C"][concat](l2c(d.x, d.y, path[1], d.y));
  1651. break;
  1652. case "V":
  1653. path = ["C"][concat](l2c(d.x, d.y, d.x, path[1]));
  1654. break;
  1655. case "Z":
  1656. path = ["C"][concat](l2c(d.x, d.y, d.X, d.Y));
  1657. break;
  1658. }
  1659. return path;
  1660. },
  1661. fixArc = function (pp, i) {
  1662. if (pp[i].length > 7) {
  1663. pp[i].shift();
  1664. var pi = pp[i];
  1665. while (pi.length) {
  1666. pp.splice(i++, 0, ["C"][concat](pi.splice(0, 6)));
  1667. }
  1668. pp.splice(i, 1);
  1669. ii = mmax(p.length, p2 && p2.length || 0);
  1670. }
  1671. },
  1672. fixM = function (path1, path2, a1, a2, i) {
  1673. if (path1 && path2 && path1[i][0] == "M" && path2[i][0] != "M") {
  1674. path2.splice(i, 0, ["M", a2.x, a2.y]);
  1675. a1.bx = 0;
  1676. a1.by = 0;
  1677. a1.x = path1[i][1];
  1678. a1.y = path1[i][2];
  1679. ii = mmax(p.length, p2 && p2.length || 0);
  1680. }
  1681. };
  1682. for (var i = 0, ii = mmax(p.length, p2 && p2.length || 0); i < ii; i++) {
  1683. p[i] = processPath(p[i], attrs);
  1684. fixArc(p, i);
  1685. p2 && (p2[i] = processPath(p2[i], attrs2));
  1686. p2 && fixArc(p2, i);
  1687. fixM(p, p2, attrs, attrs2, i);
  1688. fixM(p2, p, attrs2, attrs, i);
  1689. var seg = p[i],
  1690. seg2 = p2 && p2[i],
  1691. seglen = seg.length,
  1692. seg2len = p2 && seg2.length;
  1693. attrs.x = seg[seglen - 2];
  1694. attrs.y = seg[seglen - 1];
  1695. attrs.bx = toFloat(seg[seglen - 4]) || attrs.x;
  1696. attrs.by = toFloat(seg[seglen - 3]) || attrs.y;
  1697. attrs2.bx = p2 && (toFloat(seg2[seg2len - 4]) || attrs2.x);
  1698. attrs2.by = p2 && (toFloat(seg2[seg2len - 3]) || attrs2.y);
  1699. attrs2.x = p2 && seg2[seg2len - 2];
  1700. attrs2.y = p2 && seg2[seg2len - 1];
  1701. }
  1702. if (!p2) {
  1703. pth.curve = pathClone(p);
  1704. }
  1705. return p2 ? [p, p2] : p;
  1706. }, null, pathClone),
  1707. parseDots = R._parseDots = cacher(function (gradient) {
  1708. var dots = [];
  1709. for (var i = 0, ii = gradient.length; i < ii; i++) {
  1710. var dot = {},
  1711. par = gradient[i].match(/^([^:]*):?([\d\.]*)/);
  1712. dot.color = R.getRGB(par[1]);
  1713. if (dot.color.error) {
  1714. return null;
  1715. }
  1716. dot.color = dot.color.hex;
  1717. par[2] && (dot.offset = par[2] + "%");
  1718. dots.push(dot);
  1719. }
  1720. for (i = 1, ii = dots.length - 1; i < ii; i++) {
  1721. if (!dots[i].offset) {
  1722. var start = toFloat(dots[i - 1].offset || 0),
  1723. end = 0;
  1724. for (var j = i + 1; j < ii; j++) {
  1725. if (dots[j].offset) {
  1726. end = dots[j].offset;
  1727. break;
  1728. }
  1729. }
  1730. if (!end) {
  1731. end = 100;
  1732. j = ii;
  1733. }
  1734. end = toFloat(end);
  1735. var d = (end - start) / (j - i + 1);
  1736. for (; i < j; i++) {
  1737. start += d;
  1738. dots[i].offset = start + "%";
  1739. }
  1740. }
  1741. }
  1742. return dots;
  1743. }),
  1744. tear = R._tear = function (el, paper) {
  1745. el == paper.top && (paper.top = el.prev);
  1746. el == paper.bottom && (paper.bottom = el.next);
  1747. el.next && (el.next.prev = el.prev);
  1748. el.prev && (el.prev.next = el.next);
  1749. },
  1750. tofront = R._tofront = function (el, paper) {
  1751. if (paper.top === el) {
  1752. return;
  1753. }
  1754. tear(el, paper);
  1755. el.next = null;
  1756. el.prev = paper.top;
  1757. paper.top.next = el;
  1758. paper.top = el;
  1759. },
  1760. toback = R._toback = function (el, paper) {
  1761. if (paper.bottom === el) {
  1762. return;
  1763. }
  1764. tear(el, paper);
  1765. el.next = paper.bottom;
  1766. el.prev = null;
  1767. paper.bottom.prev = el;
  1768. paper.bottom = el;
  1769. },
  1770. insertafter = R._insertafter = function (el, el2, paper) {
  1771. tear(el, paper);
  1772. el2 == paper.top && (paper.top = el);
  1773. el2.next && (el2.next.prev = el);
  1774. el.next = el2.next;
  1775. el.prev = el2;
  1776. el2.next = el;
  1777. },
  1778. insertbefore = R._insertbefore = function (el, el2, paper) {
  1779. tear(el, paper);
  1780. el2 == paper.bottom && (paper.bottom = el);
  1781. el2.prev && (el2.prev.next = el);
  1782. el.prev = el2.prev;
  1783. el2.prev = el;
  1784. el.next = el2;
  1785. },
  1786. toMatrix = R.toMatrix = function (path, transform) {
  1787. var bb = pathDimensions(path),
  1788. el = {
  1789. _: {
  1790. transform: E
  1791. },
  1792. getBBox: function () {
  1793. return bb;
  1794. }
  1795. };
  1796. extractTransform(el, transform);
  1797. return el.matrix;
  1798. },
  1799. transformPath = R.transformPath = function (path, transform) {
  1800. return mapPath(path, toMatrix(path, transform));
  1801. },
  1802. extractTransform = R._extractTransform = function (el, tstr) {
  1803. if (tstr == null) {
  1804. return el._.transform;
  1805. }
  1806. tstr = Str(tstr).replace(/\.{3}|\u2026/g, el._.transform || E);
  1807. var tdata = R.parseTransformString(tstr),
  1808. deg = 0,
  1809. dx = 0,
  1810. dy = 0,
  1811. sx = 1,
  1812. sy = 1,
  1813. _ = el._,
  1814. m = new Matrix;
  1815. _.transform = tdata || [];
  1816. if (tdata) {
  1817. for (var i = 0, ii = tdata.length; i < ii; i++) {
  1818. var t = tdata[i],
  1819. tlen = t.length,
  1820. command = Str(t[0]).toLowerCase(),
  1821. absolute = t[0] != command,
  1822. inver = absolute ? m.invert() : 0,
  1823. x1,
  1824. y1,
  1825. x2,
  1826. y2,
  1827. bb;
  1828. if (command == "t" && tlen == 3) {
  1829. if (absolute) {
  1830. x1 = inver.x(0, 0);
  1831. y1 = inver.y(0, 0);
  1832. x2 = inver.x(t[1], t[2]);
  1833. y2 = inver.y(t[1], t[2]);
  1834. m.translate(x2 - x1, y2 - y1);
  1835. } else {
  1836. m.translate(t[1], t[2]);
  1837. }
  1838. } else if (command == "r") {
  1839. if (tlen == 2) {
  1840. bb = bb || el.getBBox(1);
  1841. m.rotate(t[1], bb.x + bb.width / 2, bb.y + bb.height / 2);
  1842. deg += t[1];
  1843. } else if (tlen == 4) {
  1844. if (absolute) {
  1845. x2 = inver.x(t[2], t[3]);
  1846. y2 = inver.y(t[2], t[3]);
  1847. m.rotate(t[1], x2, y2);
  1848. } else {
  1849. m.rotate(t[1], t[2], t[3]);
  1850. }
  1851. deg += t[1];
  1852. }
  1853. } else if (command == "s") {
  1854. if (tlen == 2 || tlen == 3) {
  1855. bb = bb || el.getBBox(1);
  1856. m.scale(t[1], t[tlen - 1], bb.x + bb.width / 2, bb.y + bb.height / 2);
  1857. sx *= t[1];
  1858. sy *= t[tlen - 1];
  1859. } else if (tlen == 5) {
  1860. if (absolute) {
  1861. x2 = inver.x(t[3], t[4]);
  1862. y2 = inver.y(t[3], t[4]);
  1863. m.scale(t[1], t[2], x2, y2);
  1864. } else {
  1865. m.scale(t[1], t[2], t[3], t[4]);
  1866. }
  1867. sx *= t[1];
  1868. sy *= t[2];
  1869. }
  1870. } else if (command == "m" && tlen == 7) {
  1871. m.add(t[1], t[2], t[3], t[4], t[5], t[6]);
  1872. }
  1873. _.dirtyT = 1;
  1874. el.matrix = m;
  1875. }
  1876. }
  1877. el.matrix = m;
  1878. _.sx = sx;
  1879. _.sy = sy;
  1880. _.deg = deg;
  1881. _.dx = dx = m.e;
  1882. _.dy = dy = m.f;
  1883. if (sx == 1 && sy == 1 && !deg && _.bbox) {
  1884. _.bbox.x += +dx;
  1885. _.bbox.y += +dy;
  1886. } else {
  1887. _.dirtyT = 1;
  1888. }
  1889. },
  1890. getEmpty = function (item) {
  1891. var l = item[0];
  1892. switch (l.toLowerCase()) {
  1893. case "t": return [l, 0, 0];
  1894. case "m": return [l, 1, 0, 0, 1, 0, 0];
  1895. case "r": if (item.length == 4) {
  1896. return [l, 0, item[2], item[3]];
  1897. } else {
  1898. return [l, 0];
  1899. }
  1900. case "s": if (item.length == 5) {
  1901. return [l, 1, 1, item[3], item[4]];
  1902. } else if (item.length == 3) {
  1903. return [l, 1, 1];
  1904. } else {
  1905. return [l, 1];
  1906. }
  1907. }
  1908. },
  1909. equaliseTransform = R._equaliseTransform = function (t1, t2) {
  1910. t2 = Str(t2).replace(/\.{3}|\u2026/g, t1);
  1911. t1 = R.parseTransformString(t1) || [];
  1912. t2 = R.parseTransformString(t2) || [];
  1913. var maxlength = mmax(t1.length, t2.length),
  1914. from = [],
  1915. to = [],
  1916. i = 0, j, jj,
  1917. tt1, tt2;
  1918. for (; i < maxlength; i++) {
  1919. tt1 = t1[i] || getEmpty(t2[i]);
  1920. tt2 = t2[i] || getEmpty(tt1);
  1921. if ((tt1[0] != tt2[0]) ||
  1922. (tt1[0].toLowerCase() == "r" && (tt1[2] != tt2[2] || tt1[3] != tt2[3])) ||
  1923. (tt1[0].toLowerCase() == "s" && (tt1[3] != tt2[3] || tt1[4] != tt2[4]))
  1924. ) {
  1925. return;
  1926. }
  1927. from[i] = [];
  1928. to[i] = [];
  1929. for (j = 0, jj = mmax(tt1.length, tt2.length); j < jj; j++) {
  1930. j in tt1 && (from[i][j] = tt1[j]);
  1931. j in tt2 && (to[i][j] = tt2[j]);
  1932. }
  1933. }
  1934. return {
  1935. from: from,
  1936. to: to
  1937. };
  1938. };
  1939. R._getContainer = function (x, y, w, h) {
  1940. var container;
  1941. container = h == null && !R.is(x, "object") ? g.doc.getElementById(x) : x;
  1942. if (container == null) {
  1943. return;
  1944. }
  1945. if (container.tagName) {
  1946. if (y == null) {
  1947. return {
  1948. container: container,
  1949. width: container.style.pixelWidth || container.offsetWidth,
  1950. height: container.style.pixelHeight || container.offsetHeight
  1951. };
  1952. } else {
  1953. return {
  1954. container: container,
  1955. width: y,
  1956. height: w
  1957. };
  1958. }
  1959. }
  1960. return {
  1961. container: 1,
  1962. x: x,
  1963. y: y,
  1964. width: w,
  1965. height: h
  1966. };
  1967. };
  1968. R.pathToRelative = pathToRelative;
  1969. R._engine = {};
  1970. R.path2curve = path2curve;
  1971. R.matrix = function (a, b, c, d, e, f) {
  1972. return new Matrix(a, b, c, d, e, f);
  1973. };
  1974. function Matrix(a, b, c, d, e, f) {
  1975. if (a != null) {
  1976. this.a = +a;
  1977. this.b = +b;
  1978. this.c = +c;
  1979. this.d = +d;
  1980. this.e = +e;
  1981. this.f = +f;
  1982. } else {
  1983. this.a = 1;
  1984. this.b = 0;
  1985. this.c = 0;
  1986. this.d = 1;
  1987. this.e = 0;
  1988. this.f = 0;
  1989. }
  1990. }
  1991. (function (matrixproto) {
  1992. matrixproto.add = function (a, b, c, d, e, f) {
  1993. var out = [[], [], []],
  1994. m = [[this.a, this.c, this.e], [this.b, this.d, this.f], [0, 0, 1]],
  1995. matrix = [[a, c, e], [b, d, f], [0, 0, 1]],
  1996. x, y, z, res;
  1997. if (a && a instanceof Matrix) {
  1998. matrix = [[a.a, a.c, a.e], [a.b, a.d, a.f], [0, 0, 1]];
  1999. }
  2000. for (x = 0; x < 3; x++) {
  2001. for (y = 0; y < 3; y++) {
  2002. res = 0;
  2003. for (z = 0; z < 3; z++) {
  2004. res += m[x][z] * matrix[z][y];
  2005. }
  2006. out[x][y] = res;
  2007. }
  2008. }
  2009. this.a = out[0][0];
  2010. this.b = out[1][0];
  2011. this.c = out[0][1];
  2012. this.d = out[1][1];
  2013. this.e = out[0][2];
  2014. this.f = out[1][2];
  2015. };
  2016. matrixproto.invert = function () {
  2017. var me = this,
  2018. x = me.a * me.d - me.b * me.c;
  2019. return new Matrix(me.d / x, -me.b / x, -me.c / x, me.a / x, (me.c * me.f - me.d * me.e) / x, (me.b * me.e - me.a * me.f) / x);
  2020. };
  2021. matrixproto.clone = function () {
  2022. return new Matrix(this.a, this.b, this.c, this.d, this.e, this.f);
  2023. };
  2024. matrixproto.translate = function (x, y) {
  2025. this.add(1, 0, 0, 1, x, y);
  2026. };
  2027. matrixproto.scale = function (x, y, cx, cy) {
  2028. y == null && (y = x);
  2029. (cx || cy) && this.add(1, 0, 0, 1, cx, cy);
  2030. this.add(x, 0, 0, y, 0, 0);
  2031. (cx || cy) && this.add(1, 0, 0, 1, -cx, -cy);
  2032. };
  2033. matrixproto.rotate = function (a, x, y) {
  2034. a = R.rad(a);
  2035. x = x || 0;
  2036. y = y || 0;
  2037. var cos = +math.cos(a).toFixed(9),
  2038. sin = +math.sin(a).toFixed(9);
  2039. this.add(cos, sin, -sin, cos, x, y);
  2040. this.add(1, 0, 0, 1, -x, -y);
  2041. };
  2042. matrixproto.x = function (x, y) {
  2043. return x * this.a + y * this.c + this.e;
  2044. };
  2045. matrixproto.y = function (x, y) {
  2046. return x * this.b + y * this.d + this.f;
  2047. };
  2048. matrixproto.get = function (i) {
  2049. return +this[Str.fromCharCode(97 + i)].toFixed(4);
  2050. };
  2051. matrixproto.toString = function () {
  2052. return R.svg ?
  2053. "matrix(" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)].join() + ")" :
  2054. [this.get(0), this.get(2), this.get(1), this.get(3), 0, 0].join();
  2055. };
  2056. matrixproto.toFilter = function () {
  2057. return "progid:DXImageTransform.Microsoft.Matrix(M11=" + this.get(0) +
  2058. ", M12=" + this.get(2) + ", M21=" + this.get(1) + ", M22=" + this.get(3) +
  2059. ", Dx=" + this.get(4) + ", Dy=" + this.get(5) + ", sizingmethod='auto expand')";
  2060. };
  2061. matrixproto.offset = function () {
  2062. return [this.e.toFixed(4), this.f.toFixed(4)];
  2063. };
  2064. function norm(a) {
  2065. return a[0] * a[0] + a[1] * a[1];
  2066. }
  2067. function normalize(a) {
  2068. var mag = math.sqrt(norm(a));
  2069. a[0] && (a[0] /= mag);
  2070. a[1] && (a[1] /= mag);
  2071. }
  2072. matrixproto.split = function () {
  2073. var out = {};
  2074. // translation
  2075. out.dx = this.e;
  2076. out.dy = this.f;
  2077. // scale and shear
  2078. var row = [[this.a, this.c], [this.b, this.d]];
  2079. out.scalex = math.sqrt(norm(row[0]));
  2080. normalize(row[0]);
  2081. out.shear = row[0][0] * row[1][0] + row[0][1] * row[1][1];
  2082. row[1] = [row[1][0] - row[0][0] * out.shear, row[1][1] - row[0][1] * out.shear];
  2083. out.scaley = math.sqrt(norm(row[1]));
  2084. normalize(row[1]);
  2085. out.shear /= out.scaley;
  2086. // rotation
  2087. var sin = -row[0][1],
  2088. cos = row[1][1];
  2089. if (cos < 0) {
  2090. out.rotate = R.deg(math.acos(cos));
  2091. if (sin < 0) {
  2092. out.rotate = 360 - out.rotate;
  2093. }
  2094. } else {
  2095. out.rotate = R.deg(math.asin(sin));
  2096. }
  2097. out.isSimple = !+out.shear.toFixed(9) && (out.scalex.toFixed(9) == out.scaley.toFixed(9) || !out.rotate);
  2098. out.isSuperSimple = !+out.shear.toFixed(9) && out.scalex.toFixed(9) == out.scaley.toFixed(9) && !out.rotate;
  2099. out.noRotation = !+out.shear.toFixed(9) && !out.rotate;
  2100. return out;
  2101. };
  2102. matrixproto.toTransformString = function (shorter) {
  2103. var s = shorter || this[split]();
  2104. if (s.isSimple) {
  2105. s.scalex = +s.scalex.toFixed(4);
  2106. s.scaley = +s.scaley.toFixed(4);
  2107. s.rotate = +s.rotate.toFixed(4);
  2108. return (s.dx || s.dy ? "t" + [s.dx, s.dy] : E) +
  2109. (s.scalex != 1 || s.scaley != 1 ? "s" + [s.scalex, s.scaley, 0, 0] : E) +
  2110. (s.rotate ? "r" + [s.rotate, 0, 0] : E);
  2111. } else {
  2112. return "m" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)];
  2113. }
  2114. };
  2115. })(Matrix.prototype);
  2116. // WebKit rendering bug workaround method
  2117. var version = navigator.userAgent.match(/Version\/(.*?)\s/) || navigator.userAgent.match(/Chrome\/(\d+)/);
  2118. if ((navigator.vendor == "Apple Computer, Inc.") && (version && version[1] < 4 || navigator.platform.slice(0, 2) == "iP") ||
  2119. (navigator.vendor == "Google Inc." && version && version[1] < 8)) {
  2120. paperproto.safari = function () {
  2121. var rect = this.rect(-99, -99, this.width + 99, this.height + 99).attr({stroke: "none"});
  2122. setTimeout(function () {rect.remove();});
  2123. };
  2124. } else {
  2125. paperproto.safari = fun;
  2126. }
  2127. var preventDefault = function () {
  2128. this.returnValue = false;
  2129. },
  2130. preventTouch = function () {
  2131. return this.originalEvent.preventDefault();
  2132. },
  2133. stopPropagation = function () {
  2134. this.cancelBubble = true;
  2135. },
  2136. stopTouch = function () {
  2137. return this.originalEvent.stopPropagation();
  2138. },
  2139. addEvent = (function () {
  2140. if (g.doc.addEventListener) {
  2141. return function (obj, type, fn, element) {
  2142. var realName = supportsTouch && touchMap[type] ? touchMap[type] : type,
  2143. f = function (e) {
  2144. var scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop,
  2145. scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft,
  2146. x = e.clientX + scrollX,
  2147. y = e.clientY + scrollY;
  2148. if (supportsTouch && touchMap[has](type)) {
  2149. for (var i = 0, ii = e.targetTouches && e.targetTouches.length; i < ii; i++) {
  2150. if (e.targetTouches[i].target == obj) {
  2151. var olde = e;
  2152. e = e.targetTouches[i];
  2153. e.originalEvent = olde;
  2154. e.preventDefault = preventTouch;
  2155. e.stopPropagation = stopTouch;
  2156. break;
  2157. }
  2158. }
  2159. }
  2160. return fn.call(element, e, x, y);
  2161. };
  2162. obj.addEventListener(realName, f, false);
  2163. return function () {
  2164. obj.removeEventListener(realName, f, false);
  2165. return true;
  2166. };
  2167. };
  2168. } else if (g.doc.attachEvent) {
  2169. return function (obj, type, fn, element) {
  2170. var f = function (e) {
  2171. e = e || g.win.event;
  2172. var scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop,
  2173. scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft,
  2174. x = e.clientX + scrollX,
  2175. y = e.clientY + scrollY;
  2176. e.preventDefault = e.preventDefault || preventDefault;
  2177. e.stopPropagation = e.stopPropagation || stopPropagation;
  2178. return fn.call(element, e, x, y);
  2179. };
  2180. obj.attachEvent("on" + type, f);
  2181. var detacher = function () {
  2182. obj.detachEvent("on" + type, f);
  2183. return true;
  2184. };
  2185. return detacher;
  2186. };
  2187. }
  2188. })(),
  2189. drag = [],
  2190. dragMove = function (e) {
  2191. var x = e.clientX,
  2192. y = e.clientY,
  2193. scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop,
  2194. scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft,
  2195. dragi,
  2196. j = drag.length;
  2197. while (j--) {
  2198. dragi = drag[j];
  2199. if (supportsTouch) {
  2200. var i = e.touches.length,
  2201. touch;
  2202. while (i--) {
  2203. touch = e.touches[i];
  2204. if (touch.identifier == dragi.el._drag.id) {
  2205. x = touch.clientX;
  2206. y = touch.clientY;
  2207. (e.originalEvent ? e.originalEvent : e).preventDefault();
  2208. break;
  2209. }
  2210. }
  2211. } else {
  2212. e.preventDefault();
  2213. }
  2214. var node = dragi.el.node,
  2215. o,
  2216. next = node.nextSibling,
  2217. parent = node.parentNode,
  2218. display = node.style.display;
  2219. g.win.opera && parent.removeChild(node);
  2220. node.style.display = "none";
  2221. o = dragi.el.paper.getElementByPoint(x, y);
  2222. node.style.display = display;
  2223. g.win.opera && (next ? parent.insertBefore(node, next) : parent.appendChild(node));
  2224. o && eve("raphael.drag.over." + dragi.el.id, dragi.el, o);
  2225. x += scrollX;
  2226. y += scrollY;
  2227. eve("raphael.drag.move." + dragi.el.id, dragi.move_scope || dragi.el, x - dragi.el._drag.x, y - dragi.el._drag.y, x, y, e);
  2228. }
  2229. },
  2230. dragUp = function (e) {
  2231. R.unmousemove(dragMove).unmouseup(dragUp);
  2232. var i = drag.length,
  2233. dragi;
  2234. while (i--) {
  2235. dragi = drag[i];
  2236. dragi.el._drag = {};
  2237. eve("raphael.drag.end." + dragi.el.id, dragi.end_scope || dragi.start_scope || dragi.move_scope || dragi.el, e);
  2238. }
  2239. drag = [];
  2240. },
  2241. elproto = R.el = {};
  2242. for (var i = events.length; i--;) {
  2243. (function (eventName) {
  2244. R[eventName] = elproto[eventName] = function (fn, scope) {
  2245. if (R.is(fn, "function")) {
  2246. this.events = this.events || [];
  2247. this.events.push({name: eventName, f: fn, unbind: addEvent(this.shape || this.node || g.doc, eventName, fn, scope || this)});
  2248. }
  2249. return this;
  2250. };
  2251. R["un" + eventName] = elproto["un" + eventName] = function (fn) {
  2252. var events = this.events || [],
  2253. l = events.length;
  2254. while (l--) if (events[l].name == eventName && events[l].f == fn) {
  2255. events[l].unbind();
  2256. events.splice(l, 1);
  2257. !events.length && delete this.events;
  2258. return this;
  2259. }
  2260. return this;
  2261. };
  2262. })(events[i]);
  2263. }
  2264. elproto.data = function (key, value) {
  2265. var data = eldata[this.id] = eldata[this.id] || {};
  2266. if (arguments.length == 1) {
  2267. if (R.is(key, "object")) {
  2268. for (var i in key) if (key[has](i)) {
  2269. this.data(i, key[i]);
  2270. }
  2271. return this;
  2272. }
  2273. eve("raphael.data.get." + this.id, this, data[key], key);
  2274. return data[key];
  2275. }
  2276. data[key] = value;
  2277. eve("raphael.data.set." + this.id, this, value, key);
  2278. return this;
  2279. };
  2280. elproto.removeData = function (key) {
  2281. if (key == null) {
  2282. eldata[this.id] = {};
  2283. } else {
  2284. eldata[this.id] && delete eldata[this.id][key];
  2285. }
  2286. return this;
  2287. };
  2288. elproto.hover = function (f_in, f_out, scope_in, scope_out) {
  2289. return this.mouseover(f_in, scope_in).mouseout(f_out, scope_out || scope_in);
  2290. };
  2291. elproto.unhover = function (f_in, f_out) {
  2292. return this.unmouseover(f_in).unmouseout(f_out);
  2293. };
  2294. var draggable = [];
  2295. elproto.drag = function (onmove, onstart, onend, move_scope, start_scope, end_scope) {
  2296. function start(e) {
  2297. (e.originalEvent || e).preventDefault();
  2298. var scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop,
  2299. scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft;
  2300. this._drag.x = e.clientX + scrollX;
  2301. this._drag.y = e.clientY + scrollY;
  2302. this._drag.id = e.identifier;
  2303. !drag.length && R.mousemove(dragMove).mouseup(dragUp);
  2304. drag.push({el: this, move_scope: move_scope, start_scope: start_scope, end_scope: end_scope});
  2305. onstart && eve.on("raphael.drag.start." + this.id, onstart);
  2306. onmove && eve.on("raphael.drag.move." + this.id, onmove);
  2307. onend && eve.on("raphael.drag.end." + this.id, onend);
  2308. eve("raphael.drag.start." + this.id, start_scope || move_scope || this, e.clientX + scrollX, e.clientY + scrollY, e);
  2309. }
  2310. this._drag = {};
  2311. draggable.push({el: this, start: start});
  2312. this.mousedown(start);
  2313. return this;
  2314. };
  2315. elproto.onDragOver = function (f) {
  2316. f ? eve.on("raphael.drag.over." + this.id, f) : eve.unbind("raphael.drag.over." + this.id);
  2317. };
  2318. elproto.undrag = function () {
  2319. var i = draggable.length;
  2320. while (i--) if (draggable[i].el == this) {
  2321. this.unmousedown(draggable[i].start);
  2322. draggable.splice(i, 1);
  2323. eve.unbind("raphael.drag.*." + this.id);
  2324. }
  2325. !draggable.length && R.unmousemove(dragMove).unmouseup(dragUp);
  2326. };
  2327. paperproto.circle = function (x, y, r) {
  2328. var out = R._engine.circle(this, x || 0, y || 0, r || 0);
  2329. this.__set__ && this.__set__.push(out);
  2330. return out;
  2331. };
  2332. paperproto.rect = function (x, y, w, h, r) {
  2333. var out = R._engine.rect(this, x || 0, y || 0, w || 0, h || 0, r || 0);
  2334. this.__set__ && this.__set__.push(out);
  2335. return out;
  2336. };
  2337. paperproto.ellipse = function (x, y, rx, ry) {
  2338. var out = R._engine.ellipse(this, x || 0, y || 0, rx || 0, ry || 0);
  2339. this.__set__ && this.__set__.push(out);
  2340. return out;
  2341. };
  2342. paperproto.path = function (pathString) {
  2343. pathString && !R.is(pathString, string) && !R.is(pathString[0], array) && (pathString += E);
  2344. var out = R._engine.path(R.format[apply](R, arguments), this);
  2345. this.__set__ && this.__set__.push(out);
  2346. return out;
  2347. };
  2348. paperproto.image = function (src, x, y, w, h) {
  2349. var out = R._engine.image(this, src || "about:blank", x || 0, y || 0, w || 0, h || 0);
  2350. this.__set__ && this.__set__.push(out);
  2351. return out;
  2352. };
  2353. paperproto.text = function (x, y, text) {
  2354. var out = R._engine.text(this, x || 0, y || 0, Str(text));
  2355. this.__set__ && this.__set__.push(out);
  2356. return out;
  2357. };
  2358. paperproto.set = function (itemsArray) {
  2359. !R.is(itemsArray, "array") && (itemsArray = Array.prototype.splice.call(arguments, 0, arguments.length));
  2360. var out = new Set(itemsArray);
  2361. this.__set__ && this.__set__.push(out);
  2362. return out;
  2363. };
  2364. paperproto.setStart = function (set) {
  2365. this.__set__ = set || this.set();
  2366. };
  2367. paperproto.setFinish = function (set) {
  2368. var out = this.__set__;
  2369. delete this.__set__;
  2370. return out;
  2371. };
  2372. paperproto.setSize = function (width, height) {
  2373. return R._engine.setSize.call(this, width, height);
  2374. };
  2375. paperproto.setViewBox = function (x, y, w, h, fit) {
  2376. return R._engine.setViewBox.call(this, x, y, w, h, fit);
  2377. };
  2378. paperproto.top = paperproto.bottom = null;
  2379. paperproto.raphael = R;
  2380. var getOffset = function (elem) {
  2381. var box = elem.getBoundingClientRect(),
  2382. doc = elem.ownerDocument,
  2383. body = doc.body,
  2384. docElem = doc.documentElement,
  2385. clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
  2386. top = box.top + (g.win.pageYOffset || docElem.scrollTop || body.scrollTop ) - clientTop,
  2387. left = box.left + (g.win.pageXOffset || docElem.scrollLeft || body.scrollLeft) - clientLeft;
  2388. return {
  2389. y: top,
  2390. x: left
  2391. };
  2392. };
  2393. paperproto.getElementByPoint = function (x, y) {
  2394. var paper = this,
  2395. svg = paper.canvas,
  2396. target = g.doc.elementFromPoint(x, y);
  2397. if (g.win.opera && target.tagName == "svg") {
  2398. var so = getOffset(svg),
  2399. sr = svg.createSVGRect();
  2400. sr.x = x - so.x;
  2401. sr.y = y - so.y;
  2402. sr.width = sr.height = 1;
  2403. var hits = svg.getIntersectionList(sr, null);
  2404. if (hits.length) {
  2405. target = hits[hits.length - 1];
  2406. }
  2407. }
  2408. if (!target) {
  2409. return null;
  2410. }
  2411. while (target.parentNode && target != svg.parentNode && !target.raphael) {
  2412. target = target.parentNode;
  2413. }
  2414. target == paper.canvas.parentNode && (target = svg);
  2415. target = target && target.raphael ? paper.getById(target.raphaelid) : null;
  2416. return target;
  2417. };
  2418. paperproto.getById = function (id) {
  2419. var bot = this.bottom;
  2420. while (bot) {
  2421. if (bot.id == id) {
  2422. return bot;
  2423. }
  2424. bot = bot.next;
  2425. }
  2426. return null;
  2427. };
  2428. paperproto.forEach = function (callback, thisArg) {
  2429. var bot = this.bottom;
  2430. while (bot) {
  2431. if (callback.call(thisArg, bot) === false) {
  2432. return this;
  2433. }
  2434. bot = bot.next;
  2435. }
  2436. return this;
  2437. };
  2438. paperproto.getElementsByPoint = function (x, y) {
  2439. var set = this.set();
  2440. this.forEach(function (el) {
  2441. if (el.isPointInside(x, y)) {
  2442. set.push(el);
  2443. }
  2444. });
  2445. return set;
  2446. };
  2447. function x_y() {
  2448. return this.x + S + this.y;
  2449. }
  2450. function x_y_w_h() {
  2451. return this.x + S + this.y + S + this.width + " \xd7 " + this.height;
  2452. }
  2453. elproto.isPointInside = function (x, y) {
  2454. var rp = this.realPath = this.realPath || getPath[this.type](this);
  2455. return R.isPointInsidePath(rp, x, y);
  2456. };
  2457. elproto.getBBox = function (isWithoutTransform) {
  2458. if (this.removed) {
  2459. return {};
  2460. }
  2461. var _ = this._;
  2462. if (isWithoutTransform) {
  2463. if (_.dirty || !_.bboxwt) {
  2464. this.realPath = getPath[this.type](this);
  2465. _.bboxwt = pathDimensions(this.realPath);
  2466. _.bboxwt.toString = x_y_w_h;
  2467. _.dirty = 0;
  2468. }
  2469. return _.bboxwt;
  2470. }
  2471. if (_.dirty || _.dirtyT || !_.bbox) {
  2472. if (_.dirty || !this.realPath) {
  2473. _.bboxwt = 0;
  2474. this.realPath = getPath[this.type](this);
  2475. }
  2476. _.bbox = pathDimensions(mapPath(this.realPath, this.matrix));
  2477. _.bbox.toString = x_y_w_h;
  2478. _.dirty = _.dirtyT = 0;
  2479. }
  2480. return _.bbox;
  2481. };
  2482. elproto.clone = function () {
  2483. if (this.removed) {
  2484. return null;
  2485. }
  2486. var out = this.paper[this.type]().attr(this.attr());
  2487. this.__set__ && this.__set__.push(out);
  2488. return out;
  2489. };
  2490. elproto.glow = function (glow) {
  2491. if (this.type == "text") {
  2492. return null;
  2493. }
  2494. glow = glow || {};
  2495. var s = {
  2496. width: (glow.width || 10) + (+this.attr("stroke-width") || 1),
  2497. fill: glow.fill || false,
  2498. opacity: glow.opacity || .5,
  2499. offsetx: glow.offsetx || 0,
  2500. offsety: glow.offsety || 0,
  2501. color: glow.color || "#000"
  2502. },
  2503. c = s.width / 2,
  2504. r = this.paper,
  2505. out = r.set(),
  2506. path = this.realPath || getPath[this.type](this);
  2507. path = this.matrix ? mapPath(path, this.matrix) : path;
  2508. for (var i = 1; i < c + 1; i++) {
  2509. out.push(r.path(path).attr({
  2510. stroke: s.color,
  2511. fill: s.fill ? s.color : "none",
  2512. "stroke-linejoin": "round",
  2513. "stroke-linecap": "round",
  2514. "stroke-width": +(s.width / c * i).toFixed(3),
  2515. opacity: +(s.opacity / c).toFixed(3)
  2516. }));
  2517. }
  2518. return out.insertBefore(this).translate(s.offsetx, s.offsety);
  2519. };
  2520. var curveslengths = {},
  2521. getPointAtSegmentLength = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length) {
  2522. if (length == null) {
  2523. return bezlen(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y);
  2524. } else {
  2525. return R.findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, getTatLen(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length));
  2526. }
  2527. },
  2528. getLengthFactory = function (istotal, subpath) {
  2529. return function (path, length, onlystart) {
  2530. path = path2curve(path);
  2531. var x, y, p, l, sp = "", subpaths = {}, point,
  2532. len = 0;
  2533. for (var i = 0, ii = path.length; i < ii; i++) {
  2534. p = path[i];
  2535. if (p[0] == "M") {
  2536. x = +p[1];
  2537. y = +p[2];
  2538. } else {
  2539. l = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6]);
  2540. if (len + l > length) {
  2541. if (subpath && !subpaths.start) {
  2542. point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len);
  2543. sp += ["C" + point.start.x, point.start.y, point.m.x, point.m.y, point.x, point.y];
  2544. if (onlystart) {return sp;}
  2545. subpaths.start = sp;
  2546. sp = ["M" + point.x, point.y + "C" + point.n.x, point.n.y, point.end.x, point.end.y, p[5], p[6]].join();
  2547. len += l;
  2548. x = +p[5];
  2549. y = +p[6];
  2550. continue;
  2551. }
  2552. if (!istotal && !subpath) {
  2553. point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len);
  2554. return {x: point.x, y: point.y, alpha: point.alpha};
  2555. }
  2556. }
  2557. len += l;
  2558. x = +p[5];
  2559. y = +p[6];
  2560. }
  2561. sp += p.shift() + p;
  2562. }
  2563. subpaths.end = sp;
  2564. point = istotal ? len : subpath ? subpaths : R.findDotsAtSegment(x, y, p[0], p[1], p[2], p[3], p[4], p[5], 1);
  2565. point.alpha && (point = {x: point.x, y: point.y, alpha: point.alpha});
  2566. return point;
  2567. };
  2568. };
  2569. var getTotalLength = getLengthFactory(1),
  2570. getPointAtLength = getLengthFactory(),
  2571. getSubpathsAtLength = getLengthFactory(0, 1);
  2572. R.getTotalLength = getTotalLength;
  2573. R.getPointAtLength = getPointAtLength;
  2574. R.getSubpath = function (path, from, to) {
  2575. if (this.getTotalLength(path) - to < 1e-6) {
  2576. return getSubpathsAtLength(path, from).end;
  2577. }
  2578. var a = getSubpathsAtLength(path, to, 1);
  2579. return from ? getSubpathsAtLength(a, from).end : a;
  2580. };
  2581. elproto.getTotalLength = function () {
  2582. if (this.type != "path") {return;}
  2583. if (this.node.getTotalLength) {
  2584. return this.node.getTotalLength();
  2585. }
  2586. return getTotalLength(this.attrs.path);
  2587. };
  2588. elproto.getPointAtLength = function (length) {
  2589. if (this.type != "path") {return;}
  2590. return getPointAtLength(this.attrs.path, length);
  2591. };
  2592. elproto.getSubpath = function (from, to) {
  2593. if (this.type != "path") {return;}
  2594. return R.getSubpath(this.attrs.path, from, to);
  2595. };
  2596. var ef = R.easing_formulas = {
  2597. linear: function (n) {
  2598. return n;
  2599. },
  2600. "<": function (n) {
  2601. return pow(n, 1.7);
  2602. },
  2603. ">": function (n) {
  2604. return pow(n, .48);
  2605. },
  2606. "<>": function (n) {
  2607. var q = .48 - n / 1.04,
  2608. Q = math.sqrt(.1734 + q * q),
  2609. x = Q - q,
  2610. X = pow(abs(x), 1 / 3) * (x < 0 ? -1 : 1),
  2611. y = -Q - q,
  2612. Y = pow(abs(y), 1 / 3) * (y < 0 ? -1 : 1),
  2613. t = X + Y + .5;
  2614. return (1 - t) * 3 * t * t + t * t * t;
  2615. },
  2616. backIn: function (n) {
  2617. var s = 1.70158;
  2618. return n * n * ((s + 1) * n - s);
  2619. },
  2620. backOut: function (n) {
  2621. n = n - 1;
  2622. var s = 1.70158;
  2623. return n * n * ((s + 1) * n + s) + 1;
  2624. },
  2625. elastic: function (n) {
  2626. if (n == !!n) {
  2627. return n;
  2628. }
  2629. return pow(2, -10 * n) * math.sin((n - .075) * (2 * PI) / .3) + 1;
  2630. },
  2631. bounce: function (n) {
  2632. var s = 7.5625,
  2633. p = 2.75,
  2634. l;
  2635. if (n < (1 / p)) {
  2636. l = s * n * n;
  2637. } else {
  2638. if (n < (2 / p)) {
  2639. n -= (1.5 / p);
  2640. l = s * n * n + .75;
  2641. } else {
  2642. if (n < (2.5 / p)) {
  2643. n -= (2.25 / p);
  2644. l = s * n * n + .9375;
  2645. } else {
  2646. n -= (2.625 / p);
  2647. l = s * n * n + .984375;
  2648. }
  2649. }
  2650. }
  2651. return l;
  2652. }
  2653. };
  2654. ef.easeIn = ef["ease-in"] = ef["<"];
  2655. ef.easeOut = ef["ease-out"] = ef[">"];
  2656. ef.easeInOut = ef["ease-in-out"] = ef["<>"];
  2657. ef["back-in"] = ef.backIn;
  2658. ef["back-out"] = ef.backOut;
  2659. var animationElements = [],
  2660. requestAnimFrame = window.requestAnimationFrame ||
  2661. window.webkitRequestAnimationFrame ||
  2662. window.mozRequestAnimationFrame ||
  2663. window.oRequestAnimationFrame ||
  2664. window.msRequestAnimationFrame ||
  2665. function (callback) {
  2666. setTimeout(callback, 16);
  2667. },
  2668. animation = function () {
  2669. var Now = +new Date,
  2670. l = 0;
  2671. for (; l < animationElements.length; l++) {
  2672. var e = animationElements[l];
  2673. if (e.el.removed || e.paused) {
  2674. continue;
  2675. }
  2676. var time = Now - e.start,
  2677. ms = e.ms,
  2678. easing = e.easing,
  2679. from = e.from,
  2680. diff = e.diff,
  2681. to = e.to,
  2682. t = e.t,
  2683. that = e.el,
  2684. set = {},
  2685. now,
  2686. init = {},
  2687. key;
  2688. if (e.initstatus) {
  2689. time = (e.initstatus * e.anim.top - e.prev) / (e.percent - e.prev) * ms;
  2690. e.status = e.initstatus;
  2691. delete e.initstatus;
  2692. e.stop && animationElements.splice(l--, 1);
  2693. } else {
  2694. e.status = (e.prev + (e.percent - e.prev) * (time / ms)) / e.anim.top;
  2695. }
  2696. if (time < 0) {
  2697. continue;
  2698. }
  2699. if (time < ms) {
  2700. var pos = easing(time / ms);
  2701. for (var attr in from) if (from[has](attr)) {
  2702. switch (availableAnimAttrs[attr]) {
  2703. case nu:
  2704. now = +from[attr] + pos * ms * diff[attr];
  2705. break;
  2706. case "colour":
  2707. now = "rgb(" + [
  2708. upto255(round(from[attr].r + pos * ms * diff[attr].r)),
  2709. upto255(round(from[attr].g + pos * ms * diff[attr].g)),
  2710. upto255(round(from[attr].b + pos * ms * diff[attr].b))
  2711. ].join(",") + ")";
  2712. break;
  2713. case "path":
  2714. now = [];
  2715. for (var i = 0, ii = from[attr].length; i < ii; i++) {
  2716. now[i] = [from[attr][i][0]];
  2717. for (var j = 1, jj = from[attr][i].length; j < jj; j++) {
  2718. now[i][j] = +from[attr][i][j] + pos * ms * diff[attr][i][j];
  2719. }
  2720. now[i] = now[i].join(S);
  2721. }
  2722. now = now.join(S);
  2723. break;
  2724. case "transform":
  2725. if (diff[attr].real) {
  2726. now = [];
  2727. for (i = 0, ii = from[attr].length; i < ii; i++) {
  2728. now[i] = [from[attr][i][0]];
  2729. for (j = 1, jj = from[attr][i].length; j < jj; j++) {
  2730. now[i][j] = from[attr][i][j] + pos * ms * diff[attr][i][j];
  2731. }
  2732. }
  2733. } else {
  2734. var get = function (i) {
  2735. return +from[attr][i] + pos * ms * diff[attr][i];
  2736. };
  2737. // now = [["r", get(2), 0, 0], ["t", get(3), get(4)], ["s", get(0), get(1), 0, 0]];
  2738. now = [["m", get(0), get(1), get(2), get(3), get(4), get(5)]];
  2739. }
  2740. break;
  2741. case "csv":
  2742. if (attr == "clip-rect") {
  2743. now = [];
  2744. i = 4;
  2745. while (i--) {
  2746. now[i] = +from[attr][i] + pos * ms * diff[attr][i];
  2747. }
  2748. }
  2749. break;
  2750. default:
  2751. var from2 = [][concat](from[attr]);
  2752. now = [];
  2753. i = that.paper.customAttributes[attr].length;
  2754. while (i--) {
  2755. now[i] = +from2[i] + pos * ms * diff[attr][i];
  2756. }
  2757. break;
  2758. }
  2759. set[attr] = now;
  2760. }
  2761. that.attr(set);
  2762. (function (id, that, anim) {
  2763. setTimeout(function () {
  2764. eve("raphael.anim.frame." + id, that, anim);
  2765. });
  2766. })(that.id, that, e.anim);
  2767. } else {
  2768. (function(f, el, a) {
  2769. setTimeout(function() {
  2770. eve("raphael.anim.frame." + el.id, el, a);
  2771. eve("raphael.anim.finish." + el.id, el, a);
  2772. R.is(f, "function") && f.call(el);
  2773. });
  2774. })(e.callback, that, e.anim);
  2775. that.attr(to);
  2776. animationElements.splice(l--, 1);
  2777. if (e.repeat > 1 && !e.next) {
  2778. for (key in to) if (to[has](key)) {
  2779. init[key] = e.totalOrigin[key];
  2780. }
  2781. e.el.attr(init);
  2782. runAnimation(e.anim, e.el, e.anim.percents[0], null, e.totalOrigin, e.repeat - 1);
  2783. }
  2784. if (e.next && !e.stop) {
  2785. runAnimation(e.anim, e.el, e.next, null, e.totalOrigin, e.repeat);
  2786. }
  2787. }
  2788. }
  2789. R.svg && that && that.paper && that.paper.safari();
  2790. animationElements.length && requestAnimFrame(animation);
  2791. },
  2792. upto255 = function (color) {
  2793. return color > 255 ? 255 : color < 0 ? 0 : color;
  2794. };
  2795. elproto.animateWith = function (el, anim, params, ms, easing, callback) {
  2796. var element = this;
  2797. if (element.removed) {
  2798. callback && callback.call(element);
  2799. return element;
  2800. }
  2801. var a = params instanceof Animation ? params : R.animation(params, ms, easing, callback),
  2802. x, y;
  2803. runAnimation(a, element, a.percents[0], null, element.attr());
  2804. for (var i = 0, ii = animationElements.length; i < ii; i++) {
  2805. if (animationElements[i].anim == anim && animationElements[i].el == el) {
  2806. animationElements[ii - 1].start = animationElements[i].start;
  2807. break;
  2808. }
  2809. }
  2810. return element;
  2811. //
  2812. //
  2813. // var a = params ? R.animation(params, ms, easing, callback) : anim,
  2814. // status = element.status(anim);
  2815. // return this.animate(a).status(a, status * anim.ms / a.ms);
  2816. };
  2817. function CubicBezierAtTime(t, p1x, p1y, p2x, p2y, duration) {
  2818. var cx = 3 * p1x,
  2819. bx = 3 * (p2x - p1x) - cx,
  2820. ax = 1 - cx - bx,
  2821. cy = 3 * p1y,
  2822. by = 3 * (p2y - p1y) - cy,
  2823. ay = 1 - cy - by;
  2824. function sampleCurveX(t) {
  2825. return ((ax * t + bx) * t + cx) * t;
  2826. }
  2827. function solve(x, epsilon) {
  2828. var t = solveCurveX(x, epsilon);
  2829. return ((ay * t + by) * t + cy) * t;
  2830. }
  2831. function solveCurveX(x, epsilon) {
  2832. var t0, t1, t2, x2, d2, i;
  2833. for(t2 = x, i = 0; i < 8; i++) {
  2834. x2 = sampleCurveX(t2) - x;
  2835. if (abs(x2) < epsilon) {
  2836. return t2;
  2837. }
  2838. d2 = (3 * ax * t2 + 2 * bx) * t2 + cx;
  2839. if (abs(d2) < 1e-6) {
  2840. break;
  2841. }
  2842. t2 = t2 - x2 / d2;
  2843. }
  2844. t0 = 0;
  2845. t1 = 1;
  2846. t2 = x;
  2847. if (t2 < t0) {
  2848. return t0;
  2849. }
  2850. if (t2 > t1) {
  2851. return t1;
  2852. }
  2853. while (t0 < t1) {
  2854. x2 = sampleCurveX(t2);
  2855. if (abs(x2 - x) < epsilon) {
  2856. return t2;
  2857. }
  2858. if (x > x2) {
  2859. t0 = t2;
  2860. } else {
  2861. t1 = t2;
  2862. }
  2863. t2 = (t1 - t0) / 2 + t0;
  2864. }
  2865. return t2;
  2866. }
  2867. return solve(t, 1 / (200 * duration));
  2868. }
  2869. elproto.onAnimation = function (f) {
  2870. f ? eve.on("raphael.anim.frame." + this.id, f) : eve.unbind("raphael.anim.frame." + this.id);
  2871. return this;
  2872. };
  2873. function Animation(anim, ms) {
  2874. var percents = [],
  2875. newAnim = {};
  2876. this.ms = ms;
  2877. this.times = 1;
  2878. if (anim) {
  2879. for (var attr in anim) if (anim[has](attr)) {
  2880. newAnim[toFloat(attr)] = anim[attr];
  2881. percents.push(toFloat(attr));
  2882. }
  2883. percents.sort(sortByNumber);
  2884. }
  2885. this.anim = newAnim;
  2886. this.top = percents[percents.length - 1];
  2887. this.percents = percents;
  2888. }
  2889. Animation.prototype.delay = function (delay) {
  2890. var a = new Animation(this.anim, this.ms);
  2891. a.times = this.times;
  2892. a.del = +delay || 0;
  2893. return a;
  2894. };
  2895. Animation.prototype.repeat = function (times) {
  2896. var a = new Animation(this.anim, this.ms);
  2897. a.del = this.del;
  2898. a.times = math.floor(mmax(times, 0)) || 1;
  2899. return a;
  2900. };
  2901. function runAnimation(anim, element, percent, status, totalOrigin, times) {
  2902. percent = toFloat(percent);
  2903. var params,
  2904. isInAnim,
  2905. isInAnimSet,
  2906. percents = [],
  2907. next,
  2908. prev,
  2909. timestamp,
  2910. ms = anim.ms,
  2911. from = {},
  2912. to = {},
  2913. diff = {};
  2914. if (status) {
  2915. for (i = 0, ii = animationElements.length; i < ii; i++) {
  2916. var e = animationElements[i];
  2917. if (e.el.id == element.id && e.anim == anim) {
  2918. if (e.percent != percent) {
  2919. animationElements.splice(i, 1);
  2920. isInAnimSet = 1;
  2921. } else {
  2922. isInAnim = e;
  2923. }
  2924. element.attr(e.totalOrigin);
  2925. break;
  2926. }
  2927. }
  2928. } else {
  2929. status = +to; // NaN
  2930. }
  2931. for (var i = 0, ii = anim.percents.length; i < ii; i++) {
  2932. if (anim.percents[i] == percent || anim.percents[i] > status * anim.top) {
  2933. percent = anim.percents[i];
  2934. prev = anim.percents[i - 1] || 0;
  2935. ms = ms / anim.top * (percent - prev);
  2936. next = anim.percents[i + 1];
  2937. params = anim.anim[percent];
  2938. break;
  2939. } else if (status) {
  2940. element.attr(anim.anim[anim.percents[i]]);
  2941. }
  2942. }
  2943. if (!params) {
  2944. return;
  2945. }
  2946. if (!isInAnim) {
  2947. for (var attr in params) if (params[has](attr)) {
  2948. if (availableAnimAttrs[has](attr) || element.paper.customAttributes[has](attr)) {
  2949. from[attr] = element.attr(attr);
  2950. (from[attr] == null) && (from[attr] = availableAttrs[attr]);
  2951. to[attr] = params[attr];
  2952. switch (availableAnimAttrs[attr]) {
  2953. case nu:
  2954. diff[attr] = (to[attr] - from[attr]) / ms;
  2955. break;
  2956. case "colour":
  2957. from[attr] = R.getRGB(from[attr]);
  2958. var toColour = R.getRGB(to[attr]);
  2959. diff[attr] = {
  2960. r: (toColour.r - from[attr].r) / ms,
  2961. g: (toColour.g - from[attr].g) / ms,
  2962. b: (toColour.b - from[attr].b) / ms
  2963. };
  2964. break;
  2965. case "path":
  2966. var pathes = path2curve(from[attr], to[attr]),
  2967. toPath = pathes[1];
  2968. from[attr] = pathes[0];
  2969. diff[attr] = [];
  2970. for (i = 0, ii = from[attr].length; i < ii; i++) {
  2971. diff[attr][i] = [0];
  2972. for (var j = 1, jj = from[attr][i].length; j < jj; j++) {
  2973. diff[attr][i][j] = (toPath[i][j] - from[attr][i][j]) / ms;
  2974. }
  2975. }
  2976. break;
  2977. case "transform":
  2978. var _ = element._,
  2979. eq = equaliseTransform(_[attr], to[attr]);
  2980. if (eq) {
  2981. from[attr] = eq.from;
  2982. to[attr] = eq.to;
  2983. diff[attr] = [];
  2984. diff[attr].real = true;
  2985. for (i = 0, ii = from[attr].length; i < ii; i++) {
  2986. diff[attr][i] = [from[attr][i][0]];
  2987. for (j = 1, jj = from[attr][i].length; j < jj; j++) {
  2988. diff[attr][i][j] = (to[attr][i][j] - from[attr][i][j]) / ms;
  2989. }
  2990. }
  2991. } else {
  2992. var m = (element.matrix || new Matrix),
  2993. to2 = {
  2994. _: {transform: _.transform},
  2995. getBBox: function () {
  2996. return element.getBBox(1);
  2997. }
  2998. };
  2999. from[attr] = [
  3000. m.a,
  3001. m.b,
  3002. m.c,
  3003. m.d,
  3004. m.e,
  3005. m.f
  3006. ];
  3007. extractTransform(to2, to[attr]);
  3008. to[attr] = to2._.transform;
  3009. diff[attr] = [
  3010. (to2.matrix.a - m.a) / ms,
  3011. (to2.matrix.b - m.b) / ms,
  3012. (to2.matrix.c - m.c) / ms,
  3013. (to2.matrix.d - m.d) / ms,
  3014. (to2.matrix.e - m.e) / ms,
  3015. (to2.matrix.f - m.f) / ms
  3016. ];
  3017. // from[attr] = [_.sx, _.sy, _.deg, _.dx, _.dy];
  3018. // var to2 = {_:{}, getBBox: function () { return element.getBBox(); }};
  3019. // extractTransform(to2, to[attr]);
  3020. // diff[attr] = [
  3021. // (to2._.sx - _.sx) / ms,
  3022. // (to2._.sy - _.sy) / ms,
  3023. // (to2._.deg - _.deg) / ms,
  3024. // (to2._.dx - _.dx) / ms,
  3025. // (to2._.dy - _.dy) / ms
  3026. // ];
  3027. }
  3028. break;
  3029. case "csv":
  3030. var values = Str(params[attr])[split](separator),
  3031. from2 = Str(from[attr])[split](separator);
  3032. if (attr == "clip-rect") {
  3033. from[attr] = from2;
  3034. diff[attr] = [];
  3035. i = from2.length;
  3036. while (i--) {
  3037. diff[attr][i] = (values[i] - from[attr][i]) / ms;
  3038. }
  3039. }
  3040. to[attr] = values;
  3041. break;
  3042. default:
  3043. values = [][concat](params[attr]);
  3044. from2 = [][concat](from[attr]);
  3045. diff[attr] = [];
  3046. i = element.paper.customAttributes[attr].length;
  3047. while (i--) {
  3048. diff[attr][i] = ((values[i] || 0) - (from2[i] || 0)) / ms;
  3049. }
  3050. break;
  3051. }
  3052. }
  3053. }
  3054. var easing = params.easing,
  3055. easyeasy = R.easing_formulas[easing];
  3056. if (!easyeasy) {
  3057. easyeasy = Str(easing).match(bezierrg);
  3058. if (easyeasy && easyeasy.length == 5) {
  3059. var curve = easyeasy;
  3060. easyeasy = function (t) {
  3061. return CubicBezierAtTime(t, +curve[1], +curve[2], +curve[3], +curve[4], ms);
  3062. };
  3063. } else {
  3064. easyeasy = pipe;
  3065. }
  3066. }
  3067. timestamp = params.start || anim.start || +new Date;
  3068. e = {
  3069. anim: anim,
  3070. percent: percent,
  3071. timestamp: timestamp,
  3072. start: timestamp + (anim.del || 0),
  3073. status: 0,
  3074. initstatus: status || 0,
  3075. stop: false,
  3076. ms: ms,
  3077. easing: easyeasy,
  3078. from: from,
  3079. diff: diff,
  3080. to: to,
  3081. el: element,
  3082. callback: params.callback,
  3083. prev: prev,
  3084. next: next,
  3085. repeat: times || anim.times,
  3086. origin: element.attr(),
  3087. totalOrigin: totalOrigin
  3088. };
  3089. animationElements.push(e);
  3090. if (status && !isInAnim && !isInAnimSet) {
  3091. e.stop = true;
  3092. e.start = new Date - ms * status;
  3093. if (animationElements.length == 1) {
  3094. return animation();
  3095. }
  3096. }
  3097. if (isInAnimSet) {
  3098. e.start = new Date - e.ms * status;
  3099. }
  3100. animationElements.length == 1 && requestAnimFrame(animation);
  3101. } else {
  3102. isInAnim.initstatus = status;
  3103. isInAnim.start = new Date - isInAnim.ms * status;
  3104. }
  3105. eve("raphael.anim.start." + element.id, element, anim);
  3106. }
  3107. R.animation = function (params, ms, easing, callback) {
  3108. if (params instanceof Animation) {
  3109. return params;
  3110. }
  3111. if (R.is(easing, "function") || !easing) {
  3112. callback = callback || easing || null;
  3113. easing = null;
  3114. }
  3115. params = Object(params);
  3116. ms = +ms || 0;
  3117. var p = {},
  3118. json,
  3119. attr;
  3120. for (attr in params) if (params[has](attr) && toFloat(attr) != attr && toFloat(attr) + "%" != attr) {
  3121. json = true;
  3122. p[attr] = params[attr];
  3123. }
  3124. if (!json) {
  3125. return new Animation(params, ms);
  3126. } else {
  3127. easing && (p.easing = easing);
  3128. callback && (p.callback = callback);
  3129. return new Animation({100: p}, ms);
  3130. }
  3131. };
  3132. elproto.animate = function (params, ms, easing, callback) {
  3133. var element = this;
  3134. if (element.removed) {
  3135. callback && callback.call(element);
  3136. return element;
  3137. }
  3138. var anim = params instanceof Animation ? params : R.animation(params, ms, easing, callback);
  3139. runAnimation(anim, element, anim.percents[0], null, element.attr());
  3140. return element;
  3141. };
  3142. elproto.setTime = function (anim, value) {
  3143. if (anim && value != null) {
  3144. this.status(anim, mmin(value, anim.ms) / anim.ms);
  3145. }
  3146. return this;
  3147. };
  3148. elproto.status = function (anim, value) {
  3149. var out = [],
  3150. i = 0,
  3151. len,
  3152. e;
  3153. if (value != null) {
  3154. runAnimation(anim, this, -1, mmin(value, 1));
  3155. return this;
  3156. } else {
  3157. len = animationElements.length;
  3158. for (; i < len; i++) {
  3159. e = animationElements[i];
  3160. if (e.el.id == this.id && (!anim || e.anim == anim)) {
  3161. if (anim) {
  3162. return e.status;
  3163. }
  3164. out.push({
  3165. anim: e.anim,
  3166. status: e.status
  3167. });
  3168. }
  3169. }
  3170. if (anim) {
  3171. return 0;
  3172. }
  3173. return out;
  3174. }
  3175. };
  3176. elproto.pause = function (anim) {
  3177. for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) {
  3178. if (eve("raphael.anim.pause." + this.id, this, animationElements[i].anim) !== false) {
  3179. animationElements[i].paused = true;
  3180. }
  3181. }
  3182. return this;
  3183. };
  3184. elproto.resume = function (anim) {
  3185. for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) {
  3186. var e = animationElements[i];
  3187. if (eve("raphael.anim.resume." + this.id, this, e.anim) !== false) {
  3188. delete e.paused;
  3189. this.status(e.anim, e.status);
  3190. }
  3191. }
  3192. return this;
  3193. };
  3194. elproto.stop = function (anim) {
  3195. for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) {
  3196. if (eve("raphael.anim.stop." + this.id, this, animationElements[i].anim) !== false) {
  3197. animationElements.splice(i--, 1);
  3198. }
  3199. }
  3200. return this;
  3201. };
  3202. function stopAnimation(paper) {
  3203. for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.paper == paper) {
  3204. animationElements.splice(i--, 1);
  3205. }
  3206. }
  3207. eve.on("raphael.remove", stopAnimation);
  3208. eve.on("raphael.clear", stopAnimation);
  3209. elproto.toString = function () {
  3210. return "Rapha\xebl\u2019s object";
  3211. };
  3212. // Set
  3213. var Set = function (items) {
  3214. this.items = [];
  3215. this.length = 0;
  3216. this.type = "set";
  3217. if (items) {
  3218. for (var i = 0, ii = items.length; i < ii; i++) {
  3219. if (items[i] && (items[i].constructor == elproto.constructor || items[i].constructor == Set)) {
  3220. this[this.items.length] = this.items[this.items.length] = items[i];
  3221. this.length++;
  3222. }
  3223. }
  3224. }
  3225. },
  3226. setproto = Set.prototype;
  3227. setproto.push = function () {
  3228. var item,
  3229. len;
  3230. for (var i = 0, ii = arguments.length; i < ii; i++) {
  3231. item = arguments[i];
  3232. if (item && (item.constructor == elproto.constructor || item.constructor == Set)) {
  3233. len = this.items.length;
  3234. this[len] = this.items[len] = item;
  3235. this.length++;
  3236. }
  3237. }
  3238. return this;
  3239. };
  3240. setproto.pop = function () {
  3241. this.length && delete this[this.length--];
  3242. return this.items.pop();
  3243. };
  3244. setproto.forEach = function (callback, thisArg) {
  3245. for (var i = 0, ii = this.items.length; i < ii; i++) {
  3246. if (callback.call(thisArg, this.items[i], i) === false) {
  3247. return this;
  3248. }
  3249. }
  3250. return this;
  3251. };
  3252. for (var method in elproto) if (elproto[has](method)) {
  3253. setproto[method] = (function (methodname) {
  3254. return function () {
  3255. var arg = arguments;
  3256. return this.forEach(function (el) {
  3257. el[methodname][apply](el, arg);
  3258. });
  3259. };
  3260. })(method);
  3261. }
  3262. setproto.attr = function (name, value) {
  3263. if (name && R.is(name, array) && R.is(name[0], "object")) {
  3264. for (var j = 0, jj = name.length; j < jj; j++) {
  3265. this.items[j].attr(name[j]);
  3266. }
  3267. } else {
  3268. for (var i = 0, ii = this.items.length; i < ii; i++) {
  3269. this.items[i].attr(name, value);
  3270. }
  3271. }
  3272. return this;
  3273. };
  3274. setproto.clear = function () {
  3275. while (this.length) {
  3276. this.pop();
  3277. }
  3278. };
  3279. setproto.splice = function (index, count, insertion) {
  3280. index = index < 0 ? mmax(this.length + index, 0) : index;
  3281. count = mmax(0, mmin(this.length - index, count));
  3282. var tail = [],
  3283. todel = [],
  3284. args = [],
  3285. i;
  3286. for (i = 2; i < arguments.length; i++) {
  3287. args.push(arguments[i]);
  3288. }
  3289. for (i = 0; i < count; i++) {
  3290. todel.push(this[index + i]);
  3291. }
  3292. for (; i < this.length - index; i++) {
  3293. tail.push(this[index + i]);
  3294. }
  3295. var arglen = args.length;
  3296. for (i = 0; i < arglen + tail.length; i++) {
  3297. this.items[index + i] = this[index + i] = i < arglen ? args[i] : tail[i - arglen];
  3298. }
  3299. i = this.items.length = this.length -= count - arglen;
  3300. while (this[i]) {
  3301. delete this[i++];
  3302. }
  3303. return new Set(todel);
  3304. };
  3305. setproto.exclude = function (el) {
  3306. for (var i = 0, ii = this.length; i < ii; i++) if (this[i] == el) {
  3307. this.splice(i, 1);
  3308. return true;
  3309. }
  3310. };
  3311. setproto.animate = function (params, ms, easing, callback) {
  3312. (R.is(easing, "function") || !easing) && (callback = easing || null);
  3313. var len = this.items.length,
  3314. i = len,
  3315. item,
  3316. set = this,
  3317. collector;
  3318. if (!len) {
  3319. return this;
  3320. }
  3321. callback && (collector = function () {
  3322. !--len && callback.call(set);
  3323. });
  3324. easing = R.is(easing, string) ? easing : collector;
  3325. var anim = R.animation(params, ms, easing, collector);
  3326. item = this.items[--i].animate(anim);
  3327. while (i--) {
  3328. this.items[i] && !this.items[i].removed && this.items[i].animateWith(item, anim, anim);
  3329. }
  3330. return this;
  3331. };
  3332. setproto.insertAfter = function (el) {
  3333. var i = this.items.length;
  3334. while (i--) {
  3335. this.items[i].insertAfter(el);
  3336. }
  3337. return this;
  3338. };
  3339. setproto.getBBox = function () {
  3340. var x = [],
  3341. y = [],
  3342. x2 = [],
  3343. y2 = [];
  3344. for (var i = this.items.length; i--;) if (!this.items[i].removed) {
  3345. var box = this.items[i].getBBox();
  3346. x.push(box.x);
  3347. y.push(box.y);
  3348. x2.push(box.x + box.width);
  3349. y2.push(box.y + box.height);
  3350. }
  3351. x = mmin[apply](0, x);
  3352. y = mmin[apply](0, y);
  3353. x2 = mmax[apply](0, x2);
  3354. y2 = mmax[apply](0, y2);
  3355. return {
  3356. x: x,
  3357. y: y,
  3358. x2: x2,
  3359. y2: y2,
  3360. width: x2 - x,
  3361. height: y2 - y
  3362. };
  3363. };
  3364. setproto.clone = function (s) {
  3365. s = new Set;
  3366. for (var i = 0, ii = this.items.length; i < ii; i++) {
  3367. s.push(this.items[i].clone());
  3368. }
  3369. return s;
  3370. };
  3371. setproto.toString = function () {
  3372. return "Rapha\xebl\u2018s set";
  3373. };
  3374. R.registerFont = function (font) {
  3375. if (!font.face) {
  3376. return font;
  3377. }
  3378. this.fonts = this.fonts || {};
  3379. var fontcopy = {
  3380. w: font.w,
  3381. face: {},
  3382. glyphs: {}
  3383. },
  3384. family = font.face["font-family"];
  3385. for (var prop in font.face) if (font.face[has](prop)) {
  3386. fontcopy.face[prop] = font.face[prop];
  3387. }
  3388. if (this.fonts[family]) {
  3389. this.fonts[family].push(fontcopy);
  3390. } else {
  3391. this.fonts[family] = [fontcopy];
  3392. }
  3393. if (!font.svg) {
  3394. fontcopy.face["units-per-em"] = toInt(font.face["units-per-em"], 10);
  3395. for (var glyph in font.glyphs) if (font.glyphs[has](glyph)) {
  3396. var path = font.glyphs[glyph];
  3397. fontcopy.glyphs[glyph] = {
  3398. w: path.w,
  3399. k: {},
  3400. d: path.d && "M" + path.d.replace(/[mlcxtrv]/g, function (command) {
  3401. return {l: "L", c: "C", x: "z", t: "m", r: "l", v: "c"}[command] || "M";
  3402. }) + "z"
  3403. };
  3404. if (path.k) {
  3405. for (var k in path.k) if (path[has](k)) {
  3406. fontcopy.glyphs[glyph].k[k] = path.k[k];
  3407. }
  3408. }
  3409. }
  3410. }
  3411. return font;
  3412. };
  3413. paperproto.getFont = function (family, weight, style, stretch) {
  3414. stretch = stretch || "normal";
  3415. style = style || "normal";
  3416. weight = +weight || {normal: 400, bold: 700, lighter: 300, bolder: 800}[weight] || 400;
  3417. if (!R.fonts) {
  3418. return;
  3419. }
  3420. var font = R.fonts[family];
  3421. if (!font) {
  3422. var name = new RegExp("(^|\\s)" + family.replace(/[^\w\d\s+!~.:_-]/g, E) + "(\\s|$)", "i");
  3423. for (var fontName in R.fonts) if (R.fonts[has](fontName)) {
  3424. if (name.test(fontName)) {
  3425. font = R.fonts[fontName];
  3426. break;
  3427. }
  3428. }
  3429. }
  3430. var thefont;
  3431. if (font) {
  3432. for (var i = 0, ii = font.length; i < ii; i++) {
  3433. thefont = font[i];
  3434. if (thefont.face["font-weight"] == weight && (thefont.face["font-style"] == style || !thefont.face["font-style"]) && thefont.face["font-stretch"] == stretch) {
  3435. break;
  3436. }
  3437. }
  3438. }
  3439. return thefont;
  3440. };
  3441. paperproto.print = function (x, y, string, font, size, origin, letter_spacing) {
  3442. origin = origin || "middle"; // baseline|middle
  3443. letter_spacing = mmax(mmin(letter_spacing || 0, 1), -1);
  3444. var letters = Str(string)[split](E),
  3445. shift = 0,
  3446. notfirst = 0,
  3447. path = E,
  3448. scale;
  3449. R.is(font, string) && (font = this.getFont(font));
  3450. if (font) {
  3451. scale = (size || 16) / font.face["units-per-em"];
  3452. var bb = font.face.bbox[split](separator),
  3453. top = +bb[0],
  3454. lineHeight = bb[3] - bb[1],
  3455. shifty = 0,
  3456. height = +bb[1] + (origin == "baseline" ? lineHeight + (+font.face.descent) : lineHeight / 2);
  3457. for (var i = 0, ii = letters.length; i < ii; i++) {
  3458. if (letters[i] == "\n") {
  3459. shift = 0;
  3460. curr = 0;
  3461. notfirst = 0;
  3462. shifty += lineHeight;
  3463. } else {
  3464. var prev = notfirst && font.glyphs[letters[i - 1]] || {},
  3465. curr = font.glyphs[letters[i]];
  3466. shift += notfirst ? (prev.w || font.w) + (prev.k && prev.k[letters[i]] || 0) + (font.w * letter_spacing) : 0;
  3467. notfirst = 1;
  3468. }
  3469. if (curr && curr.d) {
  3470. path += R.transformPath(curr.d, ["t", shift * scale, shifty * scale, "s", scale, scale, top, height, "t", (x - top) / scale, (y - height) / scale]);
  3471. }
  3472. }
  3473. }
  3474. return this.path(path).attr({
  3475. fill: "#000",
  3476. stroke: "none"
  3477. });
  3478. };
  3479. paperproto.add = function (json) {
  3480. if (R.is(json, "array")) {
  3481. var res = this.set(),
  3482. i = 0,
  3483. ii = json.length,
  3484. j;
  3485. for (; i < ii; i++) {
  3486. j = json[i] || {};
  3487. elements[has](j.type) && res.push(this[j.type]().attr(j));
  3488. }
  3489. }
  3490. return res;
  3491. };
  3492. R.format = function (token, params) {
  3493. var args = R.is(params, array) ? [0][concat](params) : arguments;
  3494. token && R.is(token, string) && args.length - 1 && (token = token.replace(formatrg, function (str, i) {
  3495. return args[++i] == null ? E : args[i];
  3496. }));
  3497. return token || E;
  3498. };
  3499. R.fullfill = (function () {
  3500. var tokenRegex = /\{([^\}]+)\}/g,
  3501. objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g, // matches .xxxxx or ["xxxxx"] to run over object properties
  3502. replacer = function (all, key, obj) {
  3503. var res = obj;
  3504. key.replace(objNotationRegex, function (all, name, quote, quotedName, isFunc) {
  3505. name = name || quotedName;
  3506. if (res) {
  3507. if (name in res) {
  3508. res = res[name];
  3509. }
  3510. typeof res == "function" && isFunc && (res = res());
  3511. }
  3512. });
  3513. res = (res == null || res == obj ? all : res) + "";
  3514. return res;
  3515. };
  3516. return function (str, obj) {
  3517. return String(str).replace(tokenRegex, function (all, key) {
  3518. return replacer(all, key, obj);
  3519. });
  3520. };
  3521. })();
  3522. R.ninja = function () {
  3523. oldRaphael.was ? (g.win.Raphael = oldRaphael.is) : delete Raphael;
  3524. return R;
  3525. };
  3526. R.st = setproto;
  3527. // Firefox <3.6 fix: http://webreflection.blogspot.com/2009/11/195-chars-to-help-lazy-loading.html
  3528. (function (doc, loaded, f) {
  3529. if (doc.readyState == null && doc.addEventListener){
  3530. doc.addEventListener(loaded, f = function () {
  3531. doc.removeEventListener(loaded, f, false);
  3532. doc.readyState = "complete";
  3533. }, false);
  3534. doc.readyState = "loading";
  3535. }
  3536. function isLoaded() {
  3537. (/in/).test(doc.readyState) ? setTimeout(isLoaded, 9) : R.eve("raphael.DOMload");
  3538. }
  3539. isLoaded();
  3540. })(document, "DOMContentLoaded");
  3541. oldRaphael.was ? (g.win.Raphael = R) : (Raphael = R);
  3542. eve.on("raphael.DOMload", function () {
  3543. loaded = true;
  3544. });
  3545. })();
  3546. // ┌─────────────────────────────────────────────────────────────────────┐ \\
  3547. // │ Raphaël - JavaScript Vector Library │ \\
  3548. // ├─────────────────────────────────────────────────────────────────────┤ \\
  3549. // │ SVG Module │ \\
  3550. // ├─────────────────────────────────────────────────────────────────────┤ \\
  3551. // │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\
  3552. // │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\
  3553. // │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\
  3554. // └─────────────────────────────────────────────────────────────────────┘ \\
  3555. window.Raphael.svg && function (R) {
  3556. var has = "hasOwnProperty",
  3557. Str = String,
  3558. toFloat = parseFloat,
  3559. toInt = parseInt,
  3560. math = Math,
  3561. mmax = math.max,
  3562. abs = math.abs,
  3563. pow = math.pow,
  3564. separator = /[, ]+/,
  3565. eve = R.eve,
  3566. E = "",
  3567. S = " ";
  3568. var xlink = "http://www.w3.org/1999/xlink",
  3569. markers = {
  3570. block: "M5,0 0,2.5 5,5z",
  3571. classic: "M5,0 0,2.5 5,5 3.5,3 3.5,2z",
  3572. diamond: "M2.5,0 5,2.5 2.5,5 0,2.5z",
  3573. open: "M6,1 1,3.5 6,6",
  3574. oval: "M2.5,0A2.5,2.5,0,0,1,2.5,5 2.5,2.5,0,0,1,2.5,0z"
  3575. },
  3576. markerCounter = {};
  3577. R.toString = function () {
  3578. return "Your browser supports SVG.\nYou are running Rapha\xebl " + this.version;
  3579. };
  3580. var $ = function (el, attr) {
  3581. if (attr) {
  3582. if (typeof el == "string") {
  3583. el = $(el);
  3584. }
  3585. for (var key in attr) if (attr[has](key)) {
  3586. if (key.substring(0, 6) == "xlink:") {
  3587. el.setAttributeNS(xlink, key.substring(6), Str(attr[key]));
  3588. } else {
  3589. el.setAttribute(key, Str(attr[key]));
  3590. }
  3591. }
  3592. } else {
  3593. el = R._g.doc.createElementNS("http://www.w3.org/2000/svg", el);
  3594. el.style && (el.style.webkitTapHighlightColor = "rgba(0,0,0,0)");
  3595. }
  3596. return el;
  3597. },
  3598. addGradientFill = function (element, gradient) {
  3599. var type = "linear",
  3600. id = element.id + gradient,
  3601. fx = .5, fy = .5,
  3602. o = element.node,
  3603. SVG = element.paper,
  3604. s = o.style,
  3605. el = R._g.doc.getElementById(id);
  3606. if (!el) {
  3607. gradient = Str(gradient).replace(R._radial_gradient, function (all, _fx, _fy) {
  3608. type = "radial";
  3609. if (_fx && _fy) {
  3610. fx = toFloat(_fx);
  3611. fy = toFloat(_fy);
  3612. var dir = ((fy > .5) * 2 - 1);
  3613. pow(fx - .5, 2) + pow(fy - .5, 2) > .25 &&
  3614. (fy = math.sqrt(.25 - pow(fx - .5, 2)) * dir + .5) &&
  3615. fy != .5 &&
  3616. (fy = fy.toFixed(5) - 1e-5 * dir);
  3617. }
  3618. return E;
  3619. });
  3620. gradient = gradient.split(/\s*\-\s*/);
  3621. if (type == "linear") {
  3622. var angle = gradient.shift();
  3623. angle = -toFloat(angle);
  3624. if (isNaN(angle)) {
  3625. return null;
  3626. }
  3627. var vector = [0, 0, math.cos(R.rad(angle)), math.sin(R.rad(angle))],
  3628. max = 1 / (mmax(abs(vector[2]), abs(vector[3])) || 1);
  3629. vector[2] *= max;
  3630. vector[3] *= max;
  3631. if (vector[2] < 0) {
  3632. vector[0] = -vector[2];
  3633. vector[2] = 0;
  3634. }
  3635. if (vector[3] < 0) {
  3636. vector[1] = -vector[3];
  3637. vector[3] = 0;
  3638. }
  3639. }
  3640. var dots = R._parseDots(gradient);
  3641. if (!dots) {
  3642. return null;
  3643. }
  3644. id = id.replace(/[\(\)\s,\xb0#]/g, "_");
  3645. if (element.gradient && id != element.gradient.id) {
  3646. SVG.defs.removeChild(element.gradient);
  3647. delete element.gradient;
  3648. }
  3649. if (!element.gradient) {
  3650. el = $(type + "Gradient", {id: id});
  3651. element.gradient = el;
  3652. $(el, type == "radial" ? {
  3653. fx: fx,
  3654. fy: fy
  3655. } : {
  3656. x1: vector[0],
  3657. y1: vector[1],
  3658. x2: vector[2],
  3659. y2: vector[3],
  3660. gradientTransform: element.matrix.invert()
  3661. });
  3662. SVG.defs.appendChild(el);
  3663. for (var i = 0, ii = dots.length; i < ii; i++) {
  3664. el.appendChild($("stop", {
  3665. offset: dots[i].offset ? dots[i].offset : i ? "100%" : "0%",
  3666. "stop-color": dots[i].color || "#fff"
  3667. }));
  3668. }
  3669. }
  3670. }
  3671. $(o, {
  3672. fill: "url(#" + id + ")",
  3673. opacity: 1,
  3674. "fill-opacity": 1
  3675. });
  3676. s.fill = E;
  3677. s.opacity = 1;
  3678. s.fillOpacity = 1;
  3679. return 1;
  3680. },
  3681. updatePosition = function (o) {
  3682. var bbox = o.getBBox(1);
  3683. $(o.pattern, {patternTransform: o.matrix.invert() + " translate(" + bbox.x + "," + bbox.y + ")"});
  3684. },
  3685. addArrow = function (o, value, isEnd) {
  3686. if (o.type == "path") {
  3687. var values = Str(value).toLowerCase().split("-"),
  3688. p = o.paper,
  3689. se = isEnd ? "end" : "start",
  3690. node = o.node,
  3691. attrs = o.attrs,
  3692. stroke = attrs["stroke-width"],
  3693. i = values.length,
  3694. type = "classic",
  3695. from,
  3696. to,
  3697. dx,
  3698. refX,
  3699. attr,
  3700. w = 3,
  3701. h = 3,
  3702. t = 5;
  3703. while (i--) {
  3704. switch (values[i]) {
  3705. case "block":
  3706. case "classic":
  3707. case "oval":
  3708. case "diamond":
  3709. case "open":
  3710. case "none":
  3711. type = values[i];
  3712. break;
  3713. case "wide": h = 5; break;
  3714. case "narrow": h = 2; break;
  3715. case "long": w = 5; break;
  3716. case "short": w = 2; break;
  3717. }
  3718. }
  3719. if (type == "open") {
  3720. w += 2;
  3721. h += 2;
  3722. t += 2;
  3723. dx = 1;
  3724. refX = isEnd ? 4 : 1;
  3725. attr = {
  3726. fill: "none",
  3727. stroke: attrs.stroke
  3728. };
  3729. } else {
  3730. refX = dx = w / 2;
  3731. attr = {
  3732. fill: attrs.stroke,
  3733. stroke: "none"
  3734. };
  3735. }
  3736. if (o._.arrows) {
  3737. if (isEnd) {
  3738. o._.arrows.endPath && markerCounter[o._.arrows.endPath]--;
  3739. o._.arrows.endMarker && markerCounter[o._.arrows.endMarker]--;
  3740. } else {
  3741. o._.arrows.startPath && markerCounter[o._.arrows.startPath]--;
  3742. o._.arrows.startMarker && markerCounter[o._.arrows.startMarker]--;
  3743. }
  3744. } else {
  3745. o._.arrows = {};
  3746. }
  3747. if (type != "none") {
  3748. var pathId = "raphael-marker-" + type,
  3749. markerId = "raphael-marker-" + se + type + w + h;
  3750. if (!R._g.doc.getElementById(pathId)) {
  3751. p.defs.appendChild($($("path"), {
  3752. "stroke-linecap": "round",
  3753. d: markers[type],
  3754. id: pathId
  3755. }));
  3756. markerCounter[pathId] = 1;
  3757. } else {
  3758. markerCounter[pathId]++;
  3759. }
  3760. var marker = R._g.doc.getElementById(markerId),
  3761. use;
  3762. if (!marker) {
  3763. marker = $($("marker"), {
  3764. id: markerId,
  3765. markerHeight: h,
  3766. markerWidth: w,
  3767. orient: "auto",
  3768. refX: refX,
  3769. refY: h / 2
  3770. });
  3771. use = $($("use"), {
  3772. "xlink:href": "#" + pathId,
  3773. transform: (isEnd ? "rotate(180 " + w / 2 + " " + h / 2 + ") " : E) + "scale(" + w / t + "," + h / t + ")",
  3774. "stroke-width": (1 / ((w / t + h / t) / 2)).toFixed(4)
  3775. });
  3776. marker.appendChild(use);
  3777. p.defs.appendChild(marker);
  3778. markerCounter[markerId] = 1;
  3779. } else {
  3780. markerCounter[markerId]++;
  3781. use = marker.getElementsByTagName("use")[0];
  3782. }
  3783. $(use, attr);
  3784. var delta = dx * (type != "diamond" && type != "oval");
  3785. if (isEnd) {
  3786. from = o._.arrows.startdx * stroke || 0;
  3787. to = R.getTotalLength(attrs.path) - delta * stroke;
  3788. } else {
  3789. from = delta * stroke;
  3790. to = R.getTotalLength(attrs.path) - (o._.arrows.enddx * stroke || 0);
  3791. }
  3792. attr = {};
  3793. attr["marker-" + se] = "url(#" + markerId + ")";
  3794. if (to || from) {
  3795. attr.d = Raphael.getSubpath(attrs.path, from, to);
  3796. }
  3797. $(node, attr);
  3798. o._.arrows[se + "Path"] = pathId;
  3799. o._.arrows[se + "Marker"] = markerId;
  3800. o._.arrows[se + "dx"] = delta;
  3801. o._.arrows[se + "Type"] = type;
  3802. o._.arrows[se + "String"] = value;
  3803. } else {
  3804. if (isEnd) {
  3805. from = o._.arrows.startdx * stroke || 0;
  3806. to = R.getTotalLength(attrs.path) - from;
  3807. } else {
  3808. from = 0;
  3809. to = R.getTotalLength(attrs.path) - (o._.arrows.enddx * stroke || 0);
  3810. }
  3811. o._.arrows[se + "Path"] && $(node, {d: Raphael.getSubpath(attrs.path, from, to)});
  3812. delete o._.arrows[se + "Path"];
  3813. delete o._.arrows[se + "Marker"];
  3814. delete o._.arrows[se + "dx"];
  3815. delete o._.arrows[se + "Type"];
  3816. delete o._.arrows[se + "String"];
  3817. }
  3818. for (attr in markerCounter) if (markerCounter[has](attr) && !markerCounter[attr]) {
  3819. var item = R._g.doc.getElementById(attr);
  3820. item && item.parentNode.removeChild(item);
  3821. }
  3822. }
  3823. },
  3824. dasharray = {
  3825. "": [0],
  3826. "none": [0],
  3827. "-": [3, 1],
  3828. ".": [1, 1],
  3829. "-.": [3, 1, 1, 1],
  3830. "-..": [3, 1, 1, 1, 1, 1],
  3831. ". ": [1, 3],
  3832. "- ": [4, 3],
  3833. "--": [8, 3],
  3834. "- .": [4, 3, 1, 3],
  3835. "--.": [8, 3, 1, 3],
  3836. "--..": [8, 3, 1, 3, 1, 3]
  3837. },
  3838. addDashes = function (o, value, params) {
  3839. value = dasharray[Str(value).toLowerCase()];
  3840. if (value) {
  3841. var width = o.attrs["stroke-width"] || "1",
  3842. butt = {round: width, square: width, butt: 0}[o.attrs["stroke-linecap"] || params["stroke-linecap"]] || 0,
  3843. dashes = [],
  3844. i = value.length;
  3845. while (i--) {
  3846. dashes[i] = value[i] * width + ((i % 2) ? 1 : -1) * butt;
  3847. }
  3848. $(o.node, {"stroke-dasharray": dashes.join(",")});
  3849. }
  3850. },
  3851. setFillAndStroke = function (o, params) {
  3852. var node = o.node,
  3853. attrs = o.attrs,
  3854. vis = node.style.visibility;
  3855. node.style.visibility = "hidden";
  3856. for (var att in params) {
  3857. if (params[has](att)) {
  3858. if (!R._availableAttrs[has](att)) {
  3859. continue;
  3860. }
  3861. var value = params[att];
  3862. attrs[att] = value;
  3863. switch (att) {
  3864. case "blur":
  3865. o.blur(value);
  3866. break;
  3867. case "href":
  3868. case "title":
  3869. case "target":
  3870. var pn = node.parentNode;
  3871. if (pn.tagName.toLowerCase() != "a") {
  3872. var hl = $("a");
  3873. pn.insertBefore(hl, node);
  3874. hl.appendChild(node);
  3875. pn = hl;
  3876. }
  3877. if (att == "target") {
  3878. pn.setAttributeNS(xlink, "show", value == "blank" ? "new" : value);
  3879. } else {
  3880. pn.setAttributeNS(xlink, att, value);
  3881. }
  3882. break;
  3883. case "cursor":
  3884. node.style.cursor = value;
  3885. break;
  3886. case "transform":
  3887. o.transform(value);
  3888. break;
  3889. case "arrow-start":
  3890. addArrow(o, value);
  3891. break;
  3892. case "arrow-end":
  3893. addArrow(o, value, 1);
  3894. break;
  3895. case "clip-rect":
  3896. var rect = Str(value).split(separator);
  3897. if (rect.length == 4) {
  3898. o.clip && o.clip.parentNode.parentNode.removeChild(o.clip.parentNode);
  3899. var el = $("clipPath"),
  3900. rc = $("rect");
  3901. el.id = R.createUUID();
  3902. $(rc, {
  3903. x: rect[0],
  3904. y: rect[1],
  3905. width: rect[2],
  3906. height: rect[3]
  3907. });
  3908. el.appendChild(rc);
  3909. o.paper.defs.appendChild(el);
  3910. $(node, {"clip-path": "url(#" + el.id + ")"});
  3911. o.clip = rc;
  3912. }
  3913. if (!value) {
  3914. var path = node.getAttribute("clip-path");
  3915. if (path) {
  3916. var clip = R._g.doc.getElementById(path.replace(/(^url\(#|\)$)/g, E));
  3917. clip && clip.parentNode.removeChild(clip);
  3918. $(node, {"clip-path": E});
  3919. delete o.clip;
  3920. }
  3921. }
  3922. break;
  3923. case "path":
  3924. if (o.type == "path") {
  3925. $(node, {d: value ? attrs.path = R._pathToAbsolute(value) : "M0,0"});
  3926. o._.dirty = 1;
  3927. if (o._.arrows) {
  3928. "startString" in o._.arrows && addArrow(o, o._.arrows.startString);
  3929. "endString" in o._.arrows && addArrow(o, o._.arrows.endString, 1);
  3930. }
  3931. }
  3932. break;
  3933. case "width":
  3934. node.setAttribute(att, value);
  3935. o._.dirty = 1;
  3936. if (attrs.fx) {
  3937. att = "x";
  3938. value = attrs.x;
  3939. } else {
  3940. break;
  3941. }
  3942. case "x":
  3943. if (attrs.fx) {
  3944. value = -attrs.x - (attrs.width || 0);
  3945. }
  3946. case "rx":
  3947. if (att == "rx" && o.type == "rect") {
  3948. break;
  3949. }
  3950. case "cx":
  3951. node.setAttribute(att, value);
  3952. o.pattern && updatePosition(o);
  3953. o._.dirty = 1;
  3954. break;
  3955. case "height":
  3956. node.setAttribute(att, value);
  3957. o._.dirty = 1;
  3958. if (attrs.fy) {
  3959. att = "y";
  3960. value = attrs.y;
  3961. } else {
  3962. break;
  3963. }
  3964. case "y":
  3965. if (attrs.fy) {
  3966. value = -attrs.y - (attrs.height || 0);
  3967. }
  3968. case "ry":
  3969. if (att == "ry" && o.type == "rect") {
  3970. break;
  3971. }
  3972. case "cy":
  3973. node.setAttribute(att, value);
  3974. o.pattern && updatePosition(o);
  3975. o._.dirty = 1;
  3976. break;
  3977. case "r":
  3978. if (o.type == "rect") {
  3979. $(node, {rx: value, ry: value});
  3980. } else {
  3981. node.setAttribute(att, value);
  3982. }
  3983. o._.dirty = 1;
  3984. break;
  3985. case "src":
  3986. if (o.type == "image") {
  3987. node.setAttributeNS(xlink, "href", value);
  3988. }
  3989. break;
  3990. case "stroke-width":
  3991. if (o._.sx != 1 || o._.sy != 1) {
  3992. value /= mmax(abs(o._.sx), abs(o._.sy)) || 1;
  3993. }
  3994. if (o.paper._vbSize) {
  3995. value *= o.paper._vbSize;
  3996. }
  3997. node.setAttribute(att, value);
  3998. if (attrs["stroke-dasharray"]) {
  3999. addDashes(o, attrs["stroke-dasharray"], params);
  4000. }
  4001. if (o._.arrows) {
  4002. "startString" in o._.arrows && addArrow(o, o._.arrows.startString);
  4003. "endString" in o._.arrows && addArrow(o, o._.arrows.endString, 1);
  4004. }
  4005. break;
  4006. case "stroke-dasharray":
  4007. addDashes(o, value, params);
  4008. break;
  4009. case "fill":
  4010. var isURL = Str(value).match(R._ISURL);
  4011. if (isURL) {
  4012. el = $("pattern");
  4013. var ig = $("image");
  4014. el.id = R.createUUID();
  4015. $(el, {x: 0, y: 0, patternUnits: "userSpaceOnUse", height: 1, width: 1});
  4016. $(ig, {x: 0, y: 0, "xlink:href": isURL[1]});
  4017. el.appendChild(ig);
  4018. (function (el) {
  4019. R._preload(isURL[1], function () {
  4020. var w = this.offsetWidth,
  4021. h = this.offsetHeight;
  4022. $(el, {width: w, height: h});
  4023. $(ig, {width: w, height: h});
  4024. o.paper.safari();
  4025. });
  4026. })(el);
  4027. o.paper.defs.appendChild(el);
  4028. $(node, {fill: "url(#" + el.id + ")"});
  4029. o.pattern = el;
  4030. o.pattern && updatePosition(o);
  4031. break;
  4032. }
  4033. var clr = R.getRGB(value);
  4034. if (!clr.error) {
  4035. delete params.gradient;
  4036. delete attrs.gradient;
  4037. !R.is(attrs.opacity, "undefined") &&
  4038. R.is(params.opacity, "undefined") &&
  4039. $(node, {opacity: attrs.opacity});
  4040. !R.is(attrs["fill-opacity"], "undefined") &&
  4041. R.is(params["fill-opacity"], "undefined") &&
  4042. $(node, {"fill-opacity": attrs["fill-opacity"]});
  4043. } else if ((o.type == "circle" || o.type == "ellipse" || Str(value).charAt() != "r") && addGradientFill(o, value)) {
  4044. if ("opacity" in attrs || "fill-opacity" in attrs) {
  4045. var gradient = R._g.doc.getElementById(node.getAttribute("fill").replace(/^url\(#|\)$/g, E));
  4046. if (gradient) {
  4047. var stops = gradient.getElementsByTagName("stop");
  4048. $(stops[stops.length - 1], {"stop-opacity": ("opacity" in attrs ? attrs.opacity : 1) * ("fill-opacity" in attrs ? attrs["fill-opacity"] : 1)});
  4049. }
  4050. }
  4051. attrs.gradient = value;
  4052. attrs.fill = "none";
  4053. break;
  4054. }
  4055. clr[has]("opacity") && $(node, {"fill-opacity": clr.opacity > 1 ? clr.opacity / 100 : clr.opacity});
  4056. case "stroke":
  4057. clr = R.getRGB(value);
  4058. node.setAttribute(att, clr.hex);
  4059. att == "stroke" && clr[has]("opacity") && $(node, {"stroke-opacity": clr.opacity > 1 ? clr.opacity / 100 : clr.opacity});
  4060. if (att == "stroke" && o._.arrows) {
  4061. "startString" in o._.arrows && addArrow(o, o._.arrows.startString);
  4062. "endString" in o._.arrows && addArrow(o, o._.arrows.endString, 1);
  4063. }
  4064. break;
  4065. case "gradient":
  4066. (o.type == "circle" || o.type == "ellipse" || Str(value).charAt() != "r") && addGradientFill(o, value);
  4067. break;
  4068. case "opacity":
  4069. if (attrs.gradient && !attrs[has]("stroke-opacity")) {
  4070. $(node, {"stroke-opacity": value > 1 ? value / 100 : value});
  4071. }
  4072. // fall
  4073. case "fill-opacity":
  4074. if (attrs.gradient) {
  4075. gradient = R._g.doc.getElementById(node.getAttribute("fill").replace(/^url\(#|\)$/g, E));
  4076. if (gradient) {
  4077. stops = gradient.getElementsByTagName("stop");
  4078. $(stops[stops.length - 1], {"stop-opacity": value});
  4079. }
  4080. break;
  4081. }
  4082. default:
  4083. att == "font-size" && (value = toInt(value, 10) + "px");
  4084. var cssrule = att.replace(/(\-.)/g, function (w) {
  4085. return w.substring(1).toUpperCase();
  4086. });
  4087. node.style[cssrule] = value;
  4088. o._.dirty = 1;
  4089. node.setAttribute(att, value);
  4090. break;
  4091. }
  4092. }
  4093. }
  4094. tuneText(o, params);
  4095. node.style.visibility = vis;
  4096. },
  4097. leading = 1.2,
  4098. tuneText = function (el, params) {
  4099. if (el.type != "text" || !(params[has]("text") || params[has]("font") || params[has]("font-size") || params[has]("x") || params[has]("y"))) {
  4100. return;
  4101. }
  4102. var a = el.attrs,
  4103. node = el.node,
  4104. fontSize = node.firstChild ? toInt(R._g.doc.defaultView.getComputedStyle(node.firstChild, E).getPropertyValue("font-size"), 10) : 10;
  4105. if (params[has]("text")) {
  4106. a.text = params.text;
  4107. while (node.firstChild) {
  4108. node.removeChild(node.firstChild);
  4109. }
  4110. var texts = Str(params.text).split("\n"),
  4111. tspans = [],
  4112. tspan;
  4113. for (var i = 0, ii = texts.length; i < ii; i++) {
  4114. tspan = $("tspan");
  4115. i && $(tspan, {dy: fontSize * leading, x: a.x});
  4116. tspan.appendChild(R._g.doc.createTextNode(texts[i]));
  4117. node.appendChild(tspan);
  4118. tspans[i] = tspan;
  4119. }
  4120. } else {
  4121. tspans = node.getElementsByTagName("tspan");
  4122. for (i = 0, ii = tspans.length; i < ii; i++) if (i) {
  4123. $(tspans[i], {dy: fontSize * leading, x: a.x});
  4124. } else {
  4125. $(tspans[0], {dy: 0});
  4126. }
  4127. }
  4128. $(node, {x: a.x, y: a.y});
  4129. el._.dirty = 1;
  4130. var bb = el._getBBox(),
  4131. dif = a.y - (bb.y + bb.height / 2);
  4132. dif && R.is(dif, "finite") && $(tspans[0], {dy: dif});
  4133. },
  4134. Element = function (node, svg) {
  4135. var X = 0,
  4136. Y = 0;
  4137. this[0] = this.node = node;
  4138. node.raphael = true;
  4139. this.id = R._oid++;
  4140. node.raphaelid = this.id;
  4141. this.matrix = R.matrix();
  4142. this.realPath = null;
  4143. this.paper = svg;
  4144. this.attrs = this.attrs || {};
  4145. this._ = {
  4146. transform: [],
  4147. sx: 1,
  4148. sy: 1,
  4149. deg: 0,
  4150. dx: 0,
  4151. dy: 0,
  4152. dirty: 1
  4153. };
  4154. !svg.bottom && (svg.bottom = this);
  4155. this.prev = svg.top;
  4156. svg.top && (svg.top.next = this);
  4157. svg.top = this;
  4158. this.next = null;
  4159. },
  4160. elproto = R.el;
  4161. Element.prototype = elproto;
  4162. elproto.constructor = Element;
  4163. R._engine.path = function (pathString, SVG) {
  4164. var el = $("path");
  4165. SVG.canvas && SVG.canvas.appendChild(el);
  4166. var p = new Element(el, SVG);
  4167. p.type = "path";
  4168. setFillAndStroke(p, {
  4169. fill: "none",
  4170. stroke: "#000",
  4171. path: pathString
  4172. });
  4173. return p;
  4174. };
  4175. elproto.rotate = function (deg, cx, cy) {
  4176. if (this.removed) {
  4177. return this;
  4178. }
  4179. deg = Str(deg).split(separator);
  4180. if (deg.length - 1) {
  4181. cx = toFloat(deg[1]);
  4182. cy = toFloat(deg[2]);
  4183. }
  4184. deg = toFloat(deg[0]);
  4185. (cy == null) && (cx = cy);
  4186. if (cx == null || cy == null) {
  4187. var bbox = this.getBBox(1);
  4188. cx = bbox.x + bbox.width / 2;
  4189. cy = bbox.y + bbox.height / 2;
  4190. }
  4191. this.transform(this._.transform.concat([["r", deg, cx, cy]]));
  4192. return this;
  4193. };
  4194. elproto.scale = function (sx, sy, cx, cy) {
  4195. if (this.removed) {
  4196. return this;
  4197. }
  4198. sx = Str(sx).split(separator);
  4199. if (sx.length - 1) {
  4200. sy = toFloat(sx[1]);
  4201. cx = toFloat(sx[2]);
  4202. cy = toFloat(sx[3]);
  4203. }
  4204. sx = toFloat(sx[0]);
  4205. (sy == null) && (sy = sx);
  4206. (cy == null) && (cx = cy);
  4207. if (cx == null || cy == null) {
  4208. var bbox = this.getBBox(1);
  4209. }
  4210. cx = cx == null ? bbox.x + bbox.width / 2 : cx;
  4211. cy = cy == null ? bbox.y + bbox.height / 2 : cy;
  4212. this.transform(this._.transform.concat([["s", sx, sy, cx, cy]]));
  4213. return this;
  4214. };
  4215. elproto.translate = function (dx, dy) {
  4216. if (this.removed) {
  4217. return this;
  4218. }
  4219. dx = Str(dx).split(separator);
  4220. if (dx.length - 1) {
  4221. dy = toFloat(dx[1]);
  4222. }
  4223. dx = toFloat(dx[0]) || 0;
  4224. dy = +dy || 0;
  4225. this.transform(this._.transform.concat([["t", dx, dy]]));
  4226. return this;
  4227. };
  4228. elproto.transform = function (tstr) {
  4229. var _ = this._;
  4230. if (tstr == null) {
  4231. return _.transform;
  4232. }
  4233. R._extractTransform(this, tstr);
  4234. this.clip && $(this.clip, {transform: this.matrix.invert()});
  4235. this.pattern && updatePosition(this);
  4236. this.node && $(this.node, {transform: this.matrix});
  4237. if (_.sx != 1 || _.sy != 1) {
  4238. var sw = this.attrs[has]("stroke-width") ? this.attrs["stroke-width"] : 1;
  4239. this.attr({"stroke-width": sw});
  4240. }
  4241. return this;
  4242. };
  4243. elproto.hide = function () {
  4244. !this.removed && this.paper.safari(this.node.style.display = "none");
  4245. return this;
  4246. };
  4247. elproto.show = function () {
  4248. !this.removed && this.paper.safari(this.node.style.display = "");
  4249. return this;
  4250. };
  4251. elproto.remove = function () {
  4252. if (this.removed || !this.node.parentNode) {
  4253. return;
  4254. }
  4255. var paper = this.paper;
  4256. paper.__set__ && paper.__set__.exclude(this);
  4257. eve.unbind("raphael.*.*." + this.id);
  4258. if (this.gradient) {
  4259. paper.defs.removeChild(this.gradient);
  4260. }
  4261. R._tear(this, paper);
  4262. if (this.node.parentNode.tagName.toLowerCase() == "a") {
  4263. this.node.parentNode.parentNode.removeChild(this.node.parentNode);
  4264. } else {
  4265. this.node.parentNode.removeChild(this.node);
  4266. }
  4267. for (var i in this) {
  4268. this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;
  4269. }
  4270. this.removed = true;
  4271. };
  4272. elproto._getBBox = function () {
  4273. if (this.node.style.display == "none") {
  4274. this.show();
  4275. var hide = true;
  4276. }
  4277. var bbox = {};
  4278. try {
  4279. bbox = this.node.getBBox();
  4280. } catch(e) {
  4281. // Firefox 3.0.x plays badly here
  4282. } finally {
  4283. bbox = bbox || {};
  4284. }
  4285. hide && this.hide();
  4286. return bbox;
  4287. };
  4288. elproto.attr = function (name, value) {
  4289. if (this.removed) {
  4290. return this;
  4291. }
  4292. if (name == null) {
  4293. var res = {};
  4294. for (var a in this.attrs) if (this.attrs[has](a)) {
  4295. res[a] = this.attrs[a];
  4296. }
  4297. res.gradient && res.fill == "none" && (res.fill = res.gradient) && delete res.gradient;
  4298. res.transform = this._.transform;
  4299. return res;
  4300. }
  4301. if (value == null && R.is(name, "string")) {
  4302. if (name == "fill" && this.attrs.fill == "none" && this.attrs.gradient) {
  4303. return this.attrs.gradient;
  4304. }
  4305. if (name == "transform") {
  4306. return this._.transform;
  4307. }
  4308. var names = name.split(separator),
  4309. out = {};
  4310. for (var i = 0, ii = names.length; i < ii; i++) {
  4311. name = names[i];
  4312. if (name in this.attrs) {
  4313. out[name] = this.attrs[name];
  4314. } else if (R.is(this.paper.customAttributes[name], "function")) {
  4315. out[name] = this.paper.customAttributes[name].def;
  4316. } else {
  4317. out[name] = R._availableAttrs[name];
  4318. }
  4319. }
  4320. return ii - 1 ? out : out[names[0]];
  4321. }
  4322. if (value == null && R.is(name, "array")) {
  4323. out = {};
  4324. for (i = 0, ii = name.length; i < ii; i++) {
  4325. out[name[i]] = this.attr(name[i]);
  4326. }
  4327. return out;
  4328. }
  4329. if (value != null) {
  4330. var params = {};
  4331. params[name] = value;
  4332. } else if (name != null && R.is(name, "object")) {
  4333. params = name;
  4334. }
  4335. for (var key in params) {
  4336. eve("raphael.attr." + key + "." + this.id, this, params[key]);
  4337. }
  4338. for (key in this.paper.customAttributes) if (this.paper.customAttributes[has](key) && params[has](key) && R.is(this.paper.customAttributes[key], "function")) {
  4339. var par = this.paper.customAttributes[key].apply(this, [].concat(params[key]));
  4340. this.attrs[key] = params[key];
  4341. for (var subkey in par) if (par[has](subkey)) {
  4342. params[subkey] = par[subkey];
  4343. }
  4344. }
  4345. setFillAndStroke(this, params);
  4346. return this;
  4347. };
  4348. elproto.toFront = function () {
  4349. if (this.removed) {
  4350. return this;
  4351. }
  4352. if (this.node.parentNode.tagName.toLowerCase() == "a") {
  4353. this.node.parentNode.parentNode.appendChild(this.node.parentNode);
  4354. } else {
  4355. this.node.parentNode.appendChild(this.node);
  4356. }
  4357. var svg = this.paper;
  4358. svg.top != this && R._tofront(this, svg);
  4359. return this;
  4360. };
  4361. elproto.toBack = function () {
  4362. if (this.removed) {
  4363. return this;
  4364. }
  4365. var parent = this.node.parentNode;
  4366. if (parent.tagName.toLowerCase() == "a") {
  4367. parent.parentNode.insertBefore(this.node.parentNode, this.node.parentNode.parentNode.firstChild);
  4368. } else if (parent.firstChild != this.node) {
  4369. parent.insertBefore(this.node, this.node.parentNode.firstChild);
  4370. }
  4371. R._toback(this, this.paper);
  4372. var svg = this.paper;
  4373. return this;
  4374. };
  4375. elproto.insertAfter = function (element) {
  4376. if (this.removed) {
  4377. return this;
  4378. }
  4379. var node = element.node || element[element.length - 1].node;
  4380. if (node.nextSibling) {
  4381. node.parentNode.insertBefore(this.node, node.nextSibling);
  4382. } else {
  4383. node.parentNode.appendChild(this.node);
  4384. }
  4385. R._insertafter(this, element, this.paper);
  4386. return this;
  4387. };
  4388. elproto.insertBefore = function (element) {
  4389. if (this.removed) {
  4390. return this;
  4391. }
  4392. var node = element.node || element[0].node;
  4393. node.parentNode.insertBefore(this.node, node);
  4394. R._insertbefore(this, element, this.paper);
  4395. return this;
  4396. };
  4397. elproto.blur = function (size) {
  4398. // Experimental. No Safari support. Use it on your own risk.
  4399. var t = this;
  4400. if (+size !== 0) {
  4401. var fltr = $("filter"),
  4402. blur = $("feGaussianBlur");
  4403. t.attrs.blur = size;
  4404. fltr.id = R.createUUID();
  4405. $(blur, {stdDeviation: +size || 1.5});
  4406. fltr.appendChild(blur);
  4407. t.paper.defs.appendChild(fltr);
  4408. t._blur = fltr;
  4409. $(t.node, {filter: "url(#" + fltr.id + ")"});
  4410. } else {
  4411. if (t._blur) {
  4412. t._blur.parentNode.removeChild(t._blur);
  4413. delete t._blur;
  4414. delete t.attrs.blur;
  4415. }
  4416. t.node.removeAttribute("filter");
  4417. }
  4418. };
  4419. R._engine.circle = function (svg, x, y, r) {
  4420. var el = $("circle");
  4421. svg.canvas && svg.canvas.appendChild(el);
  4422. var res = new Element(el, svg);
  4423. res.attrs = {cx: x, cy: y, r: r, fill: "none", stroke: "#000"};
  4424. res.type = "circle";
  4425. $(el, res.attrs);
  4426. return res;
  4427. };
  4428. R._engine.rect = function (svg, x, y, w, h, r) {
  4429. var el = $("rect");
  4430. svg.canvas && svg.canvas.appendChild(el);
  4431. var res = new Element(el, svg);
  4432. res.attrs = {x: x, y: y, width: w, height: h, r: r || 0, rx: r || 0, ry: r || 0, fill: "none", stroke: "#000"};
  4433. res.type = "rect";
  4434. $(el, res.attrs);
  4435. return res;
  4436. };
  4437. R._engine.ellipse = function (svg, x, y, rx, ry) {
  4438. var el = $("ellipse");
  4439. svg.canvas && svg.canvas.appendChild(el);
  4440. var res = new Element(el, svg);
  4441. res.attrs = {cx: x, cy: y, rx: rx, ry: ry, fill: "none", stroke: "#000"};
  4442. res.type = "ellipse";
  4443. $(el, res.attrs);
  4444. return res;
  4445. };
  4446. R._engine.image = function (svg, src, x, y, w, h) {
  4447. var el = $("image");
  4448. $(el, {x: x, y: y, width: w, height: h, preserveAspectRatio: "none"});
  4449. el.setAttributeNS(xlink, "href", src);
  4450. svg.canvas && svg.canvas.appendChild(el);
  4451. var res = new Element(el, svg);
  4452. res.attrs = {x: x, y: y, width: w, height: h, src: src};
  4453. res.type = "image";
  4454. return res;
  4455. };
  4456. R._engine.text = function (svg, x, y, text) {
  4457. var el = $("text");
  4458. svg.canvas && svg.canvas.appendChild(el);
  4459. var res = new Element(el, svg);
  4460. res.attrs = {
  4461. x: x,
  4462. y: y,
  4463. "text-anchor": "middle",
  4464. text: text,
  4465. font: R._availableAttrs.font,
  4466. stroke: "none",
  4467. fill: "#000"
  4468. };
  4469. res.type = "text";
  4470. setFillAndStroke(res, res.attrs);
  4471. return res;
  4472. };
  4473. R._engine.setSize = function (width, height) {
  4474. this.width = width || this.width;
  4475. this.height = height || this.height;
  4476. this.canvas.setAttribute("width", this.width);
  4477. this.canvas.setAttribute("height", this.height);
  4478. if (this._viewBox) {
  4479. this.setViewBox.apply(this, this._viewBox);
  4480. }
  4481. return this;
  4482. };
  4483. R._engine.create = function () {
  4484. var con = R._getContainer.apply(0, arguments),
  4485. container = con && con.container,
  4486. x = con.x,
  4487. y = con.y,
  4488. width = con.width,
  4489. height = con.height;
  4490. if (!container) {
  4491. throw new Error("SVG container not found.");
  4492. }
  4493. var cnvs = $("svg"),
  4494. css = "overflow:hidden;",
  4495. isFloating;
  4496. x = x || 0;
  4497. y = y || 0;
  4498. width = width || 512;
  4499. height = height || 342;
  4500. $(cnvs, {
  4501. height: height,
  4502. version: 1.1,
  4503. width: width,
  4504. xmlns: "http://www.w3.org/2000/svg"
  4505. });
  4506. if (container == 1) {
  4507. cnvs.style.cssText = css + "position:absolute;left:" + x + "px;top:" + y + "px";
  4508. R._g.doc.body.appendChild(cnvs);
  4509. isFloating = 1;
  4510. } else {
  4511. cnvs.style.cssText = css + "position:relative";
  4512. if (container.firstChild) {
  4513. container.insertBefore(cnvs, container.firstChild);
  4514. } else {
  4515. container.appendChild(cnvs);
  4516. }
  4517. }
  4518. container = new R._Paper;
  4519. container.width = width;
  4520. container.height = height;
  4521. container.canvas = cnvs;
  4522. container.clear();
  4523. container._left = container._top = 0;
  4524. isFloating && (container.renderfix = function () {});
  4525. container.renderfix();
  4526. return container;
  4527. };
  4528. R._engine.setViewBox = function (x, y, w, h, fit) {
  4529. eve("raphael.setViewBox", this, this._viewBox, [x, y, w, h, fit]);
  4530. var size = mmax(w / this.width, h / this.height),
  4531. top = this.top,
  4532. aspectRatio = fit ? "meet" : "xMinYMin",
  4533. vb,
  4534. sw;
  4535. if (x == null) {
  4536. if (this._vbSize) {
  4537. size = 1;
  4538. }
  4539. delete this._vbSize;
  4540. vb = "0 0 " + this.width + S + this.height;
  4541. } else {
  4542. this._vbSize = size;
  4543. vb = x + S + y + S + w + S + h;
  4544. }
  4545. $(this.canvas, {
  4546. viewBox: vb,
  4547. preserveAspectRatio: aspectRatio
  4548. });
  4549. while (size && top) {
  4550. sw = "stroke-width" in top.attrs ? top.attrs["stroke-width"] : 1;
  4551. top.attr({"stroke-width": sw});
  4552. top._.dirty = 1;
  4553. top._.dirtyT = 1;
  4554. top = top.prev;
  4555. }
  4556. this._viewBox = [x, y, w, h, !!fit];
  4557. return this;
  4558. };
  4559. R.prototype.renderfix = function () {
  4560. var cnvs = this.canvas,
  4561. s = cnvs.style,
  4562. pos;
  4563. try {
  4564. pos = cnvs.getScreenCTM() || cnvs.createSVGMatrix();
  4565. } catch (e) {
  4566. pos = cnvs.createSVGMatrix();
  4567. }
  4568. var left = -pos.e % 1,
  4569. top = -pos.f % 1;
  4570. if (left || top) {
  4571. if (left) {
  4572. this._left = (this._left + left) % 1;
  4573. s.left = this._left + "px";
  4574. }
  4575. if (top) {
  4576. this._top = (this._top + top) % 1;
  4577. s.top = this._top + "px";
  4578. }
  4579. }
  4580. };
  4581. R.prototype.clear = function () {
  4582. R.eve("raphael.clear", this);
  4583. var c = this.canvas;
  4584. while (c.firstChild) {
  4585. c.removeChild(c.firstChild);
  4586. }
  4587. this.bottom = this.top = null;
  4588. (this.desc = $("desc")).appendChild(R._g.doc.createTextNode("Created with Rapha\xebl " + R.version));
  4589. c.appendChild(this.desc);
  4590. c.appendChild(this.defs = $("defs"));
  4591. };
  4592. R.prototype.remove = function () {
  4593. eve("raphael.remove", this);
  4594. this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas);
  4595. for (var i in this) {
  4596. this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;
  4597. }
  4598. };
  4599. var setproto = R.st;
  4600. for (var method in elproto) if (elproto[has](method) && !setproto[has](method)) {
  4601. setproto[method] = (function (methodname) {
  4602. return function () {
  4603. var arg = arguments;
  4604. return this.forEach(function (el) {
  4605. el[methodname].apply(el, arg);
  4606. });
  4607. };
  4608. })(method);
  4609. }
  4610. }(window.Raphael);
  4611. // ┌─────────────────────────────────────────────────────────────────────┐ \\
  4612. // │ Raphaël - JavaScript Vector Library │ \\
  4613. // ├─────────────────────────────────────────────────────────────────────┤ \\
  4614. // │ VML Module │ \\
  4615. // ├─────────────────────────────────────────────────────────────────────┤ \\
  4616. // │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\
  4617. // │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\
  4618. // │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\
  4619. // └─────────────────────────────────────────────────────────────────────┘ \\
  4620. window.Raphael.vml && function (R) {
  4621. var has = "hasOwnProperty",
  4622. Str = String,
  4623. toFloat = parseFloat,
  4624. math = Math,
  4625. round = math.round,
  4626. mmax = math.max,
  4627. mmin = math.min,
  4628. abs = math.abs,
  4629. fillString = "fill",
  4630. separator = /[, ]+/,
  4631. eve = R.eve,
  4632. ms = " progid:DXImageTransform.Microsoft",
  4633. S = " ",
  4634. E = "",
  4635. map = {M: "m", L: "l", C: "c", Z: "x", m: "t", l: "r", c: "v", z: "x"},
  4636. bites = /([clmz]),?([^clmz]*)/gi,
  4637. blurregexp = / progid:\S+Blur\([^\)]+\)/g,
  4638. val = /-?[^,\s-]+/g,
  4639. cssDot = "position:absolute;left:0;top:0;width:1px;height:1px",
  4640. zoom = 21600,
  4641. pathTypes = {path: 1, rect: 1, image: 1},
  4642. ovalTypes = {circle: 1, ellipse: 1},
  4643. path2vml = function (path) {
  4644. var total = /[ahqstv]/ig,
  4645. command = R._pathToAbsolute;
  4646. Str(path).match(total) && (command = R._path2curve);
  4647. total = /[clmz]/g;
  4648. if (command == R._pathToAbsolute && !Str(path).match(total)) {
  4649. var res = Str(path).replace(bites, function (all, command, args) {
  4650. var vals = [],
  4651. isMove = command.toLowerCase() == "m",
  4652. res = map[command];
  4653. args.replace(val, function (value) {
  4654. if (isMove && vals.length == 2) {
  4655. res += vals + map[command == "m" ? "l" : "L"];
  4656. vals = [];
  4657. }
  4658. vals.push(round(value * zoom));
  4659. });
  4660. return res + vals;
  4661. });
  4662. return res;
  4663. }
  4664. var pa = command(path), p, r;
  4665. res = [];
  4666. for (var i = 0, ii = pa.length; i < ii; i++) {
  4667. p = pa[i];
  4668. r = pa[i][0].toLowerCase();
  4669. r == "z" && (r = "x");
  4670. for (var j = 1, jj = p.length; j < jj; j++) {
  4671. r += round(p[j] * zoom) + (j != jj - 1 ? "," : E);
  4672. }
  4673. res.push(r);
  4674. }
  4675. return res.join(S);
  4676. },
  4677. compensation = function (deg, dx, dy) {
  4678. var m = R.matrix();
  4679. m.rotate(-deg, .5, .5);
  4680. return {
  4681. dx: m.x(dx, dy),
  4682. dy: m.y(dx, dy)
  4683. };
  4684. },
  4685. setCoords = function (p, sx, sy, dx, dy, deg) {
  4686. var _ = p._,
  4687. m = p.matrix,
  4688. fillpos = _.fillpos,
  4689. o = p.node,
  4690. s = o.style,
  4691. y = 1,
  4692. flip = "",
  4693. dxdy,
  4694. kx = zoom / sx,
  4695. ky = zoom / sy;
  4696. s.visibility = "hidden";
  4697. if (!sx || !sy) {
  4698. return;
  4699. }
  4700. o.coordsize = abs(kx) + S + abs(ky);
  4701. s.rotation = deg * (sx * sy < 0 ? -1 : 1);
  4702. if (deg) {
  4703. var c = compensation(deg, dx, dy);
  4704. dx = c.dx;
  4705. dy = c.dy;
  4706. }
  4707. sx < 0 && (flip += "x");
  4708. sy < 0 && (flip += " y") && (y = -1);
  4709. s.flip = flip;
  4710. o.coordorigin = (dx * -kx) + S + (dy * -ky);
  4711. if (fillpos || _.fillsize) {
  4712. var fill = o.getElementsByTagName(fillString);
  4713. fill = fill && fill[0];
  4714. o.removeChild(fill);
  4715. if (fillpos) {
  4716. c = compensation(deg, m.x(fillpos[0], fillpos[1]), m.y(fillpos[0], fillpos[1]));
  4717. fill.position = c.dx * y + S + c.dy * y;
  4718. }
  4719. if (_.fillsize) {
  4720. fill.size = _.fillsize[0] * abs(sx) + S + _.fillsize[1] * abs(sy);
  4721. }
  4722. o.appendChild(fill);
  4723. }
  4724. s.visibility = "visible";
  4725. };
  4726. R.toString = function () {
  4727. return "Your browser doesn\u2019t support SVG. Falling down to VML.\nYou are running Rapha\xebl " + this.version;
  4728. };
  4729. var addArrow = function (o, value, isEnd) {
  4730. var values = Str(value).toLowerCase().split("-"),
  4731. se = isEnd ? "end" : "start",
  4732. i = values.length,
  4733. type = "classic",
  4734. w = "medium",
  4735. h = "medium";
  4736. while (i--) {
  4737. switch (values[i]) {
  4738. case "block":
  4739. case "classic":
  4740. case "oval":
  4741. case "diamond":
  4742. case "open":
  4743. case "none":
  4744. type = values[i];
  4745. break;
  4746. case "wide":
  4747. case "narrow": h = values[i]; break;
  4748. case "long":
  4749. case "short": w = values[i]; break;
  4750. }
  4751. }
  4752. var stroke = o.node.getElementsByTagName("stroke")[0];
  4753. stroke[se + "arrow"] = type;
  4754. stroke[se + "arrowlength"] = w;
  4755. stroke[se + "arrowwidth"] = h;
  4756. },
  4757. setFillAndStroke = function (o, params) {
  4758. // o.paper.canvas.style.display = "none";
  4759. o.attrs = o.attrs || {};
  4760. var node = o.node,
  4761. a = o.attrs,
  4762. s = node.style,
  4763. xy,
  4764. newpath = pathTypes[o.type] && (params.x != a.x || params.y != a.y || params.width != a.width || params.height != a.height || params.cx != a.cx || params.cy != a.cy || params.rx != a.rx || params.ry != a.ry || params.r != a.r),
  4765. isOval = ovalTypes[o.type] && (a.cx != params.cx || a.cy != params.cy || a.r != params.r || a.rx != params.rx || a.ry != params.ry),
  4766. res = o;
  4767. for (var par in params) if (params[has](par)) {
  4768. a[par] = params[par];
  4769. }
  4770. if (newpath) {
  4771. a.path = R._getPath[o.type](o);
  4772. o._.dirty = 1;
  4773. }
  4774. params.href && (node.href = params.href);
  4775. params.title && (node.title = params.title);
  4776. params.target && (node.target = params.target);
  4777. params.cursor && (s.cursor = params.cursor);
  4778. "blur" in params && o.blur(params.blur);
  4779. if (params.path && o.type == "path" || newpath) {
  4780. node.path = path2vml(~Str(a.path).toLowerCase().indexOf("r") ? R._pathToAbsolute(a.path) : a.path);
  4781. if (o.type == "image") {
  4782. o._.fillpos = [a.x, a.y];
  4783. o._.fillsize = [a.width, a.height];
  4784. setCoords(o, 1, 1, 0, 0, 0);
  4785. }
  4786. }
  4787. "transform" in params && o.transform(params.transform);
  4788. if (isOval) {
  4789. var cx = +a.cx,
  4790. cy = +a.cy,
  4791. rx = +a.rx || +a.r || 0,
  4792. ry = +a.ry || +a.r || 0;
  4793. node.path = R.format("ar{0},{1},{2},{3},{4},{1},{4},{1}x", round((cx - rx) * zoom), round((cy - ry) * zoom), round((cx + rx) * zoom), round((cy + ry) * zoom), round(cx * zoom));
  4794. }
  4795. if ("clip-rect" in params) {
  4796. var rect = Str(params["clip-rect"]).split(separator);
  4797. if (rect.length == 4) {
  4798. rect[2] = +rect[2] + (+rect[0]);
  4799. rect[3] = +rect[3] + (+rect[1]);
  4800. var div = node.clipRect || R._g.doc.createElement("div"),
  4801. dstyle = div.style;
  4802. dstyle.clip = R.format("rect({1}px {2}px {3}px {0}px)", rect);
  4803. if (!node.clipRect) {
  4804. dstyle.position = "absolute";
  4805. dstyle.top = 0;
  4806. dstyle.left = 0;
  4807. dstyle.width = o.paper.width + "px";
  4808. dstyle.height = o.paper.height + "px";
  4809. node.parentNode.insertBefore(div, node);
  4810. div.appendChild(node);
  4811. node.clipRect = div;
  4812. }
  4813. }
  4814. if (!params["clip-rect"]) {
  4815. node.clipRect && (node.clipRect.style.clip = "auto");
  4816. }
  4817. }
  4818. if (o.textpath) {
  4819. var textpathStyle = o.textpath.style;
  4820. params.font && (textpathStyle.font = params.font);
  4821. params["font-family"] && (textpathStyle.fontFamily = '"' + params["font-family"].split(",")[0].replace(/^['"]+|['"]+$/g, E) + '"');
  4822. params["font-size"] && (textpathStyle.fontSize = params["font-size"]);
  4823. params["font-weight"] && (textpathStyle.fontWeight = params["font-weight"]);
  4824. params["font-style"] && (textpathStyle.fontStyle = params["font-style"]);
  4825. }
  4826. if ("arrow-start" in params) {
  4827. addArrow(res, params["arrow-start"]);
  4828. }
  4829. if ("arrow-end" in params) {
  4830. addArrow(res, params["arrow-end"], 1);
  4831. }
  4832. if (params.opacity != null ||
  4833. params["stroke-width"] != null ||
  4834. params.fill != null ||
  4835. params.src != null ||
  4836. params.stroke != null ||
  4837. params["stroke-width"] != null ||
  4838. params["stroke-opacity"] != null ||
  4839. params["fill-opacity"] != null ||
  4840. params["stroke-dasharray"] != null ||
  4841. params["stroke-miterlimit"] != null ||
  4842. params["stroke-linejoin"] != null ||
  4843. params["stroke-linecap"] != null) {
  4844. var fill = node.getElementsByTagName(fillString),
  4845. newfill = false;
  4846. fill = fill && fill[0];
  4847. !fill && (newfill = fill = createNode(fillString));
  4848. if (o.type == "image" && params.src) {
  4849. fill.src = params.src;
  4850. }
  4851. params.fill && (fill.on = true);
  4852. if (fill.on == null || params.fill == "none" || params.fill === null) {
  4853. fill.on = false;
  4854. }
  4855. if (fill.on && params.fill) {
  4856. var isURL = Str(params.fill).match(R._ISURL);
  4857. if (isURL) {
  4858. fill.parentNode == node && node.removeChild(fill);
  4859. fill.rotate = true;
  4860. fill.src = isURL[1];
  4861. fill.type = "tile";
  4862. var bbox = o.getBBox(1);
  4863. fill.position = bbox.x + S + bbox.y;
  4864. o._.fillpos = [bbox.x, bbox.y];
  4865. R._preload(isURL[1], function () {
  4866. o._.fillsize = [this.offsetWidth, this.offsetHeight];
  4867. });
  4868. } else {
  4869. fill.color = R.getRGB(params.fill).hex;
  4870. fill.src = E;
  4871. fill.type = "solid";
  4872. if (R.getRGB(params.fill).error && (res.type in {circle: 1, ellipse: 1} || Str(params.fill).charAt() != "r") && addGradientFill(res, params.fill, fill)) {
  4873. a.fill = "none";
  4874. a.gradient = params.fill;
  4875. fill.rotate = false;
  4876. }
  4877. }
  4878. }
  4879. if ("fill-opacity" in params || "opacity" in params) {
  4880. var opacity = ((+a["fill-opacity"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1) * ((+R.getRGB(params.fill).o + 1 || 2) - 1);
  4881. opacity = mmin(mmax(opacity, 0), 1);
  4882. fill.opacity = opacity;
  4883. if (fill.src) {
  4884. fill.color = "none";
  4885. }
  4886. }
  4887. node.appendChild(fill);
  4888. var stroke = (node.getElementsByTagName("stroke") && node.getElementsByTagName("stroke")[0]),
  4889. newstroke = false;
  4890. !stroke && (newstroke = stroke = createNode("stroke"));
  4891. if ((params.stroke && params.stroke != "none") ||
  4892. params["stroke-width"] ||
  4893. params["stroke-opacity"] != null ||
  4894. params["stroke-dasharray"] ||
  4895. params["stroke-miterlimit"] ||
  4896. params["stroke-linejoin"] ||
  4897. params["stroke-linecap"]) {
  4898. stroke.on = true;
  4899. }
  4900. (params.stroke == "none" || params.stroke === null || stroke.on == null || params.stroke == 0 || params["stroke-width"] == 0) && (stroke.on = false);
  4901. var strokeColor = R.getRGB(params.stroke);
  4902. stroke.on && params.stroke && (stroke.color = strokeColor.hex);
  4903. opacity = ((+a["stroke-opacity"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1) * ((+strokeColor.o + 1 || 2) - 1);
  4904. var width = (toFloat(params["stroke-width"]) || 1) * .75;
  4905. opacity = mmin(mmax(opacity, 0), 1);
  4906. params["stroke-width"] == null && (width = a["stroke-width"]);
  4907. params["stroke-width"] && (stroke.weight = width);
  4908. width && width < 1 && (opacity *= width) && (stroke.weight = 1);
  4909. stroke.opacity = opacity;
  4910. params["stroke-linejoin"] && (stroke.joinstyle = params["stroke-linejoin"] || "miter");
  4911. stroke.miterlimit = params["stroke-miterlimit"] || 8;
  4912. params["stroke-linecap"] && (stroke.endcap = params["stroke-linecap"] == "butt" ? "flat" : params["stroke-linecap"] == "square" ? "square" : "round");
  4913. if (params["stroke-dasharray"]) {
  4914. var dasharray = {
  4915. "-": "shortdash",
  4916. ".": "shortdot",
  4917. "-.": "shortdashdot",
  4918. "-..": "shortdashdotdot",
  4919. ". ": "dot",
  4920. "- ": "dash",
  4921. "--": "longdash",
  4922. "- .": "dashdot",
  4923. "--.": "longdashdot",
  4924. "--..": "longdashdotdot"
  4925. };
  4926. stroke.dashstyle = dasharray[has](params["stroke-dasharray"]) ? dasharray[params["stroke-dasharray"]] : E;
  4927. }
  4928. newstroke && node.appendChild(stroke);
  4929. }
  4930. if (res.type == "text") {
  4931. res.paper.canvas.style.display = E;
  4932. var span = res.paper.span,
  4933. m = 100,
  4934. fontSize = a.font && a.font.match(/\d+(?:\.\d*)?(?=px)/);
  4935. s = span.style;
  4936. a.font && (s.font = a.font);
  4937. a["font-family"] && (s.fontFamily = a["font-family"]);
  4938. a["font-weight"] && (s.fontWeight = a["font-weight"]);
  4939. a["font-style"] && (s.fontStyle = a["font-style"]);
  4940. fontSize = toFloat(a["font-size"] || fontSize && fontSize[0]) || 10;
  4941. s.fontSize = fontSize * m + "px";
  4942. res.textpath.string && (span.innerHTML = Str(res.textpath.string).replace(/</g, "&#60;").replace(/&/g, "&#38;").replace(/\n/g, "<br>"));
  4943. var brect = span.getBoundingClientRect();
  4944. res.W = a.w = (brect.right - brect.left) / m;
  4945. res.H = a.h = (brect.bottom - brect.top) / m;
  4946. // res.paper.canvas.style.display = "none";
  4947. res.X = a.x;
  4948. res.Y = a.y + res.H / 2;
  4949. ("x" in params || "y" in params) && (res.path.v = R.format("m{0},{1}l{2},{1}", round(a.x * zoom), round(a.y * zoom), round(a.x * zoom) + 1));
  4950. var dirtyattrs = ["x", "y", "text", "font", "font-family", "font-weight", "font-style", "font-size"];
  4951. for (var d = 0, dd = dirtyattrs.length; d < dd; d++) if (dirtyattrs[d] in params) {
  4952. res._.dirty = 1;
  4953. break;
  4954. }
  4955. // text-anchor emulation
  4956. switch (a["text-anchor"]) {
  4957. case "start":
  4958. res.textpath.style["v-text-align"] = "left";
  4959. res.bbx = res.W / 2;
  4960. break;
  4961. case "end":
  4962. res.textpath.style["v-text-align"] = "right";
  4963. res.bbx = -res.W / 2;
  4964. break;
  4965. default:
  4966. res.textpath.style["v-text-align"] = "center";
  4967. res.bbx = 0;
  4968. break;
  4969. }
  4970. res.textpath.style["v-text-kern"] = true;
  4971. }
  4972. // res.paper.canvas.style.display = E;
  4973. },
  4974. addGradientFill = function (o, gradient, fill) {
  4975. o.attrs = o.attrs || {};
  4976. var attrs = o.attrs,
  4977. pow = Math.pow,
  4978. opacity,
  4979. oindex,
  4980. type = "linear",
  4981. fxfy = ".5 .5";
  4982. o.attrs.gradient = gradient;
  4983. gradient = Str(gradient).replace(R._radial_gradient, function (all, fx, fy) {
  4984. type = "radial";
  4985. if (fx && fy) {
  4986. fx = toFloat(fx);
  4987. fy = toFloat(fy);
  4988. pow(fx - .5, 2) + pow(fy - .5, 2) > .25 && (fy = math.sqrt(.25 - pow(fx - .5, 2)) * ((fy > .5) * 2 - 1) + .5);
  4989. fxfy = fx + S + fy;
  4990. }
  4991. return E;
  4992. });
  4993. gradient = gradient.split(/\s*\-\s*/);
  4994. if (type == "linear") {
  4995. var angle = gradient.shift();
  4996. angle = -toFloat(angle);
  4997. if (isNaN(angle)) {
  4998. return null;
  4999. }
  5000. }
  5001. var dots = R._parseDots(gradient);
  5002. if (!dots) {
  5003. return null;
  5004. }
  5005. o = o.shape || o.node;
  5006. if (dots.length) {
  5007. o.removeChild(fill);
  5008. fill.on = true;
  5009. fill.method = "none";
  5010. fill.color = dots[0].color;
  5011. fill.color2 = dots[dots.length - 1].color;
  5012. var clrs = [];
  5013. for (var i = 0, ii = dots.length; i < ii; i++) {
  5014. dots[i].offset && clrs.push(dots[i].offset + S + dots[i].color);
  5015. }
  5016. fill.colors = clrs.length ? clrs.join() : "0% " + fill.color;
  5017. if (type == "radial") {
  5018. fill.type = "gradientTitle";
  5019. fill.focus = "100%";
  5020. fill.focussize = "0 0";
  5021. fill.focusposition = fxfy;
  5022. fill.angle = 0;
  5023. } else {
  5024. // fill.rotate= true;
  5025. fill.type = "gradient";
  5026. fill.angle = (270 - angle) % 360;
  5027. }
  5028. o.appendChild(fill);
  5029. }
  5030. return 1;
  5031. },
  5032. Element = function (node, vml) {
  5033. this[0] = this.node = node;
  5034. node.raphael = true;
  5035. this.id = R._oid++;
  5036. node.raphaelid = this.id;
  5037. this.X = 0;
  5038. this.Y = 0;
  5039. this.attrs = {};
  5040. this.paper = vml;
  5041. this.matrix = R.matrix();
  5042. this._ = {
  5043. transform: [],
  5044. sx: 1,
  5045. sy: 1,
  5046. dx: 0,
  5047. dy: 0,
  5048. deg: 0,
  5049. dirty: 1,
  5050. dirtyT: 1
  5051. };
  5052. !vml.bottom && (vml.bottom = this);
  5053. this.prev = vml.top;
  5054. vml.top && (vml.top.next = this);
  5055. vml.top = this;
  5056. this.next = null;
  5057. };
  5058. var elproto = R.el;
  5059. Element.prototype = elproto;
  5060. elproto.constructor = Element;
  5061. elproto.transform = function (tstr) {
  5062. if (tstr == null) {
  5063. return this._.transform;
  5064. }
  5065. var vbs = this.paper._viewBoxShift,
  5066. vbt = vbs ? "s" + [vbs.scale, vbs.scale] + "-1-1t" + [vbs.dx, vbs.dy] : E,
  5067. oldt;
  5068. if (vbs) {
  5069. oldt = tstr = Str(tstr).replace(/\.{3}|\u2026/g, this._.transform || E);
  5070. }
  5071. R._extractTransform(this, vbt + tstr);
  5072. var matrix = this.matrix.clone(),
  5073. skew = this.skew,
  5074. o = this.node,
  5075. split,
  5076. isGrad = ~Str(this.attrs.fill).indexOf("-"),
  5077. isPatt = !Str(this.attrs.fill).indexOf("url(");
  5078. matrix.translate(-.5, -.5);
  5079. if (isPatt || isGrad || this.type == "image") {
  5080. skew.matrix = "1 0 0 1";
  5081. skew.offset = "0 0";
  5082. split = matrix.split();
  5083. if ((isGrad && split.noRotation) || !split.isSimple) {
  5084. o.style.filter = matrix.toFilter();
  5085. var bb = this.getBBox(),
  5086. bbt = this.getBBox(1),
  5087. dx = bb.x - bbt.x,
  5088. dy = bb.y - bbt.y;
  5089. o.coordorigin = (dx * -zoom) + S + (dy * -zoom);
  5090. setCoords(this, 1, 1, dx, dy, 0);
  5091. } else {
  5092. o.style.filter = E;
  5093. setCoords(this, split.scalex, split.scaley, split.dx, split.dy, split.rotate);
  5094. }
  5095. } else {
  5096. o.style.filter = E;
  5097. skew.matrix = Str(matrix);
  5098. skew.offset = matrix.offset();
  5099. }
  5100. oldt && (this._.transform = oldt);
  5101. return this;
  5102. };
  5103. elproto.rotate = function (deg, cx, cy) {
  5104. if (this.removed) {
  5105. return this;
  5106. }
  5107. if (deg == null) {
  5108. return;
  5109. }
  5110. deg = Str(deg).split(separator);
  5111. if (deg.length - 1) {
  5112. cx = toFloat(deg[1]);
  5113. cy = toFloat(deg[2]);
  5114. }
  5115. deg = toFloat(deg[0]);
  5116. (cy == null) && (cx = cy);
  5117. if (cx == null || cy == null) {
  5118. var bbox = this.getBBox(1);
  5119. cx = bbox.x + bbox.width / 2;
  5120. cy = bbox.y + bbox.height / 2;
  5121. }
  5122. this._.dirtyT = 1;
  5123. this.transform(this._.transform.concat([["r", deg, cx, cy]]));
  5124. return this;
  5125. };
  5126. elproto.translate = function (dx, dy) {
  5127. if (this.removed) {
  5128. return this;
  5129. }
  5130. dx = Str(dx).split(separator);
  5131. if (dx.length - 1) {
  5132. dy = toFloat(dx[1]);
  5133. }
  5134. dx = toFloat(dx[0]) || 0;
  5135. dy = +dy || 0;
  5136. if (this._.bbox) {
  5137. this._.bbox.x += dx;
  5138. this._.bbox.y += dy;
  5139. }
  5140. this.transform(this._.transform.concat([["t", dx, dy]]));
  5141. return this;
  5142. };
  5143. elproto.scale = function (sx, sy, cx, cy) {
  5144. if (this.removed) {
  5145. return this;
  5146. }
  5147. sx = Str(sx).split(separator);
  5148. if (sx.length - 1) {
  5149. sy = toFloat(sx[1]);
  5150. cx = toFloat(sx[2]);
  5151. cy = toFloat(sx[3]);
  5152. isNaN(cx) && (cx = null);
  5153. isNaN(cy) && (cy = null);
  5154. }
  5155. sx = toFloat(sx[0]);
  5156. (sy == null) && (sy = sx);
  5157. (cy == null) && (cx = cy);
  5158. if (cx == null || cy == null) {
  5159. var bbox = this.getBBox(1);
  5160. }
  5161. cx = cx == null ? bbox.x + bbox.width / 2 : cx;
  5162. cy = cy == null ? bbox.y + bbox.height / 2 : cy;
  5163. this.transform(this._.transform.concat([["s", sx, sy, cx, cy]]));
  5164. this._.dirtyT = 1;
  5165. return this;
  5166. };
  5167. elproto.hide = function () {
  5168. !this.removed && (this.node.style.display = "none");
  5169. return this;
  5170. };
  5171. elproto.show = function () {
  5172. !this.removed && (this.node.style.display = E);
  5173. return this;
  5174. };
  5175. elproto._getBBox = function () {
  5176. if (this.removed) {
  5177. return {};
  5178. }
  5179. return {
  5180. x: this.X + (this.bbx || 0) - this.W / 2,
  5181. y: this.Y - this.H,
  5182. width: this.W,
  5183. height: this.H
  5184. };
  5185. };
  5186. elproto.remove = function () {
  5187. if (this.removed || !this.node.parentNode) {
  5188. return;
  5189. }
  5190. this.paper.__set__ && this.paper.__set__.exclude(this);
  5191. R.eve.unbind("raphael.*.*." + this.id);
  5192. R._tear(this, this.paper);
  5193. this.node.parentNode.removeChild(this.node);
  5194. this.shape && this.shape.parentNode.removeChild(this.shape);
  5195. for (var i in this) {
  5196. this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;
  5197. }
  5198. this.removed = true;
  5199. };
  5200. elproto.attr = function (name, value) {
  5201. if (this.removed) {
  5202. return this;
  5203. }
  5204. if (name == null) {
  5205. var res = {};
  5206. for (var a in this.attrs) if (this.attrs[has](a)) {
  5207. res[a] = this.attrs[a];
  5208. }
  5209. res.gradient && res.fill == "none" && (res.fill = res.gradient) && delete res.gradient;
  5210. res.transform = this._.transform;
  5211. return res;
  5212. }
  5213. if (value == null && R.is(name, "string")) {
  5214. if (name == fillString && this.attrs.fill == "none" && this.attrs.gradient) {
  5215. return this.attrs.gradient;
  5216. }
  5217. var names = name.split(separator),
  5218. out = {};
  5219. for (var i = 0, ii = names.length; i < ii; i++) {
  5220. name = names[i];
  5221. if (name in this.attrs) {
  5222. out[name] = this.attrs[name];
  5223. } else if (R.is(this.paper.customAttributes[name], "function")) {
  5224. out[name] = this.paper.customAttributes[name].def;
  5225. } else {
  5226. out[name] = R._availableAttrs[name];
  5227. }
  5228. }
  5229. return ii - 1 ? out : out[names[0]];
  5230. }
  5231. if (this.attrs && value == null && R.is(name, "array")) {
  5232. out = {};
  5233. for (i = 0, ii = name.length; i < ii; i++) {
  5234. out[name[i]] = this.attr(name[i]);
  5235. }
  5236. return out;
  5237. }
  5238. var params;
  5239. if (value != null) {
  5240. params = {};
  5241. params[name] = value;
  5242. }
  5243. value == null && R.is(name, "object") && (params = name);
  5244. for (var key in params) {
  5245. eve("raphael.attr." + key + "." + this.id, this, params[key]);
  5246. }
  5247. if (params) {
  5248. for (key in this.paper.customAttributes) if (this.paper.customAttributes[has](key) && params[has](key) && R.is(this.paper.customAttributes[key], "function")) {
  5249. var par = this.paper.customAttributes[key].apply(this, [].concat(params[key]));
  5250. this.attrs[key] = params[key];
  5251. for (var subkey in par) if (par[has](subkey)) {
  5252. params[subkey] = par[subkey];
  5253. }
  5254. }
  5255. // this.paper.canvas.style.display = "none";
  5256. if (params.text && this.type == "text") {
  5257. this.textpath.string = params.text;
  5258. }
  5259. setFillAndStroke(this, params);
  5260. // this.paper.canvas.style.display = E;
  5261. }
  5262. return this;
  5263. };
  5264. elproto.toFront = function () {
  5265. !this.removed && this.node.parentNode.appendChild(this.node);
  5266. this.paper && this.paper.top != this && R._tofront(this, this.paper);
  5267. return this;
  5268. };
  5269. elproto.toBack = function () {
  5270. if (this.removed) {
  5271. return this;
  5272. }
  5273. if (this.node.parentNode.firstChild != this.node) {
  5274. this.node.parentNode.insertBefore(this.node, this.node.parentNode.firstChild);
  5275. R._toback(this, this.paper);
  5276. }
  5277. return this;
  5278. };
  5279. elproto.insertAfter = function (element) {
  5280. if (this.removed) {
  5281. return this;
  5282. }
  5283. if (element.constructor == R.st.constructor) {
  5284. element = element[element.length - 1];
  5285. }
  5286. if (element.node.nextSibling) {
  5287. element.node.parentNode.insertBefore(this.node, element.node.nextSibling);
  5288. } else {
  5289. element.node.parentNode.appendChild(this.node);
  5290. }
  5291. R._insertafter(this, element, this.paper);
  5292. return this;
  5293. };
  5294. elproto.insertBefore = function (element) {
  5295. if (this.removed) {
  5296. return this;
  5297. }
  5298. if (element.constructor == R.st.constructor) {
  5299. element = element[0];
  5300. }
  5301. element.node.parentNode.insertBefore(this.node, element.node);
  5302. R._insertbefore(this, element, this.paper);
  5303. return this;
  5304. };
  5305. elproto.blur = function (size) {
  5306. var s = this.node.runtimeStyle,
  5307. f = s.filter;
  5308. f = f.replace(blurregexp, E);
  5309. if (+size !== 0) {
  5310. this.attrs.blur = size;
  5311. s.filter = f + S + ms + ".Blur(pixelradius=" + (+size || 1.5) + ")";
  5312. s.margin = R.format("-{0}px 0 0 -{0}px", round(+size || 1.5));
  5313. } else {
  5314. s.filter = f;
  5315. s.margin = 0;
  5316. delete this.attrs.blur;
  5317. }
  5318. };
  5319. R._engine.path = function (pathString, vml) {
  5320. var el = createNode("shape");
  5321. el.style.cssText = cssDot;
  5322. el.coordsize = zoom + S + zoom;
  5323. el.coordorigin = vml.coordorigin;
  5324. var p = new Element(el, vml),
  5325. attr = {fill: "none", stroke: "#000"};
  5326. pathString && (attr.path = pathString);
  5327. p.type = "path";
  5328. p.path = [];
  5329. p.Path = E;
  5330. setFillAndStroke(p, attr);
  5331. vml.canvas.appendChild(el);
  5332. var skew = createNode("skew");
  5333. skew.on = true;
  5334. el.appendChild(skew);
  5335. p.skew = skew;
  5336. p.transform(E);
  5337. return p;
  5338. };
  5339. R._engine.rect = function (vml, x, y, w, h, r) {
  5340. var path = R._rectPath(x, y, w, h, r),
  5341. res = vml.path(path),
  5342. a = res.attrs;
  5343. res.X = a.x = x;
  5344. res.Y = a.y = y;
  5345. res.W = a.width = w;
  5346. res.H = a.height = h;
  5347. a.r = r;
  5348. a.path = path;
  5349. res.type = "rect";
  5350. return res;
  5351. };
  5352. R._engine.ellipse = function (vml, x, y, rx, ry) {
  5353. var res = vml.path(),
  5354. a = res.attrs;
  5355. res.X = x - rx;
  5356. res.Y = y - ry;
  5357. res.W = rx * 2;
  5358. res.H = ry * 2;
  5359. res.type = "ellipse";
  5360. setFillAndStroke(res, {
  5361. cx: x,
  5362. cy: y,
  5363. rx: rx,
  5364. ry: ry
  5365. });
  5366. return res;
  5367. };
  5368. R._engine.circle = function (vml, x, y, r) {
  5369. var res = vml.path(),
  5370. a = res.attrs;
  5371. res.X = x - r;
  5372. res.Y = y - r;
  5373. res.W = res.H = r * 2;
  5374. res.type = "circle";
  5375. setFillAndStroke(res, {
  5376. cx: x,
  5377. cy: y,
  5378. r: r
  5379. });
  5380. return res;
  5381. };
  5382. R._engine.image = function (vml, src, x, y, w, h) {
  5383. var path = R._rectPath(x, y, w, h),
  5384. res = vml.path(path).attr({stroke: "none"}),
  5385. a = res.attrs,
  5386. node = res.node,
  5387. fill = node.getElementsByTagName(fillString)[0];
  5388. a.src = src;
  5389. res.X = a.x = x;
  5390. res.Y = a.y = y;
  5391. res.W = a.width = w;
  5392. res.H = a.height = h;
  5393. a.path = path;
  5394. res.type = "image";
  5395. fill.parentNode == node && node.removeChild(fill);
  5396. fill.rotate = true;
  5397. fill.src = src;
  5398. fill.type = "tile";
  5399. res._.fillpos = [x, y];
  5400. res._.fillsize = [w, h];
  5401. node.appendChild(fill);
  5402. setCoords(res, 1, 1, 0, 0, 0);
  5403. return res;
  5404. };
  5405. R._engine.text = function (vml, x, y, text) {
  5406. var el = createNode("shape"),
  5407. path = createNode("path"),
  5408. o = createNode("textpath");
  5409. x = x || 0;
  5410. y = y || 0;
  5411. text = text || "";
  5412. path.v = R.format("m{0},{1}l{2},{1}", round(x * zoom), round(y * zoom), round(x * zoom) + 1);
  5413. path.textpathok = true;
  5414. o.string = Str(text);
  5415. o.on = true;
  5416. el.style.cssText = cssDot;
  5417. el.coordsize = zoom + S + zoom;
  5418. el.coordorigin = "0 0";
  5419. var p = new Element(el, vml),
  5420. attr = {
  5421. fill: "#000",
  5422. stroke: "none",
  5423. font: R._availableAttrs.font,
  5424. text: text
  5425. };
  5426. p.shape = el;
  5427. p.path = path;
  5428. p.textpath = o;
  5429. p.type = "text";
  5430. p.attrs.text = Str(text);
  5431. p.attrs.x = x;
  5432. p.attrs.y = y;
  5433. p.attrs.w = 1;
  5434. p.attrs.h = 1;
  5435. setFillAndStroke(p, attr);
  5436. el.appendChild(o);
  5437. el.appendChild(path);
  5438. vml.canvas.appendChild(el);
  5439. var skew = createNode("skew");
  5440. skew.on = true;
  5441. el.appendChild(skew);
  5442. p.skew = skew;
  5443. p.transform(E);
  5444. return p;
  5445. };
  5446. R._engine.setSize = function (width, height) {
  5447. var cs = this.canvas.style;
  5448. this.width = width;
  5449. this.height = height;
  5450. width == +width && (width += "px");
  5451. height == +height && (height += "px");
  5452. cs.width = width;
  5453. cs.height = height;
  5454. cs.clip = "rect(0 " + width + " " + height + " 0)";
  5455. if (this._viewBox) {
  5456. R._engine.setViewBox.apply(this, this._viewBox);
  5457. }
  5458. return this;
  5459. };
  5460. R._engine.setViewBox = function (x, y, w, h, fit) {
  5461. R.eve("raphael.setViewBox", this, this._viewBox, [x, y, w, h, fit]);
  5462. var width = this.width,
  5463. height = this.height,
  5464. size = 1 / mmax(w / width, h / height),
  5465. H, W;
  5466. if (fit) {
  5467. H = height / h;
  5468. W = width / w;
  5469. if (w * H < width) {
  5470. x -= (width - w * H) / 2 / H;
  5471. }
  5472. if (h * W < height) {
  5473. y -= (height - h * W) / 2 / W;
  5474. }
  5475. }
  5476. this._viewBox = [x, y, w, h, !!fit];
  5477. this._viewBoxShift = {
  5478. dx: -x,
  5479. dy: -y,
  5480. scale: size
  5481. };
  5482. this.forEach(function (el) {
  5483. el.transform("...");
  5484. });
  5485. return this;
  5486. };
  5487. var createNode;
  5488. R._engine.initWin = function (win) {
  5489. var doc = win.document;
  5490. doc.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)");
  5491. try {
  5492. !doc.namespaces.rvml && doc.namespaces.add("rvml", "urn:schemas-microsoft-com:vml");
  5493. createNode = function (tagName) {
  5494. return doc.createElement('<rvml:' + tagName + ' class="rvml">');
  5495. };
  5496. } catch (e) {
  5497. createNode = function (tagName) {
  5498. return doc.createElement('<' + tagName + ' xmlns="urn:schemas-microsoft.com:vml" class="rvml">');
  5499. };
  5500. }
  5501. };
  5502. R._engine.initWin(R._g.win);
  5503. R._engine.create = function () {
  5504. var con = R._getContainer.apply(0, arguments),
  5505. container = con.container,
  5506. height = con.height,
  5507. s,
  5508. width = con.width,
  5509. x = con.x,
  5510. y = con.y;
  5511. if (!container) {
  5512. throw new Error("VML container not found.");
  5513. }
  5514. var res = new R._Paper,
  5515. c = res.canvas = R._g.doc.createElement("div"),
  5516. cs = c.style;
  5517. x = x || 0;
  5518. y = y || 0;
  5519. width = width || 512;
  5520. height = height || 342;
  5521. res.width = width;
  5522. res.height = height;
  5523. width == +width && (width += "px");
  5524. height == +height && (height += "px");
  5525. res.coordsize = zoom * 1e3 + S + zoom * 1e3;
  5526. res.coordorigin = "0 0";
  5527. res.span = R._g.doc.createElement("span");
  5528. res.span.style.cssText = "position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;";
  5529. c.appendChild(res.span);
  5530. cs.cssText = R.format("top:0;left:0;width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden", width, height);
  5531. if (container == 1) {
  5532. R._g.doc.body.appendChild(c);
  5533. cs.left = x + "px";
  5534. cs.top = y + "px";
  5535. cs.position = "absolute";
  5536. } else {
  5537. if (container.firstChild) {
  5538. container.insertBefore(c, container.firstChild);
  5539. } else {
  5540. container.appendChild(c);
  5541. }
  5542. }
  5543. res.renderfix = function () {};
  5544. return res;
  5545. };
  5546. R.prototype.clear = function () {
  5547. R.eve("raphael.clear", this);
  5548. this.canvas.innerHTML = E;
  5549. this.span = R._g.doc.createElement("span");
  5550. this.span.style.cssText = "position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";
  5551. this.canvas.appendChild(this.span);
  5552. this.bottom = this.top = null;
  5553. };
  5554. R.prototype.remove = function () {
  5555. R.eve("raphael.remove", this);
  5556. this.canvas.parentNode.removeChild(this.canvas);
  5557. for (var i in this) {
  5558. this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;
  5559. }
  5560. return true;
  5561. };
  5562. var setproto = R.st;
  5563. for (var method in elproto) if (elproto[has](method) && !setproto[has](method)) {
  5564. setproto[method] = (function (methodname) {
  5565. return function () {
  5566. var arg = arguments;
  5567. return this.forEach(function (el) {
  5568. el[methodname].apply(el, arg);
  5569. });
  5570. };
  5571. })(method);
  5572. }
  5573. }(window.Raphael);