1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572 |
- (function () {
- var _p = {
- r: function(index) {
- if (_p[index].inited) {
- return _p[index].value;
- }
- if (typeof _p[index].value === "function") {
- var module = {
- exports: {}
- }, returnValue = _p[index].value(null, module.exports, module);
- _p[index].inited = true;
- _p[index].value = returnValue;
- if (returnValue !== undefined) {
- return returnValue;
- } else {
- for (var key in module.exports) {
- if (module.exports.hasOwnProperty(key)) {
- _p[index].inited = true;
- _p[index].value = module.exports;
- return module.exports;
- }
- }
- }
- } else {
- _p[index].inited = true;
- return _p[index].value;
- }
- }
- };
- _p[0] = {
- value: function(require) {
- function parseTime(str) {
- var value = parseFloat(str, 10);
- if (/ms/.test(str)) {
- return value;
- }
- if (/s/.test(str)) {
- return value * 1e3;
- }
- if (/min/.test(str)) {
- return value * 60 * 1e3;
- }
- return value;
- }
- var Timeline = _p.r(8);
- var easingTable = _p.r(1);
-
- var Animator = _p.r(11).createClass("Animator", {
-
- constructor: function(beginValue, finishValue, setter) {
- if (arguments.length == 1) {
- var opt = arguments[0];
- this.beginValue = opt.beginValue;
- this.finishValue = opt.finishValue;
- this.setter = opt.setter;
- } else {
- this.beginValue = beginValue;
- this.finishValue = finishValue;
- this.setter = setter;
- }
- },
-
- start: function(target, duration, easing, delay, callback) {
- if (arguments.length === 2 && typeof duration == "object") {
- easing = duration.easing;
- delay = duration.delay;
- callback = duration.callback;
- duration = duration.duration;
- }
- if (arguments.length === 4 && typeof delay == "function") {
- callback = delay;
- delay = 0;
- }
- var timeline = this.create(target, duration, easing, callback);
- delay = parseTime(delay);
- if (delay > 0) {
- setTimeout(function() {
- timeline.play();
- }, delay);
- } else {
- timeline.play();
- }
- return timeline;
- },
-
- create: function(target, duration, easing, callback) {
- var timeline;
- duration = duration && parseTime(duration) || Animator.DEFAULT_DURATION;
- easing = easing || Animator.DEFAULT_EASING;
- if (typeof easing == "string") {
- easing = easingTable[easing];
- }
- timeline = new Timeline(this, target, duration, easing);
- if (typeof callback == "function") {
- timeline.on("finish", callback);
- }
- return timeline;
- },
-
- reverse: function() {
- return new Animator(this.finishValue, this.beginValue, this.setter);
- }
- });
- Animator.DEFAULT_DURATION = 300;
- Animator.DEFAULT_EASING = "linear";
- var Shape = _p.r(60);
- _p.r(11).extendClass(Shape, {
-
- animate: function(animator, duration, easing, delay, callback) {
- var queue = this._KityAnimateQueue = this._KityAnimateQueue || [];
- var timeline = animator.create(this, duration, easing, callback);
- function dequeue() {
- queue.shift();
- if (queue.length) {
- setTimeout(queue[0].t.play.bind(queue[0].t), queue[0].d);
- }
- }
- timeline.on("finish", dequeue);
- queue.push({
- t: timeline,
- d: delay
- });
- if (queue.length == 1) {
- setTimeout(timeline.play.bind(timeline), delay);
- }
- return this;
- },
-
- timeline: function() {
- return this._KityAnimateQueue[0].t;
- },
-
- stop: function() {
- var queue = this._KityAnimateQueue;
- if (queue) {
- while (queue.length) {
- queue.shift().t.stop();
- }
- }
- return this;
- }
- });
- return Animator;
- }
- };
- _p[1] = {
- value: function(require, exports, module) {
- var easings = {
-
- linear: function(t, b, c, d) {
- return c * (t / d) + b;
- },
- swing: function(t, b, c, d) {
- return easings.easeOutQuad(t, b, c, d);
- },
- ease: function(t, b, c, d) {
- return easings.easeInOutCubic(t, b, c, d);
- },
- easeInQuad: function(t, b, c, d) {
- return c * (t /= d) * t + b;
- },
- easeOutQuad: function(t, b, c, d) {
- return -c * (t /= d) * (t - 2) + b;
- },
- easeInOutQuad: function(t, b, c, d) {
- if ((t /= d / 2) < 1) return c / 2 * t * t + b;
- return -c / 2 * (--t * (t - 2) - 1) + b;
- },
- easeInCubic: function(t, b, c, d) {
- return c * (t /= d) * t * t + b;
- },
- easeOutCubic: function(t, b, c, d) {
- return c * ((t = t / d - 1) * t * t + 1) + b;
- },
- easeInOutCubic: function(t, b, c, d) {
- if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
- return c / 2 * ((t -= 2) * t * t + 2) + b;
- },
- easeInQuart: function(t, b, c, d) {
- return c * (t /= d) * t * t * t + b;
- },
- easeOutQuart: function(t, b, c, d) {
- return -c * ((t = t / d - 1) * t * t * t - 1) + b;
- },
- easeInOutQuart: function(t, b, c, d) {
- if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
- return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
- },
- easeInQuint: function(t, b, c, d) {
- return c * (t /= d) * t * t * t * t + b;
- },
- easeOutQuint: function(t, b, c, d) {
- return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
- },
- easeInOutQuint: function(t, b, c, d) {
- if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
- return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
- },
- easeInSine: function(t, b, c, d) {
- return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
- },
- easeOutSine: function(t, b, c, d) {
- return c * Math.sin(t / d * (Math.PI / 2)) + b;
- },
- easeInOutSine: function(t, b, c, d) {
- return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
- },
- easeInExpo: function(t, b, c, d) {
- return t === 0 ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
- },
- easeOutExpo: function(t, b, c, d) {
- return t == d ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
- },
- easeInOutExpo: function(t, b, c, d) {
- if (t === 0) return b;
- if (t == d) return b + c;
- if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
- return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
- },
- easeInCirc: function(t, b, c, d) {
- return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
- },
- easeOutCirc: function(t, b, c, d) {
- return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
- },
- easeInOutCirc: function(t, b, c, d) {
- if ((t /= d / 2) < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
- return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
- },
- easeInElastic: function(t, b, c, d) {
- var s = 1.70158;
- var p = 0;
- var a = c;
- if (t === 0) return b;
- if ((t /= d) == 1) return b + c;
- if (!p) p = d * .3;
- if (a < Math.abs(c)) {
- a = c;
- s = p / 4;
- } else s = p / (2 * Math.PI) * Math.asin(c / a);
- return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
- },
- easeOutElastic: function(t, b, c, d) {
- var s = 1.70158;
- var p = 0;
- var a = c;
- if (t === 0) return b;
- if ((t /= d) == 1) return b + c;
- if (!p) p = d * .3;
- if (a < Math.abs(c)) {
- a = c;
- s = p / 4;
- } else s = p / (2 * Math.PI) * Math.asin(c / a);
- return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
- },
- easeInOutElastic: function(t, b, c, d) {
- var s = 1.70158;
- var p = 0;
- var a = c;
- if (t === 0) return b;
- if ((t /= d / 2) == 2) return b + c;
- if (!p) p = d * (.3 * 1.5);
- if (a < Math.abs(c)) {
- a = c;
- var s = p / 4;
- } else var s = p / (2 * Math.PI) * Math.asin(c / a);
- if (t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
- return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
- },
- easeInBack: function(t, b, c, d, s) {
- if (s == undefined) s = 1.70158;
- return c * (t /= d) * t * ((s + 1) * t - s) + b;
- },
- easeOutBack: function(t, b, c, d, s) {
- if (s == undefined) s = 1.70158;
- return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
- },
- easeInOutBack: function(t, b, c, d, s) {
- if (s == undefined) s = 1.70158;
- if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= 1.525) + 1) * t - s)) + b;
- return c / 2 * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2) + b;
- },
- easeInBounce: function(t, b, c, d) {
- return c - easings.easeOutBounce(d - t, 0, c, d) + b;
- },
- easeOutBounce: function(t, b, c, d) {
- if ((t /= d) < 1 / 2.75) {
- return c * (7.5625 * t * t) + b;
- } else if (t < 2 / 2.75) {
- return c * (7.5625 * (t -= 1.5 / 2.75) * t + .75) + b;
- } else if (t < 2.5 / 2.75) {
- return c * (7.5625 * (t -= 2.25 / 2.75) * t + .9375) + b;
- } else {
- return c * (7.5625 * (t -= 2.625 / 2.75) * t + .984375) + b;
- }
- },
- easeInOutBounce: function(t, b, c, d) {
- if (t < d / 2) return easings.easeInBounce(t * 2, 0, c, d) * .5 + b;
- return easings.easeOutBounce(t * 2 - d, 0, c, d) * .5 + c * .5 + b;
- }
- };
- return easings;
- }
- };
- _p[2] = {
- value: function(require, exports) {
-
- var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || function(fn) {
- return setTimeout(fn, 1e3 / 60);
- };
- var cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.msCancelAnimationFrame || window.clearTimeout;
-
- var frameRequestId;
-
- var pendingFrames = [];
-
- function pushFrame(frame) {
- if (pendingFrames.push(frame) === 1) {
- frameRequestId = requestAnimationFrame(executePendingFrames);
- }
- }
-
- function executePendingFrames() {
- var frames = pendingFrames;
- pendingFrames = [];
- while (frames.length) {
- executeFrame(frames.pop());
- }
- frameRequestId = 0;
- }
-
- function requestFrame(action) {
- var frame = initFrame(action);
- pushFrame(frame);
- return frame;
- }
-
- function releaseFrame(frame) {
- var index = pendingFrames.indexOf(frame);
- if (~index) {
- pendingFrames.splice(index, 1);
- }
- if (pendingFrames.length === 0) {
- cancelAnimationFrame(frameRequestId);
- }
- }
-
- function initFrame(action) {
- var frame = {
- index: 0,
- time: +new Date(),
- elapsed: 0,
- action: action,
- next: function() {
- pushFrame(frame);
- }
- };
- return frame;
- }
-
- function executeFrame(frame) {
-
- var time = +new Date();
-
- var dur = time - frame.time;
-
-
-
-
-
- if (dur > 200) {
- dur = 1e3 / 60;
- }
- frame.dur = dur;
- frame.elapsed += dur;
- frame.time = time;
- frame.action.call(null, frame);
- frame.index++;
- }
-
- exports.requestFrame = requestFrame;
- exports.releaseFrame = releaseFrame;
- }
- };
- _p[3] = {
- value: function(require) {
- var Animator = _p.r(0);
- var g = _p.r(34);
- var Path = _p.r(46);
- var Shape = _p.r(60);
-
- var MotionAnimator = _p.r(11).createClass("MotionAnimator", {
- base: Animator,
-
- constructor: function(path, doRotate) {
- var me = this;
- this.callBase({
- beginValue: 0,
- finishValue: 1,
- setter: function(target, value) {
- var path = me.motionPath instanceof Path ? me.motionPath.getPathData() : me.motionPath;
- var point = g.pointAtPath(path, value);
- target.setTranslate(point.x, point.y);
- if (this.doRotate) target.setRotate(point.tan.getAngle());
- }
- });
-
- this.doRotate = doRotate;
-
- this.motionPath = path;
- }
- });
- _p.r(11).extendClass(Shape, {
-
- motion: function(path, duration, easing, delay, callback) {
- return this.animate(new MotionAnimator(path), duration, easing, delay, callback);
- }
- });
- return MotionAnimator;
- }
- };
- _p[4] = {
- value: function(require) {
- var Animator = _p.r(0);
-
- var OpacityAnimator = _p.r(11).createClass("OpacityAnimator", {
- base: Animator,
-
- constructor: function(opacity) {
- this.callBase({
- beginValue: function(target) {
- return target.getOpacity();
- },
- finishValue: opacity,
- setter: function(target, value) {
- target.setOpacity(value);
- }
- });
- }
- });
- var Shape = _p.r(60);
- _p.r(11).extendClass(Shape, {
-
- fxOpacity: function(opacity, duration, easing, delay, callback) {
- return this.animate(new OpacityAnimator(opacity), duration, easing, delay, callback);
- },
-
- fadeTo: function() {
- return this.fxOpacity.apply(this, arguments);
- },
-
- fadeIn: function() {
- return this.fxOpacity.apply(this, [ 1 ].concat([].slice.call(arguments)));
- },
-
- fadeOut: function() {
- return this.fxOpacity.apply(this, [ 0 ].concat([].slice.call(arguments)));
- }
- });
- return OpacityAnimator;
- }
- };
- _p[5] = {
- value: function(require) {
- var Animator = _p.r(0);
- var g = _p.r(34);
-
- var PathAnimator = _p.r(11).createClass("OpacityAnimator", {
- base: Animator,
-
- constructor: function(path) {
- this.callBase({
- beginValue: function(target) {
- this.beginPath = target.getPathData();
- return 0;
- },
- finishValue: 1,
- setter: function(target, value) {
- target.setPathData(g.pathTween(this.beginPath, path, value));
- }
- });
- }
- });
- var Path = _p.r(46);
- _p.r(11).extendClass(Path, {
-
- fxPath: function(path, duration, easing, delay, callback) {
- return this.animate(new PathAnimator(path), duration, easing, delay, callback);
- }
- });
- return PathAnimator;
- }
- };
- _p[6] = {
- value: function(require) {
- var Animator = _p.r(0);
-
- var RotateAnimator = _p.r(11).createClass("RotateAnimator", {
- base: Animator,
-
- constructor: function(deg) {
- this.callBase({
- beginValue: 0,
- finishValue: deg,
- setter: function(target, value, timeline) {
- var delta = timeline.getDelta();
- target.rotate(delta, ax, ay);
- }
- });
- }
- });
- var Shape = _p.r(60);
- _p.r(11).extendClass(Shape, {
-
- fxRotate: function(deg, duration, easing, delay, callback) {
- return this.animate(new RotateAnimator(deg), duration, easing, delay, callback);
- }
- });
- return RotateAnimator;
- }
- };
- _p[7] = {
- value: function(require) {
- var Animator = _p.r(0);
-
- var ScaleAnimator = _p.r(11).createClass("ScaleAnimator", {
- base: Animator,
-
- constructor: function(sx, sy) {
- this.callBase({
- beginValue: 0,
- finishValue: 1,
- setter: function(target, value, timeline) {
- var delta = timeline.getDelta();
- var kx = Math.pow(sx, delta);
- var ky = Math.pow(sy, delta);
- target.scale(ky, kx);
- }
- });
- }
- });
- var Shape = _p.r(60);
- _p.r(11).extendClass(Shape, {
-
- fxScale: function(sx, sy, duration, easing, delay, callback) {
- return this.animate(new ScaleAnimator(sx, sy), duration, easing, delay, callback);
- }
- });
- return ScaleAnimator;
- }
- };
- _p[8] = {
- value: function(require) {
- var EventHandler = _p.r(33);
- var utils = _p.r(12);
- var frame = _p.r(2);
- function getPercentValue(b, f, p) {
- return utils.paralle(b, f, function(b, f) {
- return b + (f - b) * p;
- });
- }
- function getDelta(v1, v2) {
- return utils.paralle(v1, v2, function(v1, v2) {
- return v2 - v1;
- });
- }
- function TimelineEvent(timeline, type, param) {
- this.timeline = timeline;
- this.target = timeline.target;
- this.type = type;
- for (var name in param) {
- if (param.hasOwnProperty(name)) {
- this[name] = param[name];
- }
- }
- }
-
- var Timeline = _p.r(11).createClass("Timeline", {
- mixins: [ EventHandler ],
-
- constructor: function(animator, target, duration, easing) {
- this.callMixin();
- this.target = target;
- this.time = 0;
- this.duration = duration;
- this.easing = easing;
- this.animator = animator;
- this.beginValue = animator.beginValue;
- this.finishValue = animator.finishValue;
- this.setter = animator.setter;
- this.status = "ready";
- },
-
- nextFrame: function(frame) {
- if (this.status != "playing") {
- return;
- }
- this.time += frame.dur;
- this.setValue(this.getValue());
- if (this.time >= this.duration) {
- this.timeUp();
- }
- frame.next();
- },
-
- getPlayTime: function() {
- return this.rollbacking ? this.duration - this.time : this.time;
- },
-
- getTimeProportion: function() {
- return this.getPlayTime() / this.duration;
- },
-
- getValueProportion: function() {
- return this.easing(this.getPlayTime(), 0, 1, this.duration);
- },
-
- getValue: function() {
- var b = this.beginValue;
- var f = this.finishValue;
- var p = this.getValueProportion();
- return getPercentValue(b, f, p);
- },
-
- setValue: function(value) {
- this.lastValue = this.currentValue;
- this.currentValue = value;
- this.setter.call(this.target, this.target, value, this);
- },
-
- getDelta: function() {
- this.lastValue = this.lastValue === undefined ? this.beginValue : this.lastValue;
- return getDelta(this.lastValue, this.currentValue);
- },
-
- play: function() {
- var lastStatus = this.status;
- this.status = "playing";
- switch (lastStatus) {
- case "ready":
- if (utils.isFunction(this.beginValue)) {
- this.beginValue = this.beginValue.call(this.target, this.target);
- }
- if (utils.isFunction(this.finishValue)) {
- this.finishValue = this.finishValue.call(this.target, this.target);
- }
- this.time = 0;
- this.setValue(this.beginValue);
- this.frame = frame.requestFrame(this.nextFrame.bind(this));
- break;
- case "finished":
- case "stoped":
- this.time = 0;
- this.frame = frame.requestFrame(this.nextFrame.bind(this));
- break;
- case "paused":
- this.frame.next();
- }
-
- this.fire("play", new TimelineEvent(this, "play", {
- lastStatus: lastStatus
- }));
- return this;
- },
-
- pause: function() {
- this.status = "paused";
-
- this.fire("pause", new TimelineEvent(this, "pause"));
- frame.releaseFrame(this.frame);
- return this;
- },
-
- stop: function() {
- this.status = "stoped";
- this.setValue(this.finishValue);
- this.rollbacking = false;
-
- this.fire("stop", new TimelineEvent(this, "stop"));
- frame.releaseFrame(this.frame);
- return this;
- },
-
- timeUp: function() {
- if (this.repeatOption) {
- this.time = 0;
- if (this.rollback) {
- if (this.rollbacking) {
- this.decreaseRepeat();
- this.rollbacking = false;
- } else {
- this.rollbacking = true;
-
- this.fire("rollback", new TimelineEvent(this, "rollback"));
- }
- } else {
- this.decreaseRepeat();
- }
- if (!this.repeatOption) {
- this.finish();
- } else {
-
- this.fire("repeat", new TimelineEvent(this, "repeat"));
- }
- } else {
- this.finish();
- }
- },
-
- finish: function() {
- this.setValue(this.finishValue);
- this.status = "finished";
-
- this.fire("finish", new TimelineEvent(this, "finish"));
- frame.releaseFrame(this.frame);
- },
-
- decreaseRepeat: function() {
- if (this.repeatOption !== true) {
- this.repeatOption--;
- }
- },
-
- repeat: function(repeat, rollback) {
- this.repeatOption = repeat;
- this.rollback = rollback;
- return this;
- }
- });
- Timeline.requestFrame = frame.requestFrame;
- Timeline.releaseFrame = frame.releaseFrame;
- return Timeline;
- }
- };
- _p[9] = {
- value: function(require) {
- var Animator = _p.r(0);
-
- var TranslateAnimator = _p.r(11).createClass("TranslateAnimator", {
- base: Animator,
-
- constructor: function(x, y) {
- this.callBase({
- x: 0,
- y: 0
- }, {
- x: x,
- y: y
- }, function(target, value, timeline) {
- var delta = timeline.getDelta();
- target.translate(delta.x, delta.y);
- });
- }
- });
- var Shape = _p.r(60);
- _p.r(11).extendClass(Shape, {
-
- fxTranslate: function(x, y, duration, easing, delay, callback) {
- return this.animate(new TranslateAnimator(x, y), duration, easing, delay, callback);
- }
- });
- return TranslateAnimator;
- }
- };
- _p[10] = {
- value: function() {
-
- var browser = function() {
- var agent = navigator.userAgent.toLowerCase(), opera = window.opera, browser;
-
- browser = {
-
- platform: function(navigator) {
- var _p = {
- win32: "Win",
- macintel: "Mac"
- };
- return _p[navigator.platform.toLowerCase()] || "Lux";
- }(navigator),
-
- lb: function(agent) {
- if (~agent.indexOf("lbbrowser")) {
- return ~agent.indexOf("msie") ? "ie" : "chrome";
- }
- return false;
- }(agent),
-
- sg: /se[\s\S]+metasr/.test(agent),
-
- bd: !!~agent.indexOf("bidubrowser"),
-
- edge: !!~agent.indexOf("edge"),
-
- chrome: false,
-
- opera: !!opera && opera.version,
-
- webkit: agent.indexOf(" applewebkit/") > -1,
-
- mac: agent.indexOf("macintosh") > -1
- };
-
- browser.ie = !browser.lb && /(msie\s|trident.*rv:)([\w.]+)/.test(agent);
- browser.gecko = navigator.product == "Gecko" && !browser.webkit && !browser.opera && !browser.ie;
- var version = 0;
-
- if (browser.ie) {
- version = (agent.match(/(msie\s|trident.*rv:)([\w.]+)/)[2] || 0) * 1;
- browser.ie11Compat = document.documentMode == 11;
- browser.ie9Compat = document.documentMode == 9;
- }
-
- if (browser.gecko) {
- var geckoRelease = agent.match(/rv:([\d\.]+)/);
- if (geckoRelease) {
- geckoRelease = geckoRelease[1].split(".");
- version = geckoRelease[0] * 1e4 + (geckoRelease[1] || 0) * 100 + (geckoRelease[2] || 0) * 1;
- }
- }
-
- if (/chrome\/(\d+\.\d)/i.test(agent) && !browser.bd && !browser.opera && !browser.lb && !browser.sg && !browser.edge) {
-
- browser.chrome = +RegExp["$1"];
- }
- if (/(\d+\.\d)?(?:\.\d)?\s+safari\/?(\d+\.\d+)?/i.test(agent) && !/chrome/i.test(agent)) {
- browser.safari = +(RegExp["$1"] || RegExp["$2"]);
- }
-
- if (browser.opera) version = parseFloat(opera.version());
-
- if (browser.webkit) version = parseFloat(agent.match(/ applewebkit\/(\d+)/)[1]);
-
-
-
- if (browser.bd) version = parseFloat(agent.match(/bidubrowser\/(\d+)/)[1]);
-
- if (browser.opera) version = parseFloat(agent.match(/opr\/(\d+)/)[1]);
-
- if (browser.edge) version = parseFloat(agent.match(/edge\/(\d+)/)[1]);
-
- browser.version = version;
- browser.isCompatible = !browser.mobile && (browser.ie && version >= 6 || browser.gecko && version >= 10801 || browser.opera && version >= 9.5 || browser.air && version >= 1 || browser.webkit && version >= 522 || false);
- return browser;
- }();
- return browser;
- }
- };
- _p[11] = {
- value: function(require, exports) {
-
- function Class() {}
- exports.Class = Class;
- Class.__KityClassName = "Class";
-
- Class.prototype.base = function(name) {
- var caller = arguments.callee.caller;
- var method = caller.__KityMethodClass.__KityBaseClass.prototype[name];
- return method.apply(this, Array.prototype.slice.call(arguments, 1));
- };
-
- Class.prototype.callBase = function() {
- var caller = arguments.callee.caller;
- var method = caller.__KityMethodClass.__KityBaseClass.prototype[caller.__KityMethodName];
- return method.apply(this, arguments);
- };
- Class.prototype.mixin = function(name) {
- var caller = arguments.callee.caller;
- var mixins = caller.__KityMethodClass.__KityMixins;
- if (!mixins) {
- return this;
- }
- var method = mixins[name];
- return method.apply(this, Array.prototype.slice.call(arguments, 1));
- };
- Class.prototype.callMixin = function() {
- var caller = arguments.callee.caller;
- var methodName = caller.__KityMethodName;
- var mixins = caller.__KityMethodClass.__KityMixins;
- if (!mixins) {
- return this;
- }
- var method = mixins[methodName];
- if (methodName == "constructor") {
- for (var i = 0, l = method.length; i < l; i++) {
- method[i].call(this);
- }
- return this;
- } else {
- return method.apply(this, arguments);
- }
- };
-
- Class.prototype.pipe = function(fn) {
- if (typeof fn == "function") {
- fn.call(this, this);
- }
- return this;
- };
-
- Class.prototype.getType = function() {
- return this.__KityClassName;
- };
-
- Class.prototype.getClass = function() {
- return this.constructor;
- };
-
-
- function checkBaseConstructorCall(targetClass, classname) {
- var code = targetClass.toString();
- if (!/this\.callBase/.test(code)) {
- throw new Error(classname + " : 类构造函数没有调用父类的构造函数!为了安全,请调用父类的构造函数");
- }
- }
- var KITY_INHERIT_FLAG = "__KITY_INHERIT_FLAG_" + +new Date();
- function inherit(constructor, BaseClass, classname) {
- var KityClass = eval("(function " + classname + "( __inherit__flag ) {" + "if( __inherit__flag != KITY_INHERIT_FLAG ) {" + "KityClass.__KityConstructor.apply(this, arguments);" + "}" + "this.__KityClassName = KityClass.__KityClassName;" + "})");
- KityClass.__KityConstructor = constructor;
- KityClass.prototype = new BaseClass(KITY_INHERIT_FLAG);
- for (var methodName in BaseClass.prototype) {
- if (BaseClass.prototype.hasOwnProperty(methodName) && methodName.indexOf("__Kity") !== 0) {
- KityClass.prototype[methodName] = BaseClass.prototype[methodName];
- }
- }
- KityClass.prototype.constructor = KityClass;
- return KityClass;
- }
- function mixin(NewClass, mixins) {
- if (false === mixins instanceof Array) {
- return NewClass;
- }
- var i, length = mixins.length, proto, method;
- NewClass.__KityMixins = {
- constructor: []
- };
- for (i = 0; i < length; i++) {
- proto = mixins[i].prototype;
- for (method in proto) {
- if (false === proto.hasOwnProperty(method) || method.indexOf("__Kity") === 0) {
- continue;
- }
- if (method === "constructor") {
-
- NewClass.__KityMixins.constructor.push(proto[method]);
- } else {
- NewClass.prototype[method] = NewClass.__KityMixins[method] = proto[method];
- }
- }
- }
- return NewClass;
- }
- function extend(BaseClass, extension) {
- if (extension.__KityClassName) {
- extension = extension.prototype;
- }
- for (var methodName in extension) {
- if (extension.hasOwnProperty(methodName) && methodName.indexOf("__Kity") && methodName != "constructor") {
- var method = BaseClass.prototype[methodName] = extension[methodName];
- method.__KityMethodClass = BaseClass;
- method.__KityMethodName = methodName;
- }
- }
- return BaseClass;
- }
-
- exports.createClass = function(classname, defines) {
- var constructor, NewClass, BaseClass;
- if (arguments.length === 1) {
- defines = arguments[0];
- classname = "AnonymousClass";
- }
- BaseClass = defines.base || Class;
- if (defines.hasOwnProperty("constructor")) {
- constructor = defines.constructor;
- if (BaseClass != Class) {
- checkBaseConstructorCall(constructor, classname);
- }
- } else {
- constructor = function() {
- this.callBase.apply(this, arguments);
- this.callMixin.apply(this, arguments);
- };
- }
- NewClass = inherit(constructor, BaseClass, classname);
- NewClass = mixin(NewClass, defines.mixins);
- NewClass.__KityClassName = constructor.__KityClassName = classname;
- NewClass.__KityBaseClass = constructor.__KityBaseClass = BaseClass;
- NewClass.__KityMethodName = constructor.__KityMethodName = "constructor";
- NewClass.__KityMethodClass = constructor.__KityMethodClass = NewClass;
- // 下面这些不需要拷贝到原型链上
- delete defines.mixins;
- delete defines.constructor;
- delete defines.base;
- NewClass = extend(NewClass, defines);
- return NewClass;
- };
- /**
- * @method kity.extendClass()
- * @grammar kity.extendClass(clazz, extension) => {Class}
- * @description 拓展一个已有的类
- *
- * @example
- *
- * ```js
- * kity.extendClass(Dog, {
- * spark: function() {
- * console.log('wao wao wao!');
- * }
- * });
- *
- * new Dog().spark(); // "wao wao wao!";
- * ```
- */
- exports.extendClass = extend;
- }
- };
- //src/core/utils.js
- _p[12] = {
- value: function() {
-
- var utils = {
-
- each: function each(obj, iterator, context) {
- if (obj === null) {
- return;
- }
- if (obj.length === +obj.length) {
- for (var i = 0, l = obj.length; i < l; i++) {
- if (iterator.call(context, obj[i], i, obj) === false) {
- return false;
- }
- }
- } else {
- for (var key in obj) {
- if (obj.hasOwnProperty(key)) {
- if (iterator.call(context, obj[key], key, obj) === false) {
- return false;
- }
- }
- }
- }
- },
-
- extend: function extend(t) {
- var a = arguments, notCover = this.isBoolean(a[a.length - 1]) ? a[a.length - 1] : false, len = this.isBoolean(a[a.length - 1]) ? a.length - 1 : a.length;
- for (var i = 1; i < len; i++) {
- var x = a[i];
- for (var k in x) {
- if (!notCover || !t.hasOwnProperty(k)) {
- t[k] = x[k];
- }
- }
- }
- return t;
- },
-
- deepExtend: function(t, s) {
- var a = arguments, notCover = this.isBoolean(a[a.length - 1]) ? a[a.length - 1] : false, len = this.isBoolean(a[a.length - 1]) ? a.length - 1 : a.length;
- for (var i = 1; i < len; i++) {
- var x = a[i];
- for (var k in x) {
- if (!notCover || !t.hasOwnProperty(k)) {
- if (this.isObject(t[k]) && this.isObject(x[k])) {
- this.deepExtend(t[k], x[k], notCover);
- } else {
- t[k] = x[k];
- }
- }
- }
- }
- return t;
- },
-
- clone: function clone(obj) {
- var cloned = {};
- for (var m in obj) {
- if (obj.hasOwnProperty(m)) {
- cloned[m] = obj[m];
- }
- }
- return cloned;
- },
-
- copy: function copy(obj) {
- if (typeof obj !== "object") return obj;
- if (typeof obj === "function") return null;
- return JSON.parse(JSON.stringify(obj));
- },
- queryPath: function(path, obj) {
- var arr = path.split(".");
- var i = 0, tmp = obj, l = arr.length;
- while (i < l) {
- if (arr[i] in tmp) {
- tmp = tmp[arr[i]];
- i++;
- if (i >= l || tmp === undefined) {
- return tmp;
- }
- } else {
- return undefined;
- }
- }
- },
- getValue: function(value, defaultValue) {
- return value !== undefined ? value : defaultValue;
- },
-
- flatten: function flatten(arr) {
- var result = [], length = arr.length, i;
- for (i = 0; i < length; i++) {
- if (arr[i] instanceof Array) {
- result = result.concat(utils.flatten(arr[i]));
- } else {
- result.push(arr[i]);
- }
- }
- return result;
- },
-
- paralle: function paralle(v1, v2, op) {
- var Class, field, index, name, value;
-
- if (v1 instanceof Array) {
- value = [];
- for (index = 0; index < v1.length; index++) {
- value.push(utils.paralle(v1[index], v2[index], op));
- }
- return value;
- }
-
- if (v1 instanceof Object) {
-
- Class = v1.getClass && v1.getClass();
- if (Class && Class.parse) {
- v1 = v1.valueOf();
- v2 = v2.valueOf();
- value = utils.paralle(v1, v2, op);
- value = Class.parse(value);
- } else {
- value = {};
- for (name in v1) {
- if (v1.hasOwnProperty(name) && v2.hasOwnProperty(name)) {
- value[name] = utils.paralle(v1[name], v2[name], op);
- }
- }
- }
- return value;
- }
-
- if (false === isNaN(parseFloat(v1))) {
- return op(v1, v2);
- }
- return value;
- },
-
- parallelize: function parallelize(op) {
- return function(v1, v2) {
- return utils.paralle(v1, v2, op);
- };
- }
- };
-
-
-
-
-
-
-
- utils.each([ "String", "Function", "Array", "Number", "RegExp", "Object", "Boolean" ], function(v) {
- utils["is" + v] = function typeCheck(obj) {
- return Object.prototype.toString.apply(obj) == "[object " + v + "]";
- };
- });
- return utils;
- }
- };
- _p[13] = {
- value: function(require, exports, module) {
- var Effect = _p.r(16), Utils = _p.r(12);
- var ColorMatrixEffect = _p.r(11).createClass("ColorMatrixEffect", {
- base: Effect,
- constructor: function(type, input) {
- this.callBase(Effect.NAME_COLOR_MATRIX);
- this.set("type", Utils.getValue(type, ColorMatrixEffect.TYPE_MATRIX));
- this.set("in", Utils.getValue(input, Effect.INPUT_SOURCE_GRAPHIC));
- }
- });
- Utils.extend(ColorMatrixEffect, {
-
- TYPE_MATRIX: "matrix",
- TYPE_SATURATE: "saturate",
- TYPE_HUE_ROTATE: "hueRotate",
- TYPE_LUMINANCE_TO_ALPHA: "luminanceToAlpha",
-
- MATRIX_ORIGINAL: "10000010000010000010".split("").join(" "),
- MATRIX_EMPTY: "00000000000000000000".split("").join(" ")
- });
- return ColorMatrixEffect;
- }
- };
- _p[14] = {
- value: function(require, exports, module) {
- var Effect = _p.r(16), Utils = _p.r(12);
- var CompositeEffect = _p.r(11).createClass("CompositeEffect", {
- base: Effect,
- constructor: function(operator, input, input2) {
- this.callBase(Effect.NAME_COMPOSITE);
- this.set("operator", Utils.getValue(operator, CompositeEffect.OPERATOR_OVER));
- if (input) {
- this.set("in", input);
- }
- if (input2) {
- this.set("in2", input2);
- }
- }
- });
- Utils.extend(CompositeEffect, {
-
- OPERATOR_OVER: "over",
- OPERATOR_IN: "in",
- OPERATOR_OUT: "out",
- OPERATOR_ATOP: "atop",
- OPERATOR_XOR: "xor",
- OPERATOR_ARITHMETIC: "arithmetic"
- });
- return CompositeEffect;
- }
- };
- _p[15] = {
- value: function(require, exports, module) {
- var Effect = _p.r(16), Utils = _p.r(12);
- var ConvolveMatrixEffect = _p.r(11).createClass("ConvolveMatrixEffect", {
- base: Effect,
- constructor: function(edgeMode, input) {
- this.callBase(Effect.NAME_CONVOLVE_MATRIX);
- this.set("edgeMode", Utils.getValue(edgeMode, ConvolveMatrixEffect.MODE_DUPLICATE));
- this.set("in", Utils.getValue(input, Effect.INPUT_SOURCE_GRAPHIC));
- }
- });
- Utils.extend(ConvolveMatrixEffect, {
- MODE_DUPLICATE: "duplicate",
- MODE_WRAP: "wrap",
- MODE_NONE: "none"
- });
- return ConvolveMatrixEffect;
- }
- };
- _p[16] = {
- value: function(require, exports, module) {
- var svg = _p.r(67), Effect = _p.r(11).createClass("Effect", {
- constructor: function(type) {
- this.node = svg.createNode(type);
- },
- getId: function() {
- return this.node.id;
- },
- setId: function(id) {
- this.node.id = id;
- return this;
- },
- set: function(key, value) {
- this.node.setAttribute(key, value);
- return this;
- },
- get: function(key) {
- return this.node.getAttribute(key);
- },
- getNode: function() {
- return this.node;
- },
-
- toString: function() {
- return this.node.getAttribute("result") || "";
- }
- });
- _p.r(12).extend(Effect, {
-
- NAME_GAUSSIAN_BLUR: "feGaussianBlur",
- NAME_OFFSET: "feOffset",
- NAME_COMPOSITE: "feComposite",
- NAME_COLOR_MATRIX: "feColorMatrix",
- NAME_CONVOLVE_MATRIX: "feConvolveMatrix",
-
- INPUT_SOURCE_GRAPHIC: "SourceGraphic",
- INPUT_SOURCE_ALPHA: "SourceAlpha",
- INPUT_BACKGROUND_IMAGE: "BackgroundImage",
- INPUT_BACKGROUND_ALPHA: "BackgroundAlpha",
- INPUT_FILL_PAINT: "FillPaint",
- INPUT_STROKE_PAINT: "StrokePaint"
- });
- return Effect;
- }
- };
- _p[17] = {
- value: function(require, exports, module) {
- var Effect = _p.r(16), Utils = _p.r(12);
- return _p.r(11).createClass("GaussianblurEffect", {
- base: Effect,
- constructor: function(stdDeviation, input) {
- this.callBase(Effect.NAME_GAUSSIAN_BLUR);
- this.set("stdDeviation", Utils.getValue(stdDeviation, 1));
- this.set("in", Utils.getValue(input, Effect.INPUT_SOURCE_GRAPHIC));
- }
- });
- }
- };
- _p[18] = {
- value: function(require, exports, module) {
- var Effect = _p.r(16), Utils = _p.r(12);
- return _p.r(11).createClass("OffsetEffect", {
- base: Effect,
- constructor: function(dx, dy, input) {
- this.callBase(Effect.NAME_OFFSET);
- this.set("dx", Utils.getValue(dx, 0));
- this.set("dy", Utils.getValue(dy, 0));
- this.set("in", Utils.getValue(input, Effect.INPUT_SOURCE_GRAPHIC));
- }
- });
- }
- };
- _p[19] = {
- value: function(require) {
- return _p.r(11).createClass("EffectContainer", {
- base: _p.r(29),
- addEffect: function(point, pos) {
- return this.addItem.apply(this, arguments);
- },
- prependEffect: function() {
- return this.prependItem.apply(this, arguments);
- },
- appendEffect: function() {
- return this.appendItem.apply(this, arguments);
- },
- removeEffect: function(pos) {
- return this.removeItem.apply(this, arguments);
- },
- addEffects: function() {
- return this.addItems.apply(this, arguments);
- },
- setEffects: function() {
- return this.setItems.apply(this, arguments);
- },
- getEffect: function() {
- return this.getItem.apply(this, arguments);
- },
- getEffects: function() {
- return this.getItems.apply(this, arguments);
- },
- getFirstEffect: function() {
- return this.getFirstItem.apply(this, arguments);
- },
- getLastEffect: function() {
- return this.getLastItem.apply(this, arguments);
- },
- handleAdd: function(effectItem, pos) {
- var count = this.getEffects().length, nextEffectItem = this.getItem(pos + 1);
-
- if (count === pos + 1) {
- this.node.appendChild(effectItem.getNode());
- return;
- }
- this.node.insertBefore(effectItem.getNode(), nextEffectItem.getNode());
- }
- });
- }
- };
- _p[20] = {
- value: function(require, exports, module) {
- var svg = _p.r(67);
- var Class = _p.r(11);
- var Filter = Class.createClass("Filter", {
- mixins: [ _p.r(19) ],
- constructor: function(x, y, width, height) {
- this.node = svg.createNode("filter");
- if (x !== undefined) {
- this.set("x", x);
- }
- if (y !== undefined) {
- this.set("y", y);
- }
- if (width !== undefined) {
- this.set("width", width);
- }
- if (height !== undefined) {
- this.set("height", height);
- }
- },
- getId: function() {
- return this.id;
- },
- setId: function(id) {
- this.node.id = id;
- return this;
- },
- set: function(key, value) {
- this.node.setAttribute(key, value);
- return this;
- },
- get: function(key) {
- return this.node.getAttribute(key);
- },
- getNode: function() {
- return this.node;
- }
- });
- var Shape = _p.r(60);
- Class.extendClass(Shape, {
- applyFilter: function(filter) {
- var filterId = filter.get("id");
- if (filterId) {
- this.node.setAttribute("filter", "url(#" + filterId + ")");
- }
- return this;
- }
- });
- return Filter;
- }
- };
- _p[21] = {
- value: function(require, exports, module) {
- var GaussianblurEffect = _p.r(17);
- return _p.r(11).createClass("GaussianblurFilter", {
- base: _p.r(20),
- constructor: function(stdDeviation) {
- this.callBase();
- this.addEffect(new GaussianblurEffect(stdDeviation));
- }
- });
- }
- };
- _p[22] = {
- value: function(require, exports, module) {
- var GaussianblurEffect = _p.r(17), Effect = _p.r(16), ColorMatrixEffect = _p.r(13), Color = _p.r(28), Utils = _p.r(12), CompositeEffect = _p.r(14), OffsetEffect = _p.r(18);
- return _p.r(11).createClass("ProjectionFilter", {
- base: _p.r(20),
- constructor: function(stdDeviation, dx, dy) {
- this.callBase();
- this.gaussianblurEffect = new GaussianblurEffect(stdDeviation, Effect.INPUT_SOURCE_ALPHA);
- this.gaussianblurEffect.set("result", "gaussianblur");
- this.addEffect(this.gaussianblurEffect);
- this.offsetEffect = new OffsetEffect(dx, dy, this.gaussianblurEffect);
- this.offsetEffect.set("result", "offsetBlur");
- this.addEffect(this.offsetEffect);
- this.colorMatrixEffect = new ColorMatrixEffect(ColorMatrixEffect.TYPE_MATRIX, this.offsetEffect);
- this.colorMatrixEffect.set("values", ColorMatrixEffect.MATRIX_ORIGINAL);
- this.colorMatrixEffect.set("result", "colorOffsetBlur");
- this.addEffect(this.colorMatrixEffect);
- this.compositeEffect = new CompositeEffect(CompositeEffect.OPERATOR_OVER, Effect.INPUT_SOURCE_GRAPHIC, this.colorMatrixEffect);
- this.addEffect(this.compositeEffect);
- },
-
- setColor: function(color) {
- var matrix = null, originMatrix = null, colorValue = [];
- if (Utils.isString(color)) {
- color = Color.parse(color);
- }
- if (!color) {
- return this;
- }
- matrix = ColorMatrixEffect.MATRIX_EMPTY.split(" ");
- colorValue.push(color.get("r"));
- colorValue.push(color.get("g"));
- colorValue.push(color.get("b"));
-
- for (var i = 0, len = colorValue.length; i < len; i++) {
- matrix[i * 5 + 3] = colorValue[i] / 255;
- }
-
- matrix[18] = color.get("a");
- this.colorMatrixEffect.set("values", matrix.join(" "));
- return this;
- },
-
- setOpacity: function(opacity) {
- var matrix = this.colorMatrixEffect.get("values").split(" ");
- matrix[18] = opacity;
- this.colorMatrixEffect.set("values", matrix.join(" "));
- return this;
- },
-
- setOffset: function(dx, dy) {
- this.setOffsetX(dx);
- this.setOffsetY(dy);
- },
- setOffsetX: function(dx) {
- this.offsetEffect.set("dx", dx);
- },
- setOffsetY: function(dy) {
- this.offsetEffect.set("dy", dy);
- },
- setDeviation: function(deviation) {
- this.gaussianblurEffect.set("stdDeviation", deviation);
- }
- });
- }
- };
- _p[23] = {
- value: function(require, exports, module) {
-
- return _p.r(11).createClass("Bezier", {
- mixins: [ _p.r(51) ],
- base: _p.r(46),
-
- constructor: function(bezierPoints) {
- this.callBase();
- bezierPoints = bezierPoints || [];
- this.changeable = true;
- this.setBezierPoints(bezierPoints);
- },
-
- getBezierPoints: function() {
- return this.getPoints();
- },
-
- setBezierPoints: function(bezierPoints) {
- return this.setPoints(bezierPoints);
- },
-
- onContainerChanged: function() {
- if (this.changeable) {
- this.update();
- }
- },
- update: function() {
- var drawer = null, bezierPoints = this.getBezierPoints();
-
- if (bezierPoints.length < 2) {
- return;
- }
- drawer = this.getDrawer();
- drawer.clear();
- var vertex = bezierPoints[0].getVertex(), forward = null, backward = null;
- drawer.moveTo(vertex.x, vertex.y);
- for (var i = 1, len = bezierPoints.length; i < len; i++) {
- vertex = bezierPoints[i].getVertex();
- backward = bezierPoints[i].getBackward();
- forward = bezierPoints[i - 1].getForward();
- drawer.bezierTo(forward.x, forward.y, backward.x, backward.y, vertex.x, vertex.y);
- }
- return this;
- }
- });
- }
- };
- _p[24] = {
- value: function(require, exports, module) {
- var ShapePoint = _p.r(63);
- var Vector = _p.r(73);
-
- var BezierPoint = _p.r(11).createClass("BezierPoint", {
-
- constructor: function(x, y, isSmooth) {
-
- this.vertex = new ShapePoint(x, y);
-
- this.forward = new ShapePoint(x, y);
- this.backward = new ShapePoint(x, y);
-
- this.setSmooth(isSmooth === undefined || isSmooth);
- this.setSymReflaction(true);
- },
-
- clone: function() {
- var newPoint = new BezierPoint(), tmp = null;
- tmp = this.getVertex();
- newPoint.setVertex(tmp.x, tmp.y);
- tmp = this.getForward();
- newPoint.setForward(tmp.x, tmp.y);
- tmp = this.getBackward();
- newPoint.setBackward(tmp.x, tmp.y);
- newPoint.setSymReflaction(this.isSymReflaction);
- newPoint.setSmooth(this.isSmooth());
- return newPoint;
- },
-
- setVertex: function(x, y) {
- this.vertex.setPoint(x, y);
- this.update();
- return this;
- },
-
- moveTo: function(x, y) {
- var oldForward = this.forward.getPoint(), oldBackward = this.backward.getPoint(), oldVertex = this.vertex.getPoint(),
- distance = {
- left: x - oldVertex.x,
- top: y - oldVertex.y
- };
-
- this.forward.setPoint(oldForward.x + distance.left, oldForward.y + distance.top);
- this.backward.setPoint(oldBackward.x + distance.left, oldBackward.y + distance.top);
- this.vertex.setPoint(x, y);
- this.update();
- },
-
- setForward: function(x, y) {
- this.forward.setPoint(x, y);
-
- if (this.smooth) {
- this.updateAnother(this.forward, this.backward);
- }
- this.update();
- this.lastControlPointSet = this.forward;
- return this;
- },
-
- setBackward: function(x, y) {
- this.backward.setPoint(x, y);
-
- if (this.smooth) {
- this.updateAnother(this.backward, this.forward);
- }
- this.update();
- this.lastControlPointSet = this.backward;
- return this;
- },
-
- setSymReflaction: function(value) {
- this.symReflaction = value;
- if (this.smooth) this.setSmooth(true);
- return this;
- },
-
- isSymReflaction: function() {
- return this.symReflaction;
- },
-
- updateAnother: function(p, q) {
- var v = this.getVertex(), pv = Vector.fromPoints(p.getPoint(), v), vq = Vector.fromPoints(v, q.getPoint());
- vq = pv.normalize(this.isSymReflaction() ? pv.length() : vq.length());
- q.setPoint(v.x + vq.x, v.y + vq.y);
- return this;
- },
-
- setSmooth: function(isSmooth) {
- var lc;
- this.smooth = !!isSmooth;
- if (this.smooth && (lc = this.lastControlPointSet)) {
- this.updateAnother(lc, lc == this.forward ? this.backward : this.forward);
- }
- return this;
- },
-
- isSmooth: function() {
- return this.smooth;
- },
-
- getVertex: function() {
- return this.vertex.getPoint();
- },
-
- getForward: function() {
- return this.forward.getPoint();
- },
-
- getBackward: function() {
- return this.backward.getPoint();
- },
-
- update: function() {
- if (!this.container) {
- return this;
- }
-
- if (this.container.update) this.container.update(this);
- }
- });
- return BezierPoint;
- }
- };
- _p[25] = {
- value: function(require, exports, module) {
-
- var Box = _p.r(11).createClass("Box", {
-
- constructor: function(x, y, width, height) {
- var box = arguments[0];
- if (box && typeof box === "object") {
- x = box.x;
- y = box.y;
- width = box.width;
- height = box.height;
- }
- if (width < 0) {
- x -= width = -width;
- }
- if (height < 0) {
- y -= height = -height;
- }
-
- this.x = x || 0;
-
- this.y = y || 0;
-
- this.width = width || 0;
-
- this.height = height || 0;
-
- this.left = this.x;
-
- this.right = this.x + this.width;
-
- this.top = this.y;
-
- this.bottom = this.y + this.height;
-
- this.cx = this.x + this.width / 2;
-
- this.cy = this.y + this.height / 2;
- },
-
- getRangeX: function() {
- return [ this.left, this.right ];
- },
-
- getRangeY: function() {
- return [ this.top, this.bottom ];
- },
-
- merge: function(another) {
- if (this.isEmpty()) {
- return new Box(another.x, another.y, another.width, another.height);
- }
- var left = Math.min(this.left, another.left), right = Math.max(this.right, another.right), top = Math.min(this.top, another.top), bottom = Math.max(this.bottom, another.bottom);
- return new Box(left, top, right - left, bottom - top);
- },
-
- intersect: function(another) {
- if (!another instanceof Box) {
- another = new Box(another);
- }
- var left = Math.max(this.left, another.left), right = Math.min(this.right, another.right), top = Math.max(this.top, another.top), bottom = Math.min(this.bottom, another.bottom);
- if (left > right || top > bottom) return new Box();
- return new Box(left, top, right - left, bottom - top);
- },
-
- expand: function(top, right, bottom, left) {
- if (arguments.length < 1) {
- return new Box(this);
- }
- if (arguments.length < 2) {
- right = top;
- }
- if (arguments.length < 3) {
- bottom = top;
- }
- if (arguments.length < 4) {
- left = right;
- }
- var x = this.left - left, y = this.top - top, width = this.width + right, height = this.height + top;
- return new Box(x, y, width, height);
- },
-
- valueOf: function() {
- return [ this.x, this.y, this.width, this.height ];
- },
-
- toString: function() {
- return this.valueOf().join(" ");
- },
-
- isEmpty: function() {
- return !this.width || !this.height;
- }
- });
-
- Box.parse = function(any) {
- if (typeof any == "string") {
- return Box.parse(any.split(/[\s,]+/).map(parseFloat));
- }
- if (any instanceof Array) {
- return new Box(any[0], any[1], any[2], any[3]);
- }
- if ("x" in any) return new Box(any);
- return null;
- };
- return Box;
- }
- };
- _p[26] = {
- value: function(require, exports, module) {
-
- return _p.r(11).createClass("Circle", {
- base: _p.r(32),
-
- constructor: function(radius, cx, cy) {
- this.callBase(radius, radius, cx, cy);
- },
-
- getRadius: function() {
- return this.getRadiusX();
- },
-
- setRadius: function(radius) {
- return this.callBase(radius, radius);
- }
- });
- }
- };
- _p[27] = {
- value: function(require, exports, module) {
- var Class = _p.r(11);
- var Shape = _p.r(60);
-
- var Clip = Class.createClass("Clip", {
- base: Shape,
- mixins: [ _p.r(61) ],
-
- constructor: function(paper) {
- this.callBase("clipPath", paper);
- },
-
- clip: function(shape) {
- shape.getNode().setAttribute("clip-path", this);
- return this;
- }
- });
- Class.extendClass(Shape, {
-
- clipWith: function(clip) {
- if (clip instanceof Shape) {
- clip = new Clip(clip.getPaper()).addShape(clip);
- }
- clip.clip(this);
- return this;
- }
- });
- return Clip;
- }
- };
- _p[28] = {
- value: function(require, exports, module) {
- var Utils = _p.r(12), StandardColor = _p.r(64), ColorUtils = {},
- Color = _p.r(11).createClass("Color", {
-
- constructor: function() {
- var colorValue = null;
-
- if (typeof arguments[0] === "string") {
- colorValue = ColorUtils.parseToValue(arguments[0]);
-
- if (colorValue === null) {
- colorValue = {
- r: 0,
- g: 0,
- b: 0,
- h: 0,
- s: 0,
- l: 0,
- a: 1
- };
- }
- } else {
- colorValue = {
- r: arguments[0] | 0,
- g: arguments[1] | 0,
- b: arguments[2] | 0,
-
- a: arguments[3] === undefined ? 1 : parseFloat(arguments[3])
- };
- colorValue = ColorUtils.overflowFormat(colorValue);
-
- colorValue = Utils.extend(colorValue, ColorUtils.rgbValueToHslValue(colorValue));
- }
- this._color = colorValue;
- },
-
- set: function(name, value) {
- var values = null;
-
- if (!Color._MAX_VALUE[name]) {
- throw new Error("Color set(): Illegal parameter");
- }
- if (name !== "a") {
- value = Math.floor(value);
- }
- if (name == "h") {
- value = (value + 360) % 360;
- }
- this._color[name] = Math.max(Color._MIN_VALUE[name], Math.min(Color._MAX_VALUE[name], value));
- if ("rgb".indexOf(name) !== -1) {
- this._color = Utils.extend(this._color, ColorUtils.rgbValueToHslValue(this._color));
- } else if ("hsl".indexOf(name) !== -1) {
- this._color = Utils.extend(this._color, ColorUtils.hslValueToRGBValue(this._color));
- }
- return this;
- },
-
- inc: function(name, value) {
- value = this.get(name) + value;
- if (name == "h") {
- value = (value + 360) % 360;
- } else {
- value = Math.min(Color._MAX_VALUE[name], value);
- value = Math.max(Color._MIN_VALUE[name], value);
- }
- return this.clone().set(name, value);
- },
-
- dec: function(name, value) {
- return this.inc(name, -value);
- },
-
- clone: function() {
- return new Color(this.toRGBA());
- },
-
- get: function(name) {
- if (!Color._MAX_VALUE[name]) {
- return null;
- }
- return this._color[name];
- },
- getValues: function() {
- return Utils.clone(this._color);
- },
-
- valueOf: function() {
- return this.getValues();
- },
-
- toRGB: function() {
- return ColorUtils.toString(this._color, "rgb");
- },
-
- toRGBA: function() {
- return ColorUtils.toString(this._color, "rgba");
- },
-
- toHEX: function() {
- return ColorUtils.toString(this._color, "hex");
- },
-
- toHSL: function() {
- return ColorUtils.toString(this._color, "hsl");
- },
-
- toHSLA: function() {
- return ColorUtils.toString(this._color, "hsla");
- },
-
- toString: function() {
- if (this._color.a === 1) {
- return this.toRGB();
- }
- return this.toRGBA();
- }
- });
-
- Utils.extend(Color, {
-
- _MAX_VALUE: {
- r: 255,
- g: 255,
- b: 255,
- h: 360,
- s: 100,
- l: 100,
- a: 1
- },
-
- _MIN_VALUE: {
- r: 0,
- g: 0,
- b: 0,
- h: 0,
- s: 0,
- l: 0,
- a: 0
- },
-
- R: "r",
- G: "g",
- B: "b",
- H: "h",
- S: "s",
- L: "l",
- A: "a",
-
- parse: function(valStr) {
- var rgbValue;
- if (Utils.isString(valStr)) {
- rgbValue = ColorUtils.parseToValue(valStr);
- }
- if (Utils.isObject(valStr) && "r" in valStr) {
- rgbValue = valStr;
- }
-
- if (rgbValue === null) {
- return new Color();
- }
- return new Color(rgbValue.r, rgbValue.g, rgbValue.b, rgbValue.a);
- },
-
- createHSL: function(h, s, l) {
- return Color.createHSLA(h, s, l, 1);
- },
-
- createHSLA: function(h, s, l, a) {
- var colorValue = null;
- s += "%";
- l += "%";
- colorValue = [ "hsla(" + h, s, l, a + ")" ];
- return Color.parse(colorValue.join(", "));
- },
-
- createRGB: function(r, g, b) {
- return Color.createRGBA(r, g, b, 1);
- },
-
- createRGBA: function(r, g, b, a) {
- return new Color(r, g, b, a);
- }
- });
-
- Utils.extend(ColorUtils, {
- parseToValue: function(valStr) {
- var rgbaValue = {};
-
- valStr = StandardColor.EXTEND_STANDARD[valStr] || StandardColor.COLOR_STANDARD[valStr] || valStr;
-
-
- if (/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(valStr)) {
- rgbaValue = ColorUtils.hexToValue(valStr);
- } else if (/^(rgba?)/i.test(valStr)) {
- rgbaValue = ColorUtils.rgbaToValue(valStr);
- } else if (/^(hsla?)/i.test(valStr)) {
- rgbaValue = ColorUtils.hslaToValue(valStr);
- } else {
- return null;
- }
- return ColorUtils.overflowFormat(rgbaValue);
- },
- hexToValue: function(hexStr) {
- var result = {}, keys = [ "r", "g", "b" ];
- if (/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(hexStr)) {
- hexStr = RegExp.$1.split("");
- Utils.each(keys, function(key, index) {
- if (hexStr.length === 3) {
- result[key] = ColorUtils.toNumber(hexStr[index] + hexStr[index]);
- } else {
- result[key] = ColorUtils.toNumber(hexStr[index * 2] + hexStr[index * 2 + 1]);
- }
- });
-
- result = Utils.extend(result, ColorUtils.rgbValueToHslValue(result));
- result.a = 1;
- return result;
- }
- return null;
- },
- rgbaToValue: function(rgbaStr) {
- var result = {}, hasAlpha = false, keys = [ "r", "g", "b" ];
- if (/^(rgba?)/i.test(rgbaStr)) {
- hasAlpha = RegExp.$1.length === 4;
- rgbaStr = rgbaStr.replace(/^rgba?/i, "").replace(/\s+/g, "").replace(/[^0-9,.]/g, "").split(",");
- Utils.each(keys, function(key, index) {
- result[key] = rgbaStr[index] | 0;
- });
-
- result = Utils.extend(result, ColorUtils.rgbValueToHslValue(result));
- result.a = hasAlpha ? parseFloat(rgbaStr[3]) : 1;
- return result;
- }
- return null;
- },
- hslaToValue: function(hslaStr) {
- var result = {}, hasAlpha = false;
- if (/^(hsla?)/i.test(hslaStr)) {
- hasAlpha = RegExp.$1.length === 4;
- hslaStr = hslaStr.replace(/^hsla?/i, "").replace(/\s+/g, "").replace(/[^0-9,.]/g, "").split(",");
-
- result.h = hslaStr[0] | 0;
- result.s = hslaStr[1] | 0;
- result.l = hslaStr[2] | 0;
-
- result = Utils.extend(result, ColorUtils.hslValueToRGBValue(result));
-
- result = ColorUtils.hslValueToRGBValue(result);
- result.a = hasAlpha ? parseFloat(hslaStr[3]) : 1;
- return result;
- }
- return null;
- },
-
- hslValueToRGBValue: function(hslValue) {
- function trans(v1, v2, vH) {
- if (vH < 0) {
- vH += 1;
- } else if (vH > 1) {
- vH -= 1;
- }
- if (6 * vH < 1) {
- return v1 + (v2 - v1) * 6 * vH;
- } else if (2 * vH < 1) {
- return v2;
- } else if (3 * vH < 2) {
- return v1 + (v2 - v1) * ((2 / 3 - vH) * 6);
- }
- return v1;
- }
- var q = null, p = null, result = {};
- hslValue = Utils.extend({}, hslValue);
- hslValue.h = hslValue.h / 360;
- hslValue.s = hslValue.s / 100;
- hslValue.l = hslValue.l / 100;
-
- if (hslValue.s === 0) {
- result.r = result.g = result.b = hslValue.l;
- } else {
- if (hslValue.l < .5) {
- q = hslValue.l * (1 + hslValue.s);
- } else {
- q = hslValue.l + hslValue.s - hslValue.l * hslValue.s;
- }
- p = 2 * hslValue.l - q;
- result.r = trans(p, q, hslValue.h + 1 / 3);
- result.g = trans(p, q, hslValue.h);
- result.b = trans(p, q, hslValue.h - 1 / 3);
- }
- result.r = Math.min(Math.round(result.r * 255), 255);
- result.g = Math.min(Math.round(result.g * 255), 255);
- result.b = Math.min(Math.round(result.b * 255), 255);
- return result;
- },
-
- rgbValueToHslValue: function(rgbValue) {
- var max = null, min = null, result = {};
- rgbValue = Utils.extend({}, rgbValue);
- rgbValue.r = rgbValue.r / 255;
- rgbValue.g = rgbValue.g / 255;
- rgbValue.b = rgbValue.b / 255;
- max = Math.max(rgbValue.r, rgbValue.g, rgbValue.b);
- min = Math.min(rgbValue.r, rgbValue.g, rgbValue.b);
-
- if (max === min) {
- result.h = 0;
- } else if (max === rgbValue.r) {
- if (rgbValue.g >= rgbValue.b) {
- result.h = 60 * (rgbValue.g - rgbValue.b) / (max - min);
- } else {
- result.h = 60 * (rgbValue.g - rgbValue.b) / (max - min) + 360;
- }
- } else if (max === rgbValue.g) {
- result.h = 60 * (rgbValue.b - rgbValue.r) / (max - min) + 120;
- } else if (max === rgbValue.b) {
- result.h = 60 * (rgbValue.r - rgbValue.g) / (max - min) + 240;
- }
-
- result.l = (max + min) / 2;
-
- if (result.l === 0 || max === min) {
- result.s = 0;
- } else if (result.l > 0 && result.l <= .5) {
- result.s = (max - min) / (max + min);
- } else {
- result.s = (max - min) / (2 - max - min);
- }
-
- result.h = Math.round(result.h);
- result.s = Math.round(result.s * 100);
- result.l = Math.round(result.l * 100);
- return result;
- },
- toString: function(colorValue, type) {
- var vals = [];
- colorValue = Utils.extend({}, colorValue);
- if (type.indexOf("hsl") !== -1) {
- colorValue.s += "%";
- colorValue.l += "%";
- }
- if (type !== "hex") {
- Utils.each(type.split(""), function(key) {
- vals.push(colorValue[key]);
- });
- return (type + "(" + vals.join(", ") + ")").toLowerCase();
- } else {
- vals.push(ColorUtils.toHexValue(+colorValue.r));
- vals.push(ColorUtils.toHexValue(+colorValue.g));
- vals.push(ColorUtils.toHexValue(+colorValue.b));
- return ("#" + vals.join("")).toLowerCase();
- }
- },
-
- toNumber: function(value) {
- return Number("0x" + value) | 0;
- },
- toHexValue: function(value) {
- var result = value.toString(16);
- return result.length === 1 ? "0" + result : result;
- },
-
- overflowFormat: function(value) {
- var tmpValue = Utils.extend({}, value), keys = "rgba";
- Utils.each(keys.split(""), function(key) {
- if (!tmpValue.hasOwnProperty(key)) {
- return;
- }
-
- tmpValue[key] = Math.min(Color._MAX_VALUE[key], tmpValue[key]);
-
- tmpValue[key] = Math.max(Color._MIN_VALUE[key], tmpValue[key]);
- });
- return tmpValue;
- }
- });
- return Color;
- }
- };
- _p[29] = {
- value: function(require, exports, module) {
- function itemRemove() {
- this.container.removeItem(this);
- return this;
- }
- return _p.r(11).createClass("Container", {
- getItems: function() {
- return this.items || (this.items = []);
- },
- getItem: function(index) {
- return this.getItems()[index];
- },
- getFirstItem: function() {
- return this.getItem(0);
- },
- getLastItem: function() {
- return this.getItem(this.getItems().length - 1);
- },
- indexOf: function(item) {
- return this.getItems().indexOf(item);
- },
- eachItem: function(fn) {
- var items = this.getItems(), length = items.length, i;
- for (i = 0; i < length; i++) {
- fn.call(this, i, items[i]);
- }
- return this;
- },
- addItem: function(item, pos, noEvent) {
- var items = this.getItems(), length = items.length;
- if (~items.indexOf(item)) {
- return this;
- }
- if (!(pos >= 0 && pos < length)) {
- pos = length;
- }
- items.splice(pos, 0, item);
- if (typeof item === "object") {
- item.container = this;
- item.remove = itemRemove;
- }
- this.handleAdd(item, pos);
- if (!noEvent) {
- this.onContainerChanged("add", [ item ]);
- }
- return this;
- },
- addItems: function(items) {
- for (var i = 0, l = items.length; i < l; i++) {
- this.addItem(items[i], -1, true);
- }
- this.onContainerChanged("add", items);
- return this;
- },
- setItems: function(items) {
- return this.clear().addItems(items);
- },
- appendItem: function(item) {
- return this.addItem(item);
- },
- prependItem: function(item) {
- return this.addItem(item, 0);
- },
- removeItem: function(pos, noEvent) {
- if (typeof pos !== "number") {
- return this.removeItem(this.indexOf(pos));
- }
- var items = this.getItems(), length = items.length, item = items[pos];
- if (item === undefined) {
- return this;
- }
- items.splice(pos, 1);
- if (item.container) {
- delete item.container;
- }
- if (item.remove) {
- delete item.remove;
- }
- this.handleRemove(item, pos);
- if (!noEvent) {
- this.onContainerChanged("remove", [ item ]);
- }
- return this;
- },
- clear: function() {
- var removed = [];
- var item;
- while (item = this.getFirstItem()) {
- removed.push(item);
- this.removeItem(0, true);
- }
- this.onContainerChanged("remove", removed);
- return this;
- },
- onContainerChanged: function(type, items) {},
- handleAdd: function(item, index) {},
- handleRemove: function(item, index) {}
- });
- }
- };
- _p[30] = {
- value: function(require, exports, module) {
- var Utils = _p.r(12), CurveUtil = {
-
- getCurvePanLines: function(points, smoothFactor) {
-
- var centerPoints = CurveUtil.getCenterPoints(points),
- panLines = CurveUtil.getPanLine(points.length, centerPoints);
-
- return CurveUtil.getMovedPanLines(points, panLines, smoothFactor);
- },
-
- getCenterPoints: function(points) {
- var centerPoints = {}, key = null;
- for (var i = 0, j = 0, len = points.length; i < len; i++) {
-
- j = i === len - 1 ? 0 : i + 1;
- key = i + "," + j;
-
- centerPoints[key] = {
- x: (points[i].x + points[j].y) / 2,
- y: (points[i].x + points[j].y) / 2
- };
- }
- return centerPoints;
- },
-
- getPanLine: function(length, points) {
- var result = {},
- pointIndex = null;
- for (var i = 0, j; i < length; i++) {
- var point1 = null, point2 = null;
-
- j = (i + 1) % length;
-
- pointIndex = j;
- point1 = points[i + "," + j];
-
- i = j;
- j = (i + 1) % length;
- point2 = points[i + "," + j];
- result[pointIndex] = {
- points: [ {
- x: point1.x,
- y: point1.y
- }, {
- x: point2.x,
- y: point2.y
- } ],
- center: {
- x: (point1.x + point2.x) / 2,
- y: (point1.y + point2.y) / 2
- }
- };
-
- i = (pointIndex + length - 1) % length;
- }
- return result;
- },
-
- getMovedPanLines: function(points, panLines, smoothFactor) {
- var result = {};
- Utils.each(points, function(point, index) {
-
- var currentPanLine = panLines[index],
- center = currentPanLine.center,
- distance = {
- x: center.x - point.x,
- y: center.y - point.y
- };
- var currentResult = result[index] = {
- points: [],
- center: {
- x: point.x,
- y: point.y
- }
- };
-
- Utils.each(currentPanLine.points, function(controlPoint, index) {
- var moved = {
- x: controlPoint.x - distance.x,
- y: controlPoint.y - distance.y
- };
- var vertex = currentResult.center;
- var dx = moved.x - vertex.x;
- var dy = moved.y - vertex.y;
- moved.x = vertex.x + smoothFactor * dx;
- moved.y = vertex.y + smoothFactor * dy;
- currentResult.points.push(moved);
- });
- });
- return result;
- }
- };
- return _p.r(11).createClass("Curve", {
- base: _p.r(46),
- mixins: [ _p.r(51) ],
- constructor: function(points, isColse) {
- this.callBase();
- this.setPoints(points || []);
- this.closeState = !!isColse;
- this.changeable = true;
- this.smoothFactor = 1;
- this.update();
- },
-
- onContainerChanged: function() {
- if (this.changeable) {
- this.update();
- }
- },
- setSmoothFactor: function(factor) {
- this.smoothFactor = factor < 0 ? 0 : factor;
- this.update();
- return this;
- },
- getSmoothFactor: function() {
- return this.smoothFactor;
- },
- update: function() {
- var points = this.getPoints(), withControlPoints = null, drawer = this.getDrawer(), curPoint = null, curControlPoint = null, prevControlPoint = null;
- drawer.clear();
- if (points.length === 0) {
- return this;
- } else {
- drawer.moveTo(points[0]);
- }
- if (points.length === 1) {
- return this;
- }
- if (points.length === 2) {
- drawer.lineTo(points[1]);
- return this;
- }
-
- withControlPoints = CurveUtil.getCurvePanLines(points, this.getSmoothFactor());
- for (var i = 1, len = points.length; i < len; i++) {
-
- curPoint = withControlPoints[i].center;
-
- if (this.closeState || i != len - 1) {
- curControlPoint = withControlPoints[i].points[0];
- } else {
-
- curControlPoint = withControlPoints[i].center;
- }
- if (this.closeState || i != 1) {
- prevControlPoint = withControlPoints[i - 1].points[1];
- } else {
-
- prevControlPoint = withControlPoints[i - 1].center;
- }
- drawer.bezierTo(prevControlPoint.x, prevControlPoint.y, curControlPoint.x, curControlPoint.y, curPoint.x, curPoint.y);
- }
-
- if (this.closeState) {
- curPoint = withControlPoints[0].center;
- curControlPoint = withControlPoints[0].points[0];
- prevControlPoint = withControlPoints[points.length - 1].points[1];
- drawer.bezierTo(prevControlPoint.x, prevControlPoint.y, curControlPoint.x, curControlPoint.y, curPoint.x, curPoint.y);
- }
- return this;
- },
- close: function() {
- this.closeState = true;
- return this.update();
- },
- open: function() {
- this.closeState = false;
- return this.update();
- },
- isClose: function() {
- return !!this.closeState;
- }
- });
- }
- };
- _p[31] = {
- value: function(require, exports, module) {
- return _p.r(11).createClass("Data", {
- constructor: function() {
- this._data = {};
- },
- setData: function(name, value) {
- this._data[name] = value;
- return this;
- },
- getData: function(name) {
- return this._data[name];
- },
- removeData: function(name) {
- delete this._data[name];
- return this;
- }
- });
- }
- };
- _p[32] = {
- value: function(require, exports, module) {
- var Utils = _p.r(12), Point = _p.r(50);
- return _p.r(11).createClass("Ellipse", {
- base: _p.r(46),
- constructor: function(rx, ry, cx, cy) {
- this.callBase();
- this.rx = rx || 0;
- this.ry = ry || 0;
- this.cx = cx || 0;
- this.cy = cy || 0;
- this.update();
- },
- update: function() {
- var rx = this.rx, ry = this.ry, x1 = this.cx + rx, x2 = this.cx - rx, y = this.cy;
- var drawer = this.getDrawer();
- drawer.clear();
- drawer.moveTo(x1, y);
- drawer.arcTo(rx, ry, 0, 1, 1, x2, y);
- drawer.arcTo(rx, ry, 0, 1, 1, x1, y);
- return this;
- },
- getRadius: function() {
- return {
- x: this.rx,
- y: this.ry
- };
- },
- getRadiusX: function() {
- return this.rx;
- },
- getRadiusY: function() {
- return this.ry;
- },
- getCenter: function() {
- return new Point(this.cx, this.cy);
- },
- getCenterX: function() {
- return this.cx;
- },
- getCenterY: function() {
- return this.cy;
- },
- setRadius: function(rx, ry) {
- this.rx = rx;
- this.ry = ry;
- return this.update();
- },
- setRadiusX: function(rx) {
- this.rx = rx;
- return this.update();
- },
- setRadiusY: function(ry) {
- this.ry = ry;
- return this.update();
- },
- setCenter: function(cx, cy) {
- if (arguments.length == 1) {
- var p = Point.parse(arguments[0]);
- cx = p.x;
- cy = p.y;
- }
- this.cx = cx;
- this.cy = cy;
- return this.update();
- },
- setCenterX: function(cx) {
- this.cx = cx;
- return this.update();
- },
- setCenterY: function(cy) {
- this.cy = cy;
- return this.update();
- }
- });
- }
- };
- _p[33] = {
- value: function(require, exports, module) {
-
- (function() {
- function CustomEvent(event, params) {
- params = params || {
- bubbles: false,
- cancelable: false,
- detail: undefined
- };
- var evt = document.createEvent("CustomEvent");
- evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
- return evt;
- }
- CustomEvent.prototype = window.Event.prototype;
- window.CustomEvent = CustomEvent;
- })();
- var Utils = _p.r(12), ShapeEvent = _p.r(62);
-
- var INNER_HANDLER_CACHE = {},
- USER_HANDLER_CACHE = {}, guid = 0;
-
- function _addEvent(type, handler, isOnce) {
- isOnce = !!isOnce;
- if (Utils.isString(type)) {
- type = type.match(/\S+/g);
- }
- Utils.each(type, function(currentType) {
- listen.call(this, this.node, currentType, handler, isOnce);
- }, this);
- return this;
- }
-
- function _removeEvent(type, handler) {
- var userHandlerList = null, eventId = this._EVNET_UID, isRemoveAll = handler === undefined;
- userHandlerList = USER_HANDLER_CACHE[eventId][type];
-
- if (!isRemoveAll) {
- isRemoveAll = true;
- Utils.each(userHandlerList, function removeKityEvent(fn, index) {
- if (fn === handler) {
-
- delete userHandlerList[index];
- } else {
- isRemoveAll = false;
- }
- });
- }
-
- if (isRemoveAll) {
- deleteDomEvent(this.node, type, INNER_HANDLER_CACHE[eventId][type]);
- delete USER_HANDLER_CACHE[eventId][type];
- delete INNER_HANDLER_CACHE[eventId][type];
- }
- return this;
- }
-
- function listen(node, type, handler, isOnce) {
- var eid = this._EVNET_UID, targetObject = this;
-
- if (!INNER_HANDLER_CACHE[eid]) {
- INNER_HANDLER_CACHE[eid] = {};
- }
- if (!INNER_HANDLER_CACHE[eid][type]) {
-
- INNER_HANDLER_CACHE[eid][type] = function kityEventHandler(e) {
- e = new ShapeEvent(e || window.event);
- Utils.each(USER_HANDLER_CACHE[eid][type], function executeKityEvent(fn) {
- var result;
- if (fn) {
- result = fn.call(targetObject, e);
-
- if (isOnce) {
- targetObject.off(type, fn);
- }
- }
-
- return result;
- }, targetObject);
- };
- }
-
- if (!USER_HANDLER_CACHE[eid]) {
- USER_HANDLER_CACHE[eid] = {};
- }
- if (!USER_HANDLER_CACHE[eid][type]) {
- USER_HANDLER_CACHE[eid][type] = [ handler ];
-
-
- if (!!node && "on" + type in node) {
- bindDomEvent(node, type, INNER_HANDLER_CACHE[eid][type]);
- }
- } else {
- USER_HANDLER_CACHE[eid][type].push(handler);
- }
- }
-
- function bindDomEvent(node, type, handler) {
- if (node.addEventListener) {
- node.addEventListener(type, handler, false);
- } else {
- node.attachEvent("on" + type, handler);
- }
- }
-
- function deleteDomEvent(node, type, handler) {
- if (node.removeEventListener) {
- node.removeEventListener(type, handler, false);
- } else {
- node.detachEvent(type, handler);
- }
- }
-
- function triggerDomEvent(node, type, params) {
- var event = new CustomEvent(type, {
- bubbles: true,
- cancelable: true
- });
- event._kityParam = params;
- node.dispatchEvent(event);
- }
-
- function sendMessage(messageObj, type, msg) {
- var event = null, handler = null;
- var handlers = INNER_HANDLER_CACHE[messageObj._EVNET_UID];
- if (!handlers) return;
- handler = handlers[type];
- if (!handler) {
- return;
- }
- event = Utils.extend({
- type: type,
- target: messageObj
- }, msg || {});
- handler.call(messageObj, event);
- }
-
- return _p.r(11).createClass("EventHandler", {
- constructor: function() {
- this._EVNET_UID = ++guid;
- },
- addEventListener: function(type, handler) {
- return _addEvent.call(this, type, handler, false);
- },
- addOnceEventListener: function(type, handler) {
- return _addEvent.call(this, type, handler, true);
- },
- removeEventListener: function(type, handler) {
- return _removeEvent.call(this, type, handler);
- },
- on: function(type, handler) {
- return this.addEventListener.apply(this, arguments);
- },
- once: function(type, handler) {
- return this.addOnceEventListener.apply(this, arguments);
- },
- off: function() {
- return this.removeEventListener.apply(this, arguments);
- },
- fire: function(type, params) {
- return this.trigger.apply(this, arguments);
- },
- trigger: function(type, params) {
- sendMessage(this, type, params);
- return this;
- }
- });
- }
- };
- _p[34] = {
- value: function(require) {
- var utils = _p.r(12);
- var Point = _p.r(50);
- var Vector = _p.r(73);
- var Matrix = _p.r(43);
- var g = {};
- var pathCommand = /([achlmrqstvz])[\s,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\s]*,?\s*)+)/gi, pathValues = /(-?\d*\.?\d*(?:e[\-+]?\d+)?)\s*,?\s*/gi, paramCounts = {
- a: 7,
- c: 6,
- h: 1,
- l: 2,
- m: 2,
- q: 4,
- s: 4,
- t: 2,
- v: 1,
- z: 0
- };
- function pathClone(path) {
- var result, i, j, segment, segmentCopy;
- result = [];
- for (i = 0; i < path.length; i++) {
- segment = path[i];
- result.push(segmentCopy = []);
- for (j = 0; j < segment.length; j++) {
- segmentCopy.push(segment[j]);
- }
- }
- if (path.isUniform) result.isUniform = true;
- if (path.isAbsolute) result.isAbsolute = true;
- if (path.isCurve) result.isCurve = true;
- return result;
- }
-
-
- function cacher(f, scope, postprocessor) {
- function repush(array, item) {
- for (var i = 0, ii = array.length; i < ii; i++) if (array[i] === item) {
- return array.push(array.splice(i, 1)[0]);
- }
- }
- function newf() {
- var arg = Array.prototype.slice.call(arguments, 0), args = arg.join("␀"), cache = newf.cache = newf.cache || {}, count = newf.count = newf.count || [];
- if (cache.hasOwnProperty(args)) {
- repush(count, args);
- return postprocessor ? postprocessor(cache[args]) : cache[args];
- }
- if (count.length >= 1e3) {
- delete cache[count.shift()];
- }
- count.push(args);
- cache[args] = f.apply(scope, arg);
- return postprocessor ? postprocessor(cache[args]) : cache[args];
- }
- return newf;
- }
-
- g.pathToString = function(pathSegment) {
- pathSegment = pathSegment || this;
- if (typeof pathSegment == "string") return pathSegment;
- if (pathSegment instanceof Array) {
- pathSegment = utils.flatten(pathSegment);
- return pathSegment.join(",").replace(/,?([achlmqrstvxz]),?/gi, "$1");
- }
- };
-
- g.parsePathString = cacher(function(pathString) {
- var data = [];
- pathString.replace(pathCommand, function(a, b, c) {
- var params = [], name = b.toLowerCase();
- c.replace(pathValues, function(a, b) {
- if (b) params.push(+b);
- });
- if (name == "m" && params.length > 2) {
- data.push([ b ].concat(params.splice(0, 2)));
- name = "l";
- b = b == "m" ? "l" : "L";
- }
- if (name == "r") {
- data.push([ b ].concat(params));
- } else {
- while (params.length >= paramCounts[name]) {
- data.push([ b ].concat(params.splice(0, paramCounts[name])));
- if (!paramCounts[name]) {
- break;
- }
- }
- }
- });
- data.isUniform = true;
- data.toString = g.pathToString;
- return data;
- });
-
- g.pathToAbsolute = cacher(function(path) {
- var pathArray = path.isUniform ? path : g.parsePathString(g.pathToString(path));
- var res = [], x = 0, y = 0, mx = 0, my = 0, start = 0;
- var r, pa, i, j, k, ii, jj, kk;
- if (pathArray[0][0] == "M") {
- x = +pathArray[0][1];
- y = +pathArray[0][2];
- mx = x;
- my = y;
- start++;
- res[0] = [ "M", x, y ];
- }
- for (r, pa, i = start, ii = pathArray.length; i < ii; i++) {
- res.push(r = []);
- pa = pathArray[i];
- if (pa[0] != pa[0].toUpperCase()) {
- r[0] = pa[0].toUpperCase();
- switch (r[0]) {
- case "A":
- r[1] = pa[1];
- r[2] = pa[2];
- r[3] = pa[3];
- r[4] = pa[4];
- r[5] = pa[5];
- r[6] = +(pa[6] + x);
- r[7] = +(pa[7] + y);
- break;
- case "V":
- r[1] = +pa[1] + y;
- break;
- case "H":
- r[1] = +pa[1] + x;
- break;
- case "M":
- mx = +pa[1] + x;
- my = +pa[2] + y;
- break;
- default:
- for (j = 1, jj = pa.length; j < jj; j++) {
- r[j] = +pa[j] + (j % 2 ? x : y);
- }
- }
- } else {
- for (k = 0, kk = pa.length; k < kk; k++) {
- r[k] = pa[k];
- }
- }
- switch (r[0]) {
- case "Z":
- x = mx;
- y = my;
- break;
- case "H":
- x = r[1];
- break;
- case "V":
- y = r[1];
- break;
- case "M":
- mx = r[r.length - 2];
- my = r[r.length - 1];
- break;
- default:
- x = r[r.length - 2];
- y = r[r.length - 1];
- }
- }
- res.isUniform = true;
- res.isAbsolute = true;
- res.toString = g.pathToString;
- return res;
- });
-
- function a2c(x1, y1, rx, ry, angle, laf, sf, x2, y2, recursive) {
-
-
-
- var math = Math, PI = math.PI, abs = Math.abs, _120 = PI * 120 / 180, rad = PI / 180 * (+angle || 0), res = [], xy, rotate = function(x, y, rad) {
- var X = x * math.cos(rad) - y * math.sin(rad), Y = x * math.sin(rad) + y * math.cos(rad);
- return {
- x: X,
- y: Y
- };
- };
- var cos, sin, h, x, y, rx2, ry2, k, cx, cy, f1, f2, df, f2old, x2old, y2old, c1, s1, c2, s2, t, hx, hy, m1, m2, m3, m4, newres, i, ii;
- if (!recursive) {
- xy = rotate(x1, y1, -rad);
- x1 = xy.x;
- y1 = xy.y;
- xy = rotate(x2, y2, -rad);
- x2 = xy.x;
- y2 = xy.y;
- cos = math.cos(PI / 180 * angle);
- sin = math.sin(PI / 180 * angle);
- x = (x1 - x2) / 2;
- y = (y1 - y2) / 2;
- h = x * x / (rx * rx) + y * y / (ry * ry);
- if (h > 1) {
- h = math.sqrt(h);
- rx = h * rx;
- ry = h * ry;
- }
- rx2 = rx * rx;
- ry2 = ry * ry;
- k = (laf == sf ? -1 : 1) * math.sqrt(abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x)));
- cx = k * rx * y / ry + (x1 + x2) / 2;
- cy = k * -ry * x / rx + (y1 + y2) / 2;
- f1 = math.asin(((y1 - cy) / ry).toFixed(9));
- f2 = math.asin(((y2 - cy) / ry).toFixed(9));
- f1 = x1 < cx ? PI - f1 : f1;
- f2 = x2 < cx ? PI - f2 : f2;
- if (f1 < 0) f1 = PI * 2 + f1;
- if (f2 < 0) f2 = PI * 2 + f2;
- if (sf && f1 > f2) {
- f1 = f1 - PI * 2;
- }
- if (!sf && f2 > f1) {
- f2 = f2 - PI * 2;
- }
- } else {
- f1 = recursive[0];
- f2 = recursive[1];
- cx = recursive[2];
- cy = recursive[3];
- }
- df = f2 - f1;
- if (abs(df) > _120) {
- f2old = f2;
- x2old = x2;
- y2old = y2;
- f2 = f1 + _120 * (sf && f2 > f1 ? 1 : -1);
- x2 = cx + rx * math.cos(f2);
- y2 = cy + ry * math.sin(f2);
- res = a2c(x2, y2, rx, ry, angle, 0, sf, x2old, y2old, [ f2, f2old, cx, cy ]);
- }
- df = f2 - f1;
- c1 = math.cos(f1);
- s1 = math.sin(f1);
- c2 = math.cos(f2);
- s2 = math.sin(f2);
- t = math.tan(df / 4);
- hx = 4 / 3 * rx * t;
- hy = 4 / 3 * ry * t;
- m1 = [ x1, y1 ];
- m2 = [ x1 + hx * s1, y1 - hy * c1 ];
- m3 = [ x2 + hx * s2, y2 - hy * c2 ];
- m4 = [ x2, y2 ];
- m2[0] = 2 * m1[0] - m2[0];
- m2[1] = 2 * m1[1] - m2[1];
- if (recursive) {
- return [ m2, m3, m4 ].concat(res);
- } else {
- res = [ m2, m3, m4 ].concat(res).join().split(",");
- newres = [];
- for (i = 0, ii = res.length; i < ii; i++) {
- newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x;
- }
- return newres;
- }
- }
-
- function q2c(x1, y1, ax, ay, x2, y2) {
-
- var _13 = 1 / 3, _23 = 2 / 3;
- return [ _13 * x1 + _23 * ax, _13 * y1 + _23 * ay, _13 * x2 + _23 * ax, _13 * y2 + _23 * ay, x2, y2 ];
- }
-
- g.pathToCurve = cacher(function(path) {
- var i, j, command, param;
- var initPoint, currentPoint, endPoint, shouldClose, lastControlPoint, aussumedControlPoint;
- var controlPoint1, controlPoint2;
- var res = [];
-
- if (!path.isAbsolute) path = g.pathToAbsolute(path);
- for (i = 0; i < path.length; i++) {
- command = path[i][0];
- param = path[i].slice(1);
-
- if (command == "M") {
- initPoint = lastControlPoint = currentPoint = param;
- res.push(path[i]);
- continue;
- }
-
- if (command == "Z") {
- shouldClose = true;
- command = "L";
- param = initPoint;
- }
-
- endPoint = param.slice(param.length - 2);
-
- if (command == "H") {
- endPoint = [ param[0], currentPoint[1] ];
- command = "L";
- }
-
- if (command == "V") {
- endPoint = [ currentPoint[0], param[0] ];
- command = "L";
- }
-
- if (command == "S" || command == "T") {
-
- aussumedControlPoint = [ currentPoint[0] + (currentPoint[0] - lastControlPoint[0]), currentPoint[1] + (currentPoint[1] - lastControlPoint[1]) ];
- }
-
- switch (command) {
- case "L":
- controlPoint1 = currentPoint;
- controlPoint2 = endPoint;
- break;
- case "C":
- controlPoint1 = param.slice(0, 2);
- controlPoint2 = param.slice(2, 4);
- break;
- case "S":
- controlPoint1 = aussumedControlPoint.slice();
- controlPoint2 = param.slice(0, 2);
- break;
- case "Q":
- lastControlPoint = param.slice(0, 2);
- param = q2c.apply(null, currentPoint.concat(param));
- controlPoint1 = param.slice(0, 2);
- controlPoint2 = param.slice(2, 4);
- break;
- case "T":
- param = q2c.apply(null, currentPoint.concat(aussumedControlPoint).concat(param));
- controlPoint1 = param.slice(0, 2);
- controlPoint2 = param.slice(2, 4);
- break;
- case "A":
- param = a2c.apply(null, currentPoint.concat(param));
- j = 0;
- while (j in param) {
- controlPoint1 = param.slice(j, j + 2);
- controlPoint2 = param.slice(j + 2, j + 4);
- endPoint = param.slice(j + 4, j + 6);
-
- res.push([ "C" ].concat(controlPoint1).concat(controlPoint2).concat(endPoint));
- j += 6;
- }
- break;
- }
- if (command != "A") {
-
- res.push([ "C" ].concat(controlPoint1).concat(controlPoint2).concat(endPoint));
- }
-
- currentPoint = endPoint;
-
- if (command != "Q") {
- lastControlPoint = controlPoint2;
- }
- if (shouldClose) {
- res.push([ "Z" ]);
- shouldClose = false;
- }
- }
- res.isUniform = true;
- res.isAbsolute = true;
- res.isCurve = true;
- res.toString = g.pathToString;
- return res;
- });
-
- function cutBezier(bezierArray, t) {
- function __(t) {
- return function(p, q) {
- return p + t * (q - p);
- };
- }
- var _ = __(t || .5), ba = bezierArray, ax = ba[0], ay = ba[1], bx = ba[2], by = ba[3], cx = ba[4], cy = ba[5], dx = ba[6], dy = ba[7], ex = _(ax, bx), ey = _(ay, by), fx = _(bx, cx), fy = _(by, cy), gx = _(cx, dx), gy = _(cy, dy), hx = _(ex, fx), hy = _(ey, fy), jx = _(fx, gx), jy = _(fy, gy), kx = _(hx, jx), ky = _(hy, jy);
- return [ [ ax, ay, ex, ey, hx, hy, kx, ky ], [ kx, ky, jx, jy, gx, gy, dx, dy ] ];
- }
-
- g.cutBezier = cacher(cutBezier);
-
- g.subBezier = function(bezierArray, t, t0) {
- var b2t = cutBezier(bezierArray, t)[0];
- return t0 ? cutBezier(b2t, t0 / t)[1] : b2t;
- };
-
- g.pointAtBezier = function(bezierArray, t) {
- var b2t = cutBezier(bezierArray, t)[0];
- var p = Point.parse(b2t.slice(6)), c = Point.parse(b2t.slice(4, 2)), v = Vector.fromPoints(c, p);
- if (t === 0) {
- p.tan = g.pointAtBezier(bezierArray, .01).tan;
- } else {
- p.tan = v.normalize();
- }
- return p;
- };
-
- g.bezierLength = cacher(function bezierLength(bezierArray) {
-
- function f(x) {
- var m = c0 * Math.pow(x, 4) + c1 * Math.pow(x, 3) + c2 * Math.pow(x, 2) + c3 * x + c4;
- if (m < 0) {
- m = 0;
- }
- return Math.pow(m, .5);
- }
-
- var arr = bezierArray;
-
- var cx0, cx1, cx2;
- var cy0, cy1, cy2;
-
- var c0, c1, c2, c3, c4;
-
- cx0 = -3 * arr[0] + 9 * arr[2] - 9 * arr[4] + 3 * arr[6];
- cx1 = 6 * arr[0] - 12 * arr[2] + 6 * arr[4];
- cx2 = -3 * arr[0] + 3 * arr[2];
- cy0 = -3 * arr[1] + 9 * arr[3] - 9 * arr[5] + 3 * arr[7];
- cy1 = 6 * arr[1] - 12 * arr[3] + 6 * arr[5];
- cy2 = -3 * arr[1] + 3 * arr[3];
-
- c0 = Math.pow(cx0, 2) + Math.pow(cy0, 2);
- c1 = 2 * (cx0 * cx1 + cy0 * cy1);
- c2 = 2 * (cx0 * cx2 + cy0 * cy2) + Math.pow(cx1, 2) + Math.pow(cy1, 2);
- c3 = 2 * (cx1 * cx2 + cy1 * cy2);
- c4 = Math.pow(cx2, 2) + Math.pow(cy2, 2);
-
- return (f(0) + f(1) + 4 * (f(.125) + f(.375) + f(.625) + f(.875)) + 2 * (f(.25) + f(.5) + f(.75))) / 24;
- });
-
-
- var getBezierPathSegmentRanges = cacher(function(pathSegment) {
- var i, ii, segment, position, bezierLength, segmentRanges, totalLength;
- segmentRanges = [];
-
- totalLength = 0;
- for (i = 0, ii = pathSegment.length; i < ii; i++) {
- segment = pathSegment[i];
- if (segment[0] == "M") {
- position = segment.slice(1);
- segmentRanges.push(null);
- continue;
- }
- if (segment[0] == "Z") {
- segmentRanges.push(null);
- continue;
- }
- bezierLength = g.bezierLength(position.concat(segment.slice(1)));
- segmentRanges.push([ totalLength, totalLength + bezierLength ]);
- totalLength += bezierLength;
-
- position = segment.slice(4);
- }
- segmentRanges.totalLength = totalLength;
- return segmentRanges;
- });
-
- g.subPath = function(path, t1, t0) {
- var dt;
- t0 = t0 || 0;
- dt = t1 - t0;
- dt = dt - (dt | 0);
- t0 = t0 - (t0 | 0);
- t1 = t0 + dt;
- if (t1 > 1) {
- return g.subPath(path, 1, t0).concat(g.subPath(path, t1 - 1));
- }
- if (!path.isCurve) {
- path = g.pathToCurve(path);
- }
-
- var segmentRanges = getBezierPathSegmentRanges(path);
-
- var totalLength = segmentRanges.totalLength;
-
- var t1Length = totalLength * t1, t0Length = totalLength * (t0 || 0);
-
- var subPath = [];
-
- var i, ii, a, b, d;
- var position;
- var bezier, subBezier, stared;
- for (i = 0, ii = path.length; i < ii; i++) {
- if (path[i][0] == "M") {
- position = path[i].slice(1);
- if (stared) {
- subPath.push(path[i].slice());
- }
- continue;
- }
- if (path[i][0] == "Z") {
-
- continue;
- }
- a = segmentRanges[i][0];
- b = segmentRanges[i][1];
- d = b - a;
- bezier = position.concat(path[i].slice(1));
- if (t0Length > b) {
-
-
-
-
-
-
- position = bezier.slice(bezier.length - 2);
- continue;
- } else if (t0Length >= a) {
-
-
-
-
-
-
-
-
- subBezier = g.subBezier(bezier, Math.min((t1Length - a) / d, 1), (t0Length - a) / d);
- stared = true;
- position = subBezier.slice(0, 2);
- subPath.push([ "M" ].concat(subBezier.slice(0, 2)));
- subPath.push([ "C" ].concat(subBezier.slice(2)));
- } else if (t1Length >= b) {
-
-
-
-
-
-
- subPath.push(path[i].slice());
- } else if (t1Length >= a) {
-
-
-
-
-
- subBezier = g.subBezier(bezier, (t1Length - a) / d);
- subPath.push([ "C" ].concat(subBezier.slice(2)));
- stared = false;
- } else {
-
- break;
- }
- position = bezier.slice(bezier.length - 2);
- }
- subPath.isAbsolute = true;
- subPath.isCurve = true;
- subPath.isUniform = true;
- subPath.toString = g.pathToString;
- return subPath;
- };
-
- g.pointAtPath = function(path, t) {
- if (!path.isCurve) {
- path = g.pathToCurve(path);
- }
- var subPath = g.subPath(path, t);
- var lastCurve = subPath[subPath.length - 1][0] == "Z" ? subPath[subPath.length - 2] : subPath[subPath.length - 1];
-
- lastCurve = lastCurve.slice(1);
- var p = Point.parse(lastCurve.slice(4)), c = Point.parse(lastCurve.slice(2, 4));
- p.tan = Vector.fromPoints(c, p).normalize();
- return p;
- };
-
- g.pathLength = cacher(function(path) {
- if (!path.isCurve) {
- path = g.pathToCurve(path);
- }
-
- var segmentRanges = getBezierPathSegmentRanges(path);
- return segmentRanges.totalLength;
- });
-
- g.pathKeyPoints = cacher(function(path) {
- var i, ii, command, keyPoints;
- if (!path.isCurve) {
- path = g.pathToCurve(path);
- }
- keyPoints = [];
- for (i = 0, ii = path.length; i < ii; i++) {
- if (path[i][0] == "z") continue;
- keyPoints.push(path[i].slice(path[i].length - 2));
- }
- return keyPoints;
- });
-
-
- var alignCurve = cacher(function(path1, path2) {
- if (!path1.isCurve) path1 = g.pathToCurve(path1);
- if (!path2.isCurve) path2 = g.pathToCurve(path2);
- var p1 = pathClone(path1);
- var p2 = pathClone(path2);
- p1.i = 0;
- p2.i = 0;
- p1.o = p2;
- p2.o = p1;
- function command(p, i) {
- return p[i || p.i] && p[i || p.i][0];
- }
- function param(p, i) {
- return p[i || p.i] && p[i || p.i].slice(1);
- }
- function point(p, i) {
- var _param = param(p, i);
- return _param && _param.slice(-2);
- }
- function fixZ(p) {
- if (command(p) == "Z") {
- p.splice(p.i, 1);
- return true;
- }
- return false;
- }
- function fixM(p) {
- if (command(p) == "M") {
- p.o.splice(p.o.i, 0, [ "M" ].concat(point(p.o, p.o.i - 1)));
- p.i++;
- p.o.i++;
- return true;
- }
- return false;
- }
- function fill(p) {
- var lastPoint;
- var i = 1;
- while (!lastPoint) {
- lastPoint = point(p, p.length - i++);
- }
- p.o.i = p.i;
- while (p.length < p.o.length) {
- if (fixZ(p.o)) continue;
- if (fixM(p.o)) continue;
- p.push([ "C" ].concat(lastPoint).concat(lastPoint).concat(lastPoint));
- p.i++;
- p.o.i++;
- }
- }
- while (p1.i < p1.length && p2.i < p2.length) {
- if (fixZ(p1) || fixZ(p2)) continue;
- if (command(p1) == command(p2)) {
- p1.i++;
- p2.i++;
- continue;
- }
- if (fixM(p1) || fixM(p2)) continue;
- p1.i++;
- p2.i++;
- }
- if (p1.i == p1.length) fill(p1);
- if (p2.i == p2.length) fill(p2);
- delete p1.i;
- delete p1.o;
- delete p2.i;
- delete p2.o;
- return [ p1, p2 ];
- });
- g.alignCurve = alignCurve;
-
- g.pathTween = function(path1, path2, t) {
- if (t === 0) return path1;
- if (t === 1) return path2;
- var aligned = alignCurve(path1, path2);
- var result = [], seg, i, j;
- path1 = aligned[0];
- path2 = aligned[1];
- for (i = 0; i < path1.length; i++) {
- result.push(seg = []);
- seg.push(path1[i][0]);
- for (j = 1; j < path1[i].length; j++) {
- seg.push(path1[i][j] + t * (path2[i][j] - path1[i][j]));
- }
- }
- result.isUniform = result.isCurve = result.isAbsolute = true;
- return result;
- };
-
- g.transformPath = cacher(function(path, matrix) {
- var i, ii, j, result, seg, pair;
- if (!path.isCurve) {
- path = g.pathToCurve(path);
- }
- result = [];
- for (i = 0, ii = path.length; i < ii; i++) {
- result.push(seg = [ path[i][0] ]);
- for (j = 1; j < path[i].length; j += 2) {
- pair = path[i].slice(j, j + 2);
- pair = matrix.transformPoint(Point.parse(pair));
- result.push(pair);
- }
- }
- return result;
- });
-
- _p.r(11).extendClass(Matrix, {
- transformPath: function(path) {
- return g.transformPath(path, this);
- }
- });
- return g;
- }
- };
- _p[35] = {
- value: function(require, exports, module) {
- var svg = _p.r(67);
- var Resource = _p.r(58);
- var Color = _p.r(28);
- return _p.r(11).createClass("GradientBrush", {
- base: Resource,
- constructor: function(gradientNodeType, paper) {
- this.callBase(gradientNodeType, paper);
- this.stops = [];
- },
- addStop: function(offset, color, opacity) {
- var gstop = svg.createNode("stop");
- if (!(color instanceof Color)) {
- color = Color.parse(color);
- }
- if (opacity === undefined) {
- opacity = color.get("a");
- }
- gstop.setAttribute("offset", offset);
- gstop.setAttribute("stop-color", color.toRGB());
- if (opacity < 1) {
- gstop.setAttribute("stop-opacity", opacity);
- }
- this.node.appendChild(gstop);
- return this;
- }
- });
- }
- };
- _p[36] = {
- value: function(require, exports, module) {
- var ShapeContainer = _p.r(61);
- return _p.r(11).createClass("Group", {
- mixins: [ ShapeContainer ],
- base: _p.r(60),
- constructor: function Group() {
- this.callBase("g");
- }
- });
- }
- };
- _p[37] = {
- value: function(require, exports, module) {
- var ShapeContainer = _p.r(61);
- return _p.r(11).createClass("HyperLink", {
- mixins: [ ShapeContainer ],
- base: _p.r(60),
- constructor: function(url) {
- this.callBase("a");
- this.setHref(url);
- },
- setHref: function(href) {
- this.node.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", href);
- return this;
- },
- getHref: function() {
- return this.node.getAttributeNS("xlink:href");
- },
- setTarget: function(target) {
- this.node.setAttribute("target", target);
- return this;
- },
- getTarget: function() {
- return this.node.getAttribute("target");
- }
- });
- }
- };
- _p[38] = {
- value: function(require, exports, module) {
- return _p.r(11).createClass("Image", {
- base: _p.r(60),
- constructor: function(url, width, height, x, y) {
- this.callBase("image");
- this.url = url;
- this.width = width || 0;
- this.height = height || 0;
- this.x = x || 0;
- this.y = y || 0;
- this.update();
- },
- update: function() {
- this.node.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", this.url);
- this.node.setAttribute("x", this.x);
- this.node.setAttribute("y", this.y);
- this.node.setAttribute("width", this.width);
- this.node.setAttribute("height", this.height);
- return this;
- },
- setUrl: function(url) {
- this.url = url === "" ? null : url;
- return this.update();
- },
- getUrl: function() {
- return this.url;
- },
- setWidth: function(width) {
- this.width = width;
- return this.update();
- },
- getWidth: function() {
- return this.width;
- },
- setHeight: function(height) {
- this.height = height;
- return this.update();
- },
- getHeight: function() {
- return this.height;
- },
- setX: function(x) {
- this.x = x;
- return this.update();
- },
- getX: function() {
- return this.x;
- },
- setY: function(y) {
- this.y = y;
- return this.update();
- },
- getY: function() {
- return this.y;
- }
- });
- }
- };
- _p[39] = {
- value: function(require, exports, module) {
- return _p.r(11).createClass("Line", {
- base: _p.r(46),
- constructor: function(x1, y1, x2, y2) {
- this.callBase();
- this.point1 = {
- x: x1 || 0,
- y: y1 || 0
- };
- this.point2 = {
- x: x2 || 0,
- y: y2 || 0
- };
- this.update();
- },
- setPoint1: function(x, y) {
- this.point1.x = x;
- this.point1.y = y;
- return this.update();
- },
- setPoint2: function(x, y) {
- this.point2.x = x;
- this.point2.y = y;
- return this.update();
- },
- getPoint1: function() {
- return {
- x: this.point1.x,
- y: this.point1.y
- };
- },
- getPoint2: function() {
- return {
- x: this.point2.x,
- y: this.point2.y
- };
- },
- update: function() {
- var drawer = this.getDrawer();
- drawer.clear();
- drawer.moveTo(this.point1.x, this.point1.y);
- drawer.lineTo(this.point2.x, this.point2.y);
- return this;
- }
- });
- }
- };
- _p[40] = {
- value: function(require, exports, module) {
- var svg = _p.r(67);
- var Gradient = _p.r(35);
- return _p.r(11).createClass("LinearGradientBrush", {
- base: Gradient,
- constructor: function(paper) {
- this.callBase("linearGradient", paper);
- this.setStartPosition(0, 0);
- this.setEndPosition(1, 0);
- },
- setStartPosition: function(px, py) {
- this.node.setAttribute("x1", px);
- this.node.setAttribute("y1", py);
- return this;
- },
- setEndPosition: function(px, py) {
- this.node.setAttribute("x2", px);
- this.node.setAttribute("y2", py);
- return this;
- },
- getStartPosition: function() {
- return {
- x: +this.node.getAttribute("x1"),
- y: +this.node.getAttribute("y1")
- };
- },
- getEndPosition: function() {
- return {
- x: +this.node.getAttribute("x2"),
- y: +this.node.getAttribute("y2")
- };
- }
- });
- }
- };
- _p[41] = {
- value: function(require, exports, module) {
- var Point = _p.r(50);
- var Marker = _p.r(11).createClass("Marker", {
- base: _p.r(58),
- mixins: [ _p.r(61), _p.r(75) ],
- constructor: function() {
- this.callBase("marker");
- this.setOrient("auto");
- },
- setRef: function(x, y) {
- if (arguments.length === 1) {
- y = x.y;
- x = x.x;
- }
- this.node.setAttribute("refX", x);
- this.node.setAttribute("refY", y);
- return this;
- },
- getRef: function() {
- return new Point(+this.node.getAttribute("refX"), +this.node.getAttribute("refY"));
- },
- setWidth: function(width) {
- this.node.setAttribute("markerWidth", this.width = width);
- return this;
- },
- setOrient: function(orient) {
- this.node.setAttribute("orient", this.orient = orient);
- return this;
- },
- getOrient: function() {
- return this.orient;
- },
- getWidth: function() {
- return +this.width;
- },
- setHeight: function(height) {
- this.node.setAttribute("markerHeight", this.height = height);
- return this;
- },
- getHeight: function() {
- return +this.height;
- }
- });
- var Path = _p.r(46);
- _p.r(11).extendClass(Path, {
- setMarker: function(marker, pos) {
- pos = pos || "end";
- if (!marker) {
- this.node.removeAttribute("marker-" + pos);
- } else {
- this.node.setAttribute("marker-" + pos, marker.toString());
- }
- return this;
- }
- });
- return Marker;
- }
- };
- _p[42] = {
- value: function(require, exports, module) {
- var Class = _p.r(11);
- var Shape = _p.r(60);
- var Mask = Class.createClass("Mask", {
- base: Shape,
- mixins: [ _p.r(61) ],
- constructor: function() {
- this.callBase("mask");
- },
- mask: function(shape) {
- shape.getNode().setAttribute("mask", "url(#" + this.getId() + ")");
- return this;
- }
- });
- Class.extendClass(Shape, {
- maskWith: function(mask) {
- mask.mask(this);
- return this;
- }
- });
- return Mask;
- }
- };
- _p[43] = {
- value: function(require, exports, module) {
- var utils = _p.r(12);
- var Box = _p.r(25);
- var mPattern = /matrix\s*\((.+)\)/i;
- var Point = _p.r(50);
-
- function mergeMatrixData(m2, m1) {
- return {
- a: m1.a * m2.a + m1.c * m2.b,
- b: m1.b * m2.a + m1.d * m2.b,
- c: m1.a * m2.c + m1.c * m2.d,
- d: m1.b * m2.c + m1.d * m2.d,
- e: m1.a * m2.e + m1.c * m2.f + m1.e,
- f: m1.b * m2.e + m1.d * m2.f + m1.f
- };
- }
- function d2r(deg) {
- return deg * Math.PI / 180;
- }
- var Matrix = _p.r(11).createClass("Matrix", {
- constructor: function() {
- if (arguments.length) {
- this.setMatrix.apply(this, arguments);
- } else {
- this.setMatrix(1, 0, 0, 1, 0, 0);
- }
- },
- translate: function(x, y) {
- this.m = mergeMatrixData(this.m, {
- a: 1,
- c: 0,
- e: x,
- b: 0,
- d: 1,
- f: y
- });
- return this;
- },
- rotate: function(deg) {
- var rad = d2r(deg);
- var sin = Math.sin(rad), cos = Math.cos(rad);
- this.m = mergeMatrixData(this.m, {
- a: cos,
- c: -sin,
- e: 0,
- b: sin,
- d: cos,
- f: 0
- });
- return this;
- },
- scale: function(sx, sy) {
- if (sy === undefined) {
- sy = sx;
- }
- this.m = mergeMatrixData(this.m, {
- a: sx,
- c: 0,
- e: 0,
- b: 0,
- d: sy,
- f: 0
- });
- return this;
- },
- skew: function(degX, degY) {
- if (degY === undefined) {
- degY = degX;
- }
- var tx = Math.tan(d2r(degX)), ty = Math.tan(d2r(degY));
- this.m = mergeMatrixData(this.m, {
- a: 1,
- c: tx,
- e: 0,
- b: ty,
- d: 1,
- f: 0
- });
- return this;
- },
-
- inverse: function() {
- var m = this.m, a = m.a, b = m.b, c = m.c, d = m.d, e = m.e, f = m.f, k, aa, bb, cc, dd, ee, ff;
- k = a * d - b * c;
- aa = d / k;
- bb = -b / k;
- cc = -c / k;
- dd = a / k;
- ee = (c * f - e * d) / k;
- ff = (b * e - a * f) / k;
- return new Matrix(aa, bb, cc, dd, ee, ff);
- },
- setMatrix: function(a, b, c, d, e, f) {
- if (arguments.length === 1) {
- this.m = utils.clone(arguments[0]);
- } else {
- this.m = {
- a: a,
- b: b,
- c: c,
- d: d,
- e: e,
- f: f
- };
- }
- return this;
- },
- getMatrix: function() {
- return utils.clone(this.m);
- },
- getTranslate: function() {
- var m = this.m;
- return {
- x: m.e / m.a,
- y: m.f / m.d
- };
- },
- mergeMatrix: function(matrix) {
- return new Matrix(mergeMatrixData(this.m, matrix.m));
- },
- merge: function(matrix) {
- return this.mergeMatrix(matrix);
- },
- toString: function() {
- return this.valueOf().join(" ");
- },
- valueOf: function() {
- var m = this.m;
- return [ m.a, m.b, m.c, m.d, m.e, m.f ];
- },
- equals: function(matrix) {
- var m1 = this.m, m2 = matrix.m;
- return m1.a == m2.a && m1.b == m2.b && m1.c == m2.c && m1.d == m2.d && m1.e == m2.e && m1.f == m2.f;
- },
- transformPoint: function() {
- return Matrix.transformPoint.apply(null, [].slice.call(arguments).concat([ this.m ]));
- },
- transformBox: function(box) {
- return Matrix.transformBox(box, this.m);
- },
- clone: function() {
- return new Matrix(this.m);
- }
- });
- Matrix.parse = function(str) {
- var match;
- var f = parseFloat;
- if (str instanceof Array) {
- return new Matrix({
- a: str[0],
- b: str[1],
- c: str[2],
- d: str[3],
- e: str[4],
- f: str[5]
- });
- }
- if (match = mPattern.exec(str)) {
- var values = match[1].split(",");
- if (values.length != 6) {
- values = match[1].split(" ");
- }
- return new Matrix({
- a: f(values[0]),
- b: f(values[1]),
- c: f(values[2]),
- d: f(values[3]),
- e: f(values[4]),
- f: f(values[5])
- });
- }
- return new Matrix();
- };
- Matrix.transformPoint = function(x, y, m) {
- if (arguments.length === 2) {
- m = y;
- y = x.y;
- x = x.x;
- }
- return new Point(m.a * x + m.c * y + m.e, m.b * x + m.d * y + m.f);
- };
- Matrix.transformBox = function(box, matrix) {
- var xMin = Number.MAX_VALUE, xMax = -Number.MAX_VALUE, yMin = Number.MAX_VALUE, yMax = -Number.MAX_VALUE;
- var bps = [ [ box.x, box.y ], [ box.x + box.width, box.y ], [ box.x, box.y + box.height ], [ box.x + box.width, box.y + box.height ] ];
- var bp, rp, rps = [];
- while (bp = bps.pop()) {
- rp = Matrix.transformPoint(bp[0], bp[1], matrix);
- rps.push(rp);
- xMin = Math.min(xMin, rp.x);
- xMax = Math.max(xMax, rp.x);
- yMin = Math.min(yMin, rp.y);
- yMax = Math.max(yMax, rp.y);
- }
- box = new Box({
- x: xMin,
- y: yMin,
- width: xMax - xMin,
- height: yMax - yMin
- });
- utils.extend(box, {
- closurePoints: rps
- });
- return box;
- };
-
- Matrix.getCTM = function(target, refer) {
- var ctm = {
- a: 1,
- b: 0,
- c: 0,
- d: 1,
- e: 0,
- f: 0
- };
- var node = target.shapeNode || target.node;
- refer = refer || "parent";
-
- function getTransformToElement(target, source) {
- var matrix;
- try {
- matrix = source.getScreenCTM().inverse();
- } catch (e) {
- throw new Error("Can not inverse source element' ctm.");
- }
- return matrix.multiply(target.getScreenCTM());
- }
-
- switch (refer) {
- case "screen":
-
- ctm = node.getScreenCTM();
- break;
- case "doc":
- case "paper":
-
- ctm = node.getCTM();
- break;
- case "view":
- case "top":
-
- if (target.getPaper()) {
- ctm = node.getTransformToElement !== undefined ? node.getTransformToElement(target.getPaper().shapeNode) : getTransformToElement(node, target.getPaper().shapeNode);
- }
- break;
- case "parent":
-
- if (target.node.parentNode) {
- ctm = node.getTransformToElement !== undefined ? node.getTransformToElement(target.node.parentNode) : getTransformToElement(node, target.node.parentNode);
- }
- break;
- default:
-
- if (refer.node) {
- ctm = node.getTransformToElement !== undefined ? node.getTransformToElement(refer.shapeNode || refer.node) : getTransformToElement(node, refer.shapeNode || refer.node);
- }
- }
- return ctm ? new Matrix(ctm.a, ctm.b, ctm.c, ctm.d, ctm.e, ctm.f) : new Matrix();
- };
- return Matrix;
- }
- };
- _p[44] = {
- value: function(require, exports, module) {
-
- var StandardColor = _p.r(64), Color = _p.r(28), Utils = _p.r(12);
- var Palette = _p.r(11).createClass("Palette", {
- constructor: function() {
- this.color = {};
- },
-
- get: function(name) {
- var colorValue = this.color[name] || StandardColor.EXTEND_STANDARD[name] || StandardColor.COLOR_STANDARD[name] || "";
- if (colorValue) {
- return new Color(colorValue);
- }
- return null;
- },
-
- getColorValue: function(name) {
- return this.color[name] || StandardColor.EXTEND_STANDARD[name] || StandardColor.COLOR_STANDARD[name] || "";
- },
-
- add: function(name, value) {
- if (typeof value === "string") {
- this.color[name] = new Color(value).toRGBA();
- } else {
- this.color[name] = value.toRGBA();
- }
- return value;
- },
-
- remove: function(name) {
- if (this.color.hasOwnProperty(name)) {
- delete this.color[name];
- return true;
- }
- return false;
- }
- });
- Utils.extend(Palette, {
- getColor: function(name) {
- var colorValue = StandardColor.EXTEND_STANDARD[name] || StandardColor.COLOR_STANDARD[name];
- if (colorValue) {
- return new Color(colorValue);
- }
- return null;
- },
-
- getColorValue: function(name) {
- return StandardColor.EXTEND_STANDARD[name] || StandardColor.COLOR_STANDARD[name] || "";
- },
-
- addColor: function(name, value) {
- if (typeof value === "string") {
- StandardColor.EXTEND_STANDARD[name] = new Color(value).toRGBA();
- } else {
- StandardColor.EXTEND_STANDARD[name] = value.toRGBA();
- }
- return value;
- },
-
- removeColor: function(name) {
- if (StandardColor.EXTEND_STANDARD.hasOwnProperty(name)) {
- delete StandardColor.EXTEND_STANDARD[name];
- return true;
- }
- return false;
- }
- });
- return Palette;
- }
- };
- _p[45] = {
- value: function(require, exports, module) {
- var Class = _p.r(11);
- var utils = _p.r(12);
- var svg = _p.r(67);
- var Container = _p.r(29);
- var ShapeContainer = _p.r(61);
- var ViewBox = _p.r(75);
- var EventHandler = _p.r(33);
- var Styled = _p.r(66);
- var Matrix = _p.r(43);
- var Paper = Class.createClass("Paper", {
- mixins: [ ShapeContainer, EventHandler, Styled, ViewBox ],
- constructor: function(container) {
- this.callBase();
- this.node = this.createSVGNode();
- this.node.paper = this;
- this.node.appendChild(this.resourceNode = svg.createNode("defs"));
- this.node.appendChild(this.shapeNode = svg.createNode("g"));
- this.resources = new Container();
- this.setWidth("100%").setHeight("100%");
- if (container) {
- this.renderTo(container);
- }
- this.callMixin();
- },
- renderTo: function(container) {
- if (utils.isString(container)) {
- container = document.getElementById(container);
- }
- this.container = container;
- container.appendChild(this.node);
- },
- createSVGNode: function() {
- var node = svg.createNode("svg");
- node.setAttribute("xmlns", "http://www.w3.org/2000/svg");
- node.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
- node.setAttribute("version", "1.1");
- return node;
- },
- getNode: function() {
- return this.node;
- },
- getContainer: function() {
- return this.container;
- },
- getWidth: function() {
- return this.node.clientWidth;
- },
- setWidth: function(width) {
- this.node.setAttribute("width", width);
- return this;
- },
- getHeight: function() {
- return this.node.clientHeight;
- },
- setHeight: function(height) {
- this.node.setAttribute("height", height);
- return this;
- },
- setViewPort: function(cx, cy, zoom) {
- var viewport, box;
- if (arguments.length == 1) {
- viewport = arguments[0];
- cx = viewport.center.x;
- cy = viewport.center.y;
- zoom = viewport.zoom;
- }
- zoom = zoom || 1;
- box = this.getViewBox();
- var matrix = new Matrix();
- var dx = box.x + box.width / 2 - cx, dy = box.y + box.height / 2 - cy;
- matrix.translate(-cx, -cy);
- matrix.scale(zoom);
- matrix.translate(cx, cy);
- matrix.translate(dx, dy);
- this.shapeNode.setAttribute("transform", "matrix(" + matrix + ")");
- this.viewport = {
- center: {
- x: cx,
- y: cy
- },
- offset: {
- x: dx,
- y: dy
- },
- zoom: zoom
- };
- return this;
- },
- getViewPort: function() {
- if (!this.viewport) {
- var box = this.getViewBox();
- return {
- zoom: 1,
- center: {
- x: box.x + box.width / 2,
- y: box.y + box.height / 2
- },
- offset: {
- x: 0,
- y: 0
- }
- };
- }
- return this.viewport;
- },
- getViewPortMatrix: function() {
- return Matrix.parse(this.shapeNode.getAttribute("transform"));
- },
- getViewPortTransform: function() {
- var m = this.shapeNode.getCTM();
- return new Matrix(m.a, m.b, m.c, m.d, m.e, m.f);
- },
- getTransform: function() {
- return this.getViewPortTransform().reverse();
- },
- addResource: function(resource) {
- this.resources.appendItem(resource);
- if (resource.node) {
- this.resourceNode.appendChild(resource.node);
- }
- return this;
- },
- removeResource: function(resource) {
- if (resource.remove) {
- resource.remove();
- }
- if (resource.node) {
- this.resourceNode.removeChild(resource.node);
- }
- return this;
- },
- getPaper: function() {
- return this;
- }
- });
- var Shape = _p.r(60);
- Class.extendClass(Shape, {
- getPaper: function() {
- var parent = this.container;
- while (parent && parent instanceof Paper === false) {
- parent = parent.container;
- }
- return parent;
- },
- isAttached: function() {
- return !!this.getPaper();
- },
- whenPaperReady: function(fn) {
- var me = this;
- function check() {
- var paper = me.getPaper();
- if (paper && fn) {
- fn.call(me, paper);
- }
- return paper;
- }
- if (!check()) {
- this.on("add treeadd", function listen() {
- if (check()) {
- me.off("add", listen);
- me.off("treeadd", listen);
- }
- });
- }
- return this;
- }
- });
- return Paper;
- }
- };
- _p[46] = {
- value: function(require, exports, module) {
- var Utils = _p.r(12);
- var createClass = _p.r(11).createClass;
- var Shape = _p.r(60);
- var svg = _p.r(67);
- var g = _p.r(34);
- var slice = Array.prototype.slice, flatten = Utils.flatten;
- var PathDrawer = createClass("PathDrawer", {
- constructor: function(path) {
- this.segment = [];
- this.path = path;
- this.__clear = false;
- },
- getPath: function() {
- return this.path;
- },
- redraw: function() {
- this._transation = this._transation || [];
- return this.clear();
- },
- done: function() {
- var transation = this._transation;
- this._transation = null;
- this.push(transation);
- return this;
- },
- clear: function() {
- if (this._transation) {
- this._transation = [];
- } else {
- this.path.setPathData("M 0 0");
- }
- this._clear = true;
- return this;
- },
- push: function() {
- var segment = slice.call(arguments);
- var originData;
- if (this._transation) {
- this._transation.push(segment);
- return this;
- }
- if (this._clear) {
- originData = "";
- this._clear = false;
- } else {
- originData = this.path.getPathData();
- }
- originData = originData || "";
- this.path.setPathData(originData + g.pathToString(segment));
- return this;
- },
- moveTo: function(x, y) {
- return this.push("M", slice.call(arguments));
- },
- moveBy: function(dx, dy) {
- return this.push("m", slice.call(arguments));
- },
- lineTo: function(x, y) {
- return this.push("L", slice.call(arguments));
- },
- lineBy: function(dx, dy) {
- return this.push("l", slice.call(arguments));
- },
- arcTo: function(rx, ry, xr, laf, sf, x, y) {
- return this.push("A", slice.call(arguments));
- },
- arcBy: function(rx, ry, xr, laf, sf, dx, dy) {
- return this.push("a", arguments);
- },
- carcTo: function(r, laf, sf, x, y) {
- return this.push("A", [ r, r, 0 ].concat(slice.call(arguments, 1)));
- },
- carcBy: function(r, laf, sf, dx, dy) {
- return this.push("a", [ r, r, 0 ].concat(slice.call(arguments, 1)));
- },
- bezierTo: function(x1, y1, x2, y2, x, y) {
- return this.push("C", slice.call(arguments));
- },
- bezierBy: function(dx1, dy1, dx2, dy2, dx, dy) {
- return this.push("c", slice.call(arguments));
- },
- close: function() {
- return this.push("z");
- }
- });
- return createClass("Path", {
- base: Shape,
- constructor: function(data) {
- this.callBase("path");
- if (data) {
- this.setPathData(data);
- }
- this.node.setAttribute("fill", svg.defaults.fill);
- this.node.setAttribute("stroke", svg.defaults.stroke);
- },
- setPathData: function(data) {
- data = data || "M0,0";
- this.pathdata = g.pathToString(data);
- this.node.setAttribute("d", this.pathdata);
- this.trigger("shapeupdate", {
- type: "pathdata"
- });
- return this;
- },
- getPathData: function() {
- return this.pathdata || "";
- },
- getDrawer: function() {
- return new PathDrawer(this);
- },
- isClosed: function() {
- var data = this.getPathData();
- return !!~data.indexOf("z") || !!~data.indexOf("Z");
- }
- });
- }
- };
- _p[47] = {
- value: function(require, exports, module) {
- var Resource = _p.r(58);
- var ShapeContainer = _p.r(61);
- var svg = _p.r(67);
- return _p.r(11).createClass("PatternBrush", {
- base: Resource,
- mixins: [ ShapeContainer ],
- constructor: function(paper) {
- this.callBase("pattern", paper);
- this.node.setAttribute("patternUnits", "userSpaceOnUse");
- },
- setX: function(x) {
- this.x = x;
- this.node.setAttribute("x", x);
- return this;
- },
- setY: function(y) {
- this.y = y;
- this.node.setAttribute("y", y);
- return this;
- },
- setWidth: function(width) {
- this.width = width;
- this.node.setAttribute("width", width);
- return this;
- },
- setHeight: function(height) {
- this.height = height;
- this.node.setAttribute("height", height);
- return this;
- },
- getWidth: function() {
- return this.width;
- },
- getHeight: function() {
- return this.height;
- }
- });
- }
- };
- _p[48] = {
- value: function(require, exports, module) {
- var Color = _p.r(28);
- return _p.r(11).createClass("Pen", {
- constructor: function(brush, width) {
- this.brush = brush;
- this.width = width || 1;
- this.linecap = null;
- this.linejoin = null;
- this.dashArray = null;
- this.opacity = 1;
- },
- getBrush: function() {
- return this.brush;
- },
- setBrush: function(brush) {
- this.brush = brush;
- return this;
- },
- setColor: function(color) {
- return this.setBrush(color);
- },
- getColor: function() {
- return this.brush instanceof Color ? this.brush : null;
- },
- getWidth: function() {
- return this.width;
- },
- setWidth: function(width) {
- this.width = width;
- return this;
- },
- getOpacity: function() {
- return this.opacity;
- },
- setOpacity: function(opacity) {
- this.opacity = opacity;
- },
- getLineCap: function() {
- return this.linecap;
- },
- setLineCap: function(linecap) {
- this.linecap = linecap;
- return this;
- },
- getLineJoin: function() {
- return this.linejoin;
- },
- setLineJoin: function(linejoin) {
- this.linejoin = linejoin;
- return this;
- },
- getDashArray: function() {
- return this.dashArray;
- },
- setDashArray: function(dashArray) {
- this.dashArray = dashArray;
- return this;
- },
- stroke: function(shape) {
- var node = shape.node;
- node.setAttribute("stroke", this.brush.toString());
- node.setAttribute("stroke-width", this.getWidth());
- if (this.getOpacity() < 1) {
- node.setAttribute("stroke-opacity", this.getOpacity());
- }
- if (this.getLineCap()) {
- node.setAttribute("stroke-linecap", this.getLineCap());
- }
- if (this.getLineJoin()) {
- node.setAttribute("stroke-linejoin", this.getLineJoin());
- }
- if (this.getDashArray()) {
- node.setAttribute("stroke-dasharray", this.getDashArray());
- }
- }
- });
- }
- };
- _p[49] = {
- value: function(require, exports, module) {
- return _p.r(11).createClass({
- base: _p.r(68),
- constructor: function(radius, angle, angleOffset) {
- this.callBase([ 0, radius ], angle, angleOffset);
- },
- getRadius: function() {
- return this.getSectionArray()[1];
- },
- setRadius: function(radius) {
- this.setSectionArray([ 0, radius ]);
- }
- });
- }
- };
- _p[50] = {
- value: function(require, exports, module) {
-
- var Point = _p.r(11).createClass("Point", {
-
- constructor: function(x, y) {
-
- this.x = x || 0;
-
- this.y = y || 0;
- },
- offset: function(dx, dy) {
- if (arguments.length == 1) {
- dy = dx.y;
- dx = dx.x;
- }
- return new Point(this.x + dx, this.y + dy);
- },
- valueOf: function() {
- return [ this.x, this.y ];
- },
- toString: function() {
- return this.valueOf().join(" ");
- },
- spof: function() {
- return new Point((this.x | 0) + .5, (this.y | 0) + .5);
- },
- round: function() {
- return new Point(this.x | 0, this.y | 0);
- },
- isOrigin: function() {
- return this.x === 0 && this.y === 0;
- }
- });
-
- Point.fromPolar = function(radius, angle, unit) {
- if (unit != "rad") {
-
- angle = angle / 180 * Math.PI;
- }
- return new Point(radius * Math.cos(angle), radius * Math.sin(angle));
- };
- Point.parse = function(unknown) {
- if (!unknown) return new Point();
- if (unknown instanceof Point) {
- return unknown;
- }
- if (typeof unknown == "string") {
- return Point.parse(unknown.split(/\s*[\s,]\s*/));
- }
- if ("0" in unknown && "1" in unknown) {
- return new Point(unknown[0], unknown[1]);
- }
- };
- return Point;
- }
- };
- _p[51] = {
- value: function(require, exports, module) {
- return _p.r(11).createClass("PointContainer", {
- base: _p.r(29),
- constructor: function() {
- this.callBase();
- },
- addPoint: function(point, pos) {
- return this.addItem.apply(this, arguments);
- },
- prependPoint: function() {
- return this.prependItem.apply(this, arguments);
- },
- appendPoint: function() {
- return this.appendItem.apply(this, arguments);
- },
- removePoint: function(pos) {
- return this.removeItem.apply(this, arguments);
- },
- addPoints: function() {
- return this.addItems.apply(this, arguments);
- },
- setPoints: function() {
- return this.setItems.apply(this, arguments);
- },
- getPoint: function() {
- return this.getItem.apply(this, arguments);
- },
- getPoints: function() {
- return this.getItems.apply(this, arguments);
- },
- getFirstPoint: function() {
- return this.getFirstItem.apply(this, arguments);
- },
- getLastPoint: function() {
- return this.getLastItem.apply(this, arguments);
- }
- });
- }
- };
- _p[52] = {
- value: function(require, exports, module) {
- var Utils = _p.r(12);
- return _p.r(11).createClass("Poly", {
- base: _p.r(46),
- mixins: [ _p.r(51) ],
- constructor: function(points, closeable) {
- this.callBase();
-
- this.closeable = !!closeable;
- this.setPoints(points || []);
- this.changeable = true;
- this.update();
- },
-
- onContainerChanged: function() {
- if (this.changeable) {
- this.update();
- }
- },
- update: function() {
- var drawer = this.getDrawer(), points = this.getPoints();
- drawer.clear();
- if (!points.length) {
- return this;
- }
- drawer.moveTo(points[0]);
- for (var i = 1, point, len = points.length; i < len; i++) {
- point = points[i];
- drawer.lineTo(point);
- }
- if (this.closeable && points.length > 2) {
- drawer.close();
- }
- return this;
- }
- });
- }
- };
- _p[53] = {
- value: function(require, exports, module) {
- return _p.r(11).createClass("Polygon", {
- base: _p.r(52),
- constructor: function(points) {
- this.callBase(points, true);
- }
- });
- }
- };
- _p[54] = {
- value: function(require, exports, module) {
- return _p.r(11).createClass("Polyline", {
- base: _p.r(52),
- constructor: function(points) {
- this.callBase(points);
- }
- });
- }
- };
- _p[55] = {
- value: function(require, exports, module) {
- var Gradient = _p.r(35);
- return _p.r(11).createClass("RadialGradientBrush", {
- base: Gradient,
- constructor: function(paper) {
- this.callBase("radialGradient", paper);
- this.setCenter(.5, .5);
- this.setFocal(.5, .5);
- this.setRadius(.5);
- },
- setCenter: function(cx, cy) {
- this.node.setAttribute("cx", cx);
- this.node.setAttribute("cy", cy);
- return this;
- },
- getCenter: function() {
- return {
- x: +this.node.getAttribute("cx"),
- y: +this.node.getAttribute("cy")
- };
- },
- setFocal: function(fx, fy) {
- this.node.setAttribute("fx", fx);
- this.node.setAttribute("fy", fy);
- return this;
- },
- getFocal: function() {
- return {
- x: +this.node.getAttribute("fx"),
- y: +this.node.getAttribute("fy")
- };
- },
- setRadius: function(r) {
- this.node.setAttribute("r", r);
- return this;
- },
- getRadius: function() {
- return +this.node.getAttribute("r");
- }
- });
- }
- };
- _p[56] = {
- value: function(require, exports, module) {
- var RectUtils = {}, Utils = _p.r(12), Point = _p.r(50), Box = _p.r(25);
- Utils.extend(RectUtils, {
-
-
- formatRadius: function(width, height, radius) {
- var minValue = Math.floor(Math.min(width / 2, height / 2));
- return Math.min(minValue, radius);
- }
- });
-
- var Rect = _p.r(11).createClass("Rect", {
- base: _p.r(46),
-
- constructor: function(width, height, x, y, radius) {
- this.callBase();
- this.x = x || 0;
- this.y = y || 0;
- this.width = width || 0;
- this.height = height || 0;
- this.radius = RectUtils.formatRadius(this.width, this.height, radius || 0);
- this.update();
- },
- update: function() {
- var x = this.x, y = this.y, w = this.width, h = this.height, r = this.radius;
- var drawer = this.getDrawer().redraw();
- if (!r) {
-
- drawer.push("M", x, y);
- drawer.push("h", w);
- drawer.push("v", h);
- drawer.push("h", -w);
- drawer.push("z");
- } else {
-
- w -= 2 * r;
- h -= 2 * r;
- drawer.push("M", x + r, y);
- drawer.push("h", w);
- drawer.push("a", r, r, 0, 0, 1, r, r);
- drawer.push("v", h);
- drawer.push("a", r, r, 0, 0, 1, -r, r);
- drawer.push("h", -w);
- drawer.push("a", r, r, 0, 0, 1, -r, -r);
- drawer.push("v", -h);
- drawer.push("a", r, r, 0, 0, 1, r, -r);
- drawer.push("z");
- }
- drawer.done();
- return this;
- },
-
- setWidth: function(width) {
- this.width = width;
- return this.update();
- },
-
- setHeight: function(height) {
- this.height = height;
- return this.update();
- },
-
- setSize: function(width, height) {
- this.width = width;
- this.height = height;
- return this.update();
- },
-
- setBox: function(box) {
- this.x = box.x;
- this.y = box.y;
- this.width = box.width;
- this.height = box.height;
- return this.update();
- },
- getBox: function() {
- return new Box(this.x, this.y, this.width, this.height);
- },
- getRadius: function() {
- return this.radius;
- },
- setRadius: function(radius) {
- this.radius = RectUtils.formatRadius(this.width, this.height, radius || 0);
- return this.update();
- },
- getPosition: function() {
- return new Point(this.x, this.y);
- },
- setPosition: function(x, y) {
- if (arguments.length == 1) {
- var p = Point.parse(arguments[0]);
- y = p.y;
- x = p.x;
- }
- this.x = x;
- this.y = y;
- return this.update();
- },
- getWidth: function() {
- return this.width;
- },
- getHeight: function() {
- return this.height;
- },
- getPositionX: function() {
- return this.x;
- },
- getPositionY: function() {
- return this.y;
- },
- setPositionX: function(x) {
- this.x = x;
- return this.update();
- },
- setPositionY: function(y) {
- this.y = y;
- return this.update();
- }
- });
- return Rect;
- }
- };
- _p[57] = {
- value: function(require, exports, module) {
- var Point = _p.r(50);
- return _p.r(11).createClass("RegularPolygon", {
- base: _p.r(46),
- constructor: function(side, radius, x, y) {
- this.callBase();
- this.radius = radius || 0;
- this.side = Math.max(side || 3, 3);
- if (arguments.length > 2) {
- if (arguments.length == 3) {
- y = x.y;
- x = x.x;
- }
- }
- this.center = new Point(x, y);
- this.draw();
- },
- getSide: function() {
- return this.side;
- },
- setSide: function(side) {
- this.side = side;
- return this.draw();
- },
- getRadius: function() {
- return this.radius;
- },
- setRadius: function(radius) {
- this.radius = radius;
- return this.draw();
- },
- draw: function() {
- var radius = this.radius, side = this.side, step = Math.PI * 2 / side, drawer = this.getDrawer(), i;
- drawer.clear();
- drawer.moveTo(Point.fromPolar(radius, Math.PI / 2, "rad").offset(this.center));
- for (i = 0; i <= side; i++) {
- drawer.lineTo(Point.fromPolar(radius, step * i + Math.PI / 2, "rad").offset(this.center));
- }
- drawer.close();
- return this;
- }
- });
- }
- };
- _p[58] = {
- value: function(require, exports, module) {
- var svg = _p.r(67);
- return _p.r(11).createClass("Resource", {
- constructor: function(nodeType, paper) {
- this.callBase();
- this.node = svg.createNode(nodeType);
- if (paper) {
- paper.addResource(this);
- }
- },
- toString: function() {
- return "url(#" + this.node.id + ")";
- }
- });
- }
- };
- _p[59] = {
- value: function(require, exports, module) {
- return _p.r(11).createClass({
- base: _p.r(68),
- constructor: function(innerRadius, outerRadius) {
- this.callBase([ innerRadius, outerRadius ], 360, 0);
- },
- getInnerRadius: function() {
- return this.getSectionArray()[0];
- },
- getOuterRadius: function() {
- return this.getSectionArray()[1];
- },
- setInnerRadius: function(value) {
- this.setSectionArray([ value, this.getOuterRadius() ]);
- },
- setOuterRadius: function(value) {
- this.setSectionArray([ this.getInnerRadius(), value ]);
- }
- });
- }
- };
- _p[60] = {
- value: function(require, exports, module) {
- var svg = _p.r(67);
- var utils = _p.r(12);
- var EventHandler = _p.r(33);
- var Styled = _p.r(66);
- var Data = _p.r(31);
- var Matrix = _p.r(43);
- var Pen = _p.r(48);
- var slice = Array.prototype.slice;
- var Box = _p.r(25);
- var Shape = _p.r(11).createClass("Shape", {
- mixins: [ EventHandler, Styled, Data ],
- constructor: function Shape(tagName) {
- this.node = svg.createNode(tagName);
- this.node.shape = this;
- this.transform = {
- translate: null,
- rotate: null,
- scale: null,
- matrix: null
- };
- this.callMixin();
- },
- getId: function() {
- return this.node.id;
- },
- setId: function(id) {
- this.node.id = id;
- return this;
- },
- getNode: function() {
- return this.node;
- },
- getBoundaryBox: function() {
- var box;
- try {
- box = this.node.getBBox();
- } catch (e) {
- box = {
- x: this.node.clientLeft,
- y: this.node.clientTop,
- width: this.node.clientWidth,
- height: this.node.clientHeight
- };
- }
- return new Box(box);
- },
- getRenderBox: function(refer) {
- var box = this.getBoundaryBox();
- var matrix = this.getTransform(refer);
- return matrix.transformBox(box);
- },
- getWidth: function() {
- return this.getRenderBox().width;
- },
- getHeight: function() {
- return this.getRenderBox().height;
- },
- getSize: function() {
- var box = this.getRenderBox();
- delete box.x;
- delete box.y;
- return box;
- },
- setOpacity: function(value) {
- this.node.setAttribute("opacity", value);
- return this;
- },
- getOpacity: function() {
- var opacity = this.node.getAttribute("opacity");
- return opacity ? +opacity : 1;
- },
- setVisible: function(value) {
- if (value) {
- this.node.removeAttribute("display");
- } else {
- this.node.setAttribute("display", "none");
- }
- return this;
- },
- getVisible: function() {
- this.node.getAttribute("display");
- },
- hasAncestor: function(node) {
- var parent = this.container;
- while (parent) {
- if (parent === node) {
- return true;
- }
- parent = parent.container;
- }
- return false;
- },
- getTransform: function(refer) {
- return Matrix.getCTM(this, refer);
- },
- clearTransform: function() {
- this.node.removeAttribute("transform");
- this.transform = {
- translate: null,
- rotate: null,
- scale: null,
- matrix: null
- };
- this.trigger("shapeupdate", {
- type: "transform"
- });
- return this;
- },
- _applyTransform: function() {
- var t = this.transform, result = [];
- if (t.translate) {
- result.push([ "translate(", t.translate, ")" ]);
- }
- if (t.rotate) {
- result.push([ "rotate(", t.rotate, ")" ]);
- }
- if (t.scale) {
- result.push([ "scale(", t.scale, ")" ]);
- }
- if (t.matrix) {
- result.push([ "matrix(", t.matrix, ")" ]);
- }
- this.node.setAttribute("transform", utils.flatten(result).join(" "));
- return this;
- },
- setMatrix: function(m) {
- this.transform.matrix = m;
- return this._applyTransform();
- },
- setTranslate: function(t) {
- this.transform.translate = t !== null && slice.call(arguments) || null;
- return this._applyTransform();
- },
- setRotate: function(r) {
- this.transform.rotate = r !== null && slice.call(arguments) || null;
- return this._applyTransform();
- },
- setScale: function(s) {
- this.transform.scale = s !== null && slice.call(arguments) || null;
- return this._applyTransform();
- },
- translate: function(dx, dy) {
- var m = this.transform.matrix || new Matrix();
- if (dy === undefined) {
- dy = 0;
- }
- this.transform.matrix = m.translate(dx, dy);
- return this._applyTransform();
- },
- rotate: function(deg) {
- var m = this.transform.matrix || new Matrix();
- this.transform.matrix = m.rotate(deg);
- return this._applyTransform();
- },
- scale: function(sx, sy) {
- var m = this.transform.matrix || new Matrix();
- if (sy === undefined) {
- sy = sx;
- }
- this.transform.matrix = m.scale(sx, sy);
- return this._applyTransform();
- },
- skew: function(sx, sy) {
- var m = this.transform.matrix || new Matrix();
- if (sy === undefined) {
- sy = sx;
- }
- this.transform.matrix = m.skew(sx, sy);
- return this._applyTransform();
- },
- stroke: function(pen, width) {
- if (pen && pen.stroke) {
- pen.stroke(this);
- } else if (pen) {
-
- this.node.setAttribute("stroke", pen.toString());
- if (width) {
- this.node.setAttribute("stroke-width", width);
- }
- } else if (pen === null) {
- this.node.removeAttribute("stroe");
- }
- return this;
- },
- fill: function(brush) {
-
- if (brush) {
- this.node.setAttribute("fill", brush.toString());
- }
- if (brush === null) {
- this.node.removeAttribute("fill");
- }
- return this;
- },
- setAttr: function(a, v) {
- var me = this;
- if (utils.isObject(a)) {
- utils.each(a, function(val, key) {
- me.setAttr(key, val);
- });
- }
- if (v === undefined || v === null || v === "") {
- this.node.removeAttribute(a);
- } else {
- this.node.setAttribute(a, v);
- }
- return this;
- },
- getAttr: function(a) {
- return this.node.getAttribute(a);
- }
- });
- return Shape;
- }
- };
- _p[61] = {
- value: function(require, exports, module) {
- var Container = _p.r(29);
- var utils = _p.r(12);
- var ShapeContainer = _p.r(11).createClass("ShapeContainer", {
- base: Container,
- isShapeContainer: true,
-
- handleAdd: function(shape, index) {
- var parent = this.getShapeNode();
- parent.insertBefore(shape.node, parent.childNodes[index] || null);
- shape.trigger("add", {
- container: this
- });
- if (shape.notifyTreeModification) {
- shape.notifyTreeModification("treeadd", this);
- }
- },
-
- handleRemove: function(shape, index) {
- var parent = this.getShapeNode();
- parent.removeChild(shape.node);
- shape.trigger("remove", {
- container: this
- });
- if (shape.notifyTreeModification) {
- shape.notifyTreeModification("treeremove", this);
- }
- },
-
- notifyTreeModification: function(type, container) {
- this.eachItem(function(index, shape) {
- if (shape.notifyTreeModification) {
- shape.notifyTreeModification(type, container);
- }
- shape.trigger(type, {
- container: container
- });
- });
- },
-
- getShape: function(index) {
- return this.getItem(index);
- },
-
- addShape: function(shape, index) {
- return this.addItem(shape, index);
- },
- put: function(shape) {
- this.addShape(shape);
- return shape;
- },
- appendShape: function(shape) {
- return this.addShape(shape);
- },
- prependShape: function(shape) {
- return this.addShape(shape, 0);
- },
- replaceShape: function(replacer, origin) {
- var index = this.indexOf(origin);
- if (index === -1) {
- return;
- }
- this.removeShape(index);
- this.addShape(replacer, index);
- return this;
- },
- addShapeBefore: function(shape, refer) {
- var index = this.indexOf(refer);
- return this.addShape(shape, index);
- },
- addShapeAfter: function(shape, refer) {
- var index = this.indexOf(refer);
- return this.addShape(shape, index === -1 ? undefined : index + 1);
- },
-
- addShapes: function(shapes) {
- return this.addItems(shapes);
- },
-
- removeShape: function(index) {
- return this.removeItem(index);
- },
- getShapes: function() {
- return this.getItems();
- },
- getShapesByType: function(name) {
- var shapes = [];
- function getShapes(shape) {
- if (name.toLowerCase() == shape.getType().toLowerCase()) {
- shapes.push(shape);
- }
- if (shape.isShapeContainer) {
- utils.each(shape.getShapes(), function(n) {
- getShapes(n);
- });
- }
- }
- getShapes(this);
- return shapes;
- },
-
- getShapeById: function(id) {
- return this.getShapeNode().getElementById(id).shape;
- },
- arrangeShape: function(shape, index) {
- return this.removeShape(shape).addShape(shape, index);
- },
-
- getShapeNode: function() {
- return this.shapeNode || this.node;
- }
- });
- var Shape = _p.r(60);
- _p.r(11).extendClass(Shape, {
- bringTo: function(index) {
- this.container.arrangeShape(this, index);
- return this;
- },
- bringFront: function() {
- return this.bringTo(this.container.indexOf(this) + 1);
- },
- bringBack: function() {
- return this.bringTo(this.container.indexOf(this) - 1);
- },
- bringTop: function() {
- this.container.removeShape(this).addShape(this);
- return this;
- },
- bringRear: function() {
- return this.bringTo(0);
- },
- bringRefer: function(referShape, offset) {
- if (referShape.container) {
- if (this.remove) {
- this.remove();
- }
- referShape.container.addShape(this, referShape.container.indexOf(referShape) + (offset || 0));
- }
- return this;
- },
- bringAbove: function(referShape) {
- return this.bringRefer(referShape);
- },
- bringBelow: function(referShape) {
- return this.bringRefer(referShape, 1);
- },
- replaceBy: function(newShape) {
- if (this.container) {
- newShape.bringAbove(this);
- this.remove();
- }
- return this;
- }
- });
- return ShapeContainer;
- }
- };
- _p[62] = {
- value: function(require, exprots, module) {
- var Matrix = _p.r(43), Utils = _p.r(12), Point = _p.r(50);
- return _p.r(11).createClass("ShapeEvent", {
- constructor: function(event) {
- var target = null;
-
- if (!Utils.isObject(event.target)) {
- this.type = event.type;
- target = event.target;
-
- if (target.correspondingUseElement) {
- target = target.correspondingUseElement;
- }
- this.originEvent = event;
- this.targetShape = target.shape || target.paper || event.currentTarget && (event.currentTarget.shape || event.currentTarget.paper);
- if (event._kityParam) {
- Utils.extend(this, event._kityParam);
- }
- } else {
- Utils.extend(this, event);
- }
- },
- preventDefault: function() {
- var evt = this.originEvent;
- if (!evt) {
- return true;
- }
- if (evt.preventDefault) {
- evt.preventDefault();
- return evt.cancelable;
- } else {
- evt.returnValue = false;
- return true;
- }
- },
-
- getPosition: function(refer, touchIndex) {
- if (!this.originEvent) {
- return null;
- }
- var eventClient = this.originEvent.touches ? this.originEvent.touches[touchIndex || 0] : this.originEvent;
- var target = this.targetShape;
- var targetNode = target.shapeNode || target.node;
- var pScreen = new Point(eventClient && eventClient.clientX || 0, eventClient && eventClient.clientY || 0);
- var pTarget = Matrix.transformPoint(pScreen, targetNode.getScreenCTM().inverse());
- var pRefer = Matrix.getCTM(target, refer || "view").transformPoint(pTarget);
- return pRefer;
- },
- stopPropagation: function() {
- var evt = this.originEvent;
- if (!evt) {
- return true;
- }
- if (evt.stopPropagation) {
- evt.stopPropagation();
- } else {
- evt.cancelBubble = false;
- }
- }
- });
- }
- };
- _p[63] = {
- value: function(require, exports, module) {
- return _p.r(11).createClass("ShapePoint", {
- base: _p.r(50),
- constructor: function(px, py) {
- this.callBase(px, py);
- },
- setX: function(x) {
- return this.setPoint(x, this.y);
- },
- setY: function(y) {
- return this.setPoint(this.x, y);
- },
- setPoint: function(x, y) {
- this.x = x;
- this.y = y;
- this.update();
- return this;
- },
- getPoint: function() {
- return this;
- },
- update: function() {
- if (this.container && this.container.update) {
- this.container.update();
- }
- return this;
- }
- });
- }
- };
- _p[64] = {
- value: {
- COLOR_STANDARD: {
- aliceblue: "#f0f8ff",
- antiquewhite: "#faebd7",
- aqua: "#00ffff",
- aquamarine: "#7fffd4",
- azure: "#f0ffff",
- beige: "#f5f5dc",
- bisque: "#ffe4c4",
- black: "#000000",
- blanchedalmond: "#ffebcd",
- blue: "#0000ff",
- blueviolet: "#8a2be2",
- brown: "#a52a2a",
- burlywood: "#deb887",
- cadetblue: "#5f9ea0",
- chartreuse: "#7fff00",
- chocolate: "#d2691e",
- coral: "#ff7f50",
- cornflowerblue: "#6495ed",
- cornsilk: "#fff8dc",
- crimson: "#dc143c",
- cyan: "#00ffff",
- darkblue: "#00008b",
- darkcyan: "#008b8b",
- darkgoldenrod: "#b8860b",
- darkgray: "#a9a9a9",
- darkgreen: "#006400",
- darkgrey: "#a9a9a9",
- darkkhaki: "#bdb76b",
- darkmagenta: "#8b008b",
- darkolivegreen: "#556b2f",
- darkorange: "#ff8c00",
- darkorchid: "#9932cc",
- darkred: "#8b0000",
- darksalmon: "#e9967a",
- darkseagreen: "#8fbc8f",
- darkslateblue: "#483d8b",
- darkslategray: "#2f4f4f",
- darkslategrey: "#2f4f4f",
- darkturquoise: "#00ced1",
- darkviolet: "#9400d3",
- deeppink: "#ff1493",
- deepskyblue: "#00bfff",
- dimgray: "#696969",
- dimgrey: "#696969",
- dodgerblue: "#1e90ff",
- firebrick: "#b22222",
- floralwhite: "#fffaf0",
- forestgreen: "#228b22",
- fuchsia: "#ff00ff",
- gainsboro: "#dcdcdc",
- ghostwhite: "#f8f8ff",
- gold: "#ffd700",
- goldenrod: "#daa520",
- gray: "#808080",
- green: "#008000",
- greenyellow: "#adff2f",
- grey: "#808080",
- honeydew: "#f0fff0",
- hotpink: "#ff69b4",
- indianred: "#cd5c5c",
- indigo: "#4b0082",
- ivory: "#fffff0",
- khaki: "#f0e68c",
- lavender: "#e6e6fa",
- lavenderblush: "#fff0f5",
- lawngreen: "#7cfc00",
- lemonchiffon: "#fffacd",
- lightblue: "#add8e6",
- lightcoral: "#f08080",
- lightcyan: "#e0ffff",
- lightgoldenrodyellow: "#fafad2",
- lightgray: "#d3d3d3",
- lightgreen: "#90ee90",
- lightgrey: "#d3d3d3",
- lightpink: "#ffb6c1",
- lightsalmon: "#ffa07a",
- lightseagreen: "#20b2aa",
- lightskyblue: "#87cefa",
- lightslategray: "#778899",
- lightslategrey: "#778899",
- lightsteelblue: "#b0c4de",
- lightyellow: "#ffffe0",
- lime: "#00ff00",
- limegreen: "#32cd32",
- linen: "#faf0e6",
- magenta: "#ff00ff",
- maroon: "#800000",
- mediumaquamarine: "#66cdaa",
- mediumblue: "#0000cd",
- mediumorchid: "#ba55d3",
- mediumpurple: "#9370db",
- mediumseagreen: "#3cb371",
- mediumslateblue: "#7b68ee",
- mediumspringgreen: "#00fa9a",
- mediumturquoise: "#48d1cc",
- mediumvioletred: "#c71585",
- midnightblue: "#191970",
- mintcream: "#f5fffa",
- mistyrose: "#ffe4e1",
- moccasin: "#ffe4b5",
- navajowhite: "#ffdead",
- navy: "#000080",
- oldlace: "#fdf5e6",
- olive: "#808000",
- olivedrab: "#6b8e23",
- orange: "#ffa500",
- orangered: "#ff4500",
- orchid: "#da70d6",
- palegoldenrod: "#eee8aa",
- palegreen: "#98fb98",
- paleturquoise: "#afeeee",
- palevioletred: "#db7093",
- papayawhip: "#ffefd5",
- peachpuff: "#ffdab9",
- peru: "#cd853f",
- pink: "#ffc0cb",
- plum: "#dda0dd",
- powderblue: "#b0e0e6",
- purple: "#800080",
- red: "#ff0000",
- rosybrown: "#bc8f8f",
- royalblue: "#4169e1",
- saddlebrown: "#8b4513",
- salmon: "#fa8072",
- sandybrown: "#f4a460",
- seagreen: "#2e8b57",
- seashell: "#fff5ee",
- sienna: "#a0522d",
- silver: "#c0c0c0",
- skyblue: "#87ceeb",
- slateblue: "#6a5acd",
- slategray: "#708090",
- slategrey: "#708090",
- snow: "#fffafa",
- springgreen: "#00ff7f",
- steelblue: "#4682b4",
- tan: "#d2b48c",
- teal: "#008080",
- thistle: "#d8bfd8",
- tomato: "#ff6347",
- turquoise: "#40e0d0",
- violet: "#ee82ee",
- wheat: "#f5deb3",
- white: "#ffffff",
- whitesmoke: "#f5f5f5",
- yellow: "#ffff00"
- },
-
- EXTEND_STANDARD: {}
- }
- };
- _p[65] = {
- value: function(require, exports, module) {
-
- var defaultRatioForStar = {
- "3": .2,
-
- "5": .38196601125,
- "6": .57735026919,
- "8": .541196100146,
- "10": .726542528005,
- "12": .707106781187
- };
- var Point = _p.r(50);
- return _p.r(11).createClass("Star", {
- base: _p.r(46),
- constructor: function(vertex, radius, shrink, offset, angleOffset) {
- this.callBase();
- this.vertex = vertex || 3;
- this.radius = radius || 0;
- this.shrink = shrink;
- this.offset = offset || new Point(0, 0);
- this.angleOffset = angleOffset || 0;
- this.draw();
- },
- getVertex: function() {
- return this.vertex;
- },
- setVertex: function(value) {
- this.vertex = value;
- return this.draw();
- },
- getRadius: function() {
- return this.radius;
- },
- setRadius: function(value) {
- this.radius = value;
- return this.draw();
- },
- getShrink: function() {
- return this.shrink;
- },
- setShrink: function(value) {
- this.shrink = value;
- return this.draw();
- },
- getOffset: function() {
- return this.offset;
- },
- setOffset: function(value) {
- this.offset = value;
- return this.draw();
- },
- getAngleOffset: function() {
- return this.angleOffset;
- },
- setAngleOffset: function(value) {
- this.angleOffset = value;
- return this.draw();
- },
- draw: function() {
- var innerRadius = this.radius, outerRadius = this.radius * (this.shrink || defaultRatioForStar[this.vertex] || .5), vertex = this.vertex, offset = this.offset, angleStart = 90, angleStep = 180 / vertex, angleOffset = this.angleOffset, drawer = this.getDrawer(), i, angle;
- drawer.clear();
- drawer.moveTo(Point.fromPolar(outerRadius, angleStart));
- for (i = 1; i <= vertex * 2; i++) {
- angle = angleStart + angleStep * i;
-
- if (i % 2) {
- drawer.lineTo(Point.fromPolar(innerRadius, angle + angleOffset).offset(offset));
- } else {
- drawer.lineTo(Point.fromPolar(outerRadius, angle));
- }
- }
- drawer.close();
- }
- });
- }
- };
- _p[66] = {
- value: function(require, exports, module) {
-
- var ClassList = _p.r(11).createClass("ClassList", {
- constructor: function(node) {
- this._node = node;
- this._list = node.className.toString().split(" ");
- },
- _update: function() {
- this._node.className = this._list.join(" ");
- },
- add: function(name) {
- this._list.push(name);
- this._update();
- },
- remove: function(name) {
- var index = this._list.indexOf(name);
- if (~index) {
- this._list.splice(index, 1);
- }
- this._update();
- },
- contains: function(name) {
- return !!~this._list.indexOf(name);
- }
- });
- function getClassList(node) {
- if (!node.classList) {
- node.classList = new ClassList(node);
- }
- return node.classList;
- }
- return _p.r(11).createClass("Styled", {
- addClass: function(name) {
- getClassList(this.node).add(name);
- return this;
- },
- removeClass: function(name) {
- getClassList(this.node).remove(name);
- return this;
- },
- hasClass: function(name) {
- return getClassList(this.node).contains(name);
- },
- setStyle: function(styles) {
- if (arguments.length == 2) {
- this.node.style[arguments[0]] = arguments[1];
- return this;
- }
- for (var name in styles) {
- if (styles.hasOwnProperty(name)) {
- this.node.style[name] = styles[name];
- }
- }
- return this;
- }
- });
- }
- };
- _p[67] = {
- value: function(require, exports, module) {
- var doc = document;
- var id = 0;
- var svg = {
- createNode: function(name) {
- var node = doc.createElementNS(svg.ns, name);
- node.id = "kity_" + name + "_" + id++;
- return node;
- },
- defaults: {
- stroke: "none",
- fill: "none"
- },
- xlink: "http://www.w3.org/1999/xlink",
- ns: "http://www.w3.org/2000/svg"
- };
- return svg;
- }
- };
- _p[68] = {
- value: function(require, exports, module) {
- var Point = _p.r(50);
- return _p.r(11).createClass("Sweep", {
- base: _p.r(46),
- constructor: function(sectionArray, angle, angleOffset) {
- this.callBase();
- this.sectionArray = sectionArray || [];
- this.angle = angle || 0;
- this.angleOffset = angleOffset || 0;
- this.draw();
- },
- getSectionArray: function() {
- return this.sectionArray;
- },
- setSectionArray: function(value) {
- this.sectionArray = value;
- return this.draw();
- },
- getAngle: function() {
- return this.angle;
- },
- setAngle: function(value) {
- this.angle = value;
- return this.draw();
- },
- getAngleOffset: function() {
- return this.angleOffset;
- },
- setAngleOffset: function(value) {
- this.angleOffset = value;
- return this.draw();
- },
- draw: function() {
- var sectionArray = this.sectionArray, i;
- for (i = 0; i < sectionArray.length; i += 2) {
- this.drawSection(sectionArray[i], sectionArray[i + 1]);
- }
- return this;
- },
- drawSection: function(from, to) {
- var angleLength = this.angle && (this.angle % 360 ? this.angle % 360 : 360), angleStart = this.angleOffset, angleHalf = angleStart + angleLength / 2, angleEnd = angleStart + angleLength, sweepFlag = angleLength < 0 ? 0 : 1, drawer = this.getDrawer();
- drawer.redraw();
- if (angleLength === 0) {
- drawer.done();
- return;
- }
- drawer.moveTo(Point.fromPolar(from, angleStart));
- drawer.lineTo(Point.fromPolar(to, angleStart));
- if (to) {
- drawer.carcTo(to, 0, sweepFlag, Point.fromPolar(to, angleHalf));
- drawer.carcTo(to, 0, sweepFlag, Point.fromPolar(to, angleEnd));
- }
- drawer.lineTo(Point.fromPolar(from, angleEnd));
- if (from) {
- drawer.carcTo(from, 0, sweepFlag, Point.fromPolar(from, angleHalf));
- drawer.carcTo(from, 0, sweepFlag, Point.fromPolar(from, angleStart));
- }
- drawer.close();
- drawer.done();
- }
- });
- }
- };
- _p[69] = {
- value: function(require, exports, module) {
- var TextContent = _p.r(70);
- var ShapeContainer = _p.r(61);
- var svg = _p.r(67);
- var utils = _p.r(12);
- var offsetHash = {};
- function getTextBoundOffset(text) {
- var font = text._cachedFontHash;
- if (offsetHash[font]) {
- return offsetHash[font];
- }
- var textContent = text.getContent();
- text.setContent("百度Fex");
- var bbox = text.getBoundaryBox(), y = text.getY();
- if (!bbox.height) return {
- top: 0,
- bottom: 0,
- middle: 0
- };
- var topOffset = y - bbox.y + +text.node.getAttribute("dy"), bottomOffset = topOffset - bbox.height;
- text.setContent(textContent);
- return offsetHash[font] = {
- top: topOffset,
- bottom: bottomOffset,
- middle: (topOffset + bottomOffset) / 2
- };
- }
- return _p.r(11).createClass("Text", {
- base: TextContent,
- mixins: [ ShapeContainer ],
- constructor: function(content) {
- this.callBase("text");
- if (content !== undefined) {
- this.setContent(content);
- }
- this._buildFontHash();
- },
- fixPosition: function() {
- if (!this.__fixedPosition) {
- this.setVerticalAlign(this.getVerticalAlign());
- }
- },
- _buildFontHash: function() {
- var style = window.getComputedStyle(this.node);
- this._cachedFontHash = [ style.fontFamily, style.fontSize, style.fontStretch, style.fontStyle, style.fontVariant, style.fontWeight ].join("-");
- },
- _fontChanged: function(font) {
- var last = this._lastFont;
- var current = utils.extend({}, last, font);
- if (!last) {
- this._lastFont = font;
- return true;
- }
- var changed = last.family != current.family || last.size != current.size || last.style != current.style || last.weight != current.weight;
- this._lastFont = current;
- return changed;
- },
- setX: function(x) {
- this.node.setAttribute("x", x);
- return this;
- },
- setPosition: function(x, y) {
- return this.setX(x).setY(y);
- },
- setY: function(y) {
- this.node.setAttribute("y", y);
- return this;
- },
- getX: function() {
- return +this.node.getAttribute("x") || 0;
- },
- getY: function() {
- return +this.node.getAttribute("y") || 0;
- },
- setFont: function(font) {
- this.callBase(font);
- if (this._fontChanged(font)) {
- this._buildFontHash();
- this.setVerticalAlign(this.getVerticalAlign());
- }
- return this;
- },
- setTextAnchor: function(anchor) {
- this.node.setAttribute("text-anchor", anchor);
- return this;
- },
- getTextAnchor: function() {
- return this.node.getAttribute("text-anchor") || "start";
- },
-
- setVerticalAlign: function(align) {
- this.whenPaperReady(function() {
- var dy;
- switch (align) {
- case "top":
- dy = getTextBoundOffset(this).top;
- break;
- case "bottom":
- dy = getTextBoundOffset(this).bottom;
- break;
- case "middle":
- dy = getTextBoundOffset(this).middle;
- break;
- default:
- dy = 0;
- }
- if (dy) this.__fixedPosition = true;
- this.node.setAttribute("dy", dy);
- });
- this.verticalAlign = align;
- return this;
- },
- getVerticalAlign: function() {
- return this.verticalAlign || "baseline";
- },
- setStartOffset: function(offset) {
-
- if (this.shapeNode != this.node) {
- this.shapeNode.setAttribute("startOffset", offset * 100 + "%");
- }
- },
- addSpan: function(span) {
- this.addShape(span);
- return this;
- },
- setPath: function(path) {
- var textpath = this.shapeNode;
- if (this.shapeNode == this.node) {
-
- textpath = this.shapeNode = svg.createNode("textPath");
- while (this.node.firstChild) {
- this.shapeNode.appendChild(this.node.firstChild);
- }
- this.node.appendChild(textpath);
- }
- textpath.setAttributeNS(svg.xlink, "xlink:href", "#" + path.node.id);
- this.setTextAnchor(this.getTextAnchor());
- return this;
- }
- });
- }
- };
- _p[70] = {
- value: function(require, exports, module) {
- var Shape = _p.r(60);
- return _p.r(11).createClass("TextContent", {
- base: Shape,
- constructor: function(nodeType) {
-
- this.callBase(nodeType);
- this.shapeNode = this.shapeNode || this.node;
- this.shapeNode.setAttribute("text-rendering", "geometricPrecision");
- },
- clearContent: function() {
- while (this.shapeNode.firstChild) {
- this.shapeNode.removeChild(this.shapeNode.firstChild);
- }
- return this;
- },
- setContent: function(content) {
- this.shapeNode.textContent = content;
- return this;
- },
- getContent: function() {
- return this.shapeNode.textContent;
- },
- appendContent: function(content) {
- this.shapeNode.textContent += content;
- return this;
- },
- setSize: function(value) {
- return this.setFontSize(value);
- },
- setFontSize: function(value) {
- return this.setFont({
- size: value
- });
- },
- setFontFamily: function(value) {
- return this.setFont({
- family: value
- });
- },
- setFontBold: function(bold) {
- return this.setFont({
- weight: bold ? "bold" : "normal"
- });
- },
- setFontItalic: function(italic) {
- return this.setFont({
- style: italic ? "italic" : "normal"
- });
- },
- setFont: function(font) {
- var node = this.node;
- [ "family", "size", "weight", "style" ].forEach(function(section) {
- if (font[section] === null) {
- node.removeAttribute("font-" + section);
- } else if (font[section]) {
- node.setAttribute("font-" + section, font[section]);
- }
- });
- return this;
- },
- getExtentOfChar: function(index) {
- return this.node.getExtentOfChar(index);
- },
- getRotationOfChar: function(index) {
- return this.node.getRotationOfChar(index);
- },
- getCharNumAtPosition: function(x, y) {
- return this.node.getCharNumAtPosition(this.node.viewportElement.createSVGPoint(x, y));
- }
- });
- }
- };
- _p[71] = {
- value: function(require, exports, module) {
- var TextContent = _p.r(70);
- var Styled = _p.r(66);
- return _p.r(11).createClass("TextSpan", {
- base: TextContent,
- mixins: [ Styled ],
- constructor: function(content) {
- this.callBase("tspan");
- this.setContent(content);
- }
- });
- }
- };
- _p[72] = {
- value: function(require, exports, module) {
- var Svg = _p.r(67);
- var Class = _p.r(11);
- var Use = Class.createClass("Use", {
- base: _p.r(60),
- constructor: function(shape) {
- this.callBase("use");
- this.ref(shape);
- },
- ref: function(shape) {
- if (!shape) {
- this.node.removeAttributeNS(Svg.xlink, "xlink:href");
- return this;
- }
- var shapeId = shape.getId();
- if (shapeId) {
- this.node.setAttributeNS(Svg.xlink, "xlink:href", "#" + shapeId);
- }
-
-
- if (shape.node.getAttribute("fill") === "none") {
- shape.node.removeAttribute("fill");
- }
- if (shape.node.getAttribute("stroke") === "none") {
- shape.node.removeAttribute("stroke");
- }
- return this;
- }
- });
- var Shape = _p.r(60);
- Class.extendClass(Shape, {
-
- use: function() {
- return new Use(this);
- }
- });
- return Use;
- }
- };
- _p[73] = {
- value: function(require, exports, module) {
- var Point = _p.r(50);
- var Matrix = _p.r(43);
- var Vector = _p.r(11).createClass("Vector", {
- base: Point,
- constructor: function(x, y) {
- this.callBase(x, y);
- },
- square: function() {
- return this.x * this.x + this.y * this.y;
- },
- length: function() {
- return Math.sqrt(this.square());
- },
- add: function(q) {
- return new Vector(this.x + q.x, this.y + q.y);
- },
- minus: function(q) {
- return new Vector(this.x - q.x, this.y - q.y);
- },
- dot: function(q) {
- return this.x * q.x + this.y * q.y;
- },
- project: function(q) {
- return q.multipy(this.dot(q) / q.square());
- },
- normalize: function(length) {
- if (length === undefined) {
- length = 1;
- }
- return this.multipy(length / this.length());
- },
- multipy: function(scale) {
- return new Vector(this.x * scale, this.y * scale);
- },
- rotate: function(angle, unit) {
- if (unit == "rad") {
- angle = angle / Math.PI * 180;
- }
- var p = new Matrix().rotate(angle).transformPoint(this);
- return new Vector(p.x, p.y);
- },
- vertical: function() {
- return new Vector(this.y, -this.x);
- },
- reverse: function() {
- return this.multipy(-1);
- },
- getAngle: function() {
- var length = this.length();
- if (length === 0) return 0;
- var rad = Math.acos(this.x / length);
- var sign = this.y > 0 ? 1 : -1;
- return sign * 180 * rad / Math.PI;
- }
- });
- Vector.fromPoints = function(p1, p2) {
- return new Vector(p2.x - p1.x, p2.y - p1.y);
- };
- Vector.fromPolar = function() {
- var p = Point.fromPolar.apply(Point, arguments);
- return new Vector(p.x, p.y);
- };
- _p.r(11).extendClass(Point, {
- asVector: function() {
- return new Vector(this.x, this.y);
- }
- });
- return Vector;
- }
- };
- _p[74] = {
- value: function(require, exports, module) {
- var ShapeContainer = _p.r(61);
- var ViewBox = _p.r(75);
- return _p.r(11).createClass("View", {
- mixins: [ ShapeContainer, ViewBox ],
- base: _p.r(74),
- constructor: function() {
- this.callBase("view");
- }
- });
- }
- };
- _p[75] = {
- value: function(require, exports, module) {
- return _p.r(11).createClass("ViewBox", {
- getViewBox: function() {
- var attr = this.node.getAttribute("viewBox");
- if (attr === null) {
-
-
-
-
- return {
- x: 0,
- y: 0,
- width: this.node.clientWidth || this.node.parentNode.clientWidth,
- height: this.node.clientHeight || this.node.parentNode.clientHeight
- };
- } else {
- attr = attr.split(" ");
- return {
- x: +attr[0],
- y: +attr[1],
- width: +attr[2],
- height: +attr[3]
- };
- }
- },
- setViewBox: function(x, y, width, height) {
- this.node.setAttribute("viewBox", [ x, y, width, height ].join(" "));
- return this;
- }
- });
- }
- };
- _p[76] = {
- value: function(require, exports, module) {
- var kity = {}, utils = _p.r(12);
- kity.version = "2.0.0";
- utils.extend(kity, {
-
- createClass: _p.r(11).createClass,
- extendClass: _p.r(11).extendClass,
- Utils: utils,
- Browser: _p.r(10),
-
- Box: _p.r(25),
- Bezier: _p.r(23),
- BezierPoint: _p.r(24),
- Circle: _p.r(26),
- Clip: _p.r(27),
- Color: _p.r(28),
- Container: _p.r(29),
- Curve: _p.r(30),
- Ellipse: _p.r(32),
- Group: _p.r(36),
- Gradient: _p.r(35),
- HyperLink: _p.r(37),
- Image: _p.r(38),
- Line: _p.r(39),
- LinearGradient: _p.r(40),
- Mask: _p.r(42),
- Matrix: _p.r(43),
- Marker: _p.r(41),
- Palette: _p.r(44),
- Paper: _p.r(45),
- Path: _p.r(46),
- Pattern: _p.r(47),
- Pen: _p.r(48),
- Point: _p.r(50),
- PointContainer: _p.r(51),
- Polygon: _p.r(53),
- Polyline: _p.r(54),
- Pie: _p.r(49),
- RadialGradient: _p.r(55),
- Resource: _p.r(58),
- Rect: _p.r(56),
- RegularPolygon: _p.r(57),
- Ring: _p.r(59),
- Shape: _p.r(60),
- ShapePoint: _p.r(63),
- ShapeContainer: _p.r(61),
- Sweep: _p.r(68),
- Star: _p.r(65),
- Text: _p.r(69),
- TextSpan: _p.r(71),
- Use: _p.r(72),
- Vector: _p.r(73),
- g: _p.r(34),
-
- Animator: _p.r(0),
- Easing: _p.r(1),
- OpacityAnimator: _p.r(4),
- RotateAnimator: _p.r(6),
- ScaleAnimator: _p.r(7),
- Timeline: _p.r(8),
- TranslateAnimator: _p.r(9),
- PathAnimator: _p.r(5),
- MotionAnimator: _p.r(3),
- requestFrame: _p.r(2).requestFrame,
- releaseFrame: _p.r(2).releaseFrame,
-
- Filter: _p.r(20),
- GaussianblurFilter: _p.r(21),
- ProjectionFilter: _p.r(22),
-
- ColorMatrixEffect: _p.r(13),
- CompositeEffect: _p.r(14),
- ConvolveMatrixEffect: _p.r(15),
- Effect: _p.r(16),
- GaussianblurEffect: _p.r(17),
- OffsetEffect: _p.r(18)
- });
- return window.kity = kity;
- }
- };
- var moduleMapping = {
- kity: 76
- };
- function use(name) {
- _p.r([ moduleMapping[name] ]);
- }
- use('kity');
- })();
|