美素佳儿 litter wizard小游戏
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098
  1. var __reflect = (this && this.__reflect) || function (p, c, t) {
  2. p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;
  3. };
  4. var __extends = (this && this.__extends) || function (d, b) {
  5. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  6. function __() { this.constructor = d; }
  7. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8. };
  9. //////////////////////////////////////////////////////////////////////////////////////
  10. //
  11. // Copyright (c) 2014-present, Egret Technology.
  12. // All rights reserved.
  13. // Redistribution and use in source and binary forms, with or without
  14. // modification, are permitted provided that the following conditions are met:
  15. //
  16. // * Redistributions of source code must retain the above copyright
  17. // notice, this list of conditions and the following disclaimer.
  18. // * Redistributions in binary form must reproduce the above copyright
  19. // notice, this list of conditions and the following disclaimer in the
  20. // documentation and/or other materials provided with the distribution.
  21. // * Neither the name of the Egret nor the
  22. // names of its contributors may be used to endorse or promote products
  23. // derived from this software without specific prior written permission.
  24. //
  25. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  26. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  27. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  28. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  29. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  30. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  31. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  32. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  33. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  34. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. //
  36. //////////////////////////////////////////////////////////////////////////////////////
  37. this["DEBUG"] = true;
  38. this["RELEASE"] = false;
  39. var egret;
  40. (function (egret) {
  41. /**
  42. * @private
  43. */
  44. function _getString(code) {
  45. var params = [];
  46. for (var _i = 1; _i < arguments.length; _i++) {
  47. params[_i - 1] = arguments[_i];
  48. }
  49. return egret.sys.tr.apply(egret.sys, arguments);
  50. }
  51. egret.getString = _getString;
  52. function _error(code) {
  53. var params = [];
  54. for (var _i = 1; _i < arguments.length; _i++) {
  55. params[_i - 1] = arguments[_i];
  56. }
  57. var text = egret.sys.tr.apply(null, arguments);
  58. if (true) {
  59. egret.sys.$logToFPS("Error #" + code + ": " + text);
  60. }
  61. throw new Error("#" + code + ": " + text); //使用这种方式报错能够终止后续代码继续运行
  62. }
  63. egret.$error = _error;
  64. function _warn(code) {
  65. var params = [];
  66. for (var _i = 1; _i < arguments.length; _i++) {
  67. params[_i - 1] = arguments[_i];
  68. }
  69. var text = egret.sys.tr.apply(null, arguments);
  70. if (true) {
  71. egret.sys.$logToFPS("Warning #" + code + ": " + text);
  72. }
  73. egret.warn("Warning #" + code + ": " + text);
  74. }
  75. egret.$warn = _warn;
  76. function _markReadOnly(instance, property, isProperty) {
  77. if (isProperty === void 0) { isProperty = true; }
  78. var data = Object.getOwnPropertyDescriptor(isProperty ? instance.prototype : instance, property);
  79. if (data == null) {
  80. console.log(instance);
  81. return;
  82. }
  83. data.set = function (value) {
  84. if (isProperty) {
  85. egret.$warn(1010, egret.getQualifiedClassName(instance), property);
  86. }
  87. else {
  88. egret.$warn(1014, egret.getQualifiedClassName(instance), property);
  89. }
  90. };
  91. Object.defineProperty(instance.prototype, property, data);
  92. }
  93. egret.$markReadOnly = _markReadOnly;
  94. function markCannotUse(instance, property, defaultValue) {
  95. Object.defineProperty(instance.prototype, property, {
  96. get: function () {
  97. egret.$warn(1009, egret.getQualifiedClassName(instance), property);
  98. return defaultValue;
  99. },
  100. set: function (value) {
  101. egret.$error(1009, egret.getQualifiedClassName(instance), property);
  102. },
  103. enumerable: true,
  104. configurable: true
  105. });
  106. }
  107. egret.$markCannotUse = markCannotUse;
  108. })(egret || (egret = {}));
  109. //////////////////////////////////////////////////////////////////////////////////////
  110. //
  111. // Copyright (c) 2014-present, Egret Technology.
  112. // All rights reserved.
  113. // Redistribution and use in source and binary forms, with or without
  114. // modification, are permitted provided that the following conditions are met:
  115. //
  116. // * Redistributions of source code must retain the above copyright
  117. // notice, this list of conditions and the following disclaimer.
  118. // * Redistributions in binary form must reproduce the above copyright
  119. // notice, this list of conditions and the following disclaimer in the
  120. // documentation and/or other materials provided with the distribution.
  121. // * Neither the name of the Egret nor the
  122. // names of its contributors may be used to endorse or promote products
  123. // derived from this software without specific prior written permission.
  124. //
  125. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  126. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  127. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  128. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  129. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  130. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  131. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  132. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  133. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  134. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  135. //
  136. //////////////////////////////////////////////////////////////////////////////////////
  137. var egret;
  138. (function (egret) {
  139. /**
  140. * @language en_US
  141. * Registers the runtime class information for a class.This method adds some strings which represent the class name or
  142. * some interface names to the class definition. After the registration,you can use egret.is() method to do the type checking
  143. * for the instance of this class.<br/>
  144. * Note:If you use the TypeScript programming language, the egret command line tool will automatically generate the registration code line.
  145. * You don't need to manually call this method.
  146. *
  147. * @example the following code shows how to register the runtime class information for the EventDispatcher class and do the type checking:
  148. * <pre>
  149. * egret.registerClass(egret.EventDispatcher,"egret.EventDispatcher",["egret.IEventDispatcher"]);
  150. * let dispatcher = new egret.EventDispatcher();
  151. * egret.log(egret.is(dispatcher, "egret.IEventDispatcher")); //true。
  152. * egret.log(egret.is(dispatcher, "egret.EventDispatcher")); //true。
  153. * egret.log(egret.is(dispatcher, "egret.Bitmap")); //false。
  154. * </pre>
  155. * @param classDefinition the class definition to be registered.
  156. * @param className a unique identification string of the specific class
  157. * @param interfaceNames a list of unique identification string of the specific interfaces.
  158. * @version Egret 2.4
  159. * @platform Web,Native
  160. */
  161. /**
  162. * @language zh_CN
  163. * 为一个类定义注册运行时类信息,用此方法往类定义上注册它自身以及所有接口对应的字符串。
  164. * 在运行时,这个类的实例将可以使用 egret.is() 方法传入一个字符串来判断实例类型。
  165. * @example 以下代码演示了如何为EventDispatcher类注册运行时类信息并判断类型:
  166. * <pre>
  167. * //为egret.EventDispatcher类注册运行时类信息,由于它实现了IEventDispatcher接口,这里应同时传入接口名对应的字符串。
  168. * egret.registerClass(egret.EventDispatcher,"egret.EventDispatcher",["egret.IEventDispatcher"]);
  169. * let dispatcher = new egret.EventDispatcher();
  170. * egret.log(egret.is(dispatcher, "egret.IEventDispatcher")); //true。
  171. * egret.log(egret.is(dispatcher, "egret.EventDispatcher")); //true。
  172. * egret.log(egret.is(dispatcher, "egret.Bitmap")); //false。
  173. * </pre>
  174. * 注意:若您使用 TypeScript 来编写程序,egret 命令行会自动帮您生成类信息注册代码行到最终的 Javascript 文件中。因此您不需要手动调用此方法。
  175. *
  176. * @param classDefinition 要注册的类定义。
  177. * @param className 要注册的类名。
  178. * @param interfaceNames 要注册的类所实现的接口名列表。
  179. * @version Egret 2.4
  180. * @platform Web,Native
  181. */
  182. function registerClass(classDefinition, className, interfaceNames) {
  183. if (true) {
  184. if (!classDefinition) {
  185. egret.$error(1003, "classDefinition");
  186. }
  187. if (!classDefinition.prototype) {
  188. egret.$error(1012, "classDefinition");
  189. }
  190. if (className === void 0) {
  191. egret.$error(1003, "className");
  192. }
  193. }
  194. var prototype = classDefinition.prototype;
  195. prototype.__class__ = className;
  196. var types = [className];
  197. if (interfaceNames) {
  198. types = types.concat(interfaceNames);
  199. }
  200. var superTypes = prototype.__types__;
  201. if (prototype.__types__) {
  202. var length_1 = superTypes.length;
  203. for (var i = 0; i < length_1; i++) {
  204. var name_1 = superTypes[i];
  205. if (types.indexOf(name_1) == -1) {
  206. types.push(name_1);
  207. }
  208. }
  209. }
  210. prototype.__types__ = types;
  211. }
  212. egret.registerClass = registerClass;
  213. })(egret || (egret = {}));
  214. //////////////////////////////////////////////////////////////////////////////////////
  215. //
  216. // Copyright (c) 2014-present, Egret Technology.
  217. // All rights reserved.
  218. // Redistribution and use in source and binary forms, with or without
  219. // modification, are permitted provided that the following conditions are met:
  220. //
  221. // * Redistributions of source code must retain the above copyright
  222. // notice, this list of conditions and the following disclaimer.
  223. // * Redistributions in binary form must reproduce the above copyright
  224. // notice, this list of conditions and the following disclaimer in the
  225. // documentation and/or other materials provided with the distribution.
  226. // * Neither the name of the Egret nor the
  227. // names of its contributors may be used to endorse or promote products
  228. // derived from this software without specific prior written permission.
  229. //
  230. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  231. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  232. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  233. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  234. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  235. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  236. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  237. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  238. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  239. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  240. //
  241. //////////////////////////////////////////////////////////////////////////////////////
  242. /// <reference path="registerClass.ts" />
  243. function __extends(d, b) {
  244. for (var p in b)
  245. if (b.hasOwnProperty(p))
  246. d[p] = b[p];
  247. function __() {
  248. this.constructor = d;
  249. }
  250. __.prototype = b.prototype;
  251. d.prototype = new __();
  252. }
  253. var __define = this.__define || function (o, p, g, s) { Object.defineProperty(o, p, { configurable: true, enumerable: true, get: g, set: s }); };
  254. var egret;
  255. (function (egret) {
  256. /**
  257. * @private
  258. * 哈希计数
  259. */
  260. egret.$hashCount = 1;
  261. /**
  262. * @language en_US
  263. * The HashObject class is the base class for all objects in the Egret framework.The HashObject
  264. * class includes a hashCode property, which is a unique identification number of the instance.
  265. * @version Egret 2.4
  266. * @platform Web,Native
  267. */
  268. /**
  269. * @language zh_CN
  270. * Egret顶级对象。框架内所有对象的基类,为对象实例提供唯一的hashCode值。
  271. * @version Egret 2.4
  272. * @platform Web,Native
  273. */
  274. var HashObject = (function () {
  275. /**
  276. * @language en_US
  277. * Initializes a HashObject
  278. * @version Egret 2.4
  279. * @platform Web,Native
  280. */
  281. /**
  282. * @language zh_CN
  283. * 创建一个 HashObject 对象
  284. * @version Egret 2.4
  285. * @platform Web,Native
  286. */
  287. function HashObject() {
  288. this.$hashCode = egret.$hashCount++;
  289. }
  290. Object.defineProperty(HashObject.prototype, "hashCode", {
  291. /**
  292. * @language en_US
  293. * a unique identification number assigned to this instance.
  294. * @version Egret 2.4
  295. * @platform Web,Native
  296. */
  297. /**
  298. * @language zh_CN
  299. * 返回此对象唯一的哈希值,用于唯一确定一个对象。hashCode为大于等于1的整数。
  300. * @version Egret 2.4
  301. * @platform Web,Native
  302. */
  303. get: function () {
  304. return this.$hashCode;
  305. },
  306. enumerable: true,
  307. configurable: true
  308. });
  309. return HashObject;
  310. }());
  311. egret.HashObject = HashObject;
  312. __reflect(HashObject.prototype, "egret.HashObject", ["egret.IHashObject"]);
  313. if (true) {
  314. egret.$markReadOnly(HashObject, "hashCode");
  315. }
  316. })(egret || (egret = {}));
  317. //////////////////////////////////////////////////////////////////////////////////////
  318. //
  319. // Copyright (c) 2014-present, Egret Technology.
  320. // All rights reserved.
  321. // Redistribution and use in source and binary forms, with or without
  322. // modification, are permitted provided that the following conditions are met:
  323. //
  324. // * Redistributions of source code must retain the above copyright
  325. // notice, this list of conditions and the following disclaimer.
  326. // * Redistributions in binary form must reproduce the above copyright
  327. // notice, this list of conditions and the following disclaimer in the
  328. // documentation and/or other materials provided with the distribution.
  329. // * Neither the name of the Egret nor the
  330. // names of its contributors may be used to endorse or promote products
  331. // derived from this software without specific prior written permission.
  332. //
  333. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  334. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  335. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  336. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  337. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  338. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  339. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  340. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  341. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  342. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  343. //
  344. //////////////////////////////////////////////////////////////////////////////////////
  345. var egret;
  346. (function (egret) {
  347. var rectanglePool = [];
  348. /**
  349. * @language en_US
  350. * A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its
  351. * width and its height.<br/>
  352. * The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of
  353. * one property has no effect on the others. However, the right and bottom properties are integrally related to those
  354. * four properties. For example, if you change the value of the right property, the value of the width property changes;
  355. * if you change the bottom property, the value of the height property changes.
  356. * @version Egret 2.4
  357. * @platform Web,Native
  358. * @includeExample egret/geom/Rectangle.ts
  359. */
  360. /**
  361. * @language zh_CN
  362. * Rectangle 对象是按其位置(由它左上角的点 (x, y) 确定)以及宽度和高度定义的区域。<br/>
  363. * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。
  364. * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width
  365. * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。
  366. * @version Egret 2.4
  367. * @platform Web,Native
  368. * @includeExample egret/geom/Rectangle.ts
  369. */
  370. var Rectangle = (function (_super) {
  371. __extends(Rectangle, _super);
  372. /**
  373. * @language en_US
  374. * Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified
  375. * width and height parameters.
  376. * @param x The x coordinate of the top-left corner of the rectangle.
  377. * @param y The y coordinate of the top-left corner of the rectangle.
  378. * @param width The width of the rectangle, in pixels.
  379. * @param height The height of the rectangle, in pixels.
  380. * @version Egret 2.4
  381. * @platform Web,Native
  382. */
  383. /**
  384. * @language zh_CN
  385. * 创建一个新 Rectangle 对象,其左上角由 x 和 y 参数指定,并具有指定的 width 和 height 参数。
  386. * @param x 矩形左上角的 x 坐标。
  387. * @param y 矩形左上角的 y 坐标。
  388. * @param width 矩形的宽度(以像素为单位)。
  389. * @param height 矩形的高度(以像素为单位)。
  390. * @version Egret 2.4
  391. * @platform Web,Native
  392. */
  393. function Rectangle(x, y, width, height) {
  394. if (x === void 0) { x = 0; }
  395. if (y === void 0) { y = 0; }
  396. if (width === void 0) { width = 0; }
  397. if (height === void 0) { height = 0; }
  398. var _this = _super.call(this) || this;
  399. _this.x = x;
  400. _this.y = y;
  401. _this.width = width;
  402. _this.height = height;
  403. return _this;
  404. }
  405. /**
  406. * @language en_US
  407. * Releases a rectangle instance to the object pool.
  408. * @version Egret 2.4
  409. * @platform Web,Native
  410. */
  411. /**
  412. * @language zh_CN
  413. * 释放一个Rectangle实例到对象池
  414. * @version Egret 2.4
  415. * @platform Web,Native
  416. */
  417. Rectangle.release = function (rect) {
  418. if (!rect) {
  419. return;
  420. }
  421. rectanglePool.push(rect);
  422. };
  423. /**
  424. * @language en_US
  425. * get a rectangle instance from the object pool or create a new one.
  426. * @version Egret 2.4
  427. * @platform Web,Native
  428. */
  429. /**
  430. * @language zh_CN
  431. * 从对象池中取出或创建一个新的Rectangle对象。
  432. * @version Egret 2.4
  433. * @platform Web,Native
  434. */
  435. Rectangle.create = function () {
  436. var rect = rectanglePool.pop();
  437. if (!rect) {
  438. rect = new Rectangle();
  439. }
  440. return rect;
  441. };
  442. Object.defineProperty(Rectangle.prototype, "right", {
  443. /**
  444. * @language en_US
  445. * The sum of the x and width properties.
  446. * @version Egret 2.4
  447. * @platform Web,Native
  448. */
  449. /**
  450. * @language zh_CN
  451. * x 和 width 属性的和。
  452. * @version Egret 2.4
  453. * @platform Web,Native
  454. */
  455. get: function () {
  456. return this.x + this.width;
  457. },
  458. set: function (value) {
  459. this.width = value - this.x;
  460. },
  461. enumerable: true,
  462. configurable: true
  463. });
  464. Object.defineProperty(Rectangle.prototype, "bottom", {
  465. /**
  466. * @language en_US
  467. * The sum of the y and height properties.
  468. * @version Egret 2.4
  469. * @platform Web,Native
  470. */
  471. /**
  472. * @language zh_CN
  473. * y 和 height 属性的和。
  474. * @version Egret 2.4
  475. * @platform Web,Native
  476. */
  477. get: function () {
  478. return this.y + this.height;
  479. },
  480. set: function (value) {
  481. this.height = value - this.y;
  482. },
  483. enumerable: true,
  484. configurable: true
  485. });
  486. Object.defineProperty(Rectangle.prototype, "left", {
  487. /**
  488. * @language en_US
  489. * The x coordinate of the top-left corner of the rectangle. Changing the left property of a Rectangle object has
  490. * no effect on the y and height properties. However it does affect the width property, whereas changing the x value
  491. * does not affect the width property.
  492. * The value of the left property is equal to the value of the x property.
  493. * @version Egret 2.4
  494. * @platform Web,Native
  495. */
  496. /**
  497. * @language zh_CN
  498. * 矩形左上角的 x 坐标。更改 Rectangle 对象的 left 属性对 y 和 height 属性没有影响。但是,它会影响 width 属性,而更改 x 值不会影响 width 属性。
  499. * left 属性的值等于 x 属性的值。
  500. * @version Egret 2.4
  501. * @platform Web,Native
  502. */
  503. get: function () {
  504. return this.x;
  505. },
  506. set: function (value) {
  507. this.width += this.x - value;
  508. this.x = value;
  509. },
  510. enumerable: true,
  511. configurable: true
  512. });
  513. Object.defineProperty(Rectangle.prototype, "top", {
  514. /**
  515. * @language en_US
  516. * The y coordinate of the top-left corner of the rectangle. Changing the top property of a Rectangle object has
  517. * no effect on the x and width properties. However it does affect the height property, whereas changing the y
  518. * value does not affect the height property.<br/>
  519. * The value of the top property is equal to the value of the y property.
  520. * @version Egret 2.4
  521. * @platform Web,Native
  522. */
  523. /**
  524. * @language zh_CN
  525. * 矩形左上角的 y 坐标。更改 Rectangle 对象的 top 属性对 x 和 width 属性没有影响。但是,它会影响 height 属性,而更改 y 值不会影响 height 属性。<br/>
  526. * top 属性的值等于 y 属性的值。
  527. * @version Egret 2.4
  528. * @platform Web,Native
  529. */
  530. get: function () {
  531. return this.y;
  532. },
  533. set: function (value) {
  534. this.height += this.y - value;
  535. this.y = value;
  536. },
  537. enumerable: true,
  538. configurable: true
  539. });
  540. Object.defineProperty(Rectangle.prototype, "topLeft", {
  541. /**
  542. * @language en_US
  543. * The location of the Rectangle object's top-left corner, determined by the x and y coordinates of the point.
  544. * @version Egret 2.4
  545. * @platform Web,Native
  546. */
  547. /**
  548. * @language zh_CN
  549. * 由该点的 x 和 y 坐标确定的 Rectangle 对象左上角的位置。
  550. * @version Egret 2.4
  551. * @platform Web,Native
  552. */
  553. get: function () {
  554. return new egret.Point(this.left, this.top);
  555. },
  556. set: function (value) {
  557. this.top = value.y;
  558. this.left = value.x;
  559. },
  560. enumerable: true,
  561. configurable: true
  562. });
  563. Object.defineProperty(Rectangle.prototype, "bottomRight", {
  564. /**
  565. * @language en_US
  566. * The location of the Rectangle object's bottom-right corner, determined by the values of the right and bottom properties.
  567. * @version Egret 2.4
  568. * @platform Web,Native
  569. */
  570. /**
  571. * @language zh_CN
  572. * 由 right 和 bottom 属性的值确定的 Rectangle 对象的右下角的位置。
  573. * @version Egret 2.4
  574. * @platform Web,Native
  575. */
  576. get: function () {
  577. return new egret.Point(this.right, this.bottom);
  578. },
  579. set: function (value) {
  580. this.bottom = value.y;
  581. this.right = value.x;
  582. },
  583. enumerable: true,
  584. configurable: true
  585. });
  586. /**
  587. * @language en_US
  588. * Copies all of rectangle data from the source Rectangle object into the calling Rectangle object.
  589. * @param sourceRect The Rectangle object from which to copy the data.
  590. * @version Egret 2.4
  591. * @platform Web,Native
  592. */
  593. /**
  594. * @language zh_CN
  595. * 将源 Rectangle 对象中的所有矩形数据复制到调用方 Rectangle 对象中。
  596. * @param sourceRect 要从中复制数据的 Rectangle 对象。
  597. * @version Egret 2.4
  598. * @platform Web,Native
  599. */
  600. Rectangle.prototype.copyFrom = function (sourceRect) {
  601. this.x = sourceRect.x;
  602. this.y = sourceRect.y;
  603. this.width = sourceRect.width;
  604. this.height = sourceRect.height;
  605. return this;
  606. };
  607. /**
  608. * @language en_US
  609. * Sets the members of Rectangle to the specified values
  610. * @param x The x coordinate of the top-left corner of the rectangle.
  611. * @param y The y coordinate of the top-left corner of the rectangle.
  612. * @param width The width of the rectangle, in pixels.
  613. * @param height The height of the rectangle, in pixels.
  614. * @version Egret 2.4
  615. * @platform Web,Native
  616. */
  617. /**
  618. * @language zh_CN
  619. * 将 Rectangle 的成员设置为指定值
  620. * @param x 矩形左上角的 x 坐标。
  621. * @param y 矩形左上角的 y 坐标。
  622. * @param width 矩形的宽度(以像素为单位)。
  623. * @param height 矩形的高度(以像素为单位)。
  624. * @version Egret 2.4
  625. * @platform Web,Native
  626. */
  627. Rectangle.prototype.setTo = function (x, y, width, height) {
  628. this.x = x;
  629. this.y = y;
  630. this.width = width;
  631. this.height = height;
  632. return this;
  633. };
  634. /**
  635. * @language en_US
  636. * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object.
  637. * @param x The x coordinate (horizontal position) of the point.
  638. * @param y The y coordinate (vertical position) of the point.
  639. * @returns A value of true if the Rectangle object contains the specified point; otherwise false.
  640. * @version Egret 2.4
  641. * @platform Web,Native
  642. */
  643. /**
  644. * @language zh_CN
  645. * 确定由此 Rectangle 对象定义的矩形区域内是否包含指定的点。
  646. * @param x 检测点的x轴
  647. * @param y 检测点的y轴
  648. * @returns 如果检测点位于矩形内,返回true,否则,返回false
  649. * @version Egret 2.4
  650. * @platform Web,Native
  651. */
  652. Rectangle.prototype.contains = function (x, y) {
  653. return this.x <= x &&
  654. this.x + this.width >= x &&
  655. this.y <= y &&
  656. this.y + this.height >= y;
  657. };
  658. /**
  659. * @language en_US
  660. * If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns
  661. * the area of intersection as a Rectangle object. If the rectangles do not intersect, this method returns an empty
  662. * Rectangle object with its properties set to 0.
  663. * @param toIntersect The Rectangle object to compare against to see if it intersects with this Rectangle object.
  664. * @returns A Rectangle object that equals the area of intersection. If the rectangles do not intersect, this method
  665. * returns an empty Rectangle object; that is, a rectangle with its x, y, width, and height properties set to 0.
  666. * @version Egret 2.4
  667. * @platform Web,Native
  668. */
  669. /**
  670. * @language zh_CN
  671. * 如果在 toIntersect 参数中指定的 Rectangle 对象与此 Rectangle 对象相交,则返回交集区域作为 Rectangle 对象。如果矩形不相交,
  672. * 则此方法返回一个空的 Rectangle 对象,其属性设置为 0。
  673. * @param toIntersect 要对照比较以查看其是否与此 Rectangle 对象相交的 Rectangle 对象。
  674. * @returns 等于交集区域的 Rectangle 对象。如果该矩形不相交,则此方法返回一个空的 Rectangle 对象;即,其 x、y、width 和
  675. * height 属性均设置为 0 的矩形。
  676. * @version Egret 2.4
  677. * @platform Web,Native
  678. */
  679. Rectangle.prototype.intersection = function (toIntersect) {
  680. return this.clone().$intersectInPlace(toIntersect);
  681. };
  682. /**
  683. * @language en_US
  684. * Increases the size of the Rectangle object by the specified amounts, in pixels.
  685. * The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value.
  686. * @param dx The value to be added to the left and the right of the Rectangle object.
  687. * @param dy The value to be added to the top and the bottom of the Rectangle.
  688. * @version Egret 2.4
  689. * @platform Web,Native
  690. */
  691. /**
  692. * @language zh_CN
  693. * 按指定量增加 Rectangle 对象的大小(以像素为单位)
  694. * 保持 Rectangle 对象的中心点不变,使用 dx 值横向增加它的大小,使用 dy 值纵向增加它的大小。
  695. * @param dx Rectangle 对象横向增加的值。
  696. * @param dy Rectangle 对象纵向增加的值。
  697. * @version Egret 2.4
  698. * @platform Web,Native
  699. */
  700. Rectangle.prototype.inflate = function (dx, dy) {
  701. this.x -= dx;
  702. this.width += 2 * dx;
  703. this.y -= dy;
  704. this.height += 2 * dy;
  705. };
  706. /**
  707. * @private
  708. */
  709. Rectangle.prototype.$intersectInPlace = function (clipRect) {
  710. var x0 = this.x;
  711. var y0 = this.y;
  712. var x1 = clipRect.x;
  713. var y1 = clipRect.y;
  714. var l = Math.max(x0, x1);
  715. var r = Math.min(x0 + this.width, x1 + clipRect.width);
  716. if (l <= r) {
  717. var t = Math.max(y0, y1);
  718. var b = Math.min(y0 + this.height, y1 + clipRect.height);
  719. if (t <= b) {
  720. this.setTo(l, t, r - l, b - t);
  721. return this;
  722. }
  723. }
  724. this.setEmpty();
  725. return this;
  726. };
  727. /**
  728. * @language en_US
  729. * Determines whether the object specified in the toIntersect parameter intersects with this Rectangle object.
  730. * This method checks the x, y, width, and height properties of the specified Rectangle object to see if it
  731. * intersects with this Rectangle object.
  732. * @param toIntersect The Rectangle object to compare against this Rectangle object.
  733. * @returns A value of true if the specified object intersects with this Rectangle object; otherwise false.
  734. * @version Egret 2.4
  735. * @platform Web,Native
  736. */
  737. /**
  738. * @language zh_CN
  739. * 确定在 toIntersect 参数中指定的对象是否与此 Rectangle 对象相交。此方法检查指定的 Rectangle
  740. * 对象的 x、y、width 和 height 属性,以查看它是否与此 Rectangle 对象相交。
  741. * @param toIntersect 要与此 Rectangle 对象比较的 Rectangle 对象。
  742. * @returns 如果两个矩形相交,返回true,否则返回false
  743. * @version Egret 2.4
  744. * @platform Web,Native
  745. */
  746. Rectangle.prototype.intersects = function (toIntersect) {
  747. return Math.max(this.x, toIntersect.x) <= Math.min(this.right, toIntersect.right)
  748. && Math.max(this.y, toIntersect.y) <= Math.min(this.bottom, toIntersect.bottom);
  749. };
  750. /**
  751. * @language en_US
  752. * Determines whether or not this Rectangle object is empty.
  753. * @returns A value of true if the Rectangle object's width or height is less than or equal to 0; otherwise false.
  754. * @version Egret 2.4
  755. * @platform Web,Native
  756. */
  757. /**
  758. * @language zh_CN
  759. * 确定此 Rectangle 对象是否为空。
  760. * @returns 如果 Rectangle 对象的宽度或高度小于等于 0,则返回 true 值,否则返回 false。
  761. * @version Egret 2.4
  762. * @platform Web,Native
  763. */
  764. Rectangle.prototype.isEmpty = function () {
  765. return this.width <= 0 || this.height <= 0;
  766. };
  767. /**
  768. * @language en_US
  769. * Sets all of the Rectangle object's properties to 0. A Rectangle object is empty if its width or height is less than or equal to 0.
  770. * @version Egret 2.4
  771. * @platform Web,Native
  772. */
  773. /**
  774. * @language zh_CN
  775. * 将 Rectangle 对象的所有属性设置为 0。
  776. * @version Egret 2.4
  777. * @platform Web,Native
  778. */
  779. Rectangle.prototype.setEmpty = function () {
  780. this.x = 0;
  781. this.y = 0;
  782. this.width = 0;
  783. this.height = 0;
  784. };
  785. /**
  786. * @language en_US
  787. * Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object.
  788. * @returns A new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object.
  789. * @version Egret 2.4
  790. * @platform Web,Native
  791. */
  792. /**
  793. * @language zh_CN
  794. * 返回一个新的 Rectangle 对象,其 x、y、width 和 height 属性的值与原始 Rectangle 对象的对应值相同。
  795. * @returns 新的 Rectangle 对象,其 x、y、width 和 height 属性的值与原始 Rectangle 对象的对应值相同。
  796. * @version Egret 2.4
  797. * @platform Web,Native
  798. */
  799. Rectangle.prototype.clone = function () {
  800. return new Rectangle(this.x, this.y, this.width, this.height);
  801. };
  802. /**
  803. * @language en_US
  804. * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object.
  805. * This method is similar to the Rectangle.contains() method, except that it takes a Point object as a parameter.
  806. * @param point The point, as represented by its x and y coordinates.
  807. * @returns A value of true if the Rectangle object contains the specified point; otherwise false.
  808. * @version Egret 2.4
  809. * @platform Web,Native
  810. */
  811. /**
  812. * @language zh_CN
  813. * 确定由此 Rectangle 对象定义的矩形区域内是否包含指定的点。
  814. * 此方法与 Rectangle.contains() 方法类似,只不过它采用 Point 对象作为参数。
  815. * @param point 包含点对象
  816. * @returns 如果包含,返回true,否则返回false
  817. * @version Egret 2.4
  818. * @platform Web,Native
  819. */
  820. Rectangle.prototype.containsPoint = function (point) {
  821. if (this.x < point.x
  822. && this.x + this.width > point.x
  823. && this.y < point.y
  824. && this.y + this.height > point.y) {
  825. return true;
  826. }
  827. return false;
  828. };
  829. /**
  830. * @language en_US
  831. * Determines whether the Rectangle object specified by the rect parameter is contained within this Rectangle object.
  832. * A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first.
  833. * @param rect The Rectangle object being checked.
  834. * @returns A value of true if the Rectangle object that you specify is contained by this Rectangle object; otherwise false.
  835. * @version Egret 2.4
  836. * @platform Web,Native
  837. */
  838. /**
  839. * @language zh_CN
  840. * 确定此 Rectangle 对象内是否包含由 rect 参数指定的 Rectangle 对象。
  841. * 如果一个 Rectangle 对象完全在另一个 Rectangle 的边界内,我们说第二个 Rectangle 包含第一个 Rectangle。
  842. * @param rect 所检查的 Rectangle 对象
  843. * @returns 如果此 Rectangle 对象包含您指定的 Rectangle 对象,则返回 true 值,否则返回 false。
  844. * @version Egret 2.4
  845. * @platform Web,Native
  846. */
  847. Rectangle.prototype.containsRect = function (rect) {
  848. var r1 = rect.x + rect.width;
  849. var b1 = rect.y + rect.height;
  850. var r2 = this.x + this.width;
  851. var b2 = this.y + this.height;
  852. return (rect.x >= this.x) && (rect.x < r2) && (rect.y >= this.y) && (rect.y < b2) && (r1 > this.x) && (r1 <= r2) && (b1 > this.y) && (b1 <= b2);
  853. };
  854. /**
  855. * @language en_US
  856. * Determines whether the object specified in the toCompare parameter is equal to this Rectangle object.
  857. * This method compares the x, y, width, and height properties of an object against the same properties of this Rectangle object.
  858. * @param The rectangle to compare to this Rectangle object.
  859. * @returns A value of true if the object has exactly the same values for the x, y, width, and height properties as this Rectangle object; otherwise false.
  860. * @version Egret 2.4
  861. * @platform Web,Native
  862. */
  863. /**
  864. * @language zh_CN
  865. * 确定在 toCompare 参数中指定的对象是否等于此 Rectangle 对象。
  866. * 此方法将某个对象的 x、y、width 和 height 属性与此 Rectangle 对象所对应的相同属性进行比较。
  867. * @param toCompare 要与此 Rectangle 对象进行比较的矩形。
  868. * @returns 如果对象具有与此 Rectangle 对象完全相同的 x、y、width 和 height 属性值,则返回 true 值,否则返回 false。
  869. * @version Egret 2.4
  870. * @platform Web,Native
  871. */
  872. Rectangle.prototype.equals = function (toCompare) {
  873. if (this === toCompare) {
  874. return true;
  875. }
  876. return this.x === toCompare.x && this.y === toCompare.y
  877. && this.width === toCompare.width && this.height === toCompare.height;
  878. };
  879. /**
  880. * @language en_US
  881. * Increases the size of the Rectangle object. This method is similar to the Rectangle.inflate() method except it takes a Point object as a parameter.
  882. * @param point 此 Point 对象的 x 属性用于增加 Rectangle 对象的水平尺寸。y 属性用于增加 Rectangle 对象的垂直尺寸。
  883. * @version Egret 2.4
  884. * @platform Web,Native
  885. */
  886. /**
  887. * @language zh_CN
  888. * 增加 Rectangle 对象的大小。此方法与 Rectangle.inflate() 方法类似,只不过它采用 Point 对象作为参数。
  889. * @param point The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object.
  890. * @version Egret 2.4
  891. * @platform Web,Native
  892. */
  893. Rectangle.prototype.inflatePoint = function (point) {
  894. this.inflate(point.x, point.y);
  895. };
  896. /**
  897. * @language en_US
  898. * Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts.
  899. * @param dx Moves the x value of the Rectangle object by this amount.
  900. * @param dy Moves the y value of the Rectangle object by this amount.
  901. * @version Egret 2.4
  902. * @platform Web,Native
  903. */
  904. /**
  905. * @language zh_CN
  906. * 按指定量调整 Rectangle 对象的位置(由其左上角确定)。
  907. * @param dx 将 Rectangle 对象的 x 值移动此数量。
  908. * @param dy 将 Rectangle 对象的 t 值移动此数量。
  909. * @version Egret 2.4
  910. * @platform Web,Native
  911. */
  912. Rectangle.prototype.offset = function (dx, dy) {
  913. this.x += dx;
  914. this.y += dy;
  915. };
  916. /**
  917. * @language en_US
  918. * Adjusts the location of the Rectangle object using a Point object as a parameter. This method is similar to the Rectangle.offset() method, except that it takes a Point object as a parameter.
  919. * @param point A Point object to use to offset this Rectangle object.
  920. * @version Egret 2.4
  921. * @platform Web,Native
  922. */
  923. /**
  924. * @language zh_CN
  925. * 将 Point 对象用作参数来调整 Rectangle 对象的位置。此方法与 Rectangle.offset() 方法类似,只不过它采用 Point 对象作为参数。
  926. * @param point 要用于偏移此 Rectangle 对象的 Point 对象。
  927. * @version Egret 2.4
  928. * @platform Web,Native
  929. */
  930. Rectangle.prototype.offsetPoint = function (point) {
  931. this.offset(point.x, point.y);
  932. };
  933. /**
  934. * @language en_US
  935. * Builds and returns a string that lists the horizontal and vertical positions and the width and height of the Rectangle object.
  936. * @returns A string listing the value of each of the following properties of the Rectangle object: x, y, width, and height.
  937. * @version Egret 2.4
  938. * @platform Web,Native
  939. */
  940. /**
  941. * @language zh_CN
  942. * 生成并返回一个字符串,该字符串列出 Rectangle 对象的水平位置和垂直位置以及高度和宽度。
  943. * @returns 一个字符串,它列出了 Rectangle 对象的下列各个属性的值:x、y、width 和 height。
  944. * @version Egret 2.4
  945. * @platform Web,Native
  946. */
  947. Rectangle.prototype.toString = function () {
  948. return "(x=" + this.x + ", y=" + this.y + ", width=" + this.width + ", height=" + this.height + ")";
  949. };
  950. /**
  951. * @language en_US
  952. * Adds two rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two rectangles.
  953. * @param toUnion A Rectangle object to add to this Rectangle object.
  954. * @returns A new Rectangle object that is the union of the two rectangles.
  955. * @version Egret 2.4
  956. * @platform Web,Native
  957. */
  958. /**
  959. * @language zh_CN
  960. * 通过填充两个矩形之间的水平和垂直空间,将这两个矩形组合在一起以创建一个新的 Rectangle 对象。
  961. * @param toUnion 要添加到此 Rectangle 对象的 Rectangle 对象。
  962. * @returns 充当两个矩形的联合的新 Rectangle 对象。
  963. * @version Egret 2.4
  964. * @platform Web,Native
  965. */
  966. Rectangle.prototype.union = function (toUnion) {
  967. var result = this.clone();
  968. if (toUnion.isEmpty()) {
  969. return result;
  970. }
  971. if (result.isEmpty()) {
  972. result.copyFrom(toUnion);
  973. return result;
  974. }
  975. var l = Math.min(result.x, toUnion.x);
  976. var t = Math.min(result.y, toUnion.y);
  977. result.setTo(l, t, Math.max(result.right, toUnion.right) - l, Math.max(result.bottom, toUnion.bottom) - t);
  978. return result;
  979. };
  980. /**
  981. * @private
  982. */
  983. Rectangle.prototype.$getBaseWidth = function (angle) {
  984. var u = Math.abs(Math.cos(angle));
  985. var v = Math.abs(Math.sin(angle));
  986. return u * this.width + v * this.height;
  987. };
  988. /**
  989. * @private
  990. */
  991. Rectangle.prototype.$getBaseHeight = function (angle) {
  992. var u = Math.abs(Math.cos(angle));
  993. var v = Math.abs(Math.sin(angle));
  994. return v * this.width + u * this.height;
  995. };
  996. return Rectangle;
  997. }(egret.HashObject));
  998. egret.Rectangle = Rectangle;
  999. __reflect(Rectangle.prototype, "egret.Rectangle");
  1000. /**
  1001. * @private
  1002. * 仅供框架内复用,要防止暴露引用到外部。
  1003. */
  1004. egret.$TempRectangle = new Rectangle();
  1005. })(egret || (egret = {}));
  1006. //////////////////////////////////////////////////////////////////////////////////////
  1007. //
  1008. // Copyright (c) 2014-present, Egret Technology.
  1009. // All rights reserved.
  1010. // Redistribution and use in source and binary forms, with or without
  1011. // modification, are permitted provided that the following conditions are met:
  1012. //
  1013. // * Redistributions of source code must retain the above copyright
  1014. // notice, this list of conditions and the following disclaimer.
  1015. // * Redistributions in binary form must reproduce the above copyright
  1016. // notice, this list of conditions and the following disclaimer in the
  1017. // documentation and/or other materials provided with the distribution.
  1018. // * Neither the name of the Egret nor the
  1019. // names of its contributors may be used to endorse or promote products
  1020. // derived from this software without specific prior written permission.
  1021. //
  1022. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  1023. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  1024. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  1025. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  1026. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  1027. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  1028. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  1029. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  1030. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  1031. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1032. //
  1033. //////////////////////////////////////////////////////////////////////////////////////
  1034. var egret;
  1035. (function (egret) {
  1036. var ONCE_EVENT_LIST = [];
  1037. /**
  1038. * @language en_US
  1039. * The EventDispatcher class is the base class for all classes that dispatchEvent events. The EventDispatcher class implements
  1040. * the IEventDispatcher interface and is the base class for the DisplayObject class. The EventDispatcher class allows
  1041. * any object on the display list to be an event target and as such, to use the methods of the IEventDispatcher interface.
  1042. * Event targets are an important part of the Egret event model. The event target serves as the focal point for how events
  1043. * flow through the display list hierarchy. When an event such as a touch tap, Egret dispatches an event object into the
  1044. * event flow from the root of the display list. The event object then makes its way through the display list until it
  1045. * reaches the event target, at which point it begins its return trip through the display list. This round-trip journey
  1046. * to the event target is conceptually divided into three phases: <br/>
  1047. * the capture phase comprises the journey from the root to the last node before the event target's node, the target
  1048. * phase comprises only the event target node, and the bubbling phase comprises any subsequent nodes encountered on
  1049. * the return trip to the root of the display list. In general, the easiest way for a user-defined class to gain event
  1050. * dispatching capabilities is to extend EventDispatcher. If this is impossible (that is, if the class is already extending
  1051. * another class), you can instead implement the IEventDispatcher interface, create an EventDispatcher member, and write simple
  1052. * hooks to route calls into the aggregated EventDispatcher.
  1053. * @see egret.IEventDispatcher
  1054. * @version Egret 2.4
  1055. * @platform Web,Native
  1056. * @includeExample egret/events/EventDispatcher.ts
  1057. */
  1058. /**
  1059. * @language zh_CN
  1060. * EventDispatcher 是 Egret 的事件派发器类,负责进行事件的发送和侦听。
  1061. * 事件目标是事件如何通过显示列表层次结构这一问题的焦点。当发生鼠标单击、触摸或按键等事件时,
  1062. * 框架会将事件对象调度到从显示列表根开始的事件流中。然后该事件对象在显示列表中前进,直到到达事件目标,
  1063. * 然后从这一点开始其在显示列表中的回程。在概念上,到事件目标的此往返行程被划分为三个阶段:
  1064. * 捕获阶段包括从根到事件目标节点之前的最后一个节点的行程,目标阶段仅包括事件目标节点,冒泡阶段包括回程上遇到的任何后续节点到显示列表的根。
  1065. * 通常,使用户定义的类能够调度事件的最简单方法是扩展 EventDispatcher。如果无法扩展(即,如果该类已经扩展了另一个类),则可以实现
  1066. * IEventDispatcher 接口,创建 EventDispatcher 成员,并编写一些简单的映射,将调用连接到聚合的 EventDispatcher 中。
  1067. * @see egret.IEventDispatcher
  1068. * @version Egret 2.4
  1069. * @platform Web,Native
  1070. * @includeExample egret/events/EventDispatcher.ts
  1071. */
  1072. var EventDispatcher = (function (_super) {
  1073. __extends(EventDispatcher, _super);
  1074. /**
  1075. * @language en_US
  1076. * create an instance of the EventDispatcher class.
  1077. * @param target The target object for events dispatched to the EventDispatcher object. This parameter is used when
  1078. * the EventDispatcher instance is aggregated by a class that implements IEventDispatcher; it is necessary so that the
  1079. * containing object can be the target for events. Do not use this parameter in simple cases in which a class extends EventDispatcher.
  1080. * @version Egret 2.4
  1081. * @platform Web,Native
  1082. */
  1083. /**
  1084. * @language zh_CN
  1085. * 创建一个 EventDispatcher 类的实例
  1086. * @param target 此 EventDispatcher 所抛出事件对象的 target 指向。此参数主要用于一个实现了 IEventDispatcher 接口的自定义类,
  1087. * 以便抛出的事件对象的 target 属性可以指向自定义类自身。请勿在直接继承 EventDispatcher 的情况下使用此参数。
  1088. * @version Egret 2.4
  1089. * @platform Web,Native
  1090. */
  1091. function EventDispatcher(target) {
  1092. if (target === void 0) { target = null; }
  1093. var _this = _super.call(this) || this;
  1094. _this.$EventDispatcher = {
  1095. 0: target ? target : _this,
  1096. 1: {},
  1097. 2: {},
  1098. 3: 0
  1099. };
  1100. return _this;
  1101. }
  1102. /**
  1103. * @private
  1104. *
  1105. * @param useCapture
  1106. */
  1107. EventDispatcher.prototype.$getEventMap = function (useCapture) {
  1108. var values = this.$EventDispatcher;
  1109. var eventMap = useCapture ? values[2 /* captureEventsMap */] : values[1 /* eventsMap */];
  1110. return eventMap;
  1111. };
  1112. /**
  1113. * @inheritDoc
  1114. * @version Egret 2.4
  1115. * @platform Web,Native
  1116. */
  1117. EventDispatcher.prototype.addEventListener = function (type, listener, thisObject, useCapture, priority) {
  1118. this.$addListener(type, listener, thisObject, useCapture, priority);
  1119. };
  1120. /**
  1121. * @inheritDoc
  1122. * @version Egret 2.4
  1123. * @platform Web,Native
  1124. */
  1125. EventDispatcher.prototype.once = function (type, listener, thisObject, useCapture, priority) {
  1126. this.$addListener(type, listener, thisObject, useCapture, priority, true);
  1127. };
  1128. /**
  1129. * @private
  1130. */
  1131. EventDispatcher.prototype.$addListener = function (type, listener, thisObject, useCapture, priority, dispatchOnce) {
  1132. if (true && !listener) {
  1133. egret.$error(1003, "listener");
  1134. }
  1135. var values = this.$EventDispatcher;
  1136. var eventMap = useCapture ? values[2 /* captureEventsMap */] : values[1 /* eventsMap */];
  1137. var list = eventMap[type];
  1138. if (!list) {
  1139. list = eventMap[type] = [];
  1140. }
  1141. else if (values[3 /* notifyLevel */] !== 0) {
  1142. eventMap[type] = list = list.concat();
  1143. }
  1144. this.$insertEventBin(list, type, listener, thisObject, useCapture, priority, dispatchOnce);
  1145. };
  1146. EventDispatcher.prototype.$insertEventBin = function (list, type, listener, thisObject, useCapture, priority, dispatchOnce) {
  1147. priority = +priority | 0;
  1148. var insertIndex = -1;
  1149. var length = list.length;
  1150. for (var i = 0; i < length; i++) {
  1151. var bin = list[i];
  1152. if (bin.listener == listener && bin.thisObject == thisObject && bin.target == this) {
  1153. return false;
  1154. }
  1155. if (insertIndex == -1 && bin.priority < priority) {
  1156. insertIndex = i;
  1157. }
  1158. }
  1159. var eventBin = {
  1160. type: type, listener: listener, thisObject: thisObject, priority: priority,
  1161. target: this, useCapture: useCapture, dispatchOnce: !!dispatchOnce
  1162. };
  1163. if (insertIndex !== -1) {
  1164. list.splice(insertIndex, 0, eventBin);
  1165. }
  1166. else {
  1167. list.push(eventBin);
  1168. }
  1169. return true;
  1170. };
  1171. /**
  1172. * @inheritDoc
  1173. * @version Egret 2.4
  1174. * @platform Web,Native
  1175. */
  1176. EventDispatcher.prototype.removeEventListener = function (type, listener, thisObject, useCapture) {
  1177. var values = this.$EventDispatcher;
  1178. var eventMap = useCapture ? values[2 /* captureEventsMap */] : values[1 /* eventsMap */];
  1179. var list = eventMap[type];
  1180. if (!list) {
  1181. return;
  1182. }
  1183. if (values[3 /* notifyLevel */] !== 0) {
  1184. eventMap[type] = list = list.concat();
  1185. }
  1186. this.$removeEventBin(list, listener, thisObject);
  1187. if (list.length == 0) {
  1188. eventMap[type] = null;
  1189. }
  1190. };
  1191. EventDispatcher.prototype.$removeEventBin = function (list, listener, thisObject) {
  1192. var length = list.length;
  1193. for (var i = 0; i < length; i++) {
  1194. var bin = list[i];
  1195. if (bin.listener == listener && bin.thisObject == thisObject && bin.target == this) {
  1196. list.splice(i, 1);
  1197. return true;
  1198. }
  1199. }
  1200. return false;
  1201. };
  1202. /**
  1203. * @inheritDoc
  1204. * @version Egret 2.4
  1205. * @platform Web,Native
  1206. */
  1207. EventDispatcher.prototype.hasEventListener = function (type) {
  1208. var values = this.$EventDispatcher;
  1209. return !!(values[1 /* eventsMap */][type] || values[2 /* captureEventsMap */][type]);
  1210. };
  1211. /**
  1212. * @inheritDoc
  1213. * @version Egret 2.4
  1214. * @platform Web,Native
  1215. */
  1216. EventDispatcher.prototype.willTrigger = function (type) {
  1217. return this.hasEventListener(type);
  1218. };
  1219. /**
  1220. * @inheritDoc
  1221. * @version Egret 2.4
  1222. * @platform Web,Native
  1223. */
  1224. EventDispatcher.prototype.dispatchEvent = function (event) {
  1225. event.$currentTarget = this.$EventDispatcher[0 /* eventTarget */];
  1226. event.$setTarget(event.$currentTarget);
  1227. return this.$notifyListener(event, false);
  1228. };
  1229. /**
  1230. * @private
  1231. */
  1232. EventDispatcher.prototype.$notifyListener = function (event, capturePhase) {
  1233. var values = this.$EventDispatcher;
  1234. var eventMap = capturePhase ? values[2 /* captureEventsMap */] : values[1 /* eventsMap */];
  1235. var list = eventMap[event.$type];
  1236. if (!list) {
  1237. return true;
  1238. }
  1239. var length = list.length;
  1240. if (length == 0) {
  1241. return true;
  1242. }
  1243. var onceList = ONCE_EVENT_LIST;
  1244. //做个标记,防止外部修改原始数组导致遍历错误。这里不直接调用list.concat()因为dispatch()方法调用通常比on()等方法频繁。
  1245. values[3 /* notifyLevel */]++;
  1246. for (var i = 0; i < length; i++) {
  1247. var eventBin = list[i];
  1248. eventBin.listener.call(eventBin.thisObject, event);
  1249. if (eventBin.dispatchOnce) {
  1250. onceList.push(eventBin);
  1251. }
  1252. if (event.$isPropagationImmediateStopped) {
  1253. break;
  1254. }
  1255. }
  1256. values[3 /* notifyLevel */]--;
  1257. while (onceList.length) {
  1258. var eventBin = onceList.pop();
  1259. eventBin.target.removeEventListener(eventBin.type, eventBin.listener, eventBin.thisObject, eventBin.useCapture);
  1260. }
  1261. return !event.$isDefaultPrevented;
  1262. };
  1263. /**
  1264. * @language en_US
  1265. * Distribute a specified event parameters.
  1266. * @param type The type of the event. Event listeners can access this information through the inherited type property.
  1267. * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through
  1268. * the inherited bubbles property.
  1269. * @param data {any} data
  1270. * @param cancelable Determines whether the Event object can be canceled. The default values is false.
  1271. * @version Egret 2.4
  1272. * @platform Web,Native
  1273. */
  1274. /**
  1275. * @language zh_CN
  1276. * 派发一个指定参数的事件。
  1277. * @param type {string} 事件类型
  1278. * @param bubbles {boolean} 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。
  1279. * @param data {any} 事件data
  1280. * @param cancelable {boolean} 确定是否可以取消 Event 对象。默认值为 false。
  1281. * @version Egret 2.4
  1282. * @platform Web,Native
  1283. */
  1284. EventDispatcher.prototype.dispatchEventWith = function (type, bubbles, data, cancelable) {
  1285. if (bubbles || this.hasEventListener(type)) {
  1286. var event_1 = egret.Event.create(egret.Event, type, bubbles, cancelable);
  1287. event_1.data = data;
  1288. var result = this.dispatchEvent(event_1);
  1289. egret.Event.release(event_1);
  1290. return result;
  1291. }
  1292. return true;
  1293. };
  1294. return EventDispatcher;
  1295. }(egret.HashObject));
  1296. egret.EventDispatcher = EventDispatcher;
  1297. __reflect(EventDispatcher.prototype, "egret.EventDispatcher", ["egret.IEventDispatcher"]);
  1298. })(egret || (egret = {}));
  1299. //////////////////////////////////////////////////////////////////////////////////////
  1300. //
  1301. // Copyright (c) 2014-present, Egret Technology.
  1302. // All rights reserved.
  1303. // Redistribution and use in source and binary forms, with or without
  1304. // modification, are permitted provided that the following conditions are met:
  1305. //
  1306. // * Redistributions of source code must retain the above copyright
  1307. // notice, this list of conditions and the following disclaimer.
  1308. // * Redistributions in binary form must reproduce the above copyright
  1309. // notice, this list of conditions and the following disclaimer in the
  1310. // documentation and/or other materials provided with the distribution.
  1311. // * Neither the name of the Egret nor the
  1312. // names of its contributors may be used to endorse or promote products
  1313. // derived from this software without specific prior written permission.
  1314. //
  1315. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  1316. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  1317. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  1318. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  1319. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  1320. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  1321. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  1322. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  1323. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  1324. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1325. //
  1326. //////////////////////////////////////////////////////////////////////////////////////
  1327. var egret;
  1328. (function (egret) {
  1329. /**
  1330. * @private
  1331. * 格式化旋转角度的值
  1332. */
  1333. function clampRotation(value) {
  1334. value %= 360;
  1335. if (value > 180) {
  1336. value -= 360;
  1337. }
  1338. else if (value < -180) {
  1339. value += 360;
  1340. }
  1341. return value;
  1342. }
  1343. /**
  1344. * @language en_US
  1345. * The DisplayObject class is the base class for all objects that can be placed on the display list. The display list
  1346. * manages all objects displayed in the runtime. Use the DisplayObjectContainer class to arrange the display
  1347. * objects in the display list. DisplayObjectContainer objects can have child display objects, while other display objects,
  1348. * such as Shape and TextField objects, are "leaf" nodes that have only parents and siblings, no children.
  1349. * The DisplayObject class supports basic functionality like the x and y position of an object, as well as more advanced
  1350. * properties of the object such as its transformation matrix.<br/>
  1351. * The DisplayObject class contains several broadcast events.Normally, the target of any particular event is a specific
  1352. * DisplayObject instance. For example, the target of an added event is the specific DisplayObject instance that was added
  1353. * to the display list. Having a single target restricts the placement of event listeners to that target and in some cases
  1354. * the target's ancestors on the display list. With broadcast events, however, the target is not a specific DisplayObject
  1355. * instance, but rather all DisplayObject instances, including those that are not on the display list. This means that you
  1356. * can add a listener to any DisplayObject instance to listen for broadcast events.
  1357. *
  1358. * @event egret.Event.ADDED Dispatched when a display object is added to the display list.
  1359. * @event egret.Event.ADDED_TO_STAGE Dispatched when a display object is added to the on stage display list, either directly or through the addition of a sub tree in which the display object is contained.
  1360. * @event egret.Event.REMOVED Dispatched when a display object is about to be removed from the display list.
  1361. * @event egret.Event.REMOVED_FROM_STAGE Dispatched when a display object is about to be removed from the display list, either directly or through the removal of a sub tree in which the display object is contained.
  1362. * @event egret.Event.ENTER_FRAME [broadcast event] Dispatched when the playhead is entering a new frame.
  1363. * @event egret.Event.RENDER [broadcast event] Dispatched when the display list is about to be updated and rendered.
  1364. * @event egret.TouchEvent.TOUCH_MOVE Dispatched when the user touches the device, and is continuously dispatched until the point of contact is removed.
  1365. * @event egret.TouchEvent.TOUCH_BEGIN Dispatched when the user first contacts a touch-enabled device (such as touches a finger to a mobile phone or tablet with a touch screen).
  1366. * @event egret.TouchEvent.TOUCH_END Dispatched when the user removes contact with a touch-enabled device (such as lifts a finger off a mobile phone or tablet with a touch screen).
  1367. * @event egret.TouchEvent.TOUCH_TAP Dispatched when the user lifts the point of contact over the same DisplayObject instance on which the contact was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display object on a mobile phone or tablet with a touch screen).
  1368. * @event egret.TouchEvent.TOUCH_RELEASE_OUTSIDE Dispatched when the user lifts the point of contact over the different DisplayObject instance on which the contact was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display object on a mobile phone or tablet with a touch screen).
  1369. * @version Egret 2.4
  1370. * @platform Web,Native
  1371. * @includeExample egret/display/DisplayObject.ts
  1372. */
  1373. /**
  1374. * @language zh_CN
  1375. * DisplayObject 类是可放在显示列表中的所有对象的基类。该显示列表管理运行时中显示的所有对象。使用 DisplayObjectContainer 类排列
  1376. * 显示列表中的显示对象。DisplayObjectContainer 对象可以有子显示对象,而其他显示对象(如 Shape 和 TextField 对象)是“叶”节点,没有子项,只有父级和
  1377. * 同级。DisplayObject 类有一些基本的属性(如确定坐标位置的 x 和 y 属性),也有一些高级的对象属性(如 Matrix 矩阵变换)。<br/>
  1378. * DisplayObject 类包含若干广播事件。通常,任何特定事件的目标均为一个特定的 DisplayObject 实例。例如,added 事件的目标是已添加到显示列表
  1379. * 的目标 DisplayObject 实例。若只有一个目标,则会将事件侦听器限制为只能监听在该目标上(在某些情况下,可监听在显示列表中该目标的祖代上)。
  1380. * 但是对于广播事件,目标不是特定的 DisplayObject 实例,而是所有 DisplayObject 实例(包括那些不在显示列表中的实例)。这意味着您可以向任何
  1381. * DisplayObject 实例添加侦听器来侦听广播事件。
  1382. *
  1383. * @event egret.Event.ADDED 将显示对象添加到显示列表中时调度。
  1384. * @event egret.Event.ADDED_TO_STAGE 在将显示对象直接添加到舞台显示列表或将包含显示对象的子树添加至舞台显示列表中时调度。
  1385. * @event egret.Event.REMOVED 将要从显示列表中删除显示对象时调度。
  1386. * @event egret.Event.REMOVED_FROM_STAGE 在从显示列表中直接删除显示对象或删除包含显示对象的子树时调度。
  1387. * @event egret.Event.ENTER_FRAME [广播事件] 播放头进入新帧时调度。
  1388. * @event egret.Event.RENDER [广播事件] 将要更新和呈现显示列表时调度。
  1389. * @event egret.TouchEvent.TOUCH_MOVE 当用户触碰设备时进行调度,而且会连续调度,直到接触点被删除。
  1390. * @event egret.TouchEvent.TOUCH_BEGIN 当用户第一次触摸启用触摸的设备时(例如,用手指触摸配有触摸屏的移动电话或平板电脑)调度。
  1391. * @event egret.TouchEvent.TOUCH_END 当用户移除与启用触摸的设备的接触时(例如,将手指从配有触摸屏的移动电话或平板电脑上抬起)调度。
  1392. * @event egret.TouchEvent.TOUCH_TAP 当用户在启用触摸设备上的已启动接触的同一 DisplayObject 实例上抬起接触点时(例如,在配有触摸屏的移动电话或平板电脑的显示对象上的某一点处按下并释放手指)调度。
  1393. * @event egret.TouchEvent.TOUCH_RELEASE_OUTSIDE 当用户在启用触摸设备上的已启动接触的不同 DisplayObject 实例上抬起接触点时(例如,在配有触摸屏的移动电话或平板电脑的显示对象上的某一点处按下并释放手指)调度。
  1394. * @version Egret 2.4
  1395. * @platform Web,Native
  1396. * @includeExample egret/display/DisplayObject.ts
  1397. */
  1398. var DisplayObject = (function (_super) {
  1399. __extends(DisplayObject, _super);
  1400. /**
  1401. * @language en_US
  1402. * Initializes a DisplayObject object
  1403. * @version Egret 2.4
  1404. * @platform Web,Native
  1405. */
  1406. /**
  1407. * @language zh_CN
  1408. * 创建一个显示对象
  1409. * @version Egret 2.4
  1410. * @platform Web,Native
  1411. */
  1412. function DisplayObject() {
  1413. var _this = _super.call(this) || this;
  1414. /**
  1415. * @private
  1416. * 能够含有子项的类将子项列表存储在这个属性里。
  1417. */
  1418. _this.$children = null;
  1419. /**
  1420. * @private
  1421. */
  1422. _this.$parent = null;
  1423. /**
  1424. * @private
  1425. */
  1426. _this.$stage = null;
  1427. /**
  1428. * @private
  1429. * 这个对象在显示列表中的嵌套深度,舞台为1,它的子项为2,子项的子项为3,以此类推。当对象不在显示列表中时此属性值为0.
  1430. */
  1431. _this.$nestLevel = 0;
  1432. /**
  1433. * @private
  1434. */
  1435. _this.$visible = true;
  1436. /**
  1437. * @private
  1438. * cacheAsBitmap创建的缓存位图节点。
  1439. */
  1440. _this.$displayList = null;
  1441. /**
  1442. * @private
  1443. */
  1444. _this.$alpha = 1;
  1445. _this.$touchEnabled = DisplayObject.defaultTouchEnabled;
  1446. /**
  1447. * @private
  1448. */
  1449. _this.$scrollRect = null;
  1450. /**
  1451. * @private
  1452. */
  1453. _this.$blendMode = 0;
  1454. /**
  1455. * @private
  1456. * 被遮罩的对象
  1457. */
  1458. _this.$maskedObject = null;
  1459. /**
  1460. * @private
  1461. */
  1462. _this.$mask = null;
  1463. /**
  1464. * @private
  1465. */
  1466. _this.$maskRect = null;
  1467. /**
  1468. * @private
  1469. */
  1470. _this.$parentDisplayList = null;
  1471. /**
  1472. * @private
  1473. * 渲染节点,不为空表示自身有绘制到屏幕的内容
  1474. */
  1475. _this.$renderNode = null;
  1476. _this.$displayFlags = 2032 /* InitFlags */;
  1477. _this.$DisplayObject = {
  1478. 0: 1,
  1479. 1: 1,
  1480. 2: 0,
  1481. 3: 0,
  1482. 4: 0,
  1483. 5: "",
  1484. 6: new egret.Matrix(),
  1485. 7: new egret.Matrix(),
  1486. 8: new egret.Matrix(),
  1487. 9: new egret.Rectangle(),
  1488. 10: new egret.Rectangle(),
  1489. 11: false,
  1490. 12: 0,
  1491. 13: 0,
  1492. 14: NaN,
  1493. 15: NaN,
  1494. 16: 0,
  1495. 17: 0,
  1496. 18: 0,
  1497. 19: null,
  1498. 20: null //filters
  1499. };
  1500. return _this;
  1501. }
  1502. /**
  1503. * @private
  1504. * 添加一个标志量
  1505. */
  1506. DisplayObject.prototype.$setFlags = function (flags) {
  1507. this.$displayFlags |= flags;
  1508. };
  1509. /**
  1510. * @private
  1511. * 移除一个标志量
  1512. */
  1513. DisplayObject.prototype.$removeFlags = function (flags) {
  1514. this.$displayFlags &= ~flags;
  1515. };
  1516. /**
  1517. * @private
  1518. * 沿着显示列表向上移除标志量,如果标志量没被设置过就停止移除。
  1519. */
  1520. DisplayObject.prototype.$removeFlagsUp = function (flags) {
  1521. if (!this.$hasAnyFlags(flags)) {
  1522. return;
  1523. }
  1524. this.$removeFlags(flags);
  1525. var parent = this.$parent;
  1526. if (parent) {
  1527. parent.$removeFlagsUp(flags);
  1528. }
  1529. };
  1530. /**
  1531. * @private
  1532. * 是否含有指定的所有标志量
  1533. */
  1534. DisplayObject.prototype.$hasFlags = function (flags) {
  1535. return (this.$displayFlags & flags) == flags;
  1536. };
  1537. /**
  1538. * @private
  1539. * 沿着显示列表向上传递标志量,如果标志量已经被设置过就停止传递。
  1540. */
  1541. DisplayObject.prototype.$propagateFlagsUp = function (flags) {
  1542. if (this.$hasFlags(flags)) {
  1543. return;
  1544. }
  1545. this.$setFlags(flags);
  1546. var parent = this.$parent;
  1547. if (parent) {
  1548. parent.$propagateFlagsUp(flags);
  1549. }
  1550. };
  1551. /**
  1552. * @private
  1553. * 沿着显示列表向下传递标志量,非容器直接设置自身的flag,此方法会在 DisplayObjectContainer 中被覆盖。
  1554. */
  1555. DisplayObject.prototype.$propagateFlagsDown = function (flags, cachedBreak) {
  1556. if (cachedBreak === void 0) { cachedBreak = false; }
  1557. this.$setFlags(flags);
  1558. };
  1559. /**
  1560. * @private
  1561. * 是否含有多个标志量其中之一。
  1562. */
  1563. DisplayObject.prototype.$hasAnyFlags = function (flags) {
  1564. return !!(this.$displayFlags & flags);
  1565. };
  1566. /**
  1567. * @private
  1568. * 标记矩阵失效
  1569. */
  1570. DisplayObject.prototype.$invalidateMatrix = function () {
  1571. this.$setFlags(8 /* InvalidMatrix */);
  1572. this.$invalidatePosition();
  1573. };
  1574. /**
  1575. * @private
  1576. * 标记这个显示对象在父级容器的位置发生了改变。
  1577. */
  1578. DisplayObject.prototype.$invalidatePosition = function () {
  1579. var self = this;
  1580. self.$invalidateTransform();
  1581. self.$propagateFlagsDown(16 /* InvalidConcatenatedMatrix */ |
  1582. 32 /* InvalidInvertedConcatenatedMatrix */);
  1583. if (self.$parent) {
  1584. self.$parent.$propagateFlagsUp(4 /* InvalidBounds */);
  1585. }
  1586. };
  1587. Object.defineProperty(DisplayObject.prototype, "name", {
  1588. /**
  1589. * @language en_US
  1590. * Indicates the instance name of the DisplayObject. The object can be identified in the child list of its parent
  1591. * display object container by calling the getChildByName() method of the display object container.
  1592. * @version Egret 2.4
  1593. * @platform Web,Native
  1594. */
  1595. /**
  1596. * @language zh_CN
  1597. * 表示 DisplayObject 的实例名称。
  1598. * 通过调用父显示对象容器的 getChildByName() 方法,可以在父显示对象容器的子列表中标识该对象。
  1599. * @version Egret 2.4
  1600. * @platform Web,Native
  1601. */
  1602. get: function () {
  1603. return this.$DisplayObject[5 /* name */];
  1604. },
  1605. set: function (value) {
  1606. this.$DisplayObject[5 /* name */] = value;
  1607. },
  1608. enumerable: true,
  1609. configurable: true
  1610. });
  1611. Object.defineProperty(DisplayObject.prototype, "parent", {
  1612. /**
  1613. * @language en_US
  1614. * Indicates the DisplayObjectContainer object that contains this display object. Use the parent property to specify
  1615. * a relative path to display objects that are above the current display object in the display list hierarchy.
  1616. * @version Egret 2.4
  1617. * @platform Web,Native
  1618. */
  1619. /**
  1620. * @language zh_CN
  1621. * 表示包含此显示对象的 DisplayObjectContainer 对象。
  1622. * 使用 parent 属性可以指定高于显示列表层次结构中当前显示对象的显示对象的相对路径。
  1623. * @version Egret 2.4
  1624. * @platform Web,Native
  1625. */
  1626. get: function () {
  1627. return this.$parent;
  1628. },
  1629. enumerable: true,
  1630. configurable: true
  1631. });
  1632. /**
  1633. * @private
  1634. * 设置父级显示对象
  1635. */
  1636. DisplayObject.prototype.$setParent = function (parent) {
  1637. if (this.$parent == parent) {
  1638. return false;
  1639. }
  1640. this.$parent = parent;
  1641. return true;
  1642. };
  1643. /**
  1644. * @private
  1645. * 显示对象添加到舞台
  1646. */
  1647. DisplayObject.prototype.$onAddToStage = function (stage, nestLevel) {
  1648. this.$stage = stage;
  1649. this.$nestLevel = nestLevel;
  1650. this.$hasAddToStage = true;
  1651. egret.Sprite.$EVENT_ADD_TO_STAGE_LIST.push(this);
  1652. };
  1653. /**
  1654. * @private
  1655. * 显示对象从舞台移除
  1656. */
  1657. DisplayObject.prototype.$onRemoveFromStage = function () {
  1658. this.$nestLevel = 0;
  1659. egret.Sprite.$EVENT_REMOVE_FROM_STAGE_LIST.push(this);
  1660. };
  1661. Object.defineProperty(DisplayObject.prototype, "stage", {
  1662. /**
  1663. * @language en_US
  1664. * The Stage of the display object. you can create and load multiple display objects into the display list, and
  1665. * the stage property of each display object refers to the same Stage object.<br/>
  1666. * If a display object is not added to the display list, its stage property is set to null.
  1667. * @version Egret 2.4
  1668. * @platform Web,Native
  1669. */
  1670. /**
  1671. * @language zh_CN
  1672. * 显示对象的舞台。
  1673. * 例如,您可以创建多个显示对象并加载到显示列表中,每个显示对象的 stage 属性是指向相同的 Stage 对象。<br/>
  1674. * 如果显示对象未添加到显示列表,则其 stage 属性会设置为 null。
  1675. * @version Egret 2.4
  1676. * @platform Web,Native
  1677. */
  1678. get: function () {
  1679. return this.$stage;
  1680. },
  1681. enumerable: true,
  1682. configurable: true
  1683. });
  1684. Object.defineProperty(DisplayObject.prototype, "matrix", {
  1685. /**
  1686. * @language en_US
  1687. * A Matrix object containing values that alter the scaling, rotation, and translation of the display object.<br/>
  1688. * Note: to change the value of a display object's matrix, you must make a copy of the entire matrix object, then copy
  1689. * the new object into the matrix property of the display object.
  1690. * @example the following code increases the tx value of a display object's matrix
  1691. * <pre>
  1692. * let myMatrix:Matrix = myDisplayObject.matrix;
  1693. * myMatrix.tx += 10;
  1694. * myDisplayObject.matrix = myMatrix;
  1695. * </pre>
  1696. * @version Egret 2.4
  1697. * @platform Web,Native
  1698. */
  1699. /**
  1700. * @language zh_CN
  1701. * 一个 Matrix 对象,其中包含更改显示对象的缩放、旋转和平移的值。<br/>
  1702. * 注意:要改变一个显示对象矩阵的值,您必引用整个矩阵对象,然后将它重新赋值给显示对象的 matrix 属性。
  1703. * @example 以下代码改变了显示对象矩阵的tx属性值:
  1704. * <pre>
  1705. * let myMatrix:Matrix = myDisplayObject.matrix;
  1706. * myMatrix.tx += 10;
  1707. * myDisplayObject.matrix = myMatrix;
  1708. * </pre>
  1709. * @version Egret 2.4
  1710. * @platform Web,Native
  1711. */
  1712. get: function () {
  1713. return this.$getMatrix().clone();
  1714. },
  1715. set: function (value) {
  1716. this.$setMatrix(value);
  1717. },
  1718. enumerable: true,
  1719. configurable: true
  1720. });
  1721. /**
  1722. * @private
  1723. * 获取矩阵
  1724. */
  1725. DisplayObject.prototype.$getMatrix = function () {
  1726. var values = this.$DisplayObject;
  1727. if (this.$hasFlags(8 /* InvalidMatrix */)) {
  1728. values[6 /* matrix */].$updateScaleAndRotation(values[0 /* scaleX */], values[1 /* scaleY */], values[2 /* skewX */], values[3 /* skewY */]);
  1729. this.$removeFlags(8 /* InvalidMatrix */);
  1730. }
  1731. return values[6 /* matrix */];
  1732. };
  1733. /**
  1734. * @private
  1735. * 设置矩阵
  1736. */
  1737. DisplayObject.prototype.$setMatrix = function (matrix, needUpdateProperties) {
  1738. if (needUpdateProperties === void 0) { needUpdateProperties = true; }
  1739. var self = this;
  1740. var values = self.$DisplayObject;
  1741. var m = values[6 /* matrix */];
  1742. if (m.equals(matrix)) {
  1743. return false;
  1744. }
  1745. m.copyFrom(matrix);
  1746. if (needUpdateProperties) {
  1747. values[0 /* scaleX */] = m.$getScaleX();
  1748. values[1 /* scaleY */] = m.$getScaleY();
  1749. values[2 /* skewX */] = matrix.$getSkewX();
  1750. values[3 /* skewY */] = matrix.$getSkewY();
  1751. values[16 /* skewXdeg */] = clampRotation(values[2 /* skewX */] * 180 / Math.PI);
  1752. values[17 /* skewYdeg */] = clampRotation(values[3 /* skewY */] * 180 / Math.PI);
  1753. values[4 /* rotation */] = clampRotation(values[3 /* skewY */] * 180 / Math.PI);
  1754. }
  1755. self.$removeFlags(8 /* InvalidMatrix */);
  1756. self.$invalidatePosition();
  1757. return true;
  1758. };
  1759. /**
  1760. * @private
  1761. * 获得这个显示对象以及它所有父级对象的连接矩阵。
  1762. */
  1763. DisplayObject.prototype.$getConcatenatedMatrix = function () {
  1764. var matrix = this.$DisplayObject[7 /* concatenatedMatrix */];
  1765. if (this.$hasFlags(16 /* InvalidConcatenatedMatrix */)) {
  1766. if (this.$parent) {
  1767. this.$parent.$getConcatenatedMatrix().$preMultiplyInto(this.$getMatrix(), matrix);
  1768. }
  1769. else {
  1770. matrix.copyFrom(this.$getMatrix());
  1771. }
  1772. var values = this.$DisplayObject;
  1773. var offsetX = values[12 /* anchorOffsetX */];
  1774. var offsetY = values[13 /* anchorOffsetY */];
  1775. var rect = this.$scrollRect;
  1776. if (rect) {
  1777. matrix.$preMultiplyInto(egret.$TempMatrix.setTo(1, 0, 0, 1, -rect.x - offsetX, -rect.y - offsetY), matrix);
  1778. }
  1779. else if (offsetX != 0 || offsetY != 0) {
  1780. matrix.$preMultiplyInto(egret.$TempMatrix.setTo(1, 0, 0, 1, -offsetX, -offsetY), matrix);
  1781. }
  1782. if (this.$displayList) {
  1783. this.$displayList.$renderNode.moved = true;
  1784. }
  1785. if (this.$renderNode) {
  1786. this.$renderNode.moved = true;
  1787. }
  1788. this.$removeFlags(16 /* InvalidConcatenatedMatrix */);
  1789. }
  1790. return matrix;
  1791. };
  1792. /**
  1793. * @private
  1794. * 获取链接矩阵
  1795. */
  1796. DisplayObject.prototype.$getInvertedConcatenatedMatrix = function () {
  1797. var values = this.$DisplayObject;
  1798. if (this.$hasFlags(32 /* InvalidInvertedConcatenatedMatrix */)) {
  1799. this.$getConcatenatedMatrix().$invertInto(values[8 /* invertedConcatenatedMatrix */]);
  1800. this.$removeFlags(32 /* InvalidInvertedConcatenatedMatrix */);
  1801. }
  1802. return values[8 /* invertedConcatenatedMatrix */];
  1803. };
  1804. Object.defineProperty(DisplayObject.prototype, "x", {
  1805. /**
  1806. * @language en_US
  1807. * Indicates the x coordinate of the DisplayObject instance relative to the local coordinates of the parent
  1808. * DisplayObjectContainer.<br/>
  1809. * If the object is inside a DisplayObjectContainer that has transformations, it is in
  1810. * the local coordinate system of the enclosing DisplayObjectContainer. Thus, for a DisplayObjectContainer
  1811. * rotated 90° counterclockwise, the DisplayObjectContainer's children inherit a coordinate system that is
  1812. * rotated 90° counterclockwise. The object's coordinates refer to the registration point position.
  1813. * @default 0
  1814. * @version Egret 2.4
  1815. * @platform Web,Native
  1816. */
  1817. /**
  1818. * @language zh_CN
  1819. * 表示 DisplayObject 实例相对于父级 DisplayObjectContainer 本地坐标的 x 坐标。<br/>
  1820. * 如果该对象位于具有变形的 DisplayObjectContainer 内,则它也位于包含 DisplayObjectContainer 的本地坐标系中。
  1821. * 因此,对于逆时针旋转 90 度的 DisplayObjectContainer,该 DisplayObjectContainer 的子级将继承逆时针旋转 90 度的坐标系。
  1822. * @default 0
  1823. * @version Egret 2.4
  1824. * @platform Web,Native
  1825. */
  1826. get: function () {
  1827. return this.$getX();
  1828. },
  1829. set: function (value) {
  1830. this.$setX(value);
  1831. },
  1832. enumerable: true,
  1833. configurable: true
  1834. });
  1835. /**
  1836. * @private
  1837. * 获取x坐标
  1838. */
  1839. DisplayObject.prototype.$getX = function () {
  1840. return this.$DisplayObject[6 /* matrix */].tx;
  1841. };
  1842. /**
  1843. * @private
  1844. * 设置x坐标
  1845. */
  1846. DisplayObject.prototype.$setX = function (value) {
  1847. value = +value || 0;
  1848. var m = this.$DisplayObject[6 /* matrix */];
  1849. if (value == m.tx) {
  1850. return false;
  1851. }
  1852. m.tx = value;
  1853. this.$invalidatePosition();
  1854. return true;
  1855. };
  1856. Object.defineProperty(DisplayObject.prototype, "y", {
  1857. /**
  1858. * @language en_US
  1859. * Indicates the y coordinate of the DisplayObject instance relative to the local coordinates of the parent
  1860. * DisplayObjectContainer. <br/>
  1861. * If the object is inside a DisplayObjectContainer that has transformations, it is in
  1862. * the local coordinate system of the enclosing DisplayObjectContainer. Thus, for a DisplayObjectContainer rotated
  1863. * 90° counterclockwise, the DisplayObjectContainer's children inherit a coordinate system that is rotated 90°
  1864. * counterclockwise. The object's coordinates refer to the registration point position.
  1865. * @default 0
  1866. * @version Egret 2.4
  1867. * @platform Web,Native
  1868. */
  1869. /**
  1870. * @language zh_CN
  1871. * 表示 DisplayObject 实例相对于父级 DisplayObjectContainer 本地坐标的 y 坐标。<br/>
  1872. * 如果该对象位于具有变形的 DisplayObjectContainer 内,则它也位于包含 DisplayObjectContainer 的本地坐标系中。
  1873. * 因此,对于逆时针旋转 90 度的 DisplayObjectContainer,该 DisplayObjectContainer 的子级将继承逆时针旋转 90 度的坐标系。
  1874. * @default 0
  1875. * @version Egret 2.4
  1876. * @platform Web,Native
  1877. */
  1878. get: function () {
  1879. return this.$getY();
  1880. },
  1881. set: function (value) {
  1882. this.$setY(value);
  1883. },
  1884. enumerable: true,
  1885. configurable: true
  1886. });
  1887. /**
  1888. * @private
  1889. * 获取y坐标
  1890. */
  1891. DisplayObject.prototype.$getY = function () {
  1892. return this.$DisplayObject[6 /* matrix */].ty;
  1893. };
  1894. /**
  1895. * @private
  1896. * 设置y坐标
  1897. */
  1898. DisplayObject.prototype.$setY = function (value) {
  1899. value = +value || 0;
  1900. var m = this.$DisplayObject[6 /* matrix */];
  1901. if (value == m.ty) {
  1902. return false;
  1903. }
  1904. m.ty = value;
  1905. this.$invalidatePosition();
  1906. return true;
  1907. };
  1908. Object.defineProperty(DisplayObject.prototype, "scaleX", {
  1909. /**
  1910. * @language en_US
  1911. * Indicates the horizontal scale (percentage) of the object as applied from the registration point. <br/>
  1912. * The default 1.0 equals 100% scale.
  1913. * @default 1
  1914. * @version Egret 2.4
  1915. * @platform Web,Native
  1916. */
  1917. /**
  1918. * @language zh_CN
  1919. * 表示从注册点开始应用的对象的水平缩放比例(百分比)。<br/>
  1920. * 1.0 等于 100% 缩放。
  1921. * @default 1
  1922. * @version Egret 2.4
  1923. * @platform Web,Native
  1924. */
  1925. get: function () {
  1926. return this.$getScaleX();
  1927. },
  1928. set: function (value) {
  1929. this.$setScaleX(value);
  1930. },
  1931. enumerable: true,
  1932. configurable: true
  1933. });
  1934. /**
  1935. * @private
  1936. *
  1937. * @returns
  1938. */
  1939. DisplayObject.prototype.$getScaleX = function () {
  1940. return this.$DisplayObject[0 /* scaleX */];
  1941. };
  1942. /**
  1943. * @private
  1944. * 设置水平缩放值
  1945. */
  1946. DisplayObject.prototype.$setScaleX = function (value) {
  1947. value = +value || 0;
  1948. var values = this.$DisplayObject;
  1949. if (value == values[0 /* scaleX */]) {
  1950. return false;
  1951. }
  1952. values[0 /* scaleX */] = value;
  1953. this.$invalidateMatrix();
  1954. return true;
  1955. };
  1956. Object.defineProperty(DisplayObject.prototype, "scaleY", {
  1957. /**
  1958. * @language en_US
  1959. * Indicates the vertical scale (percentage) of an object as applied from the registration point of the object.
  1960. * 1.0 is 100% scale.
  1961. * @default 1
  1962. * @version Egret 2.4
  1963. * @platform Web,Native
  1964. */
  1965. /**
  1966. * @language zh_CN
  1967. * 表示从对象注册点开始应用的对象的垂直缩放比例(百分比)。1.0 是 100% 缩放。
  1968. * @default 1
  1969. * @version Egret 2.4
  1970. * @platform Web,Native
  1971. */
  1972. get: function () {
  1973. return this.$getScaleY();
  1974. },
  1975. set: function (value) {
  1976. this.$setScaleY(value);
  1977. },
  1978. enumerable: true,
  1979. configurable: true
  1980. });
  1981. /**
  1982. * @private
  1983. *
  1984. * @returns
  1985. */
  1986. DisplayObject.prototype.$getScaleY = function () {
  1987. return this.$DisplayObject[1 /* scaleY */];
  1988. };
  1989. /**
  1990. * @private
  1991. * 设置垂直缩放值
  1992. */
  1993. DisplayObject.prototype.$setScaleY = function (value) {
  1994. value = +value || 0;
  1995. if (value == this.$DisplayObject[1 /* scaleY */]) {
  1996. return false;
  1997. }
  1998. this.$DisplayObject[1 /* scaleY */] = value;
  1999. this.$invalidateMatrix();
  2000. return true;
  2001. };
  2002. Object.defineProperty(DisplayObject.prototype, "rotation", {
  2003. /**
  2004. * @language en_US
  2005. * Indicates the rotation of the DisplayObject instance, in degrees, from its original orientation. Values from
  2006. * 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. Values outside
  2007. * this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement
  2008. * myDisplayObject.rotation = 450 is the same as myDisplayObject.rotation = 90.
  2009. * @default 0
  2010. * @version Egret 2.4
  2011. * @platform Web,Native
  2012. */
  2013. /**
  2014. * @language zh_CN
  2015. * 表示 DisplayObject 实例距其原始方向的旋转程度,以度为单位。
  2016. * 从 0 到 180 的值表示顺时针方向旋转;从 0 到 -180 的值表示逆时针方向旋转。对于此范围之外的值,可以通过加上或
  2017. * 减去 360 获得该范围内的值。例如,myDisplayObject.rotation = 450语句与 myDisplayObject.rotation = 90 是相同的。
  2018. * @default 0
  2019. * @version Egret 2.4
  2020. * @platform Web,Native
  2021. */
  2022. get: function () {
  2023. return this.$getRotation();
  2024. },
  2025. set: function (value) {
  2026. this.$setRotation(value);
  2027. },
  2028. enumerable: true,
  2029. configurable: true
  2030. });
  2031. /**
  2032. * @private
  2033. *
  2034. * @returns
  2035. */
  2036. DisplayObject.prototype.$getRotation = function () {
  2037. return this.$DisplayObject[4 /* rotation */];
  2038. };
  2039. DisplayObject.prototype.$setRotation = function (value) {
  2040. value = +value || 0;
  2041. value = clampRotation(value);
  2042. var values = this.$DisplayObject;
  2043. if (value == values[4 /* rotation */]) {
  2044. return false;
  2045. }
  2046. var delta = value - values[4 /* rotation */];
  2047. var angle = delta / 180 * Math.PI;
  2048. values[2 /* skewX */] += angle;
  2049. values[3 /* skewY */] += angle;
  2050. values[4 /* rotation */] = value;
  2051. this.$invalidateMatrix();
  2052. return true;
  2053. };
  2054. Object.defineProperty(DisplayObject.prototype, "skewX", {
  2055. /**
  2056. * 表示DisplayObject的x方向斜切
  2057. * @member {number} egret.DisplayObject#skewX
  2058. * @default 0
  2059. * @version Egret 2.4
  2060. * @platform Web,Native
  2061. */
  2062. get: function () {
  2063. return this.$DisplayObject[16 /* skewXdeg */];
  2064. },
  2065. set: function (value) {
  2066. this.$setSkewX(value);
  2067. },
  2068. enumerable: true,
  2069. configurable: true
  2070. });
  2071. /**
  2072. * @private
  2073. *
  2074. * @param value
  2075. */
  2076. DisplayObject.prototype.$setSkewX = function (value) {
  2077. value = +value || 0;
  2078. var values = this.$DisplayObject;
  2079. if (value == values[16 /* skewXdeg */]) {
  2080. return false;
  2081. }
  2082. values[16 /* skewXdeg */] = value;
  2083. value = clampRotation(value);
  2084. value = value / 180 * Math.PI;
  2085. values[2 /* skewX */] = value;
  2086. this.$invalidateMatrix();
  2087. return true;
  2088. };
  2089. Object.defineProperty(DisplayObject.prototype, "skewY", {
  2090. /**
  2091. * 表示DisplayObject的y方向斜切
  2092. * @member {number} egret.DisplayObject#skewY
  2093. * @default 0
  2094. * @version Egret 2.4
  2095. * @platform Web,Native
  2096. */
  2097. get: function () {
  2098. return this.$DisplayObject[17 /* skewYdeg */];
  2099. },
  2100. set: function (value) {
  2101. this.$setSkewY(value);
  2102. },
  2103. enumerable: true,
  2104. configurable: true
  2105. });
  2106. /**
  2107. * @private
  2108. *
  2109. * @param value
  2110. */
  2111. DisplayObject.prototype.$setSkewY = function (value) {
  2112. value = +value || 0;
  2113. var values = this.$DisplayObject;
  2114. if (value == values[17 /* skewYdeg */]) {
  2115. return false;
  2116. }
  2117. values[17 /* skewYdeg */] = value;
  2118. value = clampRotation(value);
  2119. value = value / 180 * Math.PI;
  2120. values[3 /* skewY */] = value;
  2121. this.$invalidateMatrix();
  2122. return true;
  2123. };
  2124. Object.defineProperty(DisplayObject.prototype, "width", {
  2125. /**
  2126. * @language en_US
  2127. * Indicates the width of the display object, in pixels. The width is calculated based on the bounds of the content
  2128. * of the display object.
  2129. * @version Egret 2.4
  2130. * @platform Web,Native
  2131. */
  2132. /**
  2133. * @language zh_CN
  2134. * 表示显示对象的宽度,以像素为单位。宽度是根据显示对象内容的范围来计算的。
  2135. * @version Egret 2.4
  2136. * @platform Web,Native
  2137. */
  2138. get: function () {
  2139. return this.$getWidth();
  2140. },
  2141. set: function (value) {
  2142. this.$setWidth(value);
  2143. },
  2144. enumerable: true,
  2145. configurable: true
  2146. });
  2147. /**
  2148. * @private
  2149. * 获取显示宽度
  2150. */
  2151. DisplayObject.prototype.$getWidth = function () {
  2152. return isNaN(this.$getExplicitWidth()) ? this.$getOriginalBounds().width : this.$getExplicitWidth();
  2153. //return this.$getTransformedBounds(this.$parent, $TempRectangle).width;
  2154. };
  2155. /**
  2156. * @private
  2157. *
  2158. * @returns
  2159. */
  2160. DisplayObject.prototype.$getExplicitWidth = function () {
  2161. return this.$DisplayObject[14 /* explicitWidth */];
  2162. };
  2163. /**
  2164. * @private
  2165. * 设置显示宽度
  2166. */
  2167. DisplayObject.prototype.$setWidth = function (value) {
  2168. this.$DisplayObject[14 /* explicitWidth */] = isNaN(value) ? NaN : value;
  2169. value = +value;
  2170. if (value < 0) {
  2171. return false;
  2172. }
  2173. // if (false) {
  2174. // let values = this.$DisplayObject;
  2175. // let originalBounds = this.$getOriginalBounds();
  2176. // let bounds = this.$getTransformedBounds(this.$parent, $TempRectangle);
  2177. // let angle = values[Keys.rotation] / 180 * Math.PI;
  2178. // let baseWidth = originalBounds.$getBaseWidth(angle);
  2179. // if (!baseWidth) {
  2180. // return false;
  2181. // }
  2182. // let baseHeight = originalBounds.$getBaseHeight(angle);
  2183. // values[Keys.scaleY] = bounds.height / baseHeight;
  2184. // values[Keys.scaleX] = value / baseWidth;
  2185. // }
  2186. this.$invalidateMatrix();
  2187. return true;
  2188. };
  2189. Object.defineProperty(DisplayObject.prototype, "height", {
  2190. /**
  2191. * @language en_US
  2192. * Indicates the height of the display object, in pixels. The height is calculated based on the bounds of the
  2193. * content of the display object.
  2194. * @version Egret 2.4
  2195. * @platform Web,Native
  2196. */
  2197. /**
  2198. * @language zh_CN
  2199. * 表示显示对象的高度,以像素为单位。高度是根据显示对象内容的范围来计算的。
  2200. * @version Egret 2.4
  2201. * @platform Web,Native
  2202. */
  2203. get: function () {
  2204. return this.$getHeight();
  2205. },
  2206. set: function (value) {
  2207. this.$setHeight(value);
  2208. },
  2209. enumerable: true,
  2210. configurable: true
  2211. });
  2212. /**
  2213. * @private
  2214. * 获取显示高度
  2215. */
  2216. DisplayObject.prototype.$getHeight = function () {
  2217. return isNaN(this.$getExplicitHeight()) ? this.$getOriginalBounds().height : this.$getExplicitHeight();
  2218. //return this.$getTransformedBounds(this.$parent, $TempRectangle).height;
  2219. };
  2220. /**
  2221. * @private
  2222. *
  2223. * @returns
  2224. */
  2225. DisplayObject.prototype.$getExplicitHeight = function () {
  2226. return this.$DisplayObject[15 /* explicitHeight */];
  2227. };
  2228. /**
  2229. * @private
  2230. * 设置显示高度
  2231. */
  2232. DisplayObject.prototype.$setHeight = function (value) {
  2233. this.$DisplayObject[15 /* explicitHeight */] = isNaN(value) ? NaN : value;
  2234. value = +value;
  2235. if (value < 0) {
  2236. return false;
  2237. }
  2238. // if (false) {
  2239. // let values = this.$DisplayObject;
  2240. // let originalBounds = this.$getOriginalBounds();
  2241. // let bounds = this.$getTransformedBounds(this.$parent, $TempRectangle);
  2242. // let angle = values[Keys.rotation] / 180 * Math.PI;
  2243. // let baseHeight = originalBounds.$getBaseHeight(angle);
  2244. // if (!baseHeight) {
  2245. // return false;
  2246. // }
  2247. // let baseWidth = originalBounds.$getBaseWidth(angle);
  2248. // values[Keys.scaleY] = value / baseHeight;
  2249. // values[Keys.scaleX] = bounds.width / baseWidth;
  2250. // }
  2251. this.$invalidateMatrix();
  2252. return true;
  2253. };
  2254. Object.defineProperty(DisplayObject.prototype, "measuredWidth", {
  2255. /**
  2256. * 测量宽度
  2257. * @returns {number}
  2258. * @member {egret.Rectangle} egret.DisplayObject#measuredWidth
  2259. * @version Egret 2.4
  2260. * @platform Web,Native
  2261. */
  2262. get: function () {
  2263. return this.$getOriginalBounds().width;
  2264. },
  2265. enumerable: true,
  2266. configurable: true
  2267. });
  2268. Object.defineProperty(DisplayObject.prototype, "measuredHeight", {
  2269. /**
  2270. * 测量高度
  2271. * @returns {number}
  2272. * @member {egret.Rectangle} egret.DisplayObject#measuredWidth
  2273. * @version Egret 2.4
  2274. * @platform Web,Native
  2275. */
  2276. get: function () {
  2277. return this.$getOriginalBounds().height;
  2278. },
  2279. enumerable: true,
  2280. configurable: true
  2281. });
  2282. Object.defineProperty(DisplayObject.prototype, "anchorOffsetX", {
  2283. /**
  2284. * @language en_US
  2285. * X represents the object of which is the anchor.
  2286. * @default 0
  2287. * @version Egret 2.4
  2288. * @platform Web,Native
  2289. */
  2290. /**
  2291. * @language zh_CN
  2292. * 表示从对象绝对锚点X。
  2293. * @default 0
  2294. * @version Egret 2.4
  2295. * @platform Web,Native
  2296. */
  2297. get: function () {
  2298. return this.$DisplayObject[12 /* anchorOffsetX */];
  2299. },
  2300. set: function (value) {
  2301. this.$setAnchorOffsetX(value);
  2302. },
  2303. enumerable: true,
  2304. configurable: true
  2305. });
  2306. /**
  2307. * @private
  2308. */
  2309. DisplayObject.prototype.$getAnchorOffsetX = function () {
  2310. return this.$DisplayObject[12 /* anchorOffsetX */];
  2311. };
  2312. /**
  2313. * @private
  2314. *
  2315. * @param value
  2316. * @returns
  2317. */
  2318. DisplayObject.prototype.$setAnchorOffsetX = function (value) {
  2319. value = +value || 0;
  2320. if (value == this.$DisplayObject[12 /* anchorOffsetX */]) {
  2321. return false;
  2322. }
  2323. this.$DisplayObject[12 /* anchorOffsetX */] = value;
  2324. this.$invalidatePosition();
  2325. return true;
  2326. };
  2327. Object.defineProperty(DisplayObject.prototype, "anchorOffsetY", {
  2328. /**
  2329. * @language en_US
  2330. * Y represents the object of which is the anchor.
  2331. * @default 0
  2332. * @version Egret 2.4
  2333. * @platform Web,Native
  2334. */
  2335. /**
  2336. * @language zh_CN
  2337. * 表示从对象绝对锚点Y。
  2338. * @default 0
  2339. * @version Egret 2.4
  2340. * @platform Web,Native
  2341. */
  2342. get: function () {
  2343. return this.$DisplayObject[13 /* anchorOffsetY */];
  2344. },
  2345. set: function (value) {
  2346. this.$setAnchorOffsetY(value);
  2347. },
  2348. enumerable: true,
  2349. configurable: true
  2350. });
  2351. /**
  2352. * @private
  2353. */
  2354. DisplayObject.prototype.$getAnchorOffsetY = function () {
  2355. return this.$DisplayObject[13 /* anchorOffsetY */];
  2356. };
  2357. /**
  2358. * @private
  2359. *
  2360. * @param value
  2361. * @returns
  2362. */
  2363. DisplayObject.prototype.$setAnchorOffsetY = function (value) {
  2364. value = +value || 0;
  2365. if (value == this.$DisplayObject[13 /* anchorOffsetY */]) {
  2366. return false;
  2367. }
  2368. this.$DisplayObject[13 /* anchorOffsetY */] = value;
  2369. this.$invalidatePosition();
  2370. return true;
  2371. };
  2372. Object.defineProperty(DisplayObject.prototype, "visible", {
  2373. /**
  2374. * @language en_US
  2375. * Whether or not the display object is visible. Display objects that are not visible are disabled. For example,
  2376. * if visible=false for an DisplayObject instance, it cannot receive touch or other user input.
  2377. * @default true
  2378. * @version Egret 2.4
  2379. * @platform Web,Native
  2380. */
  2381. /**
  2382. * @language zh_CN
  2383. * 显示对象是否可见。不可见的显示对象将被禁用。例如,如果实例的 visible 为 false,则无法接受触摸或用户交互操作。
  2384. * @default true
  2385. * @version Egret 2.4
  2386. * @platform Web,Native
  2387. */
  2388. get: function () {
  2389. return this.$visible;
  2390. },
  2391. set: function (value) {
  2392. this.$setVisible(value);
  2393. },
  2394. enumerable: true,
  2395. configurable: true
  2396. });
  2397. DisplayObject.prototype.$setVisible = function (value) {
  2398. value = !!value;
  2399. if (value == this.$visible) {
  2400. return false;
  2401. }
  2402. this.$visible = value;
  2403. this.$propagateFlagsDown(1024 /* InvalidConcatenatedVisible */);
  2404. this.$invalidateTransform();
  2405. return true;
  2406. };
  2407. /**
  2408. * @private
  2409. * 获取这个显示对象跟它所有父级透明度的乘积
  2410. */
  2411. DisplayObject.prototype.$getConcatenatedVisible = function () {
  2412. var values = this.$DisplayObject;
  2413. if (this.$hasFlags(1024 /* InvalidConcatenatedVisible */)) {
  2414. if (this.$parent) {
  2415. var parentVisible = this.$parent.$getConcatenatedVisible();
  2416. values[19 /* concatenatedVisible */] = parentVisible && this.$visible;
  2417. }
  2418. else {
  2419. values[19 /* concatenatedVisible */] = this.$visible;
  2420. }
  2421. this.$removeFlags(1024 /* InvalidConcatenatedVisible */);
  2422. }
  2423. return values[19 /* concatenatedVisible */];
  2424. };
  2425. Object.defineProperty(DisplayObject.prototype, "cacheAsBitmap", {
  2426. /**
  2427. * @language en_US
  2428. * If set to true, Egret runtime caches an internal bitmap representation of the display object. This caching can
  2429. * increase performance for display objects that contain complex vector content. After you set the cacheAsBitmap
  2430. * property to true, the rendering does not change, however the display object performs pixel snapping automatically.
  2431. * The execution speed can be significantly faster depending on the complexity of the content.The cacheAsBitmap
  2432. * property is best used with display objects that have mostly static content and that do not scale and rotate frequently.<br/>
  2433. * Note: The display object will not create the bitmap caching when the memory exceeds the upper limit,even if you set it to true.
  2434. * @default false
  2435. * @version Egret 2.4
  2436. * @platform Web,Native
  2437. */
  2438. /**
  2439. * @language zh_CN
  2440. * 如果设置为 true,则 Egret 运行时将缓存显示对象的内部位图表示形式。此缓存可以提高包含复杂矢量内容的显示对象的性能。
  2441. * 将 cacheAsBitmap 属性设置为 true 后,呈现并不更改,但是,显示对象将自动执行像素贴紧。执行速度可能会大大加快,
  2442. * 具体取决于显示对象内容的复杂性。最好将 cacheAsBitmap 属性与主要具有静态内容且不频繁缩放或旋转的显示对象一起使用。<br/>
  2443. * 注意:在内存超过上限的情况下,即使将 cacheAsBitmap 属性设置为 true,显示对象也不使用位图缓存。
  2444. * @default false
  2445. * @version Egret 2.4
  2446. * @platform Web,Native
  2447. */
  2448. get: function () {
  2449. return this.$DisplayObject[11 /* cacheAsBitmap */];
  2450. },
  2451. set: function (value) {
  2452. value = !!value;
  2453. this.$DisplayObject[11 /* cacheAsBitmap */] = value;
  2454. this.$setHasDisplayList(value);
  2455. },
  2456. enumerable: true,
  2457. configurable: true
  2458. });
  2459. DisplayObject.prototype.$setHasDisplayList = function (value) {
  2460. var hasDisplayList = !!this.$displayList;
  2461. if (hasDisplayList == value) {
  2462. return;
  2463. }
  2464. if (value) {
  2465. var displayList = egret.sys.DisplayList.create(this);
  2466. if (displayList) {
  2467. this.$displayList = displayList;
  2468. if (this.$parentDisplayList) {
  2469. this.$parentDisplayList.markDirty(displayList);
  2470. }
  2471. this.$cacheAsBitmapChanged();
  2472. }
  2473. }
  2474. else {
  2475. this.$displayList = null;
  2476. this.$cacheAsBitmapChanged();
  2477. }
  2478. };
  2479. /**
  2480. * @private
  2481. * cacheAsBitmap属性改变
  2482. */
  2483. DisplayObject.prototype.$cacheAsBitmapChanged = function () {
  2484. var parentCache = this.$displayList || this.$parentDisplayList;
  2485. if (this.$renderNode && parentCache) {
  2486. parentCache.markDirty(this);
  2487. }
  2488. this.$propagateFlagsDown(16 /* InvalidConcatenatedMatrix */ |
  2489. 32 /* InvalidInvertedConcatenatedMatrix */);
  2490. };
  2491. Object.defineProperty(DisplayObject.prototype, "alpha", {
  2492. /**
  2493. * @language en_US
  2494. * Indicates the alpha transparency value of the object specified. Valid values are 0 (fully transparent) to 1 (fully opaque).
  2495. * The default value is 1. Display objects with alpha set to 0 are active, even though they are invisible.
  2496. * @default 1
  2497. * @version Egret 2.4
  2498. * @platform Web,Native
  2499. */
  2500. /**
  2501. * @language zh_CN
  2502. * 表示指定对象的 Alpha 透明度值。
  2503. * 有效值为 0(完全透明)到 1(完全不透明)。alpha 设置为 0 的显示对象是可触摸的,即使它们不可见。
  2504. * @default 1
  2505. * @version Egret 2.4
  2506. * @platform Web,Native
  2507. */
  2508. get: function () {
  2509. return this.$alpha;
  2510. },
  2511. set: function (value) {
  2512. this.$setAlpha(value);
  2513. },
  2514. enumerable: true,
  2515. configurable: true
  2516. });
  2517. /**
  2518. * @private
  2519. *
  2520. * @param value
  2521. */
  2522. DisplayObject.prototype.$setAlpha = function (value) {
  2523. value = +value || 0;
  2524. if (value == this.$alpha) {
  2525. return false;
  2526. }
  2527. this.$alpha = value;
  2528. this.$propagateFlagsDown(64 /* InvalidConcatenatedAlpha */);
  2529. this.$invalidate();
  2530. return true;
  2531. };
  2532. /**
  2533. * @private
  2534. * 获取这个显示对象跟它所有父级透明度的乘积
  2535. */
  2536. DisplayObject.prototype.$getConcatenatedAlpha = function () {
  2537. var values = this.$DisplayObject;
  2538. if (this.$hasFlags(64 /* InvalidConcatenatedAlpha */)) {
  2539. if (this.$parent) {
  2540. var parentAlpha = this.$parent.$getConcatenatedAlpha();
  2541. values[18 /* concatenatedAlpha */] = parentAlpha * this.$alpha;
  2542. }
  2543. else {
  2544. values[18 /* concatenatedAlpha */] = this.$alpha;
  2545. }
  2546. this.$removeFlags(64 /* InvalidConcatenatedAlpha */);
  2547. }
  2548. return values[18 /* concatenatedAlpha */];
  2549. };
  2550. Object.defineProperty(DisplayObject.prototype, "touchEnabled", {
  2551. /**
  2552. * @language en_US
  2553. * Specifies whether this object receives touch or other user input. The default value is false, which means that
  2554. * by default any DisplayObject instance that is on the display list cannot receive touch events. If touchEnabled is
  2555. * set to false, the instance does not receive any touch events (or other user input events). Any children of
  2556. * this instance on the display list are not affected. To change the touchEnabled behavior for all children of
  2557. * an object on the display list, use DisplayObjectContainer.touchChildren.
  2558. * @see egret.DisplayObjectContainer#touchChildren
  2559. * @default false
  2560. * @version Egret 2.4
  2561. * @platform Web,Native
  2562. */
  2563. /**
  2564. * @language zh_CN
  2565. * 指定此对象是否接收触摸或其他用户输入。默认值为 false,这表示默认情况下,显示列表上的任何 DisplayObject 实例都不会接收触摸事件或
  2566. * 其他用户输入事件。如果将 touchEnabled 设置为 false,则实例将不接收任何触摸事件(或其他用户输入事件)。显示列表上的该实例的任
  2567. * 何子级都不会受到影响。要更改显示列表上对象的所有子级的 touchEnabled 行为,请使用 DisplayObjectContainer.touchChildren。
  2568. * @see egret.DisplayObjectContainer#touchChildren
  2569. * @default false
  2570. * @version Egret 2.4
  2571. * @platform Web,Native
  2572. */
  2573. get: function () {
  2574. return this.$getTouchEnabled();
  2575. },
  2576. set: function (value) {
  2577. this.$setTouchEnabled(value);
  2578. },
  2579. enumerable: true,
  2580. configurable: true
  2581. });
  2582. /**
  2583. * @private
  2584. *
  2585. * @returns
  2586. */
  2587. DisplayObject.prototype.$getTouchEnabled = function () {
  2588. return this.$touchEnabled;
  2589. };
  2590. /**
  2591. * @private
  2592. */
  2593. DisplayObject.prototype.$setTouchEnabled = function (value) {
  2594. if (this.$touchEnabled == value) {
  2595. return false;
  2596. }
  2597. this.$touchEnabled = value;
  2598. return true;
  2599. };
  2600. Object.defineProperty(DisplayObject.prototype, "scrollRect", {
  2601. /**
  2602. * @language en_US
  2603. * The scroll rectangle bounds of the display object. The display object is cropped to the size defined by the rectangle,
  2604. * and it scrolls within the rectangle when you change the x and y properties of the scrollRect object. A scrolled display
  2605. * object always scrolls in whole pixel increments.You can scroll an object left and right by setting the x property of
  2606. * the scrollRect Rectangle object. You can scroll an object up and down by setting the y property of the scrollRect
  2607. * Rectangle object. If the display object is rotated 90° and you scroll it left and right, the display object actually
  2608. * scrolls up and down.<br/>
  2609. *
  2610. * Note: to change the value of a display object's scrollRect, you must make a copy of the entire scrollRect object, then copy
  2611. * the new object into the scrollRect property of the display object.
  2612. * @example the following code increases the x value of a display object's scrollRect
  2613. * <pre>
  2614. * let myRectangle:Rectangle = myDisplayObject.scrollRect;
  2615. * myRectangle.x += 10;
  2616. * myDisplayObject.scrollRect = myRectangle;
  2617. * </pre>
  2618. * @version Egret 2.4
  2619. * @platform Web,Native
  2620. */
  2621. /**
  2622. * @language zh_CN
  2623. * 显示对象的滚动矩形范围。显示对象被裁切为矩形定义的大小,当您更改 scrollRect 对象的 x 和 y 属性时,它会在矩形内滚动。
  2624. * 滚动的显示对象始终以整像素为增量进行滚动。您可以通过设置 scrollRect Rectangle 对象的 x 属性来左右滚动对象, 还可以通过设置
  2625. * scrollRect 对象的 y 属性来上下滚动对象。如果显示对象旋转了 90 度,并且您左右滚动它,则实际上显示对象会上下滚动。<br/>
  2626. *
  2627. * 注意:要改变一个显示对象 scrollRect 属性的值,您必引用整个 scrollRect 对象,然后将它重新赋值给显示对象的 scrollRect 属性。
  2628. * @example 以下代码改变了显示对象 scrollRect 的 x 属性值:
  2629. * <pre>
  2630. * let myRectangle:Rectangle = myDisplayObject.scrollRect;
  2631. * myRectangle.x += 10;
  2632. * myDisplayObject.scrollRect = myRectangle;//设置完scrollRect的x、y、width、height值之后,一定要对myDisplayObject重新赋值scrollRect,不然会出问题。
  2633. * </pre>
  2634. * @version Egret 2.4
  2635. * @platform Web,Native
  2636. */
  2637. get: function () {
  2638. return this.$scrollRect;
  2639. },
  2640. set: function (value) {
  2641. this.$setScrollRect(value);
  2642. },
  2643. enumerable: true,
  2644. configurable: true
  2645. });
  2646. /**
  2647. * @private
  2648. *
  2649. * @param value
  2650. */
  2651. DisplayObject.prototype.$setScrollRect = function (value) {
  2652. if (!value && !this.$scrollRect) {
  2653. return false;
  2654. }
  2655. if (value) {
  2656. if (!this.$scrollRect) {
  2657. this.$scrollRect = new egret.Rectangle();
  2658. }
  2659. this.$scrollRect.copyFrom(value);
  2660. }
  2661. else {
  2662. this.$scrollRect = null;
  2663. }
  2664. this.$invalidatePosition();
  2665. return true;
  2666. };
  2667. Object.defineProperty(DisplayObject.prototype, "blendMode", {
  2668. /**
  2669. * @language en_US
  2670. * A value from the BlendMode class that specifies which blend mode to use. Determine how a source image (new one)
  2671. * is drawn on the target image (old one).<br/>
  2672. * If you attempt to set this property to an invalid value, Egret runtime set the value to BlendMode.NORMAL.
  2673. * @default egret.BlendMode.NORMAL
  2674. * @see egret.BlendMode
  2675. * @version Egret 2.4
  2676. * @platform Web,Native
  2677. */
  2678. /**
  2679. * @language zh_CN
  2680. * BlendMode 枚举中的一个值,用于指定要使用的混合模式,确定如何将一个源(新的)图像绘制到目标(已有)的图像上<br/>
  2681. * 如果尝试将此属性设置为无效值,则运行时会将此值设置为 BlendMode.NORMAL。
  2682. * @default egret.BlendMode.NORMAL
  2683. * @see egret.BlendMode
  2684. * @version Egret 2.4
  2685. * @platform Web,Native
  2686. */
  2687. get: function () {
  2688. return egret.sys.numberToBlendMode(this.$blendMode);
  2689. },
  2690. set: function (value) {
  2691. var mode = egret.sys.blendModeToNumber(value);
  2692. if (mode == this.$blendMode) {
  2693. return;
  2694. }
  2695. this.$blendMode = mode;
  2696. this.$invalidateTransform();
  2697. },
  2698. enumerable: true,
  2699. configurable: true
  2700. });
  2701. Object.defineProperty(DisplayObject.prototype, "mask", {
  2702. /**
  2703. * @language en_US
  2704. * The calling display object is masked by the specified mask object. To ensure that masking works when the Stage
  2705. * is scaled, the mask display object must be in an active part of the display list. The mask object itself is not drawn.
  2706. * Set mask to null to remove the mask. To be able to scale a mask object, it must be on the display list. To be
  2707. * able to drag a mask object , it must be on the display list.<br/>
  2708. * Note: A single mask object cannot be used to mask more than one calling display object. When the mask is assigned
  2709. * to a second display object, it is removed as the mask of the first object, and that object's mask property becomes null.
  2710. * @version Egret 2.4
  2711. * @platform Web,Native
  2712. */
  2713. /**
  2714. * @language zh_CN
  2715. * 调用显示对象被指定的 mask 对象遮罩。要确保当舞台缩放时蒙版仍然有效,mask 显示对象必须处于显示列表的活动部分。
  2716. * 但不绘制 mask 对象本身。将 mask 设置为 null 可删除蒙版。要能够缩放遮罩对象,它必须在显示列表中。要能够拖动蒙版
  2717. * 对象,它必须在显示列表中。<br/>
  2718. * 注意:单个 mask 对象不能用于遮罩多个执行调用的显示对象。在将 mask 分配给第二个显示对象时,会撤消其作为第一个对象的遮罩,
  2719. * 该对象的 mask 属性将变为 null。
  2720. *
  2721. * 下面例子为 mask 为 Rectangle 类型对象,这种情况下,修改 mask 的值后,一定要对 myDisplayObject 重新赋值 mask,不然会出问题。
  2722. * @example 以下代码改变了显示对象 mask 的 x 属性值:
  2723. * <pre>
  2724. * let myMask:Rectangle = myDisplayObject.mask;
  2725. * myMask.x += 10;
  2726. * myDisplayObject.mask = myMask;//设置完 mask 的x、y、width、height值之后,一定要对myDisplayObject重新赋值 mask,不然会出问题。
  2727. * </pre>
  2728. * @version Egret 2.4
  2729. * @platform Web,Native
  2730. */
  2731. get: function () {
  2732. return this.$mask ? this.$mask : this.$maskRect;
  2733. },
  2734. set: function (value) {
  2735. if (value === this) {
  2736. return;
  2737. }
  2738. if (value) {
  2739. if (value instanceof DisplayObject) {
  2740. if (value == this.$mask) {
  2741. return;
  2742. }
  2743. if (value.$maskedObject) {
  2744. value.$maskedObject.mask = null;
  2745. }
  2746. value.$maskedObject = this;
  2747. value.$invalidateTransform();
  2748. this.$mask = value;
  2749. this.$maskRect = null;
  2750. }
  2751. else {
  2752. this.$setMaskRect(value);
  2753. if (this.$mask) {
  2754. this.$mask.$maskedObject = null;
  2755. this.$mask.$invalidateTransform();
  2756. }
  2757. this.$mask = null;
  2758. }
  2759. }
  2760. else {
  2761. if (this.$mask) {
  2762. this.$mask.$maskedObject = null;
  2763. this.$mask.$invalidateTransform();
  2764. }
  2765. this.$mask = null;
  2766. this.$maskRect = null;
  2767. }
  2768. this.$invalidateTransform();
  2769. },
  2770. enumerable: true,
  2771. configurable: true
  2772. });
  2773. DisplayObject.prototype.$setMaskRect = function (value) {
  2774. if (!value && !this.$maskRect) {
  2775. return false;
  2776. }
  2777. if (value) {
  2778. if (!this.$maskRect) {
  2779. this.$maskRect = new egret.Rectangle();
  2780. }
  2781. this.$maskRect.copyFrom(value);
  2782. }
  2783. else {
  2784. this.$maskRect = null;
  2785. }
  2786. this.$invalidatePosition();
  2787. return true;
  2788. };
  2789. Object.defineProperty(DisplayObject.prototype, "filters", {
  2790. /**
  2791. * @language en_US
  2792. * An indexed array that contains each filter object currently associated with the display object.
  2793. * @version Egret 3.1.0
  2794. * @platform Web
  2795. */
  2796. /**
  2797. * @language zh_CN
  2798. * 包含当前与显示对象关联的每个滤镜对象的索引数组。
  2799. * @version Egret 3.1.0
  2800. * @platform Web
  2801. */
  2802. get: function () {
  2803. return this.$DisplayObject[20 /* filters */];
  2804. },
  2805. set: function (value) {
  2806. var filters = this.$DisplayObject[20 /* filters */];
  2807. if (!filters && !value) {
  2808. this.$DisplayObject[20 /* filters */] = value;
  2809. return;
  2810. }
  2811. this.$invalidateContentBounds();
  2812. //需要通知子项
  2813. this.$invalidate(true);
  2814. if (filters && filters.length) {
  2815. var length_2 = filters.length;
  2816. for (var i = 0; i < length_2; i++) {
  2817. filters[i].$removeTarget(this);
  2818. }
  2819. }
  2820. this.$DisplayObject[20 /* filters */] = value;
  2821. if (value && value.length) {
  2822. var length_3 = value.length;
  2823. for (var i = 0; i < length_3; i++) {
  2824. value[i].$addTarget(this);
  2825. }
  2826. }
  2827. },
  2828. enumerable: true,
  2829. configurable: true
  2830. });
  2831. /**
  2832. * @private
  2833. * 获取filters
  2834. */
  2835. DisplayObject.prototype.$getFilters = function () {
  2836. return this.$DisplayObject[20 /* filters */];
  2837. };
  2838. /**
  2839. * @language en_US
  2840. * Returns a rectangle that defines the area of the display object relative to the coordinate system of the targetCoordinateSpace object.
  2841. * @param targetCoordinateSpace The display object that defines the coordinate system to use.
  2842. * @param resultRect A reusable instance of Rectangle for saving the results. Passing this parameter can reduce the number of reallocate objects
  2843. *, which allows you to get better code execution performance..
  2844. * @returns The rectangle that defines the area of the display object relative to the targetCoordinateSpace object's coordinate system.
  2845. * @version Egret 2.4
  2846. * @platform Web,Native
  2847. */
  2848. /**
  2849. * @language zh_CN
  2850. * 返回一个矩形,该矩形定义相对于 targetCoordinateSpace 对象坐标系的显示对象区域。
  2851. * @param targetCoordinateSpace 定义要使用的坐标系的显示对象。
  2852. * @param resultRect 一个用于存储结果的可复用Rectangle实例,传入此参数能够减少内部创建对象的次数,从而获得更高的运行性能。
  2853. * @returns 定义与 targetCoordinateSpace 对象坐标系统相关的显示对象面积的矩形。
  2854. * @version Egret 2.4
  2855. * @platform Web,Native
  2856. */
  2857. DisplayObject.prototype.getTransformedBounds = function (targetCoordinateSpace, resultRect) {
  2858. targetCoordinateSpace = targetCoordinateSpace || this;
  2859. return this.$getTransformedBounds(targetCoordinateSpace, resultRect);
  2860. };
  2861. /**
  2862. * @language en_US
  2863. * Obtain measurement boundary of display object
  2864. * @param resultRect {Rectangle} Optional. It is used to import Rectangle object for saving results, preventing duplicate object creation.
  2865. * @param calculateAnchor {boolean} Optional. It is used to determine whether to calculate anchor point.
  2866. * @returns {Rectangle}
  2867. * @version Egret 2.4
  2868. * @platform Web,Native
  2869. */
  2870. /**
  2871. * @language zh_CN
  2872. * 获取显示对象的测量边界
  2873. * @param resultRect {Rectangle} 可选参数,传入用于保存结果的Rectangle对象,避免重复创建对象。
  2874. * @param calculateAnchor {boolean} 可选参数,是否会计算锚点。
  2875. * @returns {Rectangle}
  2876. * @version Egret 2.4
  2877. * @platform Web,Native
  2878. */
  2879. DisplayObject.prototype.getBounds = function (resultRect, calculateAnchor) {
  2880. if (calculateAnchor === void 0) { calculateAnchor = true; }
  2881. resultRect = this.$getTransformedBounds(this, resultRect);
  2882. if (calculateAnchor) {
  2883. var values = this.$DisplayObject;
  2884. if (values[12 /* anchorOffsetX */] != 0 || values[13 /* anchorOffsetY */] != 0) {
  2885. resultRect.x -= values[12 /* anchorOffsetX */];
  2886. resultRect.y -= values[13 /* anchorOffsetY */];
  2887. }
  2888. }
  2889. return resultRect;
  2890. };
  2891. /**
  2892. * @private
  2893. */
  2894. DisplayObject.prototype.$getTransformedBounds = function (targetCoordinateSpace, resultRect) {
  2895. var bounds = this.$getOriginalBounds();
  2896. if (!resultRect) {
  2897. resultRect = new egret.Rectangle();
  2898. }
  2899. resultRect.copyFrom(bounds);
  2900. if (targetCoordinateSpace == this) {
  2901. return resultRect;
  2902. }
  2903. var m;
  2904. if (targetCoordinateSpace) {
  2905. m = egret.$TempMatrix;
  2906. var invertedTargetMatrix = targetCoordinateSpace.$getInvertedConcatenatedMatrix();
  2907. invertedTargetMatrix.$preMultiplyInto(this.$getConcatenatedMatrix(), m);
  2908. }
  2909. else {
  2910. m = this.$getConcatenatedMatrix();
  2911. }
  2912. m.$transformBounds(resultRect);
  2913. return resultRect;
  2914. };
  2915. /**
  2916. * @language en_US
  2917. * Converts the point object from the Stage (global) coordinates to the display object's (local) coordinates.
  2918. * @param stageX the x value in the global coordinates
  2919. * @param stageY the y value in the global coordinates
  2920. * @param resultPoint A reusable instance of Point for saving the results. Passing this parameter can reduce the
  2921. * number of reallocate objects, which allows you to get better code execution performance.
  2922. * @returns A Point object with coordinates relative to the display object.
  2923. * @version Egret 2.4
  2924. * @platform Web,Native
  2925. */
  2926. /**
  2927. * @language zh_CN
  2928. * 将从舞台(全局)坐标转换为显示对象的(本地)坐标。
  2929. * @param stageX 舞台坐标x
  2930. * @param stageY 舞台坐标y
  2931. * @param resultPoint 一个用于存储结果的可复用 Point 实例,传入此参数能够减少内部创建对象的次数,从而获得更高的运行性能。
  2932. * @returns 具有相对于显示对象的坐标的 Point 对象。
  2933. * @version Egret 2.4
  2934. * @platform Web,Native
  2935. */
  2936. DisplayObject.prototype.globalToLocal = function (stageX, stageY, resultPoint) {
  2937. if (stageX === void 0) { stageX = 0; }
  2938. if (stageY === void 0) { stageY = 0; }
  2939. var m = this.$getInvertedConcatenatedMatrix();
  2940. return m.transformPoint(stageX, stageY, resultPoint);
  2941. };
  2942. /**
  2943. * @language en_US
  2944. * Converts the point object from the display object's (local) coordinates to the Stage (global) coordinates.
  2945. * @param localX the x value in the local coordinates
  2946. * @param localY the x value in the local coordinates
  2947. * @param resultPoint A reusable instance of Point for saving the results. Passing this parameter can reduce the
  2948. * number of reallocate objects, which allows you to get better code execution performance.
  2949. * @returns A Point object with coordinates relative to the Stage.
  2950. * @version Egret 2.4
  2951. * @platform Web,Native
  2952. */
  2953. /**
  2954. * @language zh_CN
  2955. * 将显示对象的(本地)坐标转换为舞台(全局)坐标。
  2956. * @param localX 本地坐标 x
  2957. * @param localY 本地坐标 y
  2958. * @param resultPoint 一个用于存储结果的可复用 Point 实例,传入此参数能够减少内部创建对象的次数,从而获得更高的运行性能。
  2959. * @returns 一个具有相对于舞台坐标的 Point 对象。
  2960. * @version Egret 2.4
  2961. * @platform Web,Native
  2962. */
  2963. DisplayObject.prototype.localToGlobal = function (localX, localY, resultPoint) {
  2964. if (localX === void 0) { localX = 0; }
  2965. if (localY === void 0) { localY = 0; }
  2966. var m = this.$getConcatenatedMatrix();
  2967. return m.transformPoint(localX, localY, resultPoint);
  2968. };
  2969. /**
  2970. * @private
  2971. * 标记自身的测量尺寸失效
  2972. */
  2973. DisplayObject.prototype.$invalidateContentBounds = function () {
  2974. this.$invalidate();
  2975. this.$setFlags(2 /* InvalidContentBounds */);
  2976. this.$propagateFlagsUp(4 /* InvalidBounds */);
  2977. };
  2978. /**
  2979. * @private
  2980. * 获取显示对象占用的矩形区域集合,通常包括自身绘制的测量区域,如果是容器,还包括所有子项占据的区域。
  2981. */
  2982. DisplayObject.prototype.$getOriginalBounds = function () {
  2983. var bounds = this.$DisplayObject[9 /* bounds */];
  2984. if (this.$hasFlags(4 /* InvalidBounds */)) {
  2985. bounds.copyFrom(this.$getContentBounds());
  2986. this.$measureChildBounds(bounds);
  2987. this.$removeFlags(4 /* InvalidBounds */);
  2988. if (this.$displayList) {
  2989. this.$displayList.$renderNode.moved = true;
  2990. }
  2991. var offset = this.$measureFiltersOffset();
  2992. if (offset) {
  2993. bounds.x += offset.minX;
  2994. bounds.y += offset.minY;
  2995. bounds.width += offset.maxX;
  2996. bounds.height += offset.maxY;
  2997. }
  2998. }
  2999. return bounds;
  3000. };
  3001. /**
  3002. * @private
  3003. * 测量子项占用的矩形区域
  3004. * @param bounds 测量结果存储在这个矩形对象内
  3005. */
  3006. DisplayObject.prototype.$measureChildBounds = function (bounds) {
  3007. };
  3008. /**
  3009. * @private
  3010. */
  3011. DisplayObject.prototype.$getContentBounds = function () {
  3012. var bounds = this.$DisplayObject[10 /* contentBounds */];
  3013. if (this.$hasFlags(2 /* InvalidContentBounds */)) {
  3014. this.$measureContentBounds(bounds);
  3015. if (this.$renderNode) {
  3016. this.$renderNode.moved = true;
  3017. }
  3018. this.$removeFlags(2 /* InvalidContentBounds */);
  3019. }
  3020. return bounds;
  3021. };
  3022. /**
  3023. * @private
  3024. * 测量自身占用的矩形区域,注意:此测量结果并不包括子项占据的区域。
  3025. * @param bounds 测量结果存储在这个矩形对象内
  3026. */
  3027. DisplayObject.prototype.$measureContentBounds = function (bounds) {
  3028. };
  3029. /**
  3030. * @private
  3031. * 标记此显示对象需要重绘。此方法会触发自身的cacheAsBitmap重绘。如果只是矩阵改变,自身显示内容并不改变,应该调用$invalidateTransform().
  3032. * @param notiryChildren 是否标记子项也需要重绘。传入false或不传入,将只标记自身需要重绘。注意:当子项cache时不会继续向下标记
  3033. */
  3034. DisplayObject.prototype.$invalidate = function (notifyChildren) {
  3035. if (!this.$renderNode || this.$hasFlags(256 /* DirtyRender */ | 128 /* InvalidRenderNodes */)) {
  3036. return;
  3037. }
  3038. this.$setFlags(256 /* DirtyRender */ | 128 /* InvalidRenderNodes */);
  3039. var displayList = this.$displayList ? this.$displayList : this.$parentDisplayList;
  3040. if (displayList) {
  3041. displayList.markDirty(this);
  3042. }
  3043. };
  3044. /**
  3045. * @private
  3046. * 标记自身以及所有子项在父级中变换叠加的显示内容失效。此方法不会触发自身的cacheAsBitmap重绘。
  3047. * 通常用于矩阵改变或从显示列表添加和移除时。若自身的显示内容已经改变需要重绘,应该调用$invalidate()。
  3048. */
  3049. DisplayObject.prototype.$invalidateTransform = function () {
  3050. var self = this;
  3051. if (self.$hasFlags(512 /* DirtyChildren */)) {
  3052. return;
  3053. }
  3054. self.$setFlags(512 /* DirtyChildren */);
  3055. var displayList = self.$displayList;
  3056. if ((displayList || self.$renderNode) && self.$parentDisplayList) {
  3057. self.$parentDisplayList.markDirty(displayList || self);
  3058. }
  3059. };
  3060. /**
  3061. * @private
  3062. * 获取渲染节点
  3063. */
  3064. DisplayObject.prototype.$getRenderNode = function () {
  3065. var node = this.$renderNode;
  3066. if (!node) {
  3067. return null;
  3068. }
  3069. if (this.$displayFlags & 128 /* InvalidRenderNodes */) {
  3070. node.cleanBeforeRender();
  3071. this.$render();
  3072. this.$removeFlags(128 /* InvalidRenderNodes */);
  3073. node = this.$renderNode;
  3074. }
  3075. return node;
  3076. };
  3077. /**
  3078. * @private
  3079. * 更新对象在舞台上的显示区域,返回显示区域是否发生改变。
  3080. */
  3081. DisplayObject.prototype.$update = function (dirtyRegionPolicy, bounds) {
  3082. var self = this;
  3083. self.$removeFlagsUp(768 /* Dirty */);
  3084. var node = self.$renderNode;
  3085. node.renderAlpha = self.$getConcatenatedAlpha();
  3086. //必须在访问moved属性前调用以下两个方法,因为moved属性在以下两个方法内重置。
  3087. var concatenatedMatrix = self.$getConcatenatedMatrix();
  3088. if (dirtyRegionPolicy == egret.DirtyRegionPolicy.OFF) {
  3089. var displayList = self.$displayList || self.$parentDisplayList;
  3090. if (!displayList) {
  3091. return false;
  3092. }
  3093. var matrix = node.renderMatrix;
  3094. matrix.copyFrom(concatenatedMatrix);
  3095. var root = displayList.root;
  3096. if (root !== self.$stage) {
  3097. self.$getConcatenatedMatrixAt(root, matrix);
  3098. }
  3099. }
  3100. else {
  3101. var renderBounds = bounds || self.$getContentBounds();
  3102. node.renderVisible = self.$getConcatenatedVisible();
  3103. var displayList = self.$displayList || self.$parentDisplayList;
  3104. var region = node.renderRegion;
  3105. if (!displayList) {
  3106. region.setTo(0, 0, 0, 0);
  3107. node.moved = false;
  3108. return false;
  3109. }
  3110. if (!node.moved) {
  3111. return false;
  3112. }
  3113. node.moved = false;
  3114. var matrix = node.renderMatrix;
  3115. matrix.copyFrom(concatenatedMatrix);
  3116. var root = displayList.root;
  3117. if (root !== self.$stage) {
  3118. self.$getConcatenatedMatrixAt(root, matrix);
  3119. }
  3120. region.updateRegion(renderBounds, matrix);
  3121. var offset = self.$measureFiltersOffset();
  3122. if (offset) {
  3123. region.minX += offset.minX;
  3124. region.minY += offset.minY;
  3125. region.maxX += offset.maxX;
  3126. region.maxY += offset.maxY;
  3127. region.updateArea();
  3128. }
  3129. }
  3130. return true;
  3131. };
  3132. /**
  3133. * @private
  3134. */
  3135. DisplayObject.prototype.$measureFiltersOffset = function () {
  3136. var filters = this.$DisplayObject[20 /* filters */];
  3137. if (filters && filters.length) {
  3138. var length_4 = filters.length;
  3139. var minX = 0;
  3140. var minY = 0;
  3141. var maxX = 0;
  3142. var maxY = 0;
  3143. for (var i = 0; i < length_4; i++) {
  3144. var filter = filters[i];
  3145. if (filter.type == "blur") {
  3146. var offsetX = filter.blurX;
  3147. var offsetY = filter.blurY;
  3148. minX -= offsetX;
  3149. minY -= offsetY;
  3150. maxX += offsetX * 2;
  3151. maxY += offsetY * 2;
  3152. }
  3153. else if (filter.type == "glow") {
  3154. var offsetX = filter.blurX;
  3155. var offsetY = filter.blurY;
  3156. minX -= offsetX;
  3157. minY -= offsetY;
  3158. maxX += offsetX * 2;
  3159. maxY += offsetY * 2;
  3160. var distance = filter.distance || 0;
  3161. var angle = filter.angle || 0;
  3162. var distanceX = 0;
  3163. var distanceY = 0;
  3164. if (distance != 0) {
  3165. //todo 缓存这个数据
  3166. distanceX = Math.ceil(distance * egret.NumberUtils.cos(angle));
  3167. distanceY = Math.ceil(distance * egret.NumberUtils.sin(angle));
  3168. if (distanceX > 0) {
  3169. maxX += distanceX;
  3170. }
  3171. else if (distanceX < 0) {
  3172. minX += distanceX;
  3173. maxX -= distanceX;
  3174. }
  3175. if (distanceY > 0) {
  3176. maxY += distanceY;
  3177. }
  3178. else if (distanceY < 0) {
  3179. minY += distanceY;
  3180. maxY -= distanceY;
  3181. }
  3182. }
  3183. }
  3184. }
  3185. return { minX: minX, minY: minY, maxX: maxX, maxY: maxY };
  3186. }
  3187. return null;
  3188. };
  3189. /**
  3190. * @private
  3191. * 获取相对于指定根节点的连接矩阵。
  3192. * @param root 根节点显示对象
  3193. * @param matrix 目标显示对象相对于舞台的完整连接矩阵。
  3194. */
  3195. DisplayObject.prototype.$getConcatenatedMatrixAt = function (root, matrix) {
  3196. var invertMatrix = root.$getInvertedConcatenatedMatrix();
  3197. if (invertMatrix.a === 0 || invertMatrix.d === 0) {
  3198. var target = this;
  3199. var rootLevel = root.$nestLevel;
  3200. matrix.identity();
  3201. while (target.$nestLevel > rootLevel) {
  3202. var rect = target.$scrollRect;
  3203. if (rect) {
  3204. matrix.concat(egret.$TempMatrix.setTo(1, 0, 0, 1, -rect.x, -rect.y));
  3205. }
  3206. matrix.concat(target.$getMatrix());
  3207. target = target.$parent;
  3208. }
  3209. }
  3210. else {
  3211. invertMatrix.$preMultiplyInto(matrix, matrix);
  3212. }
  3213. };
  3214. DisplayObject.prototype.$getConcatenatedAlphaAt = function (root, alpha) {
  3215. var rootAlpha = root.$getConcatenatedAlpha();
  3216. if (rootAlpha === 0) {
  3217. alpha = 1;
  3218. var target = this;
  3219. var rootLevel = root.$nestLevel;
  3220. while (target.$nestLevel > rootLevel) {
  3221. alpha *= target.$alpha;
  3222. target = target.$parent;
  3223. }
  3224. }
  3225. else {
  3226. alpha /= rootAlpha;
  3227. }
  3228. return alpha;
  3229. };
  3230. /**
  3231. * @private
  3232. * 执行渲染,绘制自身到屏幕
  3233. */
  3234. DisplayObject.prototype.$render = function () {
  3235. };
  3236. /**
  3237. * @private
  3238. */
  3239. DisplayObject.prototype.$hitTest = function (stageX, stageY) {
  3240. var values = this.$DisplayObject;
  3241. if (!this.$renderNode || !this.$visible || values[0 /* scaleX */] == 0 || values[1 /* scaleY */] == 0) {
  3242. return null;
  3243. }
  3244. var m = this.$getInvertedConcatenatedMatrix();
  3245. if (m.a == 0 && m.b == 0 && m.c == 0 && m.d == 0) {
  3246. return null;
  3247. }
  3248. var bounds = this.$getContentBounds();
  3249. var localX = m.a * stageX + m.c * stageY + m.tx;
  3250. var localY = m.b * stageX + m.d * stageY + m.ty;
  3251. if (bounds.contains(localX, localY)) {
  3252. if (!this.$children) {
  3253. var rect = this.$scrollRect ? this.$scrollRect : this.$maskRect;
  3254. if (rect && !rect.contains(localX, localY)) {
  3255. return null;
  3256. }
  3257. if (this.$mask && !this.$mask.$hitTest(stageX, stageY)) {
  3258. return null;
  3259. }
  3260. }
  3261. return this;
  3262. }
  3263. return null;
  3264. };
  3265. /**
  3266. * @language en_US
  3267. * Calculate the display object to determine whether it overlaps or crosses with the points specified by the x and y parameters. The x and y parameters specify the points in the coordinates of the stage, rather than the points in the display object container that contains display objects (except the situation where the display object container is a stage).
  3268. * Note: Don't use accurate pixel collision detection on a large number of objects. Otherwise, this will cause serious performance deterioration.
  3269. * @param x {number} x coordinate of the object to be tested.
  3270. * @param y {number} y coordinate of the object to be tested.
  3271. * @param shapeFlag {boolean} Whether to check the actual pixel of object (true) or check that of border (false).Write realized.
  3272. * @returns {boolean} If display object overlaps or crosses with the specified point, it is true; otherwise, it is false.
  3273. * @version Egret 2.4
  3274. * @platform Web,Native
  3275. */
  3276. /**
  3277. * @language zh_CN
  3278. * 计算显示对象,以确定它是否与 x 和 y 参数指定的点重叠或相交。x 和 y 参数指定舞台的坐标空间中的点,而不是包含显示对象的显示对象容器中的点(除非显示对象容器是舞台)。
  3279. * 注意,不要在大量物体中使用精确碰撞像素检测,这回带来巨大的性能开销
  3280. * @param x {number} 要测试的此对象的 x 坐标。
  3281. * @param y {number} 要测试的此对象的 y 坐标。
  3282. * @param shapeFlag {boolean} 是检查对象 (true) 的实际像素,还是检查边框 (false) 的实际像素。
  3283. * @returns {boolean} 如果显示对象与指定的点重叠或相交,则为 true;否则为 false。
  3284. * @version Egret 2.4
  3285. * @platform Web,Native
  3286. */
  3287. DisplayObject.prototype.hitTestPoint = function (x, y, shapeFlag) {
  3288. if (!shapeFlag) {
  3289. var values = this.$DisplayObject;
  3290. if (values[0 /* scaleX */] == 0 || values[1 /* scaleY */] == 0) {
  3291. return false;
  3292. }
  3293. var m = this.$getInvertedConcatenatedMatrix();
  3294. var bounds = this.getBounds(null, false);
  3295. var localX = m.a * x + m.c * y + m.tx;
  3296. var localY = m.b * x + m.d * y + m.ty;
  3297. if (bounds.contains(localX, localY)) {
  3298. //这里不考虑设置mask的情况
  3299. var rect = this.$scrollRect ? this.$scrollRect : this.$maskRect;
  3300. if (rect && !rect.contains(localX, localY)) {
  3301. return false;
  3302. }
  3303. return true;
  3304. }
  3305. return false;
  3306. }
  3307. else {
  3308. var m = this.$getInvertedConcatenatedMatrix();
  3309. var localX = m.a * x + m.c * y + m.tx;
  3310. var localY = m.b * x + m.d * y + m.ty;
  3311. var data = void 0;
  3312. var displayList = this.$displayList;
  3313. if (displayList) {
  3314. var buffer = displayList.renderBuffer;
  3315. try {
  3316. data = buffer.getPixels(localX - displayList.offsetX, localY - displayList.offsetY);
  3317. }
  3318. catch (e) {
  3319. throw new Error(egret.sys.tr(1039));
  3320. }
  3321. }
  3322. else {
  3323. var buffer = egret.sys.customHitTestBuffer;
  3324. buffer.resize(3, 3);
  3325. var matrix = egret.Matrix.create();
  3326. matrix.identity();
  3327. matrix.translate(1 - localX, 1 - localY);
  3328. egret.sys.systemRenderer.render(this, buffer, matrix, null, true);
  3329. egret.Matrix.release(matrix);
  3330. try {
  3331. data = buffer.getPixels(1, 1);
  3332. }
  3333. catch (e) {
  3334. throw new Error(egret.sys.tr(1039));
  3335. }
  3336. }
  3337. if (data[3] === 0) {
  3338. return false;
  3339. }
  3340. return true;
  3341. }
  3342. };
  3343. /**
  3344. * @private
  3345. */
  3346. DisplayObject.prototype.$addListener = function (type, listener, thisObject, useCapture, priority, dispatchOnce) {
  3347. _super.prototype.$addListener.call(this, type, listener, thisObject, useCapture, priority, dispatchOnce);
  3348. var isEnterFrame = (type == egret.Event.ENTER_FRAME);
  3349. if (isEnterFrame || type == egret.Event.RENDER) {
  3350. var list = isEnterFrame ? DisplayObject.$enterFrameCallBackList : DisplayObject.$renderCallBackList;
  3351. if (list.indexOf(this) == -1) {
  3352. list.push(this);
  3353. }
  3354. }
  3355. };
  3356. /**
  3357. * @inheritDoc
  3358. * @version Egret 2.4
  3359. * @platform Web,Native
  3360. */
  3361. DisplayObject.prototype.removeEventListener = function (type, listener, thisObject, useCapture) {
  3362. _super.prototype.removeEventListener.call(this, type, listener, thisObject, useCapture);
  3363. var isEnterFrame = (type == egret.Event.ENTER_FRAME);
  3364. if ((isEnterFrame || type == egret.Event.RENDER) && !this.hasEventListener(type)) {
  3365. var list = isEnterFrame ? DisplayObject.$enterFrameCallBackList : DisplayObject.$renderCallBackList;
  3366. var index = list.indexOf(this);
  3367. if (index !== -1) {
  3368. list.splice(index, 1);
  3369. }
  3370. }
  3371. };
  3372. /**
  3373. * @inheritDoc
  3374. * @version Egret 2.4
  3375. * @platform Web,Native
  3376. */
  3377. DisplayObject.prototype.dispatchEvent = function (event) {
  3378. if (!event.$bubbles) {
  3379. return _super.prototype.dispatchEvent.call(this, event);
  3380. }
  3381. var list = this.$getPropagationList(this);
  3382. var targetIndex = list.length * 0.5;
  3383. event.$setTarget(this);
  3384. this.$dispatchPropagationEvent(event, list, targetIndex);
  3385. return !event.$isDefaultPrevented;
  3386. };
  3387. /**
  3388. * @private
  3389. * 获取事件流列表。注意:Egret框架的事件流与Flash实现并不一致。
  3390. *
  3391. * 事件流有三个阶段:捕获,目标,冒泡。
  3392. * Flash里默认的的事件监听若不开启useCapture将监听目标和冒泡阶段。若开始capture将只能监听捕获当不包括目标的事件。
  3393. * 可以在Flash中写一个简单的测试:实例化一个非容器显示对象,例如TextField。分别监听useCapture为true和false时的鼠标事件。
  3394. * 点击后将只有useCapture为false的回调函数输出信息。也就带来一个问题「Flash的捕获阶段不能监听到最内层对象本身,只在父级列表有效」。
  3395. *
  3396. * 而HTML里的事件流设置useCapture为true时是能监听到目标阶段的,也就是目标阶段会被触发两次,在捕获和冒泡过程各触发一次。这样可以避免
  3397. * 前面提到的监听捕获无法监听目标本身的问题。
  3398. *
  3399. * Egret最终采用了HTML里目标节点触发两次的事件流方式。
  3400. */
  3401. DisplayObject.prototype.$getPropagationList = function (target) {
  3402. var list = [];
  3403. while (target) {
  3404. list.push(target);
  3405. target = target.$parent;
  3406. }
  3407. var captureList = list.concat();
  3408. captureList.reverse(); //使用一次reverse()方法比多次调用unshift()性能高。
  3409. list = captureList.concat(list);
  3410. return list;
  3411. };
  3412. /**
  3413. * @private
  3414. */
  3415. DisplayObject.prototype.$dispatchPropagationEvent = function (event, list, targetIndex) {
  3416. var length = list.length;
  3417. var captureIndex = targetIndex - 1;
  3418. for (var i = 0; i < length; i++) {
  3419. var currentTarget = list[i];
  3420. event.$currentTarget = currentTarget;
  3421. if (i < captureIndex)
  3422. event.$eventPhase = 1 /* CAPTURING_PHASE */;
  3423. else if (i == targetIndex || i == captureIndex)
  3424. event.$eventPhase = 2 /* AT_TARGET */;
  3425. else
  3426. event.$eventPhase = 3 /* BUBBLING_PHASE */;
  3427. currentTarget.$notifyListener(event, i < targetIndex);
  3428. if (event.$isPropagationStopped || event.$isPropagationImmediateStopped) {
  3429. return;
  3430. }
  3431. }
  3432. };
  3433. /**
  3434. * @inheritDoc
  3435. * @version Egret 2.4
  3436. * @platform Web,Native
  3437. */
  3438. DisplayObject.prototype.willTrigger = function (type) {
  3439. var parent = this;
  3440. while (parent) {
  3441. if (parent.hasEventListener(type))
  3442. return true;
  3443. parent = parent.$parent;
  3444. }
  3445. return false;
  3446. };
  3447. return DisplayObject;
  3448. }(egret.EventDispatcher));
  3449. /**
  3450. * @private
  3451. * @language en_US
  3452. * The default touchEnabled property of DisplayObject
  3453. * @default false
  3454. * @version Egret 2.5
  3455. * @platform Web,Native
  3456. */
  3457. /**
  3458. * @private
  3459. * @language zh_CN
  3460. * 显示对象默认的 touchEnabled 属性
  3461. * @default false
  3462. * @version Egret 2.5
  3463. * @platform Web,Native
  3464. */
  3465. DisplayObject.defaultTouchEnabled = false;
  3466. DisplayObject.boundsForUpdate = new egret.Rectangle();
  3467. /**
  3468. * @private
  3469. */
  3470. DisplayObject.$enterFrameCallBackList = [];
  3471. /**
  3472. * @private
  3473. */
  3474. DisplayObject.$renderCallBackList = [];
  3475. egret.DisplayObject = DisplayObject;
  3476. __reflect(DisplayObject.prototype, "egret.DisplayObject", ["egret.sys.Renderable"]);
  3477. if (true) {
  3478. egret.$markReadOnly(DisplayObject, "parent");
  3479. egret.$markReadOnly(DisplayObject, "stage");
  3480. }
  3481. })(egret || (egret = {}));
  3482. //////////////////////////////////////////////////////////////////////////////////////
  3483. //
  3484. // Copyright (c) 2014-present, Egret Technology.
  3485. // All rights reserved.
  3486. // Redistribution and use in source and binary forms, with or without
  3487. // modification, are permitted provided that the following conditions are met:
  3488. //
  3489. // * Redistributions of source code must retain the above copyright
  3490. // notice, this list of conditions and the following disclaimer.
  3491. // * Redistributions in binary form must reproduce the above copyright
  3492. // notice, this list of conditions and the following disclaimer in the
  3493. // documentation and/or other materials provided with the distribution.
  3494. // * Neither the name of the Egret nor the
  3495. // names of its contributors may be used to endorse or promote products
  3496. // derived from this software without specific prior written permission.
  3497. //
  3498. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  3499. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  3500. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  3501. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  3502. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  3503. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  3504. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  3505. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  3506. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  3507. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3508. //
  3509. //////////////////////////////////////////////////////////////////////////////////////
  3510. var egret;
  3511. (function (egret) {
  3512. /**
  3513. * @language en_US
  3514. * The DisplayObjectContainer class is a basic display list building block: a display list node that can contain children.
  3515. * @version Egret 2.4
  3516. * @platform Web,Native
  3517. * @includeExample egret/display/DisplayObjectContainer.ts
  3518. */
  3519. /**
  3520. * @language zh_CN
  3521. * DisplayObjectContainer 类是基本显示列表构造块:一个可包含子项的显示列表节点。
  3522. * @version Egret 2.4
  3523. * @platform Web,Native
  3524. * @includeExample egret/display/DisplayObjectContainer.ts
  3525. */
  3526. var DisplayObjectContainer = (function (_super) {
  3527. __extends(DisplayObjectContainer, _super);
  3528. /**
  3529. * @language en_US
  3530. * Creates a new DisplayObjectContainer instance.
  3531. * @version Egret 2.4
  3532. * @platform Web,Native
  3533. */
  3534. /**
  3535. * @language zh_CN
  3536. * 实例化一个容器
  3537. * @version Egret 2.4
  3538. * @platform Web,Native
  3539. */
  3540. function DisplayObjectContainer() {
  3541. var _this = _super.call(this) || this;
  3542. _this.$touchChildren = true;
  3543. _this.$children = [];
  3544. return _this;
  3545. }
  3546. /**
  3547. * @private
  3548. */
  3549. DisplayObjectContainer.prototype.$propagateFlagsDown = function (flags, cachedBreak) {
  3550. if (cachedBreak === void 0) { cachedBreak = false; }
  3551. if (this.$hasFlags(flags)) {
  3552. return;
  3553. }
  3554. this.$setFlags(flags);
  3555. if (cachedBreak && this.$displayList) {
  3556. return;
  3557. }
  3558. var children = this.$children;
  3559. var length = children.length;
  3560. for (var i = 0; i < length; i++) {
  3561. children[i].$propagateFlagsDown(flags, cachedBreak);
  3562. }
  3563. };
  3564. Object.defineProperty(DisplayObjectContainer.prototype, "numChildren", {
  3565. /**
  3566. * @language en_US
  3567. * Returns the number of children of this object.
  3568. * @version Egret 2.4
  3569. * @platform Web,Native
  3570. */
  3571. /**
  3572. * @language zh_CN
  3573. * 返回此对象的子项数目。
  3574. * @version Egret 2.4
  3575. * @platform Web,Native
  3576. */
  3577. get: function () {
  3578. return this.$children.length;
  3579. },
  3580. enumerable: true,
  3581. configurable: true
  3582. });
  3583. /**
  3584. * @language en_US
  3585. * Adds a child DisplayObject instance to this DisplayObjectContainer instance. The child is added to the front
  3586. * (top) of all other children in this DisplayObjectContainer instance. (To add a child to a specific index position,
  3587. * use the addChildAt() method.)If you add a child object that already has a different display object container
  3588. * as a parent, the object is removed from the child list of the other display object container.
  3589. * @param child The DisplayObject instance to add as a child of this DisplayObjectContainer instance.
  3590. * @returns 在 child The DisplayObject instance that you pass in the child parameter.
  3591. * @see #addChildAt()
  3592. * @version Egret 2.4
  3593. * @platform Web,Native
  3594. */
  3595. /**
  3596. * @language zh_CN
  3597. * 将一个 DisplayObject 子实例添加到该 DisplayObjectContainer 实例中。子项将被添加到该 DisplayObjectContainer 实例中其他
  3598. * 所有子项的前(上)面。(要将某子项添加到特定索引位置,请使用 addChildAt() 方法。)
  3599. * @param child 要作为该 DisplayObjectContainer 实例的子项添加的 DisplayObject 实例。
  3600. * @returns 在 child 参数中传递的 DisplayObject 实例。
  3601. * @see #addChildAt()
  3602. * @version Egret 2.4
  3603. * @platform Web,Native
  3604. */
  3605. DisplayObjectContainer.prototype.addChild = function (child) {
  3606. var index = this.$children.length;
  3607. if (child.$parent == this)
  3608. index--;
  3609. return this.$doAddChild(child, index);
  3610. };
  3611. /**
  3612. * @language en_US
  3613. * Adds a child DisplayObject instance to this DisplayObjectContainer instance. The child is added at the index position
  3614. * specified. An index of 0 represents the back (bottom) of the display list for this DisplayObjectContainer object.
  3615. * If you add a child object that already has a different display object container as a parent, the object is removed
  3616. * from the child list of the other display object container.
  3617. * @param child The DisplayObject instance to add as a child of this DisplayObjectContainer instance.
  3618. * @param index The index position to which the child is added. If you specify a currently occupied index position,
  3619. * the child object that exists at that position and all higher positions are moved up one position in the child list.
  3620. * @returns The DisplayObject instance that you pass in the child parameter.
  3621. * @see #addChild()
  3622. * @version Egret 2.4
  3623. * @platform Web,Native
  3624. */
  3625. /**
  3626. * @language zh_CN
  3627. * 将一个 DisplayObject 子实例添加到该 DisplayObjectContainer 实例中。该子项将被添加到指定的索引位置。索引为 0 表示该
  3628. * DisplayObjectContainer 对象的显示列表的后(底)部。如果添加一个已将其它显示对象容器作为父项的子对象,则会从其它显示对象容器的子列表中删除该对象。
  3629. * @param child 要作为该 DisplayObjectContainer 实例的子项添加的 DisplayObject 实例。
  3630. * @param index 添加该子项的索引位置。 如果指定当前占用的索引位置,则该位置以及所有更高位置上的子对象会在子级列表中上移一个位置。
  3631. * @returns 在 child 参数中传递的 DisplayObject 实例。
  3632. * @see #addChild()
  3633. * @version Egret 2.4
  3634. * @platform Web,Native
  3635. */
  3636. DisplayObjectContainer.prototype.addChildAt = function (child, index) {
  3637. index = +index | 0;
  3638. if (index < 0 || index >= this.$children.length) {
  3639. index = this.$children.length;
  3640. if (child.$parent == this) {
  3641. index--;
  3642. }
  3643. }
  3644. return this.$doAddChild(child, index);
  3645. };
  3646. /**
  3647. * @private
  3648. */
  3649. DisplayObjectContainer.prototype.$doAddChild = function (child, index, notifyListeners) {
  3650. if (notifyListeners === void 0) { notifyListeners = true; }
  3651. if (true) {
  3652. if (child == this) {
  3653. egret.$error(1005);
  3654. }
  3655. else if ((child instanceof egret.DisplayObjectContainer) && child.contains(this)) {
  3656. egret.$error(1004);
  3657. }
  3658. }
  3659. var host = child.$parent;
  3660. if (host == this) {
  3661. this.doSetChildIndex(child, index);
  3662. return child;
  3663. }
  3664. if (host) {
  3665. host.removeChild(child);
  3666. }
  3667. this.$children.splice(index, 0, child);
  3668. child.$setParent(this);
  3669. var stage = this.$stage;
  3670. if (stage) {
  3671. child.$onAddToStage(stage, this.$nestLevel + 1);
  3672. }
  3673. if (notifyListeners) {
  3674. child.dispatchEventWith(egret.Event.ADDED, true);
  3675. }
  3676. if (stage) {
  3677. var list = DisplayObjectContainer.$EVENT_ADD_TO_STAGE_LIST;
  3678. while (list.length) {
  3679. var childAddToStage = list.shift();
  3680. if (childAddToStage.$stage && notifyListeners) {
  3681. childAddToStage.dispatchEventWith(egret.Event.ADDED_TO_STAGE);
  3682. }
  3683. }
  3684. }
  3685. var displayList = this.$displayList || this.$parentDisplayList;
  3686. this.assignParentDisplayList(child, displayList, displayList);
  3687. child.$propagateFlagsDown(1648 /* DownOnAddedOrRemoved */, true);
  3688. this.$propagateFlagsUp(4 /* InvalidBounds */);
  3689. this.$childAdded(child, index);
  3690. return child;
  3691. };
  3692. /**
  3693. * @language en_US
  3694. * Determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance
  3695. * itself. The search includes the entire display list including this DisplayObjectContainer instance. Grandchildren,
  3696. * great-grandchildren, and so on each return true.
  3697. * @param child The child object to test.
  3698. * @returns true if the child object is a child of the DisplayObjectContainer or the container itself; otherwise false.
  3699. * @version Egret 2.4
  3700. * @platform Web,Native
  3701. */
  3702. /**
  3703. * @language zh_CN
  3704. * 确定指定显示对象是 DisplayObjectContainer 实例的子项还是该实例本身。搜索包括整个显示列表(其中包括此 DisplayObjectContainer 实例)。
  3705. * 孙项、曾孙项等,每项都返回 true。
  3706. * @param child 要测试的子对象。
  3707. * @returns 如果指定的显示对象为 DisplayObjectContainer 该实例本身,则返回true,如果指定的显示对象为当前实例子项,则返回false。
  3708. * @version Egret 2.4
  3709. * @platform Web,Native
  3710. */
  3711. DisplayObjectContainer.prototype.contains = function (child) {
  3712. while (child) {
  3713. if (child == this) {
  3714. return true;
  3715. }
  3716. child = child.$parent;
  3717. }
  3718. return false;
  3719. };
  3720. /**
  3721. * @language en_US
  3722. * Returns the child display object instance that exists at the specified index.
  3723. * @param index The index position of the child object.
  3724. * @returns The child display object at the specified index position.
  3725. * @see #getChildByName()
  3726. * @version Egret 2.4
  3727. * @platform Web,Native
  3728. */
  3729. /**
  3730. * @language zh_CN
  3731. * 返回位于指定索引处的子显示对象实例。
  3732. * @param index 子对象的索引位置。
  3733. * @returns 位于指定索引位置处的子显示对象。
  3734. * @see #getChildByName()
  3735. * @version Egret 2.4
  3736. * @platform Web,Native
  3737. */
  3738. DisplayObjectContainer.prototype.getChildAt = function (index) {
  3739. index = +index | 0;
  3740. if (index >= 0 && index < this.$children.length) {
  3741. return this.$children[index];
  3742. }
  3743. else {
  3744. true && egret.$error(1007);
  3745. return null;
  3746. }
  3747. };
  3748. /**
  3749. * @language en_US
  3750. * Returns the index position of a child DisplayObject instance.
  3751. * @param child The DisplayObject instance to identify.
  3752. * @returns The index position of the child display object to identify.
  3753. * @version Egret 2.4
  3754. * @platform Web,Native
  3755. */
  3756. /**
  3757. * @language zh_CN
  3758. * 返回 DisplayObject 的 child 实例的索引位置。
  3759. * @param child 要测试的子对象。
  3760. * @returns 要查找的子显示对象的索引位置。
  3761. * @version Egret 2.4
  3762. * @platform Web,Native
  3763. */
  3764. DisplayObjectContainer.prototype.getChildIndex = function (child) {
  3765. return this.$children.indexOf(child);
  3766. };
  3767. /**
  3768. * @language en_US
  3769. * Returns the child display object that exists with the specified name. If more that one child display object has
  3770. * the specified name, the method returns the first object in the child list.The getChildAt() method is faster than
  3771. * the getChildByName() method. The getChildAt() method accesses a child from a cached array, whereas the getChildByName()
  3772. * method has to traverse a linked list to access a child.
  3773. * @param name The name of the child to return.
  3774. * @returns The child display object with the specified name.
  3775. * @see #getChildAt()
  3776. * @see egret.DisplayObject#name
  3777. * @version Egret 2.4
  3778. * @platform Web,Native
  3779. */
  3780. /**
  3781. * @language zh_CN
  3782. * 返回具有指定名称的子显示对象。如果多个子显示对象具有指定名称,则该方法会返回子级列表中的第一个对象。
  3783. * getChildAt() 方法比 getChildByName() 方法快。getChildAt() 方法从缓存数组中访问子项,而 getChildByName() 方法则必须遍历链接的列表来访问子项。
  3784. * @param name 要返回的子项的名称。
  3785. * @returns 具有指定名称的子显示对象。
  3786. * @see #getChildAt()
  3787. * @see egret.DisplayObject#name
  3788. * @version Egret 2.4
  3789. * @platform Web,Native
  3790. */
  3791. DisplayObjectContainer.prototype.getChildByName = function (name) {
  3792. var children = this.$children;
  3793. var length = children.length;
  3794. var displayObject;
  3795. for (var i = 0; i < length; i++) {
  3796. displayObject = children[i];
  3797. if (displayObject.name == name) {
  3798. return displayObject;
  3799. }
  3800. }
  3801. return null;
  3802. };
  3803. /**
  3804. * @language en_US
  3805. * Removes the specified child DisplayObject instance from the child list of the DisplayObjectContainer instance.
  3806. * The parent property of the removed child is set to null , and the object is garbage collected if no other references
  3807. * to the child exist. The index positions of any display objects above the child in the DisplayObjectContainer are
  3808. * decreased by 1.
  3809. * @param child The DisplayObject instance to remove.
  3810. * @returns The DisplayObject instance that you pass in the child parameter.
  3811. * @see #removeChildAt()
  3812. * @version Egret 2.4
  3813. * @platform Web,Native
  3814. */
  3815. /**
  3816. * @language zh_CN
  3817. * 从 DisplayObjectContainer 实例的子列表中删除指定的 child DisplayObject 实例。将已删除子项的 parent 属性设置为 null;
  3818. * 如果不存在对该子项的任何其它引用,则将该对象作为垃圾回收。DisplayObjectContainer 中该子项之上的任何显示对象的索引位置都减去 1。
  3819. * @param child 要删除的 DisplayObject 实例。
  3820. * @returns 在 child 参数中传递的 DisplayObject 实例。
  3821. * @see #removeChildAt()
  3822. * @version Egret 2.4
  3823. * @platform Web,Native
  3824. */
  3825. DisplayObjectContainer.prototype.removeChild = function (child) {
  3826. var index = this.$children.indexOf(child);
  3827. if (index >= 0) {
  3828. return this.$doRemoveChild(index);
  3829. }
  3830. else {
  3831. true && egret.$error(1006);
  3832. return null;
  3833. }
  3834. };
  3835. /**
  3836. * @language en_US
  3837. * Removes a child DisplayObject from the specified index position in the child list of the DisplayObjectContainer.
  3838. * The parent property of the removed child is set to null, and the object is garbage collected if no other references
  3839. * to the child exist. The index positions of any display objects above the child in the DisplayObjectContainer are decreased by 1.
  3840. * @param index The child index of the DisplayObject to remove.
  3841. * @returns The DisplayObject instance that was removed.
  3842. * @see #removeChild()
  3843. * @version Egret 2.4
  3844. * @platform Web,Native
  3845. */
  3846. /**
  3847. * @language zh_CN
  3848. * 从 DisplayObjectContainer 的子列表中指定的 index 位置删除子 DisplayObject。将已删除子项的 parent 属性设置为 null;
  3849. * 如果没有对该子项的任何其他引用,则将该对象作为垃圾回收。DisplayObjectContainer 中该子项之上的任何显示对象的索引位置都减去 1。
  3850. * @param index 要删除的 DisplayObject 的子索引。
  3851. * @returns 已删除的 DisplayObject 实例。
  3852. * @see #removeChild()
  3853. * @version Egret 2.4
  3854. * @platform Web,Native
  3855. */
  3856. DisplayObjectContainer.prototype.removeChildAt = function (index) {
  3857. index = +index | 0;
  3858. if (index >= 0 && index < this.$children.length) {
  3859. return this.$doRemoveChild(index);
  3860. }
  3861. else {
  3862. true && egret.$error(1007);
  3863. return null;
  3864. }
  3865. };
  3866. /**
  3867. * @private
  3868. */
  3869. DisplayObjectContainer.prototype.$doRemoveChild = function (index, notifyListeners) {
  3870. if (notifyListeners === void 0) { notifyListeners = true; }
  3871. index = +index | 0;
  3872. var children = this.$children;
  3873. var child = children[index];
  3874. this.$childRemoved(child, index);
  3875. if (notifyListeners) {
  3876. child.dispatchEventWith(egret.Event.REMOVED, true);
  3877. }
  3878. if (this.$stage) {
  3879. child.$onRemoveFromStage();
  3880. var list = DisplayObjectContainer.$EVENT_REMOVE_FROM_STAGE_LIST;
  3881. while (list.length > 0) {
  3882. var childAddToStage = list.shift();
  3883. if (notifyListeners && childAddToStage.$hasAddToStage) {
  3884. childAddToStage.$hasAddToStage = false;
  3885. childAddToStage.dispatchEventWith(egret.Event.REMOVED_FROM_STAGE);
  3886. }
  3887. childAddToStage.$hasAddToStage = false;
  3888. childAddToStage.$stage = null;
  3889. }
  3890. }
  3891. var displayList = this.$displayList || this.$parentDisplayList;
  3892. this.assignParentDisplayList(child, displayList, null);
  3893. child.$propagateFlagsDown(1648 /* DownOnAddedOrRemoved */, true);
  3894. child.$setParent(null);
  3895. var indexNow = children.indexOf(child);
  3896. if (indexNow != -1) {
  3897. children.splice(indexNow, 1);
  3898. }
  3899. this.$propagateFlagsUp(4 /* InvalidBounds */);
  3900. return child;
  3901. };
  3902. /**
  3903. * @language en_US
  3904. * Changes the position of an existing child in the display object container. This affects the layering of child objects.
  3905. * @param child The child DisplayObject instance for which you want to change the index number.
  3906. * @param index The resulting index number for the child display object.
  3907. * @see #addChildAt()
  3908. * @see #getChildAt()
  3909. * @version Egret 2.4
  3910. * @platform Web,Native
  3911. */
  3912. /**
  3913. * @language zh_CN
  3914. * 更改现有子项在显示对象容器中的位置。这会影响子对象的分层。
  3915. * @param child 要为其更改索引编号的 DisplayObject 子实例。
  3916. * @param index 生成的 child 显示对象的索引编号。当新的索引编号小于0或大于已有子元件数量时,新加入的DisplayObject对象将会放置于最上层。
  3917. * @see #addChildAt()
  3918. * @see #getChildAt()
  3919. * @version Egret 2.4
  3920. * @platform Web,Native
  3921. */
  3922. DisplayObjectContainer.prototype.setChildIndex = function (child, index) {
  3923. index = +index | 0;
  3924. if (index < 0 || index >= this.$children.length) {
  3925. index = this.$children.length - 1;
  3926. }
  3927. this.doSetChildIndex(child, index);
  3928. };
  3929. /**
  3930. * @private
  3931. */
  3932. DisplayObjectContainer.prototype.doSetChildIndex = function (child, index) {
  3933. var lastIndex = this.$children.indexOf(child);
  3934. if (lastIndex < 0) {
  3935. true && egret.$error(1006);
  3936. }
  3937. if (lastIndex == index) {
  3938. return;
  3939. }
  3940. this.$childRemoved(child, lastIndex);
  3941. //从原来的位置删除
  3942. this.$children.splice(lastIndex, 1);
  3943. //放到新的位置
  3944. this.$children.splice(index, 0, child);
  3945. this.$childAdded(child, index);
  3946. child.$invalidateTransform();
  3947. this.$propagateFlagsUp(4 /* InvalidBounds */);
  3948. };
  3949. /**
  3950. * @language en_US
  3951. * Swaps the z-order (front-to-back order) of the child objects at the two specified index positions in the child
  3952. * list. All other child objects in the display object container remain in the same index positions.
  3953. * @param index1 The index position of the first child object.
  3954. * @param index2 The index position of the second child object.
  3955. * @see #swapChildren()
  3956. * @version Egret 2.4
  3957. * @platform Web,Native
  3958. */
  3959. /**
  3960. * @language zh_CN
  3961. * 在子级列表中两个指定的索引位置,交换子对象的 Z 轴顺序(前后顺序)。显示对象容器中所有其他子对象的索引位置保持不变。
  3962. * @param index1 第一个子对象的索引位置。
  3963. * @param index2 第二个子对象的索引位置。
  3964. * @see #swapChildren()
  3965. * @version Egret 2.4
  3966. * @platform Web,Native
  3967. */
  3968. DisplayObjectContainer.prototype.swapChildrenAt = function (index1, index2) {
  3969. index1 = +index1 | 0;
  3970. index2 = +index2 | 0;
  3971. if (index1 >= 0 && index1 < this.$children.length && index2 >= 0 && index2 < this.$children.length) {
  3972. this.doSwapChildrenAt(index1, index2);
  3973. }
  3974. else {
  3975. true && egret.$error(1007);
  3976. }
  3977. };
  3978. /**
  3979. * @language en_US
  3980. * Swaps the z-order (front-to-back order) of the two specified child objects. All other child objects in the
  3981. * display object container remain in the same index positions.
  3982. * @param child1 The first child object.
  3983. * @param child2 The second child object.
  3984. * @see #swapChildrenAt()
  3985. * @version Egret 2.4
  3986. * @platform Web,Native
  3987. */
  3988. /**
  3989. * @language zh_CN
  3990. * 交换两个指定子对象的 Z 轴顺序(从前到后顺序)。显示对象容器中所有其他子对象的索引位置保持不变。
  3991. * @param child1 第一个子对象。
  3992. * @param child2 第二个子对象。
  3993. * @see #swapChildrenAt()
  3994. * @version Egret 2.4
  3995. * @platform Web,Native
  3996. */
  3997. DisplayObjectContainer.prototype.swapChildren = function (child1, child2) {
  3998. var index1 = this.$children.indexOf(child1);
  3999. var index2 = this.$children.indexOf(child2);
  4000. if (index1 == -1 || index2 == -1) {
  4001. true && egret.$error(1006);
  4002. }
  4003. else {
  4004. this.doSwapChildrenAt(index1, index2);
  4005. }
  4006. };
  4007. /**
  4008. * @private
  4009. */
  4010. DisplayObjectContainer.prototype.doSwapChildrenAt = function (index1, index2) {
  4011. if (index1 > index2) {
  4012. var temp = index2;
  4013. index2 = index1;
  4014. index1 = temp;
  4015. }
  4016. else if (index1 == index2) {
  4017. return;
  4018. }
  4019. var list = this.$children;
  4020. var child1 = list[index1];
  4021. var child2 = list[index2];
  4022. this.$childRemoved(child1, index1);
  4023. this.$childRemoved(child2, index2);
  4024. list[index1] = child2;
  4025. list[index2] = child1;
  4026. this.$childAdded(child2, index1);
  4027. this.$childAdded(child1, index2);
  4028. child1.$invalidateTransform();
  4029. child2.$invalidateTransform();
  4030. this.$propagateFlagsUp(4 /* InvalidBounds */);
  4031. };
  4032. /**
  4033. * @language en_US
  4034. * Removes all child DisplayObject instances from the child list of the DisplayObjectContainer instance. The parent
  4035. * property of the removed children is set to null , and the objects are garbage collected if no other references to the children exist.
  4036. * @see #removeChild()
  4037. * @see #removeChildAt()
  4038. * @version Egret 2.4
  4039. * @platform Web,Native
  4040. */
  4041. /**
  4042. * @language zh_CN
  4043. * 从 DisplayObjectContainer 实例的子级列表中删除所有 child DisplayObject 实例。
  4044. * @see #removeChild()
  4045. * @see #removeChildAt()
  4046. * @version Egret 2.4
  4047. * @platform Web,Native
  4048. */
  4049. DisplayObjectContainer.prototype.removeChildren = function () {
  4050. var children = this.$children;
  4051. for (var i = children.length - 1; i >= 0; i--) {
  4052. this.$doRemoveChild(i);
  4053. }
  4054. };
  4055. /**
  4056. * @private
  4057. * 一个子项被添加到容器内,此方法不仅在操作addChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。
  4058. * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。
  4059. */
  4060. DisplayObjectContainer.prototype.$childAdded = function (child, index) {
  4061. };
  4062. /**
  4063. * @private
  4064. * 一个子项从容器内移除,此方法不仅在操作removeChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。
  4065. * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。
  4066. */
  4067. DisplayObjectContainer.prototype.$childRemoved = function (child, index) {
  4068. };
  4069. /**
  4070. * @private
  4071. */
  4072. DisplayObjectContainer.prototype.$onAddToStage = function (stage, nestLevel) {
  4073. _super.prototype.$onAddToStage.call(this, stage, nestLevel);
  4074. var children = this.$children;
  4075. var length = children.length;
  4076. nestLevel++;
  4077. for (var i = 0; i < length; i++) {
  4078. var child = this.$children[i];
  4079. child.$onAddToStage(stage, nestLevel);
  4080. }
  4081. };
  4082. /**
  4083. * @private
  4084. *
  4085. */
  4086. DisplayObjectContainer.prototype.$onRemoveFromStage = function () {
  4087. _super.prototype.$onRemoveFromStage.call(this);
  4088. var children = this.$children;
  4089. var length = children.length;
  4090. for (var i = 0; i < length; i++) {
  4091. var child = children[i];
  4092. child.$onRemoveFromStage();
  4093. }
  4094. };
  4095. /**
  4096. * @private
  4097. */
  4098. DisplayObjectContainer.prototype.$measureChildBounds = function (bounds) {
  4099. var children = this.$children;
  4100. var length = children.length;
  4101. if (length == 0) {
  4102. return;
  4103. }
  4104. var xMin = 0, xMax = 0, yMin = 0, yMax = 0;
  4105. var found = false;
  4106. for (var i = -1; i < length; i++) {
  4107. var childBounds = i == -1 ? bounds : children[i].$getTransformedBounds(this, egret.$TempRectangle);
  4108. if (childBounds.isEmpty()) {
  4109. continue;
  4110. }
  4111. if (found) {
  4112. xMin = Math.min(xMin, childBounds.x);
  4113. xMax = Math.max(xMax, childBounds.x + childBounds.width);
  4114. yMin = Math.min(yMin, childBounds.y);
  4115. yMax = Math.max(yMax, childBounds.y + childBounds.height);
  4116. }
  4117. else {
  4118. found = true;
  4119. xMin = childBounds.x;
  4120. xMax = xMin + childBounds.width;
  4121. yMin = childBounds.y;
  4122. yMax = yMin + childBounds.height;
  4123. }
  4124. }
  4125. bounds.setTo(xMin, yMin, xMax - xMin, yMax - yMin);
  4126. };
  4127. Object.defineProperty(DisplayObjectContainer.prototype, "touchChildren", {
  4128. /**
  4129. * @language en_US
  4130. * Determines whether or not the children of the object are touch, or user input device, enabled. If an object is
  4131. * enabled, a user can interact with it by using a touch or user input device.
  4132. * @default true
  4133. * @version Egret 2.4
  4134. * @platform Web,Native
  4135. */
  4136. /**
  4137. * @language zh_CN
  4138. * 确定对象的子级是否支持触摸或用户输入设备。如果对象支持触摸或用户输入设备,用户可以通过使用触摸或用户输入设备与之交互。
  4139. * @default true
  4140. * @version Egret 2.4
  4141. * @platform Web,Native
  4142. */
  4143. get: function () {
  4144. return this.$getTouchChildren();
  4145. },
  4146. set: function (value) {
  4147. this.$setTouchChildren(!!value);
  4148. },
  4149. enumerable: true,
  4150. configurable: true
  4151. });
  4152. /**
  4153. * @private
  4154. *
  4155. * @returns
  4156. */
  4157. DisplayObjectContainer.prototype.$getTouchChildren = function () {
  4158. return this.$touchChildren;
  4159. };
  4160. /**
  4161. * @private
  4162. */
  4163. DisplayObjectContainer.prototype.$setTouchChildren = function (value) {
  4164. if (this.$touchChildren == value) {
  4165. return false;
  4166. }
  4167. this.$touchChildren = value;
  4168. return true;
  4169. };
  4170. /**
  4171. * @private
  4172. * 标记此显示对象需要重绘。此方法会触发自身的cacheAsBitmap重绘。如果只是矩阵改变,自身显示内容并不改变,应该调用$invalidateTransform().
  4173. * @param notiryChildren 是否标记子项也需要重绘。传入false或不传入,将只标记自身需要重绘。通常只有alpha属性改变会需要通知子项重绘。
  4174. */
  4175. DisplayObjectContainer.prototype.$invalidate = function (notifyChildren) {
  4176. _super.prototype.$invalidate.call(this, notifyChildren);
  4177. if (!notifyChildren) {
  4178. return;
  4179. }
  4180. var cacheRoot = this.$displayList || this.$parentDisplayList;
  4181. var children = this.$children;
  4182. if (children) {
  4183. for (var i = children.length - 1; i >= 0; i--) {
  4184. this.markChildDirty(children[i], cacheRoot);
  4185. }
  4186. }
  4187. };
  4188. /**
  4189. * @private
  4190. * 标记自身以及所有子项在父级中变换叠加的显示内容失效。此方法不会触发自身的cacheAsBitmap重绘。
  4191. * 通常用于矩阵改变或从显示列表添加和移除时。若自身的显示内容已经改变需要重绘,应该调用$invalidate()。
  4192. */
  4193. DisplayObjectContainer.prototype.$invalidateTransform = function () {
  4194. this.markChildDirty(this, this.$parentDisplayList);
  4195. };
  4196. /**
  4197. * @private
  4198. * 标记所有子项失效,若遇到cacheAsBitmap的节点,直接停止继续遍历其子项.
  4199. */
  4200. DisplayObjectContainer.prototype.markChildDirty = function (child, parentCache) {
  4201. if (child.$hasFlags(512 /* DirtyChildren */)) {
  4202. return;
  4203. }
  4204. child.$setFlags(512 /* DirtyChildren */);
  4205. var displayList = child.$displayList;
  4206. if ((displayList || child.$renderNode) && parentCache) {
  4207. parentCache.markDirty(displayList || child);
  4208. }
  4209. if (displayList) {
  4210. return;
  4211. }
  4212. var children = child.$children;
  4213. if (children) {
  4214. for (var i = children.length - 1; i >= 0; i--) {
  4215. this.markChildDirty(children[i], parentCache);
  4216. }
  4217. }
  4218. };
  4219. /**
  4220. * @private
  4221. */
  4222. DisplayObjectContainer.prototype.$cacheAsBitmapChanged = function () {
  4223. _super.prototype.$cacheAsBitmapChanged.call(this);
  4224. var cacheRoot = this.$displayList || this.$parentDisplayList;
  4225. var children = this.$children;
  4226. for (var i = children.length - 1; i >= 0; i--) {
  4227. this.assignParentDisplayList(children[i], cacheRoot, cacheRoot);
  4228. }
  4229. };
  4230. /**
  4231. * @private
  4232. */
  4233. DisplayObjectContainer.prototype.assignParentDisplayList = function (child, parentCache, newParent) {
  4234. child.$parentDisplayList = newParent;
  4235. child.$setFlags(512 /* DirtyChildren */);
  4236. var displayList = child.$displayList;
  4237. if ((child.$renderNode || displayList) && parentCache) {
  4238. parentCache.markDirty(displayList || child);
  4239. }
  4240. if (displayList) {
  4241. return;
  4242. }
  4243. var children = child.$children;
  4244. if (children) {
  4245. for (var i = children.length - 1; i >= 0; i--) {
  4246. this.assignParentDisplayList(children[i], parentCache, newParent);
  4247. }
  4248. }
  4249. };
  4250. /**
  4251. * @private
  4252. */
  4253. DisplayObjectContainer.prototype.$hitTest = function (stageX, stageY) {
  4254. if (!this.$visible) {
  4255. return null;
  4256. }
  4257. var m = this.$getInvertedConcatenatedMatrix();
  4258. var localX = m.a * stageX + m.c * stageY + m.tx;
  4259. var localY = m.b * stageX + m.d * stageY + m.ty;
  4260. var rect = this.$scrollRect ? this.$scrollRect : this.$maskRect;
  4261. if (rect && !rect.contains(localX, localY)) {
  4262. return null;
  4263. }
  4264. if (this.$mask && !this.$mask.$hitTest(stageX, stageY)) {
  4265. return null;
  4266. }
  4267. var children = this.$children;
  4268. var found = false;
  4269. var target = null;
  4270. for (var i = children.length - 1; i >= 0; i--) {
  4271. var child = children[i];
  4272. if (child.$maskedObject) {
  4273. continue;
  4274. }
  4275. target = child.$hitTest(stageX, stageY);
  4276. if (target) {
  4277. found = true;
  4278. if (target.$touchEnabled) {
  4279. break;
  4280. }
  4281. else {
  4282. target = null;
  4283. }
  4284. }
  4285. }
  4286. if (target) {
  4287. if (this.$touchChildren) {
  4288. return target;
  4289. }
  4290. return this;
  4291. }
  4292. if (found) {
  4293. return this;
  4294. }
  4295. return _super.prototype.$hitTest.call(this, stageX, stageY);
  4296. };
  4297. /**
  4298. * @private
  4299. * 子项有可能会被cache而导致标记失效。重写此方法,以便在赋值时对子项深度遍历标记脏区域
  4300. */
  4301. DisplayObjectContainer.prototype.$setAlpha = function (value) {
  4302. value = +value || 0;
  4303. if (value == this.$alpha) {
  4304. return false;
  4305. }
  4306. this.$alpha = value;
  4307. this.$propagateFlagsDown(64 /* InvalidConcatenatedAlpha */);
  4308. this.$invalidate();
  4309. this.$invalidateAllChildren();
  4310. return true;
  4311. };
  4312. /**
  4313. * @private
  4314. * 标记所有子项失效,与markChildDirty不同,此方法无视子项是否启用cacheAsBitmap,必须遍历完所有子项.通常只有alpha属性改变需要采用这种操作.
  4315. */
  4316. DisplayObjectContainer.prototype.$invalidateAllChildren = function () {
  4317. var children = this.$children;
  4318. if (children) {
  4319. for (var i = children.length - 1; i >= 0; i--) {
  4320. var child = children[i];
  4321. child.$invalidate();
  4322. if (child.$children) {
  4323. child.$invalidateAllChildren();
  4324. }
  4325. }
  4326. }
  4327. };
  4328. return DisplayObjectContainer;
  4329. }(egret.DisplayObject));
  4330. /**
  4331. * @private
  4332. */
  4333. DisplayObjectContainer.$EVENT_ADD_TO_STAGE_LIST = [];
  4334. /**
  4335. * @private
  4336. */
  4337. DisplayObjectContainer.$EVENT_REMOVE_FROM_STAGE_LIST = [];
  4338. egret.DisplayObjectContainer = DisplayObjectContainer;
  4339. __reflect(DisplayObjectContainer.prototype, "egret.DisplayObjectContainer");
  4340. if (true) {
  4341. egret.$markReadOnly(DisplayObjectContainer, "numChildren");
  4342. }
  4343. })(egret || (egret = {}));
  4344. //////////////////////////////////////////////////////////////////////////////////////
  4345. //
  4346. // Copyright (c) 2014-present, Egret Technology.
  4347. // All rights reserved.
  4348. // Redistribution and use in source and binary forms, with or without
  4349. // modification, are permitted provided that the following conditions are met:
  4350. //
  4351. // * Redistributions of source code must retain the above copyright
  4352. // notice, this list of conditions and the following disclaimer.
  4353. // * Redistributions in binary form must reproduce the above copyright
  4354. // notice, this list of conditions and the following disclaimer in the
  4355. // documentation and/or other materials provided with the distribution.
  4356. // * Neither the name of the Egret nor the
  4357. // names of its contributors may be used to endorse or promote products
  4358. // derived from this software without specific prior written permission.
  4359. //
  4360. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  4361. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  4362. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  4363. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  4364. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  4365. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  4366. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  4367. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  4368. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  4369. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4370. //
  4371. //////////////////////////////////////////////////////////////////////////////////////
  4372. var egret;
  4373. (function (egret) {
  4374. /**
  4375. * @private
  4376. * @version Egret 2.4
  4377. * @platform Web,Native
  4378. */
  4379. var Filter = (function (_super) {
  4380. __extends(Filter, _super);
  4381. function Filter() {
  4382. var _this = _super.apply(this, arguments) || this;
  4383. /**
  4384. * @version Egret 2.4
  4385. * @platform Web,Native
  4386. */
  4387. _this.type = null;
  4388. _this.$targets = [];
  4389. return _this;
  4390. }
  4391. Filter.prototype.$addTarget = function (target) {
  4392. var length = this.$targets.length;
  4393. for (var i = 0; i < length; i++) {
  4394. if (this.$targets[i].$hashCode == target.$hashCode) {
  4395. return;
  4396. }
  4397. }
  4398. this.$targets.push(target);
  4399. };
  4400. Filter.prototype.$removeTarget = function (target) {
  4401. var length = this.$targets.length;
  4402. for (var i = 0; i < length; i++) {
  4403. if (this.$targets[i].$hashCode == target.$hashCode) {
  4404. this.$targets.splice(i, 1);
  4405. return;
  4406. }
  4407. }
  4408. };
  4409. Filter.prototype.invalidate = function () {
  4410. var length = this.$targets.length;
  4411. for (var i = 0; i < length; i++) {
  4412. this.$targets[i].$invalidateContentBounds();
  4413. }
  4414. };
  4415. /**
  4416. * @private
  4417. */
  4418. Filter.prototype.$toJson = function () {
  4419. return '';
  4420. };
  4421. return Filter;
  4422. }(egret.HashObject));
  4423. egret.Filter = Filter;
  4424. __reflect(Filter.prototype, "egret.Filter");
  4425. })(egret || (egret = {}));
  4426. //////////////////////////////////////////////////////////////////////////////////////
  4427. //
  4428. // Copyright (c) 2014-present, Egret Technology.
  4429. // All rights reserved.
  4430. // Redistribution and use in source and binary forms, with or without
  4431. // modification, are permitted provided that the following conditions are met:
  4432. //
  4433. // * Redistributions of source code must retain the above copyright
  4434. // notice, this list of conditions and the following disclaimer.
  4435. // * Redistributions in binary form must reproduce the above copyright
  4436. // notice, this list of conditions and the following disclaimer in the
  4437. // documentation and/or other materials provided with the distribution.
  4438. // * Neither the name of the Egret nor the
  4439. // names of its contributors may be used to endorse or promote products
  4440. // derived from this software without specific prior written permission.
  4441. //
  4442. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  4443. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  4444. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  4445. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  4446. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  4447. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  4448. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  4449. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  4450. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  4451. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4452. //
  4453. //////////////////////////////////////////////////////////////////////////////////////
  4454. var egret;
  4455. (function (egret) {
  4456. /**
  4457. * @language en_US
  4458. * SpriteSheet is a mosaic of multiple sub-bitmaps, comprising a plurality of Texture objects.
  4459. * Each Texture object shares the set bitmap of SpriteSheet, but it points to its different areas.
  4460. * On WebGL / OpenGL, this operation can significantly improve performance.
  4461. * At the same time, SpriteSheet can carry out material integration easily to reduce the number of HTTP requests
  4462. * For specification of the SpriteSheet format, see the document https://github.com/egret-labs/egret-core/wiki/Egret-SpriteSheet-Specification
  4463. * @see http://edn.egret.com/cn/docs/page/135 The use of texture packs
  4464. * @version Egret 2.4
  4465. * @platform Web,Native
  4466. * @includeExample egret/display/SpriteSheet.ts
  4467. */
  4468. /**
  4469. * @language zh_CN
  4470. * SpriteSheet 是一张由多个子位图拼接而成的集合位图,它包含多个 Texture 对象。
  4471. * 每一个 Texture 都共享 SpriteSheet 的集合位图,但是指向它的不同的区域。
  4472. * 在WebGL / OpenGL上,这种做法可以显著提升性能
  4473. * 同时,SpriteSheet可以很方便的进行素材整合,降低HTTP请求数量
  4474. * SpriteSheet 格式的具体规范可以参见此文档 https://github.com/egret-labs/egret-core/wiki/Egret-SpriteSheet-Specification
  4475. * @see http://edn.egret.com/cn/docs/page/135 纹理集的使用
  4476. * @version Egret 2.4
  4477. * @platform Web,Native
  4478. * @includeExample egret/display/SpriteSheet.ts
  4479. */
  4480. var SpriteSheet = (function (_super) {
  4481. __extends(SpriteSheet, _super);
  4482. /**
  4483. * @language en_US
  4484. * Create an egret.SpriteSheet object
  4485. * @param texture {Texture} Texture
  4486. * @version Egret 2.4
  4487. * @platform Web,Native
  4488. */
  4489. /**
  4490. * @language zh_CN
  4491. * 创建一个 egret.SpriteSheet 对象
  4492. * @param texture {Texture} 纹理
  4493. * @version Egret 2.4
  4494. * @platform Web,Native
  4495. */
  4496. function SpriteSheet(texture) {
  4497. var _this = _super.call(this) || this;
  4498. /**
  4499. * @private
  4500. * 表示这个SpriteSheet的位图区域在bitmapData上的起始位置x。
  4501. */
  4502. _this._bitmapX = 0;
  4503. /**
  4504. * @private
  4505. * 表示这个SpriteSheet的位图区域在bitmapData上的起始位置y。
  4506. */
  4507. _this._bitmapY = 0;
  4508. /**
  4509. * @private
  4510. * 纹理缓存字典
  4511. */
  4512. _this._textureMap = egret.createMap();
  4513. _this.$texture = texture;
  4514. _this._bitmapX = texture._bitmapX - texture._offsetX;
  4515. _this._bitmapY = texture._bitmapY - texture._offsetY;
  4516. return _this;
  4517. }
  4518. /**
  4519. * @language en_US
  4520. * Obtain a cached Texture object according to the specified texture name
  4521. * @param name {string} Cache the name of this Texture object
  4522. * @returns {egret.Texture} The Texture object
  4523. * @version Egret 2.4
  4524. * @platform Web,Native
  4525. */
  4526. /**
  4527. * @language zh_CN
  4528. * 根据指定纹理名称获取一个缓存的 Texture 对象
  4529. * @param name {string} 缓存这个 Texture 对象所使用的名称
  4530. * @returns {egret.Texture} Texture 对象
  4531. * @version Egret 2.4
  4532. * @platform Web,Native
  4533. */
  4534. SpriteSheet.prototype.getTexture = function (name) {
  4535. return this._textureMap[name];
  4536. };
  4537. /**
  4538. * @language en_US
  4539. * Create a new Texture object for the specified area on SpriteSheet and cache it
  4540. * @param name {string} Cache the name of this Texture object. If the name already exists, the previous Texture object will be overwrited.
  4541. * @param bitmapX {number} Starting coordinate x of texture area on bitmapData
  4542. * @param bitmapY {number} Starting coordinate y of texture area on bitmapData
  4543. * @param bitmapWidth {number} Width of texture area on bitmapData
  4544. * @param bitmapHeight {number} Height of texture area on bitmapData
  4545. * @param offsetX {number} Starting point x for a non-transparent area of the original bitmap
  4546. * @param offsetY {number} Starting point y for a non-transparent area of the original bitmap
  4547. * @param textureWidth {number} Width of the original bitmap. If it is not passed, use the bitmapWidth value.
  4548. * @param textureHeight {number} Height of the original bitmap. If it is not passed, use the bitmapHeight value.
  4549. * @returns {egret.Texture} The created Texture object
  4550. * @version Egret 2.4
  4551. * @platform Web,Native
  4552. */
  4553. /**
  4554. * @language zh_CN
  4555. * 为 SpriteSheet 上的指定区域创建一个新的 Texture 对象并缓存它
  4556. * @param name {string} 缓存这个 Texture 对象所使用的名称,如果名称已存在,将会覆盖之前的 Texture 对象
  4557. * @param bitmapX {number} 纹理区域在 bitmapData 上的起始坐标x
  4558. * @param bitmapY {number} 纹理区域在 bitmapData 上的起始坐标y
  4559. * @param bitmapWidth {number} 纹理区域在 bitmapData 上的宽度
  4560. * @param bitmapHeight {number} 纹理区域在 bitmapData 上的高度
  4561. * @param offsetX {number} 原始位图的非透明区域 x 起始点
  4562. * @param offsetY {number} 原始位图的非透明区域 y 起始点
  4563. * @param textureWidth {number} 原始位图的高度,若不传入,则使用 bitmapWidth 的值。
  4564. * @param textureHeight {number} 原始位图的宽度,若不传入,则使用 bitmapHeight 的值。
  4565. * @returns {egret.Texture} 创建的 Texture 对象
  4566. * @version Egret 2.4
  4567. * @platform Web,Native
  4568. */
  4569. SpriteSheet.prototype.createTexture = function (name, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight) {
  4570. if (offsetX === void 0) { offsetX = 0; }
  4571. if (offsetY === void 0) { offsetY = 0; }
  4572. if (textureWidth === void 0) {
  4573. textureWidth = offsetX + bitmapWidth;
  4574. }
  4575. if (textureHeight === void 0) {
  4576. textureHeight = offsetY + bitmapHeight;
  4577. }
  4578. var texture = new egret.Texture();
  4579. texture._bitmapData = this.$texture._bitmapData;
  4580. texture.$initData(this._bitmapX + bitmapX, this._bitmapY + bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, this.$texture._sourceWidth, this.$texture._sourceHeight);
  4581. this._textureMap[name] = texture;
  4582. return texture;
  4583. };
  4584. /**
  4585. * @language en_US
  4586. * dispose texture
  4587. * @version Egret 2.4
  4588. * @platform Web,Native
  4589. */
  4590. /**
  4591. * @language zh_CN
  4592. * 释放纹理
  4593. * @version Egret 2.4
  4594. * @platform Web,Native
  4595. */
  4596. SpriteSheet.prototype.dispose = function () {
  4597. if (this.$texture) {
  4598. this.$texture.dispose();
  4599. }
  4600. };
  4601. return SpriteSheet;
  4602. }(egret.HashObject));
  4603. egret.SpriteSheet = SpriteSheet;
  4604. __reflect(SpriteSheet.prototype, "egret.SpriteSheet");
  4605. })(egret || (egret = {}));
  4606. //////////////////////////////////////////////////////////////////////////////////////
  4607. //
  4608. // Copyright (c) 2014-present, Egret Technology.
  4609. // All rights reserved.
  4610. // Redistribution and use in source and binary forms, with or without
  4611. // modification, are permitted provided that the following conditions are met:
  4612. //
  4613. // * Redistributions of source code must retain the above copyright
  4614. // notice, this list of conditions and the following disclaimer.
  4615. // * Redistributions in binary form must reproduce the above copyright
  4616. // notice, this list of conditions and the following disclaimer in the
  4617. // documentation and/or other materials provided with the distribution.
  4618. // * Neither the name of the Egret nor the
  4619. // names of its contributors may be used to endorse or promote products
  4620. // derived from this software without specific prior written permission.
  4621. //
  4622. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  4623. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  4624. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  4625. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  4626. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  4627. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  4628. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  4629. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  4630. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  4631. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4632. //
  4633. //////////////////////////////////////////////////////////////////////////////////////
  4634. var egret;
  4635. (function (egret) {
  4636. /**
  4637. * @language en_US
  4638. * The Event class is used as the base class for the creation of Event objects, which are passed as parameters to event
  4639. * listeners when an event occurs.The properties of the Event class carry basic information about an event, such as
  4640. * the event's type or whether the event's default behavior can be canceled. For many events, such as the events represented
  4641. * by the Event class constants, this basic information is sufficient. Other events, however, may require more detailed
  4642. * information. Events associated with a touch tap, for example, need to include additional information about the
  4643. * location of the touch event. You can pass such additional information to event listeners by extending the Event class,
  4644. * which is what the TouchEvent class does. Egret API defines several Event subclasses for common events that require
  4645. * additional information. Events associated with each of the Event subclasses are described in the documentation for
  4646. * each class.The methods of the Event class can be used in event listener functions to affect the behavior of the event
  4647. * object. Some events have an associated default behavior. Your event listener can cancel this behavior by calling the
  4648. * preventDefault() method. You can also make the current event listener the last one to process an event by calling
  4649. * the stopPropagation() or stopImmediatePropagation() method.
  4650. * @see egret.EventDispatcher
  4651. * @version Egret 2.4
  4652. * @platform Web,Native
  4653. * @includeExample egret/events/Event.ts
  4654. * @see http://edn.egret.com/cn/docs/page/798 取消触摸事件
  4655. */
  4656. /**
  4657. * @language zh_CN
  4658. * Event 类作为创建事件实例的基类,当发生事件时,Event 实例将作为参数传递给事件侦听器。Event 类的属性包含有关事件的基本信息,例如事件
  4659. * 的类型或者是否可以取消事件的默认行为。对于许多事件(如由 Event 类常量表示的事件),此基本信息就足够了。但其他事件可能需要更详细的信息。
  4660. * 例如,与触摸关联的事件需要包括有关触摸事件的位置信息。您可以通过扩展 Event 类(TouchEvent 类执行的操作)将此类其他信息传递给事件侦听器。
  4661. * Egret API 为需要其他信息的常见事件定义多个 Event 子类。与每个 Event 子类关联的事件将在每个类的文档中加以介绍。Event 类的方法可以在
  4662. * 事件侦听器函数中使用以影响事件对象的行为。某些事件有关联的默认行为,通过调用 preventDefault() 方法,您的事件侦听器可以取消此行为。
  4663. * 可以通过调用 stopPropagation() 或 stopImmediatePropagation() 方法,将当前事件侦听器作为处理事件的最后一个事件侦听器。
  4664. * @see egret.EventDispatcher
  4665. * @version Egret 2.4
  4666. * @platform Web,Native
  4667. * @includeExample egret/events/Event.ts
  4668. * @see http://edn.egret.com/cn/docs/page/798 取消触摸事件
  4669. */
  4670. var Event = (function (_super) {
  4671. __extends(Event, _super);
  4672. /**
  4673. * @language en_US
  4674. * Creates an Event object to pass as a parameter to event listeners.
  4675. * @param type The type of the event, accessible as Event.type.
  4676. * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false.
  4677. * @param cancelable Determines whether the Event object can be canceled. The default values is false.
  4678. * @param data the optional data associated with this event
  4679. * @version Egret 2.4
  4680. * @platform Web,Native
  4681. */
  4682. /**
  4683. * @language zh_CN
  4684. * 创建一个作为参数传递给事件侦听器的 Event 对象。
  4685. * @param type 事件的类型,可以作为 Event.type 访问。
  4686. * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。
  4687. * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。
  4688. * @param data 与此事件对象关联的可选数据。
  4689. * @version Egret 2.4
  4690. * @platform Web,Native
  4691. */
  4692. function Event(type, bubbles, cancelable, data) {
  4693. var _this = _super.call(this) || this;
  4694. /**
  4695. * @private
  4696. */
  4697. _this.$eventPhase = 2;
  4698. /**
  4699. * @private
  4700. */
  4701. _this.$currentTarget = null;
  4702. /**
  4703. * @private
  4704. */
  4705. _this.$target = null;
  4706. /**
  4707. * @private
  4708. */
  4709. _this.$isDefaultPrevented = false;
  4710. /**
  4711. * @private
  4712. */
  4713. _this.$isPropagationStopped = false;
  4714. /**
  4715. * @private
  4716. */
  4717. _this.$isPropagationImmediateStopped = false;
  4718. _this.$type = type;
  4719. _this.$bubbles = !!bubbles;
  4720. _this.$cancelable = !!cancelable;
  4721. _this.data = data;
  4722. return _this;
  4723. }
  4724. Object.defineProperty(Event.prototype, "type", {
  4725. /**
  4726. * @language en_US
  4727. * The type of event. The type is case-sensitive.
  4728. * @version Egret 2.4
  4729. * @platform Web,Native
  4730. */
  4731. /**
  4732. * @language zh_CN
  4733. * 事件的类型。类型区分大小写。
  4734. * @version Egret 2.4
  4735. * @platform Web,Native
  4736. */
  4737. get: function () {
  4738. return this.$type;
  4739. },
  4740. enumerable: true,
  4741. configurable: true
  4742. });
  4743. Object.defineProperty(Event.prototype, "bubbles", {
  4744. /**
  4745. * @language en_US
  4746. * Indicates whether an event is a bubbling event.
  4747. * @version Egret 2.4
  4748. * @platform Web,Native
  4749. */
  4750. /**
  4751. * @language zh_CN
  4752. * 表示事件是否为冒泡事件。如果事件可以冒泡,则此值为 true;否则为 false。
  4753. * @version Egret 2.4
  4754. * @platform Web,Native
  4755. */
  4756. get: function () {
  4757. return this.$bubbles;
  4758. },
  4759. enumerable: true,
  4760. configurable: true
  4761. });
  4762. Object.defineProperty(Event.prototype, "cancelable", {
  4763. /**
  4764. * @language en_US
  4765. * Indicates whether the behavior associated with the event can be prevented. If the behavior can be
  4766. * canceled, this value is true; otherwise it is false.
  4767. * @see #preventDefault()
  4768. * @version Egret 2.4
  4769. * @platform Web,Native
  4770. */
  4771. /**
  4772. * @language zh_CN
  4773. * 表示是否可以阻止与事件相关联的行为。如果可以取消该行为,则此值为 true;否则为 false。
  4774. * @see #preventDefault()
  4775. * @version Egret 2.4
  4776. * @platform Web,Native
  4777. */
  4778. get: function () {
  4779. return this.$cancelable;
  4780. },
  4781. enumerable: true,
  4782. configurable: true
  4783. });
  4784. Object.defineProperty(Event.prototype, "eventPhase", {
  4785. /**
  4786. * @language en_US
  4787. * The current phase in the event flow. This property can contain the following numeric values:
  4788. * The capture phase (EventPhase.CAPTURING_PHASE).
  4789. * The target phase (EventPhase.AT_TARGET)
  4790. * The bubbling phase (EventPhase.BUBBLING_PHASE).
  4791. * @see egret.EventPhase
  4792. * @version Egret 2.4
  4793. * @platform Web,Native
  4794. */
  4795. /**
  4796. * @language zh_CN
  4797. * 事件流中的当前阶段。此属性可以包含以下数值:
  4798. * 捕获阶段 (EventPhase.CAPTURING_PHASE)。
  4799. * 目标阶段 (EventPhase.AT_TARGET)。
  4800. * 冒泡阶段 (EventPhase.BUBBLING_PHASE)。
  4801. * @see egret.EventPhase
  4802. * @version Egret 2.4
  4803. * @platform Web,Native
  4804. */
  4805. get: function () {
  4806. return this.$eventPhase;
  4807. },
  4808. enumerable: true,
  4809. configurable: true
  4810. });
  4811. Object.defineProperty(Event.prototype, "currentTarget", {
  4812. /**
  4813. * @language en_US
  4814. * The object that is actively processing the Event object with an event listener. For example, if a
  4815. * user clicks an OK button, the current target could be the node containing that button or one of its ancestors
  4816. * that has registered an event listener for that event.
  4817. * @version Egret 2.4
  4818. * @platform Web,Native
  4819. */
  4820. /**
  4821. * @language zh_CN
  4822. * 当前正在使用某个事件侦听器处理 Event 对象的对象。例如,如果用户单击“确定”按钮,
  4823. * 则当前目标可以是包含该按钮的节点,也可以是它的已为该事件注册了事件侦听器的始祖之一。
  4824. * @version Egret 2.4
  4825. * @platform Web,Native
  4826. */
  4827. get: function () {
  4828. return this.$currentTarget;
  4829. },
  4830. enumerable: true,
  4831. configurable: true
  4832. });
  4833. Object.defineProperty(Event.prototype, "target", {
  4834. /**
  4835. * @language en_US
  4836. * The event target. This property contains the target node. For example, if a user clicks an OK button,
  4837. * the target node is the display list node containing that button.
  4838. * @version Egret 2.4
  4839. * @platform Web,Native
  4840. */
  4841. /**
  4842. * @language zh_CN
  4843. * 事件目标。此属性包含目标节点。例如,如果用户单击“确定”按钮,则目标节点就是包含该按钮的显示列表节点。
  4844. * @version Egret 2.4
  4845. * @platform Web,Native
  4846. */
  4847. get: function () {
  4848. return this.$target;
  4849. },
  4850. enumerable: true,
  4851. configurable: true
  4852. });
  4853. Event.prototype.$setTarget = function (target) {
  4854. this.$target = target;
  4855. return true;
  4856. };
  4857. /**
  4858. * @language en_US
  4859. * Checks whether the preventDefault() method has been called on the event. If the preventDefault() method has been
  4860. * called, returns true; otherwise, returns false.
  4861. * @returns If preventDefault() has been called, returns true; otherwise, returns false.
  4862. * @see #preventDefault()
  4863. * @version Egret 2.4
  4864. * @platform Web,Native
  4865. */
  4866. /**
  4867. * @language zh_CN
  4868. * 检查是否已对事件调用 preventDefault() 方法。
  4869. * @returns 如果已调用 preventDefault() 方法,则返回 true;否则返回 false。
  4870. * @see #preventDefault()
  4871. * @version Egret 2.4
  4872. * @platform Web,Native
  4873. */
  4874. Event.prototype.isDefaultPrevented = function () {
  4875. return this.$isDefaultPrevented;
  4876. };
  4877. /**
  4878. * @language en_US
  4879. * Cancels an event's default behavior if that behavior can be canceled.Many events have associated behaviors that
  4880. * are carried out by default. For example, if a user types a character into a text input, the default behavior
  4881. * is that the character is displayed in the text input. Because the TextEvent.TEXT_INPUT event's default behavior
  4882. * can be canceled, you can use the preventDefault() method to prevent the character from appearing.
  4883. * You can use the Event.cancelable property to check whether you can prevent the default behavior associated with
  4884. * a particular event. If the value of Event.cancelable is true, then preventDefault() can be used to cancel the event;
  4885. * otherwise, preventDefault() has no effect.
  4886. * @see #cancelable
  4887. * @see #isDefaultPrevented
  4888. * @version Egret 2.4
  4889. * @platform Web,Native
  4890. */
  4891. /**
  4892. * @language zh_CN
  4893. * 如果可以取消事件的默认行为,则取消该行为。
  4894. * 许多事件都有默认执行的关联行为。例如,如果用户在文本字段中键入一个字符,则默认行为就是在文本字段中显示该字符。
  4895. * 由于可以取消 TextEvent.TEXT_INPUT 事件的默认行为,因此您可以使用 preventDefault() 方法来防止显示该字符。
  4896. * 您可以使用 Event.cancelable 属性来检查是否可以防止与特定事件关联的默认行为。如果 Event.cancelable 的值为 true,
  4897. * 则可以使用 preventDefault() 来取消事件;否则,preventDefault() 无效。
  4898. * @see #cancelable
  4899. * @see #isDefaultPrevented
  4900. * @version Egret 2.4
  4901. * @platform Web,Native
  4902. */
  4903. Event.prototype.preventDefault = function () {
  4904. if (this.$cancelable)
  4905. this.$isDefaultPrevented = true;
  4906. };
  4907. /**
  4908. * @language en_US
  4909. * Prevents processing of any event listeners in nodes subsequent to the current node in the event flow. This method
  4910. * does not affect any event listeners in the current node (currentTarget). In contrast, the stopImmediatePropagation()
  4911. * method prevents processing of event listeners in both the current node and subsequent nodes. Additional calls to this
  4912. * method have no effect. This method can be called in any phase of the event flow.<br/>
  4913. * Note: This method does not cancel the behavior associated with this event; see preventDefault() for that functionality.
  4914. * @see #stopImmediatePropagation()
  4915. * @see #preventDefault()
  4916. * @version Egret 2.4
  4917. * @platform Web,Native
  4918. */
  4919. /**
  4920. * @language zh_CN
  4921. * 防止对事件流中当前节点的后续节点中的所有事件侦听器进行处理。此方法不会影响当前节点 currentTarget 中的任何事件侦听器。
  4922. * 相比之下,stopImmediatePropagation() 方法可以防止对当前节点中和后续节点中的事件侦听器进行处理。
  4923. * 对此方法的其它调用没有任何效果。可以在事件流的任何阶段中调用此方法。<br/>
  4924. * 注意:此方法不会取消与此事件相关联的行为;有关此功能的信息,请参阅 preventDefault()。
  4925. * @see #stopImmediatePropagation()
  4926. * @see #preventDefault()
  4927. * @version Egret 2.4
  4928. * @platform Web,Native
  4929. */
  4930. Event.prototype.stopPropagation = function () {
  4931. if (this.$bubbles)
  4932. this.$isPropagationStopped = true;
  4933. };
  4934. /**
  4935. * @language en_US
  4936. * Prevents processing of any event listeners in the current node and any subsequent nodes in the event flow.
  4937. * This method takes effect immediately, and it affects event listeners in the current node. In contrast, the
  4938. * stopPropagation() method doesn't take effect until all the event listeners in the current node finish processing.<br/>
  4939. * Note: This method does not cancel the behavior associated with this event; see preventDefault() for that functionality.
  4940. * @see #stopPropagation()
  4941. * @see #preventDefault()
  4942. * @version Egret 2.4
  4943. * @platform Web,Native
  4944. */
  4945. /**
  4946. * @language zh_CN
  4947. * 防止对事件流中当前节点中和所有后续节点中的事件侦听器进行处理。此方法会立即生效,并且会影响当前节点中的事件侦听器。
  4948. * 相比之下,在当前节点中的所有事件侦听器都完成处理之前,stopPropagation() 方法不会生效。<br/>
  4949. * 注意:此方法不会取消与此事件相关联的行为;有关此功能的信息,请参阅 preventDefault()。
  4950. * @see #stopPropagation()
  4951. * @see #preventDefault()
  4952. * @version Egret 2.4
  4953. * @platform Web,Native
  4954. */
  4955. Event.prototype.stopImmediatePropagation = function () {
  4956. if (this.$bubbles)
  4957. this.$isPropagationImmediateStopped = true;
  4958. };
  4959. /**
  4960. * @language en_US
  4961. * This method will be called automatically when you pass the event object as the parameters to the Event.release() method.
  4962. * If your custom event is designed for reusable,you should override this method to make sure all the references to external
  4963. * objects are cleaned. if not,it may cause memory leaking.
  4964. * @see egret.Event.create()
  4965. * @see egret.Event.release()
  4966. * @version Egret 2.4
  4967. * @platform Web,Native
  4968. */
  4969. /**
  4970. * @language zh_CN
  4971. * 当事件实例传递给Event.release()静态方法时,实例上的clean()方法将会被自动调用。
  4972. * 若此自定义事件的实例设计为可以循环复用的,为了避免引起内存泄露,自定义事件需要覆盖此方法来确保实例被缓存前断开对外部对象的一切引用。
  4973. * @see egret.Event.create()
  4974. * @see egret.Event.release()
  4975. * @version Egret 2.4
  4976. * @platform Web,Native
  4977. */
  4978. Event.prototype.clean = function () {
  4979. this.data = this.$currentTarget = null;
  4980. this.$setTarget(null);
  4981. };
  4982. /**
  4983. * @language en_US
  4984. * EventDispatcher object using the specified event object thrown Event. Objects thrown objects will be cached in the pool for the next round robin.
  4985. * @param target the event target
  4986. * @param type The type of the event. Event listeners can access this information through the inherited type property.
  4987. * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through
  4988. * the inherited bubbles property.
  4989. * @param data {any} data
  4990. * @method egret.Event.dispatchEvent
  4991. * @version Egret 2.4
  4992. * @platform Web,Native
  4993. */
  4994. /**
  4995. * @language zh_CN
  4996. * 使用指定的 EventDispatcher 对象来抛出 Event 事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。
  4997. * @param target {egret.IEventDispatcher} 派发事件目标
  4998. * @param type {string} 事件类型
  4999. * @param bubbles {boolean} 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。
  5000. * @param data {any} 事件data
  5001. * @method egret.Event.dispatchEvent
  5002. * @version Egret 2.4
  5003. * @platform Web,Native
  5004. */
  5005. Event.dispatchEvent = function (target, type, bubbles, data) {
  5006. if (bubbles === void 0) { bubbles = false; }
  5007. var event = Event.create(Event, type, bubbles);
  5008. var props = Event._getPropertyData(Event);
  5009. if (data != undefined) {
  5010. props.data = data;
  5011. }
  5012. var result = target.dispatchEvent(event);
  5013. Event.release(event);
  5014. return result;
  5015. };
  5016. /**
  5017. * @private
  5018. *
  5019. * @param EventClass
  5020. * @returns
  5021. */
  5022. Event._getPropertyData = function (EventClass) {
  5023. var props = EventClass._props;
  5024. if (!props)
  5025. props = EventClass._props = {};
  5026. return props;
  5027. };
  5028. /**
  5029. * @language en_US
  5030. * Gets one event instance from the object pool or create a new one. We highly recommend using the Event.create()
  5031. * and Event.release() methods to create and release an event object,it can reduce the number of reallocate objects,
  5032. * which allows you to get better code execution performance.<br/>
  5033. * Note: If you want to use this method to initialize your custom event object,you must make sure the constructor
  5034. * of your custom event is the same as the constructor of egret.Event.
  5035. * @param EventClass Event Class。
  5036. * @param type The type of the event, accessible as Event.type.
  5037. * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false.
  5038. * @param cancelable Determines whether the Event object can be canceled. The default values is false.
  5039. * @example
  5040. * <pre>
  5041. * let event = Event.create(Event,type, bubbles);
  5042. * event.data = data; //optional,initializes custom data here
  5043. * this.dispatchEvent(event);
  5044. * Event.release(event);
  5045. * </pre>
  5046. * @version Egret 2.4
  5047. * @platform Web,Native
  5048. */
  5049. /**
  5050. * @language zh_CN
  5051. * 从对象池中取出或创建一个新的事件实例。我们建议您尽可能使用Event.create()和Event.release() 这一对方法来创建和释放事件对象,
  5052. * 这一对方法会将事件实例在内部缓存下来供下次循环使用,减少对象的创建次数,从而获得更高的代码运行性能。<br/>
  5053. * 注意:若使用此方法来创建自定义事件的实例,自定义的构造函数参数列表必须跟Event类一致。
  5054. * @param EventClass Event类名。
  5055. * @param type 事件的类型,可以作为 Event.type 访问。
  5056. * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。
  5057. * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。
  5058. * @example
  5059. * <pre>
  5060. * let event = Event.create(Event,type, bubbles);
  5061. * event.data = data; //可选,若指定义事件上需要附加其他参数,可以在获取实例后在此处设置。
  5062. * this.dispatchEvent(event);
  5063. * Event.release(event);
  5064. * </pre>
  5065. * @see #clean()
  5066. * @version Egret 2.4
  5067. * @platform Web,Native
  5068. */
  5069. Event.create = function (EventClass, type, bubbles, cancelable) {
  5070. var eventPool = EventClass.eventPool;
  5071. if (!eventPool) {
  5072. eventPool = EventClass.eventPool = [];
  5073. }
  5074. if (eventPool.length) {
  5075. var event_2 = eventPool.pop();
  5076. event_2.$type = type;
  5077. event_2.$bubbles = !!bubbles;
  5078. event_2.$cancelable = !!cancelable;
  5079. event_2.$isDefaultPrevented = false;
  5080. event_2.$isPropagationStopped = false;
  5081. event_2.$isPropagationImmediateStopped = false;
  5082. event_2.$eventPhase = 2 /* AT_TARGET */;
  5083. return event_2;
  5084. }
  5085. return new EventClass(type, bubbles, cancelable);
  5086. };
  5087. /**
  5088. * @language en_US
  5089. * Releases an event object and cache it into the object pool.We highly recommend using the Event.create()
  5090. * and Event.release() methods to create and release an event object,it can reduce the number of reallocate objects,
  5091. * which allows you to get better code execution performance.<br/>
  5092. * Note: The parameters of this method only accepts an instance created by the Event.create() method.
  5093. * if not,it may throw an error.
  5094. * @example
  5095. * <pre>
  5096. * let event = Event.create(Event,type, bubbles);
  5097. * event.data = data; //optional,initializes custom data here
  5098. * this.dispatchEvent(event);
  5099. * Event.release(event);
  5100. * </pre>
  5101. * @see #clean()
  5102. * @version Egret 2.4
  5103. * @platform Web,Native
  5104. */
  5105. /**
  5106. * @language zh_CN
  5107. * 释放一个事件对象,并缓存到对象池。我们建议您尽可能使用Event.create()和Event.release() 这一对方法来创建和释放事件对象,
  5108. * 这一对方法会将事件实例在内部缓存下来供下次循环使用,减少对象的创建次数,从而获得更高的代码运行性能。<br/>
  5109. * 注意:此方法只能传入由Event.create()创建的事件实例,传入非法对象实例可能会导致报错。
  5110. * @example
  5111. * <pre>
  5112. * let event = Event.create(Event,type, bubbles);
  5113. * event.data = data; //可选,若指定义事件上需要附加其他参数,可以在获取实例后在此处设置。
  5114. * this.dispatchEvent(event);
  5115. * Event.release(event);
  5116. * </pre>
  5117. * @see #clean()
  5118. * @version Egret 2.4
  5119. * @platform Web,Native
  5120. */
  5121. Event.release = function (event) {
  5122. event.clean();
  5123. var EventClass = Object.getPrototypeOf(event).constructor;
  5124. EventClass.eventPool.push(event);
  5125. };
  5126. return Event;
  5127. }(egret.HashObject));
  5128. /**
  5129. * @language en_US
  5130. * Dispatched when a display object is added to the on stage display list, either directly or through the addition
  5131. * of a sub tree in which the display object is contained.
  5132. * @version Egret 2.4
  5133. * @platform Web,Native
  5134. */
  5135. /**
  5136. * @language zh_CN
  5137. * 在将显示对象直接添加到舞台显示列表或将包含显示对象的子树添加至舞台显示列表中时调度。
  5138. * @version Egret 2.4
  5139. * @platform Web,Native
  5140. */
  5141. Event.ADDED_TO_STAGE = "addedToStage";
  5142. /**
  5143. * @language en_US
  5144. * Dispatched when a display object is about to be removed from the display list, either directly or through the removal
  5145. * of a sub tree in which the display object is contained.
  5146. * @version Egret 2.4
  5147. * @platform Web,Native
  5148. */
  5149. /**
  5150. * @language zh_CN
  5151. * 在从显示列表中直接删除显示对象或删除包含显示对象的子树时调度。
  5152. * @version Egret 2.4
  5153. * @platform Web,Native
  5154. */
  5155. Event.REMOVED_FROM_STAGE = "removedFromStage";
  5156. /**
  5157. * @language en_US
  5158. * Dispatched when a display object is added to the display list.
  5159. * @version Egret 2.4
  5160. * @platform Web,Native
  5161. */
  5162. /**
  5163. * @language zh_CN
  5164. * 将显示对象添加到显示列表中时调度。
  5165. * @version Egret 2.4
  5166. * @platform Web,Native
  5167. */
  5168. Event.ADDED = "added";
  5169. /**
  5170. * @language en_US
  5171. * Dispatched when a display object is about to be removed from the display list.
  5172. * @version Egret 2.4
  5173. * @platform Web,Native
  5174. */
  5175. /**
  5176. * @language zh_CN
  5177. * 将要从显示列表中删除显示对象时调度。
  5178. * @version Egret 2.4
  5179. * @platform Web,Native
  5180. */
  5181. Event.REMOVED = "removed";
  5182. /**
  5183. * @language en_US
  5184. * [broadcast event] Dispatched when the playhead is entering a new frame.
  5185. * @version Egret 2.4
  5186. * @platform Web,Native
  5187. */
  5188. /**
  5189. * @language zh_CN
  5190. * [广播事件] 进入新的一帧,监听此事件将会在下一帧开始时触发一次回调。这是一个广播事件,可以在任何一个显示对象上监听,无论它是否在显示列表中。
  5191. * @version Egret 2.4
  5192. * @platform Web,Native
  5193. */
  5194. Event.ENTER_FRAME = "enterFrame";
  5195. /**
  5196. * @language en_US
  5197. * Dispatched when the display list is about to be updated and rendered.
  5198. * Note: Every time you want to receive a render event,you must call the stage.invalidate() method.
  5199. * @version Egret 2.4
  5200. * @platform Web,Native
  5201. */
  5202. /**
  5203. * @language zh_CN
  5204. * 渲染事件,监听此事件将会在本帧末即将开始渲染的前一刻触发回调,这是一个广播事件,可以在任何一个显示对象上监听,无论它是否在显示列表中。
  5205. * 注意:每次您希望 Egret 发送 Event.RENDER 事件时,都必须调用 stage.invalidate() 方法,由于每帧只会触发一次屏幕刷新,
  5206. * 若在 Event.RENDER 回调函数执行期间再次调用stage.invalidate(),将会被忽略。
  5207. * @version Egret 2.4
  5208. * @platform Web,Native
  5209. */
  5210. Event.RENDER = "render";
  5211. /**
  5212. * @language en_US
  5213. * Dispatched when the size of stage or UIComponent is changed.
  5214. * @version Egret 2.4
  5215. * @platform Web,Native
  5216. */
  5217. /**
  5218. * @language zh_CN
  5219. * 舞台尺寸或UI组件尺寸发生改变
  5220. * @version Egret 2.4
  5221. * @platform Web,Native
  5222. */
  5223. Event.RESIZE = "resize";
  5224. /**
  5225. * @language en_US
  5226. * Dispatched when the value or selection of a property is chaned.
  5227. * @version Egret 2.4
  5228. * @platform Web,Native
  5229. */
  5230. /**
  5231. * @language zh_CN
  5232. * 属性值或状态发生改变。通常是按钮的选中状态,或者列表的选中项索引改变。
  5233. * @version Egret 2.4
  5234. * @platform Web,Native
  5235. */
  5236. Event.CHANGE = "change";
  5237. /**
  5238. * @language en_US
  5239. * Dispatched when the value or selection of a property is going to change.you can cancel this by calling the
  5240. * preventDefault() method.
  5241. * @version Egret 2.4
  5242. * @platform Web,Native
  5243. */
  5244. /**
  5245. * @language zh_CN
  5246. * 属性值或状态即将发生改变,通常是按钮的选中状态,或者列表的选中项索引改变。可以通过调用 preventDefault() 方法阻止索引发生更改。
  5247. * @version Egret 2.4
  5248. * @platform Web,Native
  5249. */
  5250. Event.CHANGING = "changing";
  5251. /**
  5252. * @language en_US
  5253. * Dispatched when the net request is complete.
  5254. * @version Egret 2.4
  5255. * @platform Web,Native
  5256. */
  5257. /**
  5258. * @language zh_CN
  5259. * 网络请求加载完成
  5260. * @version Egret 2.4
  5261. * @platform Web,Native
  5262. */
  5263. Event.COMPLETE = "complete";
  5264. /**
  5265. * @language en_US
  5266. * Dispatched when loop completed.
  5267. * @version Egret 2.4
  5268. * @platform Web,Native
  5269. */
  5270. /**
  5271. * @language zh_CN
  5272. * 循环完成
  5273. * @version Egret 2.4
  5274. * @platform Web,Native
  5275. */
  5276. Event.LOOP_COMPLETE = "loopComplete";
  5277. /**
  5278. * @language en_US
  5279. * Dispatched when the TextInput instance gets focus.
  5280. * @version Egret 2.4
  5281. * @platform Web,Native
  5282. */
  5283. /**
  5284. * @language zh_CN
  5285. * TextInput实例获得焦点
  5286. * @version Egret 2.4
  5287. * @platform Web,Native
  5288. */
  5289. Event.FOCUS_IN = "focusIn";
  5290. /**
  5291. * @language en_US
  5292. * Dispatched when the TextInput instance loses focus.
  5293. * @version Egret 2.4
  5294. * @platform Web,Native
  5295. */
  5296. /**
  5297. * @language zh_CN
  5298. * TextInput实例失去焦点
  5299. * @version Egret 2.4
  5300. * @platform Web,Native
  5301. */
  5302. Event.FOCUS_OUT = "focusOut";
  5303. /**
  5304. * @language en_US
  5305. * Dispatched when the playback is ended.
  5306. * @version Egret 2.4
  5307. * @platform Web,Native
  5308. */
  5309. /**
  5310. * @language zh_CN
  5311. * 动画声音等播放完成
  5312. * @version Egret 2.4
  5313. * @platform Web,Native
  5314. */
  5315. Event.ENDED = "ended";
  5316. /**
  5317. * 游戏激活
  5318. * @version Egret 2.4
  5319. * @platform Web,Native
  5320. */
  5321. Event.ACTIVATE = "activate";
  5322. /**
  5323. * 取消激活
  5324. * @version Egret 2.4
  5325. * @platform Web,Native
  5326. */
  5327. Event.DEACTIVATE = "deactivate";
  5328. /**
  5329. * Event.CLOSE 常量定义 close 事件对象的 type 属性的值。
  5330. * @version Egret 2.4
  5331. * @platform Web,Native
  5332. */
  5333. Event.CLOSE = "close";
  5334. /**
  5335. * Event.CONNECT 常量定义 connect 事件对象的 type 属性的值。
  5336. * @version Egret 2.4
  5337. * @platform Web,Native
  5338. */
  5339. Event.CONNECT = "connect";
  5340. /**
  5341. * Event.LEAVE_STAGE 常量定义 leaveStage 事件对象的 type 属性的值。
  5342. * @version Egret 2.4
  5343. * @platform Web,Native
  5344. */
  5345. Event.LEAVE_STAGE = "leaveStage";
  5346. /**
  5347. * Event.SOUND_COMPLETE 常量定义 在声音完成播放后调度。
  5348. * @version Egret 2.4
  5349. * @platform Web,Native
  5350. */
  5351. Event.SOUND_COMPLETE = "soundComplete";
  5352. egret.Event = Event;
  5353. __reflect(Event.prototype, "egret.Event");
  5354. if (true) {
  5355. egret.$markReadOnly(Event, "type");
  5356. egret.$markReadOnly(Event, "bubbles");
  5357. egret.$markReadOnly(Event, "cancelable");
  5358. egret.$markReadOnly(Event, "eventPhase");
  5359. egret.$markReadOnly(Event, "currentTarget");
  5360. egret.$markReadOnly(Event, "target");
  5361. }
  5362. })(egret || (egret = {}));
  5363. //////////////////////////////////////////////////////////////////////////////////////
  5364. //
  5365. // Copyright (c) 2014-present, Egret Technology.
  5366. // All rights reserved.
  5367. // Redistribution and use in source and binary forms, with or without
  5368. // modification, are permitted provided that the following conditions are met:
  5369. //
  5370. // * Redistributions of source code must retain the above copyright
  5371. // notice, this list of conditions and the following disclaimer.
  5372. // * Redistributions in binary form must reproduce the above copyright
  5373. // notice, this list of conditions and the following disclaimer in the
  5374. // documentation and/or other materials provided with the distribution.
  5375. // * Neither the name of the Egret nor the
  5376. // names of its contributors may be used to endorse or promote products
  5377. // derived from this software without specific prior written permission.
  5378. //
  5379. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  5380. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  5381. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  5382. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  5383. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  5384. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  5385. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  5386. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  5387. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  5388. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5389. //
  5390. //////////////////////////////////////////////////////////////////////////////////////
  5391. var egret;
  5392. (function (egret) {
  5393. /**
  5394. * @language en_US
  5395. * The Bitmap class represents display objects that represent bitmap images.
  5396. * The Bitmap() constructor allows you to create a Bitmap object that contains a reference to a BitmapData object.
  5397. * After you create a Bitmap object, use the addChild() or addChildAt() method of the parent DisplayObjectContainer
  5398. * instance to place the bitmap on the display list.A Bitmap object can share its texture reference among several
  5399. * Bitmap objects, independent of translation or rotation properties. Because you can create multiple Bitmap objects
  5400. * that reference the same texture object, multiple display objects can use the same complex texture object
  5401. * without incurring the memory overhead of a texture object for each display object instance.
  5402. *
  5403. * @see egret.Texture
  5404. * @version Egret 2.4
  5405. * @platform Web,Native
  5406. * @includeExample egret/display/Bitmap.ts
  5407. */
  5408. /**
  5409. * @language zh_CN
  5410. * Bitmap 类表示用于显示位图图片的显示对象。
  5411. * 利用 Bitmap() 构造函数,可以创建包含对 BitmapData 对象引用的 Bitmap 对象。创建了 Bitmap 对象后,
  5412. * 使用父级 DisplayObjectContainer 实例的 addChild() 或 addChildAt() 方法可以将位图放在显示列表中。
  5413. * 一个 Bitmap 对象可在若干 Bitmap 对象之中共享其 texture 引用,与缩放或旋转属性无关。
  5414. * 由于能够创建引用相同 texture 对象的多个 Bitmap 对象,因此,多个显示对象可以使用相同的 texture 对象,
  5415. * 而不会因为每个显示对象实例使用一个 texture 对象而产生额外内存开销。
  5416. *
  5417. * @see egret.Texture
  5418. * @version Egret 2.4
  5419. * @platform Web,Native
  5420. * @includeExample egret/display/Bitmap.ts
  5421. */
  5422. var Bitmap = (function (_super) {
  5423. __extends(Bitmap, _super);
  5424. /**
  5425. * @language en_US
  5426. * Initializes a Bitmap object to refer to the specified BitmapData|Texture object.
  5427. * @param value The BitmapData|Texture object being referenced.
  5428. * @version Egret 2.4
  5429. * @platform Web,Native
  5430. */
  5431. /**
  5432. * @language zh_CN
  5433. * 创建一个引用指定 BitmapData|Texture 实例的 Bitmap 对象
  5434. * @param value 被引用的 BitmapData|Texture 实例
  5435. * @version Egret 2.4
  5436. * @platform Web,Native
  5437. */
  5438. function Bitmap(value) {
  5439. var _this = _super.call(this) || this;
  5440. /**
  5441. * @private
  5442. */
  5443. _this.$scale9Grid = null;
  5444. /**
  5445. * @private
  5446. */
  5447. _this.$fillMode = "scale";
  5448. _this._pixelHitTest = false;
  5449. _this.$renderNode = new egret.sys.BitmapNode();
  5450. _this.$Bitmap = {
  5451. 0: null,
  5452. 1: null,
  5453. 2: 0,
  5454. 3: 0,
  5455. 4: 0,
  5456. 5: 0,
  5457. 6: 0,
  5458. 7: 0,
  5459. 8: 0,
  5460. 9: 0,
  5461. 10: Bitmap.defaultSmoothing,
  5462. 11: NaN,
  5463. 12: NaN //explicitBitmapHeight,
  5464. };
  5465. _this.$setBitmapData(value);
  5466. return _this;
  5467. }
  5468. /**
  5469. * @private
  5470. * 显示对象添加到舞台
  5471. */
  5472. Bitmap.prototype.$onAddToStage = function (stage, nestLevel) {
  5473. _super.prototype.$onAddToStage.call(this, stage, nestLevel);
  5474. var bitmapData = this.$Bitmap[0 /* bitmapData */];
  5475. if (bitmapData) {
  5476. egret.BitmapData.$addDisplayObject(this, bitmapData);
  5477. }
  5478. };
  5479. /**
  5480. * @private
  5481. * 显示对象从舞台移除
  5482. */
  5483. Bitmap.prototype.$onRemoveFromStage = function () {
  5484. _super.prototype.$onRemoveFromStage.call(this);
  5485. var bitmapData = this.$Bitmap[0 /* bitmapData */];
  5486. if (bitmapData) {
  5487. egret.BitmapData.$removeDisplayObject(this, bitmapData);
  5488. }
  5489. };
  5490. Object.defineProperty(Bitmap.prototype, "bitmapData", {
  5491. /**
  5492. * @language en_US
  5493. * The BitmapData object being referenced.
  5494. * If you pass the constructor of type Texture or last set for texture, this value returns null.
  5495. * @version Egret 2.4
  5496. * @platform Web,Native
  5497. */
  5498. /**
  5499. * @language zh_CN
  5500. * 被引用的 BitmapData 对象。
  5501. * 如果传入构造函数的类型为 Texture 或者最后设置的为 texture,则此值返回 null。
  5502. * @version Egret 2.4
  5503. * @platform Web,Native
  5504. */
  5505. get: function () {
  5506. var value = this.$Bitmap[0 /* bitmapData */];
  5507. if (value instanceof egret.Texture) {
  5508. return null;
  5509. }
  5510. else {
  5511. return value;
  5512. }
  5513. },
  5514. set: function (value) {
  5515. this.$setBitmapData(value);
  5516. },
  5517. enumerable: true,
  5518. configurable: true
  5519. });
  5520. Object.defineProperty(Bitmap.prototype, "texture", {
  5521. /**
  5522. * @language en_US
  5523. * The Texture object being referenced.
  5524. * If you pass the constructor of type BitmapData or last set for bitmapData, this value returns null.
  5525. * @version Egret 2.4
  5526. * @platform Web,Native
  5527. */
  5528. /**
  5529. * @language zh_CN
  5530. * 被引用的 Texture 对象。
  5531. * 如果传入构造函数的类型为 BitmapData 或者最后设置的为 bitmapData,则此值返回 null。
  5532. * @version Egret 2.4
  5533. * @platform Web,Native
  5534. */
  5535. get: function () {
  5536. var value = this.$Bitmap[0 /* bitmapData */];
  5537. if (value instanceof egret.Texture) {
  5538. return value;
  5539. }
  5540. else {
  5541. return null;
  5542. }
  5543. },
  5544. set: function (value) {
  5545. this.$setBitmapData(value);
  5546. },
  5547. enumerable: true,
  5548. configurable: true
  5549. });
  5550. /**
  5551. * @private
  5552. */
  5553. Bitmap.prototype.$setBitmapData = function (value) {
  5554. var values = this.$Bitmap;
  5555. var oldBitmapData = values[0 /* bitmapData */];
  5556. if (value == oldBitmapData) {
  5557. return false;
  5558. }
  5559. values[0 /* bitmapData */] = value;
  5560. if (value) {
  5561. this.$refreshImageData();
  5562. }
  5563. else {
  5564. if (oldBitmapData) {
  5565. egret.BitmapData.$removeDisplayObject(this, oldBitmapData);
  5566. }
  5567. this.setImageData(null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  5568. this.$invalidateContentBounds();
  5569. return true;
  5570. }
  5571. if (this.$stage) {
  5572. if (oldBitmapData) {
  5573. var oldHashCode = void 0;
  5574. if (oldBitmapData._bitmapData && oldBitmapData._bitmapData.hashCode) {
  5575. oldHashCode = oldBitmapData._bitmapData.hashCode;
  5576. }
  5577. else {
  5578. oldHashCode = oldBitmapData.hashCode;
  5579. }
  5580. var newHashCode = void 0;
  5581. if (value._bitmapData && value._bitmapData.hashCode) {
  5582. newHashCode = value._bitmapData.hashCode;
  5583. }
  5584. else {
  5585. newHashCode = value.hashCode;
  5586. }
  5587. if (oldHashCode == newHashCode) {
  5588. this.$invalidateContentBounds();
  5589. return true;
  5590. }
  5591. egret.BitmapData.$removeDisplayObject(this, oldBitmapData);
  5592. }
  5593. egret.BitmapData.$addDisplayObject(this, value);
  5594. }
  5595. this.$invalidateContentBounds();
  5596. return true;
  5597. };
  5598. /**
  5599. * @private
  5600. */
  5601. Bitmap.prototype.$refreshImageData = function () {
  5602. var values = this.$Bitmap;
  5603. var bitmapData = values[0 /* bitmapData */];
  5604. if (bitmapData) {
  5605. if (bitmapData instanceof egret.Texture) {
  5606. var texture = bitmapData;
  5607. this.setImageData(texture._bitmapData, texture._bitmapX, texture._bitmapY, texture._bitmapWidth, texture._bitmapHeight, texture._offsetX, texture._offsetY, texture.$getTextureWidth(), texture.$getTextureHeight(), texture._sourceWidth, texture._sourceHeight);
  5608. }
  5609. else {
  5610. var width = bitmapData.width;
  5611. var height = bitmapData.height;
  5612. this.setImageData(bitmapData, 0, 0, width, height, 0, 0, width, height, width, height);
  5613. }
  5614. }
  5615. };
  5616. /**
  5617. * @private
  5618. */
  5619. Bitmap.prototype.setImageData = function (image, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, sourceWidth, sourceHeight) {
  5620. var values = this.$Bitmap;
  5621. values[1 /* image */] = image;
  5622. values[2 /* bitmapX */] = bitmapX;
  5623. values[3 /* bitmapY */] = bitmapY;
  5624. values[4 /* bitmapWidth */] = bitmapWidth;
  5625. values[5 /* bitmapHeight */] = bitmapHeight;
  5626. values[6 /* offsetX */] = offsetX;
  5627. values[7 /* offsetY */] = offsetY;
  5628. values[8 /* textureWidth */] = textureWidth;
  5629. values[9 /* textureHeight */] = textureHeight;
  5630. values[13 /* sourceWidth */] = sourceWidth;
  5631. values[14 /* sourceHeight */] = sourceHeight;
  5632. };
  5633. Object.defineProperty(Bitmap.prototype, "scale9Grid", {
  5634. /**
  5635. * @language en_US
  5636. * Represent a Rectangle Area that the 9 scale area of Image.
  5637. * Notice: This property is valid only when <code>fillMode</code>
  5638. * is <code>BitmapFillMode.SCALE</code>.
  5639. *
  5640. * @version Egret 2.4
  5641. * @platform Web,Native
  5642. */
  5643. /**
  5644. * @language zh_CN
  5645. * 矩形区域,它定义素材对象的九个缩放区域。
  5646. * 注意:此属性仅在<code>fillMode</code>为<code>BitmapFillMode.SCALE</code>时有效。
  5647. *
  5648. * @version Egret 2.4
  5649. * @platform Web,Native
  5650. */
  5651. get: function () {
  5652. return this.$scale9Grid;
  5653. },
  5654. set: function (value) {
  5655. this.$scale9Grid = value;
  5656. this.$invalidateContentBounds();
  5657. },
  5658. enumerable: true,
  5659. configurable: true
  5660. });
  5661. Object.defineProperty(Bitmap.prototype, "fillMode", {
  5662. /**
  5663. * @language en_US
  5664. * Determines how the bitmap fills in the dimensions.
  5665. * <p>When set to <code>BitmapFillMode.REPEAT</code>, the bitmap
  5666. * repeats to fill the region.</p>
  5667. * <p>When set to <code>BitmapFillMode.SCALE</code>, the bitmap
  5668. * stretches to fill the region.</p>
  5669. *
  5670. * @default <code>BitmapFillMode.SCALE</code>
  5671. *
  5672. * @version Egret 2.4
  5673. * @version eui 1.0
  5674. * @platform Web
  5675. */
  5676. /**
  5677. * @language zh_CN
  5678. * 确定位图填充尺寸的方式。
  5679. * <p>设置为 <code>BitmapFillMode.REPEAT</code>时,位图将重复以填充区域。</p>
  5680. * <p>设置为 <code>BitmapFillMode.SCALE</code>时,位图将拉伸以填充区域。</p>
  5681. *
  5682. * @default <code>BitmapFillMode.SCALE</code>
  5683. *
  5684. * @version Egret 2.4
  5685. * @version eui 1.0
  5686. * @platform Web
  5687. */
  5688. get: function () {
  5689. return this.$fillMode;
  5690. },
  5691. set: function (value) {
  5692. this.$setFillMode(value);
  5693. },
  5694. enumerable: true,
  5695. configurable: true
  5696. });
  5697. Bitmap.prototype.$setFillMode = function (value) {
  5698. if (value == this.$fillMode) {
  5699. return false;
  5700. }
  5701. this.$fillMode = value;
  5702. return true;
  5703. };
  5704. Object.defineProperty(Bitmap.prototype, "smoothing", {
  5705. /**
  5706. * @language en_US
  5707. * Whether or not the bitmap is smoothed when scaled.
  5708. * @version Egret 2.4
  5709. * @platform Web
  5710. */
  5711. /**
  5712. * @language zh_CN
  5713. * 控制在缩放时是否对位图进行平滑处理。
  5714. * @version Egret 2.4
  5715. * @platform Web
  5716. */
  5717. get: function () {
  5718. var values = this.$Bitmap;
  5719. return values[10 /* smoothing */];
  5720. },
  5721. set: function (value) {
  5722. value = !!value;
  5723. var values = this.$Bitmap;
  5724. if (value == values[10 /* smoothing */]) {
  5725. return;
  5726. }
  5727. values[10 /* smoothing */] = value;
  5728. this.$invalidate();
  5729. },
  5730. enumerable: true,
  5731. configurable: true
  5732. });
  5733. /**
  5734. * @private
  5735. *
  5736. * @param value
  5737. */
  5738. Bitmap.prototype.$setWidth = function (value) {
  5739. //value = +value || 0;
  5740. var values = this.$Bitmap;
  5741. if (value < 0 || value == values[11 /* explicitBitmapWidth */]) {
  5742. return false;
  5743. }
  5744. values[11 /* explicitBitmapWidth */] = value;
  5745. this.$invalidateContentBounds();
  5746. return true;
  5747. };
  5748. /**
  5749. * @private
  5750. *
  5751. * @param value
  5752. */
  5753. Bitmap.prototype.$setHeight = function (value) {
  5754. //value = +value || 0;
  5755. var values = this.$Bitmap;
  5756. if (value < 0 || value == values[12 /* explicitBitmapHeight */]) {
  5757. return false;
  5758. }
  5759. values[12 /* explicitBitmapHeight */] = value;
  5760. this.$invalidateContentBounds();
  5761. return true;
  5762. };
  5763. /**
  5764. * @private
  5765. * 获取显示宽度
  5766. */
  5767. Bitmap.prototype.$getWidth = function () {
  5768. var values = this.$Bitmap;
  5769. return isNaN(values[11 /* explicitBitmapWidth */]) ? this.$getContentBounds().width : values[11 /* explicitBitmapWidth */];
  5770. };
  5771. /**
  5772. * @private
  5773. * 获取显示宽度
  5774. */
  5775. Bitmap.prototype.$getHeight = function () {
  5776. var values = this.$Bitmap;
  5777. return isNaN(values[12 /* explicitBitmapHeight */]) ? this.$getContentBounds().height : values[12 /* explicitBitmapHeight */];
  5778. };
  5779. /**
  5780. * @private
  5781. */
  5782. Bitmap.prototype.$measureContentBounds = function (bounds) {
  5783. var values = this.$Bitmap;
  5784. if (values[1 /* image */]) {
  5785. var values_1 = this.$Bitmap;
  5786. var w = !isNaN(values_1[11 /* explicitBitmapWidth */]) ? values_1[11 /* explicitBitmapWidth */] : values_1[8 /* textureWidth */];
  5787. var h = !isNaN(values_1[12 /* explicitBitmapHeight */]) ? values_1[12 /* explicitBitmapHeight */] : values_1[9 /* textureHeight */];
  5788. bounds.setTo(0, 0, w, h);
  5789. }
  5790. else {
  5791. var w = !isNaN(values[11 /* explicitBitmapWidth */]) ? values[11 /* explicitBitmapWidth */] : 0;
  5792. var h = !isNaN(values[12 /* explicitBitmapHeight */]) ? values[12 /* explicitBitmapHeight */] : 0;
  5793. bounds.setTo(0, 0, w, h);
  5794. }
  5795. };
  5796. /**
  5797. * @private
  5798. */
  5799. Bitmap.prototype.$render = function () {
  5800. var values = this.$Bitmap;
  5801. if (values[1 /* image */]) {
  5802. var destW = !isNaN(values[11 /* explicitBitmapWidth */]) ? values[11 /* explicitBitmapWidth */] : values[8 /* textureWidth */];
  5803. var destH = !isNaN(values[12 /* explicitBitmapHeight */]) ? values[12 /* explicitBitmapHeight */] : values[9 /* textureHeight */];
  5804. egret.sys.BitmapNode.$updateTextureData(this.$renderNode, values[1 /* image */], values[2 /* bitmapX */], values[3 /* bitmapY */], values[4 /* bitmapWidth */], values[5 /* bitmapHeight */], values[6 /* offsetX */], values[7 /* offsetY */], values[8 /* textureWidth */], values[9 /* textureHeight */], destW, destH, values[13 /* sourceWidth */], values[14 /* sourceHeight */], this.scale9Grid || values[0 /* bitmapData */]["scale9Grid"], this.fillMode, values[10 /* smoothing */]);
  5805. }
  5806. };
  5807. Object.defineProperty(Bitmap.prototype, "pixelHitTest", {
  5808. /**
  5809. * @language en_US
  5810. * Specifies whether this object use precise hit testing by checking the alpha value of each pixel.If pixelHitTest
  5811. * is set to true,the transparent area of the bitmap will be touched through.<br/>
  5812. * Note:If the image is loaded from cross origin,that we can't access to the pixel data,so it might cause
  5813. * the pixelHitTest property invalid.
  5814. * @default false
  5815. * @version Egret 2.4
  5816. * @platform Web,Native
  5817. */
  5818. /**
  5819. * @language zh_CN
  5820. * 是否开启精确像素碰撞。设置为true显示对象本身的透明区域将能够被穿透。<br/>
  5821. * 注意:若图片资源是以跨域方式从外部服务器加载的,将无法访问图片的像素数据,而导致此属性失效。
  5822. * @default false
  5823. * @version Egret 2.4
  5824. * @platform Web,Native
  5825. */
  5826. get: function () {
  5827. return this._pixelHitTest;
  5828. },
  5829. set: function (value) {
  5830. this._pixelHitTest = !!value;
  5831. },
  5832. enumerable: true,
  5833. configurable: true
  5834. });
  5835. Bitmap.prototype.$hitTest = function (stageX, stageY) {
  5836. var target = _super.prototype.$hitTest.call(this, stageX, stageY);
  5837. if (target && this._pixelHitTest) {
  5838. target = this.hitTestPixel(stageX, stageY);
  5839. }
  5840. return target;
  5841. };
  5842. /**
  5843. * @private
  5844. */
  5845. Bitmap.prototype.hitTestPixel = function (stageX, stageY) {
  5846. var m = this.$getInvertedConcatenatedMatrix();
  5847. var localX = m.a * stageX + m.c * stageY + m.tx;
  5848. var localY = m.b * stageX + m.d * stageY + m.ty;
  5849. var data;
  5850. var displayList = this.$displayList;
  5851. if (displayList) {
  5852. var buffer = displayList.renderBuffer;
  5853. try {
  5854. data = buffer.getPixels(localX - displayList.offsetX, localY - displayList.offsetY);
  5855. }
  5856. catch (e) {
  5857. console.log(this.$Bitmap[0 /* bitmapData */]);
  5858. throw new Error(egret.sys.tr(1039));
  5859. }
  5860. }
  5861. else {
  5862. var buffer = egret.sys.customHitTestBuffer;
  5863. buffer.resize(3, 3);
  5864. var node = this.$getRenderNode();
  5865. var matrix = egret.Matrix.create();
  5866. matrix.identity();
  5867. matrix.translate(1 - localX, 1 - localY);
  5868. egret.sys.systemRenderer.drawNodeToBuffer(node, buffer, matrix, true);
  5869. egret.Matrix.release(matrix);
  5870. try {
  5871. data = buffer.getPixels(1, 1);
  5872. }
  5873. catch (e) {
  5874. console.log(this.$Bitmap[0 /* bitmapData */]);
  5875. throw new Error(egret.sys.tr(1039));
  5876. }
  5877. }
  5878. if (data[3] === 0) {
  5879. return null;
  5880. }
  5881. return this;
  5882. };
  5883. Bitmap.$drawImage = function (node, image, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, destW, destH, sourceWidth, sourceHeight, scale9Grid, fillMode, smoothing) {
  5884. console.warn('deprecated method : Bitmap.$drawImage,use egret.sys.BitmapNode.$drawImage instead of it');
  5885. egret.sys.BitmapNode.$updateTextureData(node, image, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, destW, destH, sourceWidth, sourceHeight, scale9Grid, fillMode, smoothing);
  5886. };
  5887. return Bitmap;
  5888. }(egret.DisplayObject));
  5889. /**
  5890. * @language en_US
  5891. * The default value of whether or not is smoothed when scaled.
  5892. * When object such as Bitmap is created,smoothing property will be set to this value.
  5893. * @default true。
  5894. * @version Egret 3.0
  5895. * @platform Web
  5896. */
  5897. /**
  5898. * @language zh_CN
  5899. * 控制在缩放时是否进行平滑处理的默认值。
  5900. * 在 Bitmap 等对象创建时,smoothing 属性会被设置为该值。
  5901. * @default true。
  5902. * @version Egret 3.0
  5903. * @platform Web
  5904. */
  5905. Bitmap.defaultSmoothing = true;
  5906. egret.Bitmap = Bitmap;
  5907. __reflect(Bitmap.prototype, "egret.Bitmap");
  5908. })(egret || (egret = {}));
  5909. //////////////////////////////////////////////////////////////////////////////////////
  5910. //
  5911. // Copyright (c) 2014-present, Egret Technology.
  5912. // All rights reserved.
  5913. // Redistribution and use in source and binary forms, with or without
  5914. // modification, are permitted provided that the following conditions are met:
  5915. //
  5916. // * Redistributions of source code must retain the above copyright
  5917. // notice, this list of conditions and the following disclaimer.
  5918. // * Redistributions in binary form must reproduce the above copyright
  5919. // notice, this list of conditions and the following disclaimer in the
  5920. // documentation and/or other materials provided with the distribution.
  5921. // * Neither the name of the Egret nor the
  5922. // names of its contributors may be used to endorse or promote products
  5923. // derived from this software without specific prior written permission.
  5924. //
  5925. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  5926. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  5927. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  5928. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  5929. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  5930. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  5931. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  5932. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  5933. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  5934. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5935. //
  5936. //////////////////////////////////////////////////////////////////////////////////////
  5937. var egret;
  5938. (function (egret) {
  5939. /**
  5940. * @language en_US
  5941. * The Sprite class is a basic display list building block: a display list node that can contain children.
  5942. * @version Egret 2.4
  5943. * @platform Web,Native
  5944. * @includeExample egret/display/Sprite.ts
  5945. */
  5946. /**
  5947. * @language zh_CN
  5948. * Sprite 类是基本显示列表构造块:一个可包含子项的显示列表节点。
  5949. * @version Egret 2.4
  5950. * @platform Web,Native
  5951. * @includeExample egret/display/Sprite.ts
  5952. */
  5953. var Sprite = (function (_super) {
  5954. __extends(Sprite, _super);
  5955. /**
  5956. * @language en_US
  5957. * Creates a new Sprite instance.
  5958. * @version Egret 2.4
  5959. * @platform Web,Native
  5960. */
  5961. /**
  5962. * @language zh_CN
  5963. * 实例化一个容器
  5964. * @version Egret 2.4
  5965. * @platform Web,Native
  5966. */
  5967. function Sprite() {
  5968. var _this = _super.call(this) || this;
  5969. _this.$graphics = new egret.Graphics();
  5970. _this.$graphics.$setTarget(_this);
  5971. return _this;
  5972. }
  5973. Object.defineProperty(Sprite.prototype, "graphics", {
  5974. /**
  5975. * @language en_US
  5976. * Specifies the Graphics object belonging to this Shape object, where vector drawing commands can occur.
  5977. * @version Egret 2.4
  5978. * @platform Web,Native
  5979. */
  5980. /**
  5981. * @language zh_CN
  5982. * 获取 Shape 中的 Graphics 对象。可通过此对象执行矢量绘图命令。
  5983. * @version Egret 2.4
  5984. * @platform Web,Native
  5985. */
  5986. get: function () {
  5987. return this.$graphics;
  5988. },
  5989. enumerable: true,
  5990. configurable: true
  5991. });
  5992. Sprite.prototype.$hitTest = function (stageX, stageY) {
  5993. if (!this.$visible) {
  5994. return null;
  5995. }
  5996. var m = this.$getInvertedConcatenatedMatrix();
  5997. var localX = m.a * stageX + m.c * stageY + m.tx;
  5998. var localY = m.b * stageX + m.d * stageY + m.ty;
  5999. var rect = this.$scrollRect ? this.$scrollRect : this.$maskRect;
  6000. if (rect && !rect.contains(localX, localY)) {
  6001. return null;
  6002. }
  6003. if (this.$mask && !this.$mask.$hitTest(stageX, stageY)) {
  6004. return null;
  6005. }
  6006. var children = this.$children;
  6007. var found = false;
  6008. var target = null;
  6009. for (var i = children.length - 1; i >= 0; i--) {
  6010. var child = children[i];
  6011. if (child.$maskedObject) {
  6012. continue;
  6013. }
  6014. target = child.$hitTest(stageX, stageY);
  6015. if (target) {
  6016. found = true;
  6017. if (target.$touchEnabled) {
  6018. break;
  6019. }
  6020. else {
  6021. target = null;
  6022. }
  6023. }
  6024. }
  6025. if (target) {
  6026. if (this.$touchChildren) {
  6027. return target;
  6028. }
  6029. return this;
  6030. }
  6031. if (found) {
  6032. return this;
  6033. }
  6034. target = egret.DisplayObject.prototype.$hitTest.call(this, stageX, stageY);
  6035. if (target) {
  6036. target = this.$graphics.$hitTest(stageX, stageY);
  6037. }
  6038. return target;
  6039. };
  6040. /**
  6041. * @private
  6042. */
  6043. Sprite.prototype.$measureContentBounds = function (bounds) {
  6044. this.$graphics.$measureContentBounds(bounds);
  6045. };
  6046. /**
  6047. * @private
  6048. */
  6049. Sprite.prototype.$onRemoveFromStage = function () {
  6050. _super.prototype.$onRemoveFromStage.call(this);
  6051. if (this.$graphics) {
  6052. this.$graphics.$onRemoveFromStage();
  6053. }
  6054. };
  6055. return Sprite;
  6056. }(egret.DisplayObjectContainer));
  6057. egret.Sprite = Sprite;
  6058. __reflect(Sprite.prototype, "egret.Sprite");
  6059. })(egret || (egret = {}));
  6060. //////////////////////////////////////////////////////////////////////////////////////
  6061. //
  6062. // Copyright (c) 2014-present, Egret Technology.
  6063. // All rights reserved.
  6064. // Redistribution and use in source and binary forms, with or without
  6065. // modification, are permitted provided that the following conditions are met:
  6066. //
  6067. // * Redistributions of source code must retain the above copyright
  6068. // notice, this list of conditions and the following disclaimer.
  6069. // * Redistributions in binary form must reproduce the above copyright
  6070. // notice, this list of conditions and the following disclaimer in the
  6071. // documentation and/or other materials provided with the distribution.
  6072. // * Neither the name of the Egret nor the
  6073. // names of its contributors may be used to endorse or promote products
  6074. // derived from this software without specific prior written permission.
  6075. //
  6076. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  6077. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  6078. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  6079. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  6080. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  6081. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  6082. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  6083. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  6084. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  6085. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  6086. //
  6087. //////////////////////////////////////////////////////////////////////////////////////
  6088. var egret;
  6089. (function (egret) {
  6090. egret.$TextureScaleFactor = 1;
  6091. /**
  6092. * @language en_US
  6093. * The Texture class encapsulates different image resources on different platforms.
  6094. * In HTML5, resource is an HTMLElement object
  6095. * In OpenGL / WebGL, resource is a texture ID obtained after the GPU is submitted
  6096. * The Texture class encapsulates the details implemented on the underlayer. Developers just need to focus on interfaces
  6097. * @see http://edn.egret.com/cn/docs/page/135 The use of texture packs
  6098. * @see http://edn.egret.com/cn/docs/page/123 Several ways of access to resources
  6099. * @version Egret 2.4
  6100. * @platform Web,Native
  6101. * @includeExample egret/display/Texture.ts
  6102. */
  6103. /**
  6104. * @language zh_CN
  6105. * 纹理类是对不同平台不同的图片资源的封装
  6106. * 在HTML5中,资源是一个HTMLElement对象
  6107. * 在OpenGL / WebGL中,资源是一个提交GPU后获取的纹理id
  6108. * Texture类封装了这些底层实现的细节,开发者只需要关心接口即可
  6109. * @see http://edn.egret.com/cn/docs/page/135 纹理集的使用
  6110. * @see http://edn.egret.com/cn/docs/page/123 获取资源的几种方式
  6111. * @version Egret 2.4
  6112. * @platform Web,Native
  6113. * @includeExample egret/display/Texture.ts
  6114. */
  6115. var Texture = (function (_super) {
  6116. __extends(Texture, _super);
  6117. /**
  6118. * @language en_US
  6119. * Create an egret.Texture object
  6120. * @version Egret 2.4
  6121. * @platform Web,Native
  6122. */
  6123. /**
  6124. * @language zh_CN
  6125. * 创建一个 egret.Texture 对象
  6126. * @version Egret 2.4
  6127. * @platform Web,Native
  6128. */
  6129. function Texture() {
  6130. var _this = _super.call(this) || this;
  6131. /**
  6132. * @private
  6133. * 表示这个纹理在 bitmapData 上的 x 起始位置
  6134. */
  6135. _this._bitmapX = 0;
  6136. /**
  6137. * @private
  6138. * 表示这个纹理在 bitmapData 上的 y 起始位置
  6139. */
  6140. _this._bitmapY = 0;
  6141. /**
  6142. * @private
  6143. * 表示这个纹理在 bitmapData 上的宽度
  6144. */
  6145. _this._bitmapWidth = 0;
  6146. /**
  6147. * @private
  6148. * 表示这个纹理在 bitmapData 上的高度
  6149. */
  6150. _this._bitmapHeight = 0;
  6151. /**
  6152. * @private
  6153. * 表示这个纹理显示了之后在 x 方向的渲染偏移量
  6154. */
  6155. _this._offsetX = 0;
  6156. /**
  6157. * @private
  6158. * 表示这个纹理显示了之后在 y 方向的渲染偏移量
  6159. */
  6160. _this._offsetY = 0;
  6161. /**
  6162. * @private
  6163. * 纹理宽度
  6164. */
  6165. _this._textureWidth = 0;
  6166. /**
  6167. * @private
  6168. * 纹理高度
  6169. */
  6170. _this._textureHeight = 0;
  6171. /**
  6172. * @private
  6173. * 表示bitmapData.width
  6174. */
  6175. _this._sourceWidth = 0;
  6176. /**
  6177. * @private
  6178. * 表示bitmapData.height
  6179. */
  6180. _this._sourceHeight = 0;
  6181. /**
  6182. * @private
  6183. */
  6184. _this._bitmapData = null;
  6185. return _this;
  6186. }
  6187. Object.defineProperty(Texture.prototype, "textureWidth", {
  6188. /**
  6189. * @language en_US
  6190. * Texture width, read only
  6191. * @version Egret 2.4
  6192. * @platform Web,Native
  6193. */
  6194. /**
  6195. * @language zh_CN
  6196. * 纹理宽度,只读属性,不可以设置
  6197. * @version Egret 2.4
  6198. * @platform Web,Native
  6199. */
  6200. get: function () {
  6201. return this.$getTextureWidth();
  6202. },
  6203. enumerable: true,
  6204. configurable: true
  6205. });
  6206. Texture.prototype.$getTextureWidth = function () {
  6207. return this._textureWidth;
  6208. };
  6209. Object.defineProperty(Texture.prototype, "textureHeight", {
  6210. /**
  6211. * @language en_US
  6212. * Texture height, read only
  6213. * @version Egret 2.4
  6214. * @platform Web,Native
  6215. */
  6216. /**
  6217. * @language zh_CN
  6218. * 纹理高度,只读属性,不可以设置
  6219. * @version Egret 2.4
  6220. * @platform Web,Native
  6221. */
  6222. get: function () {
  6223. return this.$getTextureHeight();
  6224. },
  6225. enumerable: true,
  6226. configurable: true
  6227. });
  6228. Texture.prototype.$getTextureHeight = function () {
  6229. return this._textureHeight;
  6230. };
  6231. Texture.prototype.$getScaleBitmapWidth = function () {
  6232. return this._bitmapWidth * egret.$TextureScaleFactor;
  6233. };
  6234. Texture.prototype.$getScaleBitmapHeight = function () {
  6235. return this._bitmapHeight * egret.$TextureScaleFactor;
  6236. };
  6237. Object.defineProperty(Texture.prototype, "bitmapData", {
  6238. /**
  6239. * @language en_US
  6240. * The BitmapData object being referenced.
  6241. * @version Egret 2.4
  6242. * @platform Web,Native
  6243. */
  6244. /**
  6245. * @language zh_CN
  6246. * 被引用的 BitmapData 对象。
  6247. * @version Egret 2.4
  6248. * @platform Web,Native
  6249. */
  6250. get: function () {
  6251. return this._bitmapData;
  6252. },
  6253. set: function (value) {
  6254. this._setBitmapData(value);
  6255. },
  6256. enumerable: true,
  6257. configurable: true
  6258. });
  6259. /**
  6260. * @language en_US
  6261. * Set the BitmapData object.
  6262. * @version Egret 3.2.1
  6263. * @platform Web,Native
  6264. */
  6265. /**
  6266. * @language zh_CN
  6267. * 设置 BitmapData 对象。
  6268. * @version Egret 3.2.1
  6269. * @platform Web,Native
  6270. */
  6271. Texture.prototype._setBitmapData = function (value) {
  6272. this._bitmapData = value;
  6273. var scale = egret.$TextureScaleFactor;
  6274. var w = value.width * scale;
  6275. var h = value.height * scale;
  6276. this.$initData(0, 0, w, h, 0, 0, w, h, value.width, value.height);
  6277. };
  6278. /**
  6279. * @private
  6280. * 设置Texture数据
  6281. * @param bitmapX
  6282. * @param bitmapY
  6283. * @param bitmapWidth
  6284. * @param bitmapHeight
  6285. * @param offsetX
  6286. * @param offsetY
  6287. * @param textureWidth
  6288. * @param textureHeight
  6289. * @param sourceWidth
  6290. * @param sourceHeight
  6291. */
  6292. Texture.prototype.$initData = function (bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, sourceWidth, sourceHeight) {
  6293. var scale = egret.$TextureScaleFactor;
  6294. this._bitmapX = bitmapX / scale;
  6295. this._bitmapY = bitmapY / scale;
  6296. this._bitmapWidth = bitmapWidth / scale;
  6297. this._bitmapHeight = bitmapHeight / scale;
  6298. this._offsetX = offsetX;
  6299. this._offsetY = offsetY;
  6300. this._textureWidth = textureWidth;
  6301. this._textureHeight = textureHeight;
  6302. this._sourceWidth = sourceWidth;
  6303. this._sourceHeight = sourceHeight;
  6304. //todo
  6305. egret.BitmapData.$invalidate(this);
  6306. };
  6307. /**
  6308. * @deprecated
  6309. */
  6310. Texture.prototype.getPixel32 = function (x, y) {
  6311. throw new Error();
  6312. };
  6313. /**
  6314. * @language en_US
  6315. * Obtain the color value for the specified pixel region
  6316. * @param x The x coordinate of the pixel region
  6317. * @param y The y coordinate of the pixel region
  6318. * @param width The width of the pixel region
  6319. * @param height The height of the pixel region
  6320. * @returns Specifies the color value for the pixel region
  6321. * @version Egret 3.2.1
  6322. * @platform Web,Native
  6323. */
  6324. /**
  6325. * @language zh_CN
  6326. * 获取指定像素区域的颜色值
  6327. * @param x 像素区域的X轴坐标
  6328. * @param y 像素区域的Y轴坐标
  6329. * @param width 像素点的Y轴坐标
  6330. * @param height 像素点的Y轴坐标
  6331. * @returns 指定像素区域的颜色值
  6332. * @version Egret 3.2.1
  6333. * @platform Web
  6334. */
  6335. Texture.prototype.getPixels = function (x, y, width, height) {
  6336. if (width === void 0) { width = 1; }
  6337. if (height === void 0) { height = 1; }
  6338. throw new Error();
  6339. };
  6340. /**
  6341. * @language en_US
  6342. * Convert base64 string, if the picture (or pictures included) cross-border or null
  6343. * @param type Type conversions, such as "image / png"
  6344. * @param rect The need to convert the area
  6345. * @param smoothing Whether to convert data to the smoothing process
  6346. * @returns {any} base64 string
  6347. * @version Egret 2.4
  6348. */
  6349. /**
  6350. * @language zh_CN
  6351. * 转换成base64字符串,如果图片(或者包含的图片)跨域,则返回null
  6352. * @param type 转换的类型,如 "image/png"
  6353. * @param rect 需要转换的区域
  6354. * @returns {any} base64字符串
  6355. * @version Egret 2.4
  6356. */
  6357. Texture.prototype.toDataURL = function (type, rect) {
  6358. throw new Error();
  6359. };
  6360. /**
  6361. * @language en_US
  6362. * Crop designated area and save it as image.
  6363. * native support only "image / png" and "image / jpeg"; Web browser because of the various implementations are not the same, it is recommended to use only these two kinds.
  6364. * @param type Type conversions, such as "image / png"
  6365. * @param filePath The path name of the image (the home directory for the game's private space, the path can not have "../",Web supports only pass names.)
  6366. * @param rect The need to convert the area
  6367. * @version Egret 2.4
  6368. * @platform Native
  6369. */
  6370. /**
  6371. * @language zh_CN
  6372. * 裁剪指定区域并保存成图片。
  6373. * native只支持 "image/png" 和 "image/jpeg";Web中由于各个浏览器的实现不一样,因此建议也只用这2种。
  6374. * @param type 转换的类型,如 "image/png"
  6375. * @param filePath 图片的名称的路径(主目录为游戏的私有空间,路径中不能有 "../",Web只支持传名称。)
  6376. * @param rect 需要转换的区域
  6377. * @version Egret 2.4
  6378. * @platform Native
  6379. */
  6380. Texture.prototype.saveToFile = function (type, filePath, rect) {
  6381. throw new Error();
  6382. };
  6383. /**
  6384. * @language en_US
  6385. * dispose texture
  6386. * @version Egret 2.4
  6387. * @platform Web,Native
  6388. */
  6389. /**
  6390. * @language zh_CN
  6391. * 释放纹理
  6392. * @version Egret 2.4
  6393. * @platform Web,Native
  6394. */
  6395. Texture.prototype.dispose = function () {
  6396. if (this._bitmapData) {
  6397. this._bitmapData.$dispose();
  6398. this._bitmapData = null;
  6399. }
  6400. };
  6401. return Texture;
  6402. }(egret.HashObject));
  6403. egret.Texture = Texture;
  6404. __reflect(Texture.prototype, "egret.Texture");
  6405. if (true) {
  6406. egret.$markReadOnly(Texture, "textureWidth");
  6407. egret.$markReadOnly(Texture, "textureHeight");
  6408. }
  6409. })(egret || (egret = {}));
  6410. //////////////////////////////////////////////////////////////////////////////////////
  6411. //
  6412. // Copyright (c) 2014-present, Egret Technology.
  6413. // All rights reserved.
  6414. // Redistribution and use in source and binary forms, with or without
  6415. // modification, are permitted provided that the following conditions are met:
  6416. //
  6417. // * Redistributions of source code must retain the above copyright
  6418. // notice, this list of conditions and the following disclaimer.
  6419. // * Redistributions in binary form must reproduce the above copyright
  6420. // notice, this list of conditions and the following disclaimer in the
  6421. // documentation and/or other materials provided with the distribution.
  6422. // * Neither the name of the Egret nor the
  6423. // names of its contributors may be used to endorse or promote products
  6424. // derived from this software without specific prior written permission.
  6425. //
  6426. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  6427. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  6428. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  6429. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  6430. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  6431. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  6432. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  6433. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  6434. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  6435. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  6436. //
  6437. //////////////////////////////////////////////////////////////////////////////////////
  6438. var egret;
  6439. (function (egret) {
  6440. /**
  6441. * @private
  6442. */
  6443. egret.$locale_strings = egret.$locale_strings || {};
  6444. /**
  6445. * @private
  6446. */
  6447. egret.$language = "en_US";
  6448. })(egret || (egret = {}));
  6449. (function (egret) {
  6450. var sys;
  6451. (function (sys) {
  6452. /**
  6453. * @private
  6454. * 全局多语言翻译函数
  6455. * @param code 要查询的字符串代码
  6456. * @param args 替换字符串中{0}标志的参数列表
  6457. * @returns 返回拼接后的字符串
  6458. */
  6459. function tr(code) {
  6460. var args = [];
  6461. for (var _i = 1; _i < arguments.length; _i++) {
  6462. args[_i - 1] = arguments[_i];
  6463. }
  6464. var text = egret.$locale_strings[egret.$language][code];
  6465. if (!text) {
  6466. return "{" + code + "}";
  6467. }
  6468. var length = args.length;
  6469. for (var i = 0; i < length; i++) {
  6470. text = text.replace("{" + i + "}", args[i]);
  6471. }
  6472. return text;
  6473. }
  6474. sys.tr = tr;
  6475. })(sys = egret.sys || (egret.sys = {}));
  6476. })(egret || (egret = {}));
  6477. //////////////////////////////////////////////////////////////////////////////////////
  6478. //
  6479. // Copyright (c) 2014-present, Egret Technology.
  6480. // All rights reserved.
  6481. // Redistribution and use in source and binary forms, with or without
  6482. // modification, are permitted provided that the following conditions are met:
  6483. //
  6484. // * Redistributions of source code must retain the above copyright
  6485. // notice, this list of conditions and the following disclaimer.
  6486. // * Redistributions in binary form must reproduce the above copyright
  6487. // notice, this list of conditions and the following disclaimer in the
  6488. // documentation and/or other materials provided with the distribution.
  6489. // * Neither the name of the Egret nor the
  6490. // names of its contributors may be used to endorse or promote products
  6491. // derived from this software without specific prior written permission.
  6492. //
  6493. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  6494. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  6495. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  6496. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  6497. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  6498. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  6499. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  6500. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  6501. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  6502. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  6503. //
  6504. //////////////////////////////////////////////////////////////////////////////////////
  6505. var egret;
  6506. (function (egret) {
  6507. var pointPool = [];
  6508. var DEG_TO_RAD = Math.PI / 180;
  6509. /**
  6510. * @language en_US
  6511. * The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal
  6512. * axis and y represents the vertical axis.
  6513. * @version Egret 2.4
  6514. * @platform Web,Native
  6515. * @includeExample egret/geom/Point.ts
  6516. */
  6517. /**
  6518. * @language zh_CN
  6519. * Point 对象表示二维坐标系统中的某个位置,其中 x 表示水平轴,y 表示垂直轴。
  6520. * @version Egret 2.4
  6521. * @platform Web,Native
  6522. * @includeExample egret/geom/Point.ts
  6523. */
  6524. var Point = (function (_super) {
  6525. __extends(Point, _super);
  6526. /**
  6527. * @language en_US
  6528. * Creates a new point. If you pass no parameters to this method, a point is created at (0,0).
  6529. * @param x The horizontal coordinate.
  6530. * @param y The vertical coordinate.
  6531. * @version Egret 2.4
  6532. * @platform Web,Native
  6533. */
  6534. /**
  6535. * @language zh_CN
  6536. * 创建一个 egret.Point 对象.若不传入任何参数,将会创建一个位于(0,0)位置的点。
  6537. * @param x 该对象的x属性值,默认为0
  6538. * @param y 该对象的y属性值,默认为0
  6539. * @version Egret 2.4
  6540. * @platform Web,Native
  6541. */
  6542. function Point(x, y) {
  6543. if (x === void 0) { x = 0; }
  6544. if (y === void 0) { y = 0; }
  6545. var _this = _super.call(this) || this;
  6546. _this.x = x;
  6547. _this.y = y;
  6548. return _this;
  6549. }
  6550. /**
  6551. * @language en_US
  6552. * Releases a point instance to the object pool
  6553. * @version Egret 2.4
  6554. * @platform Web,Native
  6555. */
  6556. /**
  6557. * @language zh_CN
  6558. * 释放一个Point实例到对象池
  6559. * @version Egret 2.4
  6560. * @platform Web,Native
  6561. */
  6562. Point.release = function (point) {
  6563. if (!point) {
  6564. return;
  6565. }
  6566. pointPool.push(point);
  6567. };
  6568. /**
  6569. * @language en_US
  6570. * get a point instance from the object pool or create a new one.
  6571. * @param x The horizontal coordinate.
  6572. * @param y The vertical coordinate.
  6573. * @version Egret 2.4
  6574. * @platform Web,Native
  6575. */
  6576. /**
  6577. * @language zh_CN
  6578. * 从对象池中取出或创建一个新的Point对象。
  6579. * @param x 该对象的x属性值,默认为0
  6580. * @param y 该对象的y属性值,默认为0
  6581. * @version Egret 2.4
  6582. * @platform Web,Native
  6583. */
  6584. Point.create = function (x, y) {
  6585. var point = pointPool.pop();
  6586. if (!point) {
  6587. point = new Point();
  6588. }
  6589. return point.setTo(x, y);
  6590. };
  6591. Object.defineProperty(Point.prototype, "length", {
  6592. /**
  6593. * @language en_US
  6594. * The length of the line segment from (0,0) to this point.
  6595. * @version Egret 2.4
  6596. * @platform Web,Native
  6597. */
  6598. /**
  6599. * @language zh_CN
  6600. * 从 (0,0) 到此点的线段长度。
  6601. * @version Egret 2.4
  6602. * @platform Web,Native
  6603. */
  6604. get: function () {
  6605. return Math.sqrt(this.x * this.x + this.y * this.y);
  6606. },
  6607. enumerable: true,
  6608. configurable: true
  6609. });
  6610. /**
  6611. * @language en_US
  6612. * Sets the members of Point to the specified values
  6613. * @param x The horizontal coordinate.
  6614. * @param y The vertical coordinate.
  6615. * @version Egret 2.4
  6616. * @platform Web,Native
  6617. */
  6618. /**
  6619. * @language zh_CN
  6620. * 将 Point 的成员设置为指定值
  6621. * @param x 该对象的x属性值
  6622. * @param y 该对象的y属性值
  6623. * @version Egret 2.4
  6624. * @platform Web,Native
  6625. */
  6626. Point.prototype.setTo = function (x, y) {
  6627. this.x = x;
  6628. this.y = y;
  6629. return this;
  6630. };
  6631. /**
  6632. * @language en_US
  6633. * Creates a copy of this Point object.
  6634. * @version Egret 2.4
  6635. * @platform Web,Native
  6636. */
  6637. /**
  6638. * @language zh_CN
  6639. * 克隆点对象
  6640. * @version Egret 2.4
  6641. * @platform Web,Native
  6642. */
  6643. Point.prototype.clone = function () {
  6644. return new Point(this.x, this.y);
  6645. };
  6646. /**
  6647. * @language en_US
  6648. * Determines whether two points are equal. Two points are equal if they have the same x and y values.
  6649. * @param toCompare The point to be compared.
  6650. * @returns A value of true if the object is equal to this Point object; false if it is not equal.
  6651. * @version Egret 2.4
  6652. * @platform Web,Native
  6653. */
  6654. /**
  6655. * @language zh_CN
  6656. * 确定两个点是否相同。如果两个点具有相同的 x 和 y 值,则它们是相同的点。
  6657. * @param toCompare 要比较的点。
  6658. * @returns 如果该对象与此 Point 对象相同,则为 true 值,如果不相同,则为 false。
  6659. * @version Egret 2.4
  6660. * @platform Web,Native
  6661. */
  6662. Point.prototype.equals = function (toCompare) {
  6663. return this.x == toCompare.x && this.y == toCompare.y;
  6664. };
  6665. /**
  6666. * @language en_US
  6667. * Returns the distance between pt1 and pt2.
  6668. * @param p1 The first point.
  6669. * @param p2 The second point.
  6670. * @returns The distance between the first and second points.
  6671. * @version Egret 2.4
  6672. * @platform Web,Native
  6673. */
  6674. /**
  6675. * @language zh_CN
  6676. * 返回 pt1 和 pt2 之间的距离。
  6677. * @param p1 第一个点
  6678. * @param p2 第二个点
  6679. * @returns 第一个点和第二个点之间的距离。
  6680. * @version Egret 2.4
  6681. * @platform Web,Native
  6682. */
  6683. Point.distance = function (p1, p2) {
  6684. return Math.sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
  6685. };
  6686. /**
  6687. * @language en_US
  6688. * Copies all of the point data from the source Point object into the calling Point object.
  6689. * @param sourcePoint The Point object from which to copy the data.
  6690. * @version Egret 2.4
  6691. * @platform Web,Native
  6692. */
  6693. /**
  6694. * @language zh_CN
  6695. * 将源 Point 对象中的所有点数据复制到调用方 Point 对象中。
  6696. * @param sourcePoint 要从中复制数据的 Point 对象。
  6697. * @version Egret 2.4
  6698. * @platform Web,Native
  6699. */
  6700. Point.prototype.copyFrom = function (sourcePoint) {
  6701. this.x = sourcePoint.x;
  6702. this.y = sourcePoint.y;
  6703. };
  6704. /**
  6705. * @language en_US
  6706. * Adds the coordinates of another point to the coordinates of this point to create a new point.
  6707. * @param v The point to be added.
  6708. * @returns The new point.
  6709. * @version Egret 2.4
  6710. * @platform Web,Native
  6711. */
  6712. /**
  6713. * @language zh_CN
  6714. * 将另一个点的坐标添加到此点的坐标以创建一个新点。
  6715. * @param v 要添加的点。
  6716. * @returns 新点。
  6717. * @version Egret 2.4
  6718. * @platform Web,Native
  6719. */
  6720. Point.prototype.add = function (v) {
  6721. return new Point(this.x + v.x, this.y + v.y);
  6722. };
  6723. /**
  6724. * @language en_US
  6725. * Determines a point between two specified points.
  6726. * The parameter f determines where the new interpolated point is located relative to the two end points specified by parameters pt1 and pt2. The closer the value of the parameter f is to 1.0, the closer the interpolated point is to the first point (parameter pt1). The closer the value of the parameter f is to 0, the closer the interpolated point is to the second point (parameter pt2).
  6727. * @param pt1 The first point.
  6728. * @param pt2 The second point.
  6729. * @param f The level of interpolation between the two points. Indicates where the new point will be, along the line between pt1 and pt2. If f=1, pt1 is returned; if f=0, pt2 is returned.
  6730. * @returns The new interpolated point.
  6731. * @version Egret 2.4
  6732. * @platform Web,Native
  6733. */
  6734. /**
  6735. * @language zh_CN
  6736. * 确定两个指定点之间的点。
  6737. * 参数 f 确定新的内插点相对于参数 pt1 和 pt2 指定的两个端点所处的位置。参数 f 的值越接近 1.0,则内插点就越接近第一个点(参数 pt1)。参数 f 的值越接近 0,则内插点就越接近第二个点(参数 pt2)。
  6738. * @param pt1 第一个点。
  6739. * @param pt2 第二个点。
  6740. * @param f 两个点之间的内插级别。表示新点将位于 pt1 和 pt2 连成的直线上的什么位置。如果 f=1,则返回 pt1;如果 f=0,则返回 pt2。
  6741. * @returns 新的内插点。
  6742. * @version Egret 2.4
  6743. * @platform Web,Native
  6744. */
  6745. Point.interpolate = function (pt1, pt2, f) {
  6746. var f1 = 1 - f;
  6747. return new Point(pt1.x * f + pt2.x * f1, pt1.y * f + pt2.y * f1);
  6748. };
  6749. /**
  6750. * @language en_US
  6751. * Scales the line segment between (0,0) and the current point to a set length.
  6752. * @param thickness The scaling value. For example, if the current point is (0,5), and you normalize it to 1, the point returned is at (0,1).
  6753. * @version Egret 2.4
  6754. * @platform Web,Native
  6755. */
  6756. /**
  6757. * @language zh_CN
  6758. * 将 (0,0) 和当前点之间的线段缩放为设定的长度。
  6759. * @param thickness 缩放值。例如,如果当前点为 (0,5) 并且您将它规范化为 1,则返回的点位于 (0,1) 处。
  6760. * @version Egret 2.4
  6761. * @platform Web,Native
  6762. */
  6763. Point.prototype.normalize = function (thickness) {
  6764. if (this.x != 0 || this.y != 0) {
  6765. var relativeThickness = thickness / this.length;
  6766. this.x *= relativeThickness;
  6767. this.y *= relativeThickness;
  6768. }
  6769. };
  6770. /**
  6771. * @language en_US
  6772. * Offsets the Point object by the specified amount. The value of dx is added to the original value of x to create the new x value. The value of dy is added to the original value of y to create the new y value.
  6773. * @param dx The amount by which to offset the horizontal coordinate, x.
  6774. * @param dy The amount by which to offset the vertical coordinate, y.
  6775. * @version Egret 2.4
  6776. * @platform Web,Native
  6777. */
  6778. /**
  6779. * @language zh_CN
  6780. * 按指定量偏移 Point 对象。dx 的值将添加到 x 的原始值中以创建新的 x 值。dy 的值将添加到 y 的原始值中以创建新的 y 值。
  6781. * @param dx 水平坐标 x 的偏移量。
  6782. * @param dy 水平坐标 y 的偏移量。
  6783. * @version Egret 2.4
  6784. * @platform Web,Native
  6785. */
  6786. Point.prototype.offset = function (dx, dy) {
  6787. this.x += dx;
  6788. this.y += dy;
  6789. };
  6790. /**
  6791. * @language en_US
  6792. * Converts a pair of polar coordinates to a Cartesian point coordinate.
  6793. * @param len The length coordinate of the polar pair.
  6794. * @param angle The angle, in radians, of the polar pair.
  6795. * @version Egret 2.4
  6796. * @platform Web,Native
  6797. */
  6798. /**
  6799. * @language zh_CN
  6800. * 将一对极坐标转换为笛卡尔点坐标。
  6801. * @param len 极坐标对的长度。
  6802. * @param angle 极坐标对的角度(以弧度表示)。
  6803. * @version Egret 2.4
  6804. * @platform Web,Native
  6805. */
  6806. Point.polar = function (len, angle) {
  6807. return new Point(len * egret.NumberUtils.cos(angle / DEG_TO_RAD), len * egret.NumberUtils.sin(angle / DEG_TO_RAD));
  6808. };
  6809. /**
  6810. * @language en_US
  6811. * Subtracts the coordinates of another point from the coordinates of this point to create a new point.
  6812. * @param v The point to be subtracted.
  6813. * @returns The new point.
  6814. * @version Egret 2.4
  6815. * @platform Web,Native
  6816. */
  6817. /**
  6818. * @language zh_CN
  6819. * 从此点的坐标中减去另一个点的坐标以创建一个新点。
  6820. * @param v 要减去的点。
  6821. * @returns 新点。
  6822. * @version Egret 2.4
  6823. * @platform Web,Native
  6824. */
  6825. Point.prototype.subtract = function (v) {
  6826. return new Point(this.x - v.x, this.y - v.y);
  6827. };
  6828. /**
  6829. * @language en_US
  6830. * Returns a string that contains the values of the x and y coordinates. The string has the form "(x=x, y=y)", so calling the toString() method for a point at 23,17 would return "(x=23, y=17)".
  6831. * @returns The string representation of the coordinates.
  6832. * @version Egret 2.4
  6833. * @platform Web,Native
  6834. */
  6835. /**
  6836. * @language zh_CN
  6837. * 返回包含 x 和 y 坐标的值的字符串。该字符串的格式为 "(x=x, y=y)",因此为点 23,17 调用 toString() 方法将返回 "(x=23, y=17)"。
  6838. * @returns 坐标的字符串表示形式。
  6839. * @version Egret 2.4
  6840. * @platform Web,Native
  6841. */
  6842. Point.prototype.toString = function () {
  6843. return "(x=" + this.x + ", y=" + this.y + ")";
  6844. };
  6845. return Point;
  6846. }(egret.HashObject));
  6847. egret.Point = Point;
  6848. __reflect(Point.prototype, "egret.Point");
  6849. if (true) {
  6850. egret.$markReadOnly(Point, "length");
  6851. }
  6852. /**
  6853. * @private
  6854. * 仅供框架内复用,要防止暴露引用到外部。
  6855. */
  6856. egret.$TempPoint = new Point();
  6857. })(egret || (egret = {}));
  6858. //////////////////////////////////////////////////////////////////////////////////////
  6859. //
  6860. // Copyright (c) 2014-present, Egret Technology.
  6861. // All rights reserved.
  6862. // Redistribution and use in source and binary forms, with or without
  6863. // modification, are permitted provided that the following conditions are met:
  6864. //
  6865. // * Redistributions of source code must retain the above copyright
  6866. // notice, this list of conditions and the following disclaimer.
  6867. // * Redistributions in binary form must reproduce the above copyright
  6868. // notice, this list of conditions and the following disclaimer in the
  6869. // documentation and/or other materials provided with the distribution.
  6870. // * Neither the name of the Egret nor the
  6871. // names of its contributors may be used to endorse or promote products
  6872. // derived from this software without specific prior written permission.
  6873. //
  6874. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  6875. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  6876. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  6877. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  6878. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  6879. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  6880. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  6881. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  6882. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  6883. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  6884. //
  6885. //////////////////////////////////////////////////////////////////////////////////////
  6886. var egret;
  6887. (function (egret) {
  6888. var sys;
  6889. (function (sys) {
  6890. /**
  6891. * @private
  6892. * 渲染节点基类
  6893. */
  6894. var RenderNode = (function () {
  6895. function RenderNode() {
  6896. /**
  6897. * 节点类型..
  6898. */
  6899. this.type = 0;
  6900. /**
  6901. * 是否需要重绘的标志。
  6902. */
  6903. this.needRedraw = false;
  6904. /**
  6905. * 这个对象在舞台上的整体透明度
  6906. */
  6907. this.renderAlpha = 1;
  6908. /**
  6909. * 这个对象在舞台上的透明度
  6910. */
  6911. this.renderVisible = true;
  6912. /**
  6913. * 相对于显示列表根节点或位图缓存根节点上的矩阵对象
  6914. */
  6915. this.renderMatrix = new egret.Matrix();
  6916. /**
  6917. * 此显示对象自身(不包括子项)在显示列表根节点或位图缓存根节点上的显示尺寸。
  6918. */
  6919. this.renderRegion = new sys.Region();
  6920. /**
  6921. * 是否发生移动
  6922. */
  6923. this.moved = false;
  6924. /**
  6925. * 绘制数据
  6926. */
  6927. this.drawData = [];
  6928. /**
  6929. * 绘制次数
  6930. */
  6931. this.renderCount = 0;
  6932. }
  6933. /**
  6934. * 在显示对象的$render()方法被调用前,自动清空自身的drawData数据。
  6935. */
  6936. RenderNode.prototype.cleanBeforeRender = function () {
  6937. this.drawData.length = 0;
  6938. this.renderCount = 0;
  6939. };
  6940. RenderNode.prototype.$getRenderCount = function () {
  6941. return this.renderCount;
  6942. };
  6943. return RenderNode;
  6944. }());
  6945. sys.RenderNode = RenderNode;
  6946. __reflect(RenderNode.prototype, "egret.sys.RenderNode");
  6947. })(sys = egret.sys || (egret.sys = {}));
  6948. })(egret || (egret = {}));
  6949. //////////////////////////////////////////////////////////////////////////////////////
  6950. //
  6951. // Copyright (c) 2014-present, Egret Technology.
  6952. // All rights reserved.
  6953. // Redistribution and use in source and binary forms, with or without
  6954. // modification, are permitted provided that the following conditions are met:
  6955. //
  6956. // * Redistributions of source code must retain the above copyright
  6957. // notice, this list of conditions and the following disclaimer.
  6958. // * Redistributions in binary form must reproduce the above copyright
  6959. // notice, this list of conditions and the following disclaimer in the
  6960. // documentation and/or other materials provided with the distribution.
  6961. // * Neither the name of the Egret nor the
  6962. // names of its contributors may be used to endorse or promote products
  6963. // derived from this software without specific prior written permission.
  6964. //
  6965. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  6966. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  6967. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  6968. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  6969. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  6970. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  6971. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  6972. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  6973. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  6974. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  6975. //
  6976. //////////////////////////////////////////////////////////////////////////////////////
  6977. var egret;
  6978. (function (egret) {
  6979. var sys;
  6980. (function (sys) {
  6981. /**
  6982. * @private
  6983. * 2D路径
  6984. */
  6985. var Path2D = (function () {
  6986. function Path2D() {
  6987. /**
  6988. * 路径类型
  6989. */
  6990. this.type = 0;
  6991. this.$commands = [];
  6992. this.$data = [];
  6993. this.commandPosition = 0;
  6994. this.dataPosition = 0;
  6995. /**
  6996. * 当前移动到的坐标X
  6997. * 注意:目前只有drawArc之前会被赋值
  6998. */
  6999. this.$lastX = 0;
  7000. /**
  7001. * 当前移动到的坐标Y
  7002. * 注意:目前只有drawArc之前会被赋值
  7003. */
  7004. this.$lastY = 0;
  7005. }
  7006. /**
  7007. * 将当前绘图位置移动到 (x, y)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。
  7008. * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。
  7009. * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。
  7010. */
  7011. Path2D.prototype.moveTo = function (x, y) {
  7012. this.$commands[this.commandPosition++] = 1 /* MoveTo */;
  7013. var pos = this.dataPosition;
  7014. this.$data[pos++] = x;
  7015. this.$data[pos++] = y;
  7016. this.dataPosition = pos;
  7017. };
  7018. /**
  7019. * 使用当前线条样式绘制一条从当前绘图位置开始到 (x, y) 结束的直线;当前绘图位置随后会设置为 (x, y)。
  7020. * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。
  7021. * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。
  7022. */
  7023. Path2D.prototype.lineTo = function (x, y) {
  7024. this.$commands[this.commandPosition++] = 2 /* LineTo */;
  7025. var pos = this.dataPosition;
  7026. this.$data[pos++] = x;
  7027. this.$data[pos++] = y;
  7028. this.dataPosition = pos;
  7029. };
  7030. /**
  7031. * 使用当前线条样式和由 (controlX, controlY) 指定的控制点绘制一条从当前绘图位置开始到 (anchorX, anchorY) 结束的二次贝塞尔曲线。当前绘图位置随后设置为 (anchorX, anchorY)。
  7032. * 如果在调用 moveTo() 方法之前调用了 curveTo() 方法,则当前绘图位置的默认值为 (0, 0)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。
  7033. * 绘制的曲线是二次贝塞尔曲线。二次贝塞尔曲线包含两个锚点和一个控制点。该曲线内插这两个锚点,并向控制点弯曲。
  7034. * @param controlX 一个数字,指定控制点相对于父显示对象注册点的水平位置。
  7035. * @param controlY 一个数字,指定控制点相对于父显示对象注册点的垂直位置。
  7036. * @param anchorX 一个数字,指定下一个锚点相对于父显示对象注册点的水平位置。
  7037. * @param anchorY 一个数字,指定下一个锚点相对于父显示对象注册点的垂直位置。
  7038. */
  7039. Path2D.prototype.curveTo = function (controlX, controlY, anchorX, anchorY) {
  7040. this.$commands[this.commandPosition++] = 3 /* CurveTo */;
  7041. var pos = this.dataPosition;
  7042. this.$data[pos++] = controlX;
  7043. this.$data[pos++] = controlY;
  7044. this.$data[pos++] = anchorX;
  7045. this.$data[pos++] = anchorY;
  7046. this.dataPosition = pos;
  7047. };
  7048. /**
  7049. * 从当前绘图位置到指定的锚点绘制一条三次贝塞尔曲线。三次贝塞尔曲线由两个锚点和两个控制点组成。该曲线内插这两个锚点,并向两个控制点弯曲。
  7050. * @param controlX1 指定首个控制点相对于父显示对象的注册点的水平位置。
  7051. * @param controlY1 指定首个控制点相对于父显示对象的注册点的垂直位置。
  7052. * @param controlX2 指定第二个控制点相对于父显示对象的注册点的水平位置。
  7053. * @param controlY2 指定第二个控制点相对于父显示对象的注册点的垂直位置。
  7054. * @param anchorX 指定锚点相对于父显示对象的注册点的水平位置。
  7055. * @param anchorY 指定锚点相对于父显示对象的注册点的垂直位置。
  7056. */
  7057. Path2D.prototype.cubicCurveTo = function (controlX1, controlY1, controlX2, controlY2, anchorX, anchorY) {
  7058. this.$commands[this.commandPosition++] = 4 /* CubicCurveTo */;
  7059. var pos = this.dataPosition;
  7060. this.$data[pos++] = controlX1;
  7061. this.$data[pos++] = controlY1;
  7062. this.$data[pos++] = controlX2;
  7063. this.$data[pos++] = controlY2;
  7064. this.$data[pos++] = anchorX;
  7065. this.$data[pos++] = anchorY;
  7066. this.dataPosition = pos;
  7067. };
  7068. /**
  7069. * 绘制一个矩形
  7070. * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。
  7071. * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。
  7072. * @param width 矩形的宽度(以像素为单位)。
  7073. * @param height 矩形的高度(以像素为单位)。
  7074. */
  7075. Path2D.prototype.drawRect = function (x, y, width, height) {
  7076. var x2 = x + width;
  7077. var y2 = y + height;
  7078. this.moveTo(x, y);
  7079. this.lineTo(x2, y);
  7080. this.lineTo(x2, y2);
  7081. this.lineTo(x, y2);
  7082. this.lineTo(x, y);
  7083. };
  7084. /**
  7085. * 绘制一个圆角矩形。
  7086. * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。
  7087. * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。
  7088. * @param width 矩形的宽度(以像素为单位)。
  7089. * @param height 矩形的高度(以像素为单位)。
  7090. * @param ellipseWidth 用于绘制圆角的椭圆的宽度(以像素为单位)。
  7091. * @param ellipseHeight 用于绘制圆角的椭圆的高度(以像素为单位)。 (可选)如果未指定值,则默认值与为 ellipseWidth 参数提供的值相匹配。
  7092. */
  7093. Path2D.prototype.drawRoundRect = function (x, y, width, height, ellipseWidth, ellipseHeight) {
  7094. var radiusX = (ellipseWidth * 0.5) | 0;
  7095. var radiusY = ellipseHeight ? (ellipseHeight * 0.5) | 0 : radiusX;
  7096. if (!radiusX || !radiusY) {
  7097. this.drawRect(x, y, width, height);
  7098. return;
  7099. }
  7100. var hw = width * 0.5;
  7101. var hh = height * 0.5;
  7102. if (radiusX > hw) {
  7103. radiusX = hw;
  7104. }
  7105. if (radiusY > hh) {
  7106. radiusY = hh;
  7107. }
  7108. if (hw === radiusX && hh === radiusY) {
  7109. if (radiusX === radiusY) {
  7110. this.drawCircle(x + radiusX, y + radiusY, radiusX);
  7111. }
  7112. else {
  7113. this.drawEllipse(x, y, radiusX * 2, radiusY * 2);
  7114. }
  7115. return;
  7116. }
  7117. // A-----B
  7118. // H C
  7119. // G D
  7120. // F-----E
  7121. // 从D点开始,结束在D点
  7122. var right = x + width;
  7123. var bottom = y + height;
  7124. var xlw = x + radiusX;
  7125. var xrw = right - radiusX;
  7126. var ytw = y + radiusY;
  7127. var ybw = bottom - radiusY;
  7128. this.moveTo(right, ybw);
  7129. this.curveTo(right, bottom, xrw, bottom);
  7130. this.lineTo(xlw, bottom);
  7131. this.curveTo(x, bottom, x, ybw);
  7132. this.lineTo(x, ytw);
  7133. this.curveTo(x, y, xlw, y);
  7134. this.lineTo(xrw, y);
  7135. this.curveTo(right, y, right, ytw);
  7136. this.lineTo(right, ybw);
  7137. };
  7138. /**
  7139. * 绘制一个圆。
  7140. * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。
  7141. * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。
  7142. * @param radius 圆的半径(以像素为单位)。
  7143. */
  7144. Path2D.prototype.drawCircle = function (x, y, radius) {
  7145. this.arcToBezier(x, y, radius, radius, 0, Math.PI * 2);
  7146. };
  7147. /**
  7148. * 绘制一个椭圆。
  7149. * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。
  7150. * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。
  7151. * @param width 矩形的宽度(以像素为单位)。
  7152. * @param height 矩形的高度(以像素为单位)。
  7153. */
  7154. Path2D.prototype.drawEllipse = function (x, y, width, height) {
  7155. var radiusX = width * 0.5;
  7156. var radiusY = height * 0.5;
  7157. // 移动x和y到椭圆的中心.
  7158. x += radiusX;
  7159. y += radiusY;
  7160. this.arcToBezier(x, y, radiusX, radiusY, 0, Math.PI * 2);
  7161. };
  7162. /**
  7163. * 绘制一段圆弧路径。圆弧路径的圆心在 (x, y) 位置,半径为 r ,根据anticlockwise (默认为顺时针)指定的方向从 startAngle 开始绘制,到 endAngle 结束。
  7164. * @param x 圆弧中心(圆心)的 x 轴坐标。
  7165. * @param y 圆弧中心(圆心)的 y 轴坐标。
  7166. * @param radius 圆弧的半径。
  7167. * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。
  7168. * 注意,必须在0~2π之间。
  7169. * @param endAngle 圆弧的终点, 单位以弧度表示。
  7170. * 注意,必须在0~2π之间。
  7171. * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。
  7172. */
  7173. Path2D.prototype.drawArc = function (x, y, radius, startAngle, endAngle, anticlockwise) {
  7174. if (anticlockwise) {
  7175. if (endAngle >= startAngle) {
  7176. endAngle -= Math.PI * 2;
  7177. }
  7178. }
  7179. else {
  7180. if (endAngle <= startAngle) {
  7181. endAngle += Math.PI * 2;
  7182. }
  7183. }
  7184. this.arcToBezier(x, y, radius, radius, startAngle, endAngle, anticlockwise);
  7185. };
  7186. /**
  7187. * 绘制一段圆弧路径
  7188. * @param x 圆弧中心(圆心)的 x 轴坐标。
  7189. * @param y 圆弧中心(圆心)的 y 轴坐标。
  7190. * @param radiusX 圆弧的半径 x。
  7191. * @param radiusY 圆弧的半径 y。
  7192. * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。
  7193. * 注意:必须为正数。
  7194. * @param endAngle 圆弧的终点, 单位以弧度表示。
  7195. * 注意:与startAngle差值必须在0~2π之间。
  7196. * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。
  7197. * 注意:如果为true,endAngle必须小于startAngle,反之必须大于。
  7198. */
  7199. Path2D.prototype.arcToBezier = function (x, y, radiusX, radiusY, startAngle, endAngle, anticlockwise) {
  7200. var halfPI = Math.PI * 0.5;
  7201. var start = startAngle;
  7202. var end = start;
  7203. if (anticlockwise) {
  7204. end += -halfPI - (start % halfPI);
  7205. if (end < endAngle) {
  7206. end = endAngle;
  7207. }
  7208. }
  7209. else {
  7210. end += halfPI - (start % halfPI);
  7211. if (end > endAngle) {
  7212. end = endAngle;
  7213. }
  7214. }
  7215. var currentX = x + Math.cos(start) * radiusX;
  7216. var currentY = y + Math.sin(start) * radiusY;
  7217. if (this.$lastX != currentX || this.$lastY != currentY) {
  7218. this.moveTo(currentX, currentY);
  7219. }
  7220. var u = Math.cos(start);
  7221. var v = Math.sin(start);
  7222. for (var i = 0; i < 4; i++) {
  7223. var addAngle = end - start;
  7224. var a = 4 * Math.tan(addAngle / 4) / 3;
  7225. var x1 = currentX - v * a * radiusX;
  7226. var y1 = currentY + u * a * radiusY;
  7227. u = Math.cos(end);
  7228. v = Math.sin(end);
  7229. currentX = x + u * radiusX;
  7230. currentY = y + v * radiusY;
  7231. var x2 = currentX + v * a * radiusX;
  7232. var y2 = currentY - u * a * radiusY;
  7233. this.cubicCurveTo(x1, y1, x2, y2, currentX, currentY);
  7234. if (end === endAngle) {
  7235. break;
  7236. }
  7237. start = end;
  7238. if (anticlockwise) {
  7239. end = start - halfPI;
  7240. if (end < endAngle) {
  7241. end = endAngle;
  7242. }
  7243. }
  7244. else {
  7245. end = start + halfPI;
  7246. if (end > endAngle) {
  7247. end = endAngle;
  7248. }
  7249. }
  7250. }
  7251. };
  7252. return Path2D;
  7253. }());
  7254. sys.Path2D = Path2D;
  7255. __reflect(Path2D.prototype, "egret.sys.Path2D");
  7256. })(sys = egret.sys || (egret.sys = {}));
  7257. })(egret || (egret = {}));
  7258. //////////////////////////////////////////////////////////////////////////////////////
  7259. //
  7260. // Copyright (c) 2014-present, Egret Technology.
  7261. // All rights reserved.
  7262. // Redistribution and use in source and binary forms, with or without
  7263. // modification, are permitted provided that the following conditions are met:
  7264. //
  7265. // * Redistributions of source code must retain the above copyright
  7266. // notice, this list of conditions and the following disclaimer.
  7267. // * Redistributions in binary form must reproduce the above copyright
  7268. // notice, this list of conditions and the following disclaimer in the
  7269. // documentation and/or other materials provided with the distribution.
  7270. // * Neither the name of the Egret nor the
  7271. // names of its contributors may be used to endorse or promote products
  7272. // derived from this software without specific prior written permission.
  7273. //
  7274. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  7275. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  7276. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  7277. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  7278. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  7279. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  7280. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  7281. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  7282. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  7283. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7284. //
  7285. //////////////////////////////////////////////////////////////////////////////////////
  7286. var egret;
  7287. (function (egret) {
  7288. /**
  7289. * @private
  7290. */
  7291. function createMap() {
  7292. var obj = Object.create(null);
  7293. obj.__v8__ = undefined;
  7294. delete obj.__v8__;
  7295. return obj;
  7296. }
  7297. egret.createMap = createMap;
  7298. })(egret || (egret = {}));
  7299. //////////////////////////////////////////////////////////////////////////////////////
  7300. //
  7301. // Copyright (c) 2014-present, Egret Technology.
  7302. // All rights reserved.
  7303. // Redistribution and use in source and binary forms, with or without
  7304. // modification, are permitted provided that the following conditions are met:
  7305. //
  7306. // * Redistributions of source code must retain the above copyright
  7307. // notice, this list of conditions and the following disclaimer.
  7308. // * Redistributions in binary form must reproduce the above copyright
  7309. // notice, this list of conditions and the following disclaimer in the
  7310. // documentation and/or other materials provided with the distribution.
  7311. // * Neither the name of the Egret nor the
  7312. // names of its contributors may be used to endorse or promote products
  7313. // derived from this software without specific prior written permission.
  7314. //
  7315. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  7316. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  7317. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  7318. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  7319. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  7320. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  7321. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  7322. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  7323. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  7324. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7325. //
  7326. //////////////////////////////////////////////////////////////////////////////////////
  7327. var egret;
  7328. (function (egret) {
  7329. /**
  7330. * @class egret.GlowFilter
  7331. * @classdesc
  7332. * 使用 GlowFilter 类可以对显示对象应用发光效果。在投影滤镜的 distance 和 angle 属性设置为 0 时,发光滤镜与投影滤镜极为相似。
  7333. * @extends egret.Filter
  7334. * @version Egret 3.1.4
  7335. * @platform Web,Native
  7336. */
  7337. var GlowFilter = (function (_super) {
  7338. __extends(GlowFilter, _super);
  7339. /**
  7340. * @language en_US
  7341. * Initializes a new GlowFilter instance.
  7342. * @method egret.GlowFilter#constructor
  7343. * @param color {number} The color of the glow. Valid values are in the hexadecimal format 0xRRGGBB. The default value is 0xFF0000.
  7344. * @param alpha {number} The alpha transparency value for the color. Valid values are 0 to 1. For example, .25 sets a transparency value of 25%. The default value is 1.
  7345. * @param blurX {number} The amount of horizontal blur. Valid values are 0 to 255 (floating point).
  7346. * @param blurY {number} The amount of vertical blur. Valid values are 0 to 255 (floating point).
  7347. * @param strength {number} The strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the glow and the background. Valid values are 0 to 255.
  7348. * @param quality {number} The number of times to apply the filter.
  7349. * @param inner {boolean} Specifies whether the glow is an inner glow. The value true indicates an inner glow. The default is false, an outer glow (a glow around the outer edges of the object).
  7350. * @param knockout {number} Specifies whether the object has a knockout effect. A value of true makes the object's fill transparent and reveals the background color of the document. The default value is false (no knockout effect).
  7351. * @version Egret 3.1.4
  7352. * @platform Web
  7353. */
  7354. /**
  7355. * @language zh_CN
  7356. * 初始化 GlowFilter 对象
  7357. * @method egret.GlowFilter#constructor
  7358. * @param color {number} 光晕颜色,采用十六进制格式 0xRRGGBB。默认值为 0xFF0000。
  7359. * @param alpha {number} 颜色的 Alpha 透明度值。有效值为 0 到 1。例如,0.25 设置透明度值为 25%。
  7360. * @param blurX {number} 水平模糊量。有效值为 0 到 255(浮点)。
  7361. * @param blurY {number} 垂直模糊量。有效值为 0 到 255(浮点)。
  7362. * @param strength {number} 印记或跨页的强度。该值越高,压印的颜色越深,而且发光与背景之间的对比度也越强。有效值为 0 到 255。
  7363. * @param quality {number} 应用滤镜的次数。暂未实现。
  7364. * @param inner {boolean} 指定发光是否为内侧发光。值 true 指定发光是内侧发光。值 false 指定发光是外侧发光(对象外缘周围的发光)。
  7365. * @param knockout {number} 指定对象是否具有挖空效果。值为 true 将使对象的填充变为透明,并显示文档的背景颜色。
  7366. * @version Egret 3.1.4
  7367. * @platform Web
  7368. */
  7369. function GlowFilter(color, alpha, blurX, blurY, strength, quality, inner, knockout) {
  7370. if (color === void 0) { color = 0xFF0000; }
  7371. if (alpha === void 0) { alpha = 1.0; }
  7372. if (blurX === void 0) { blurX = 6.0; }
  7373. if (blurY === void 0) { blurY = 6.0; }
  7374. if (strength === void 0) { strength = 2; }
  7375. if (quality === void 0) { quality = 1; }
  7376. if (inner === void 0) { inner = false; }
  7377. if (knockout === void 0) { knockout = false; }
  7378. var _this = _super.call(this) || this;
  7379. _this.type = "glow";
  7380. _this.$color = color;
  7381. _this.$blue = color & 0x0000FF;
  7382. _this.$green = (color & 0x00ff00) >> 8;
  7383. _this.$red = color >> 16;
  7384. _this.$alpha = alpha;
  7385. _this.$blurX = blurX;
  7386. _this.$blurY = blurY;
  7387. _this.$strength = strength;
  7388. _this.$quality = quality;
  7389. _this.$inner = inner;
  7390. _this.$knockout = knockout;
  7391. return _this;
  7392. }
  7393. Object.defineProperty(GlowFilter.prototype, "color", {
  7394. /**
  7395. * @language en_US
  7396. * The color of the glow.
  7397. * @version Egret 3.1.4
  7398. * @platform Web
  7399. */
  7400. /**
  7401. * @language zh_CN
  7402. * 光晕颜色。
  7403. * @version Egret 3.1.4
  7404. * @platform Web
  7405. */
  7406. get: function () {
  7407. return this.$color;
  7408. },
  7409. set: function (value) {
  7410. if (this.$color == value) {
  7411. return;
  7412. }
  7413. this.$color = value;
  7414. this.$blue = value & 0x0000FF;
  7415. this.$green = (value & 0x00ff00) >> 8;
  7416. this.$red = value >> 16;
  7417. this.invalidate();
  7418. },
  7419. enumerable: true,
  7420. configurable: true
  7421. });
  7422. Object.defineProperty(GlowFilter.prototype, "alpha", {
  7423. /**
  7424. * @language en_US
  7425. * The alpha transparency value for the color.
  7426. * @version Egret 3.1.4
  7427. * @platform Web
  7428. */
  7429. /**
  7430. * @language zh_CN
  7431. * 颜色的 Alpha 透明度值。
  7432. * @version Egret 3.1.4
  7433. * @platform Web
  7434. */
  7435. get: function () {
  7436. return this.$alpha;
  7437. },
  7438. set: function (value) {
  7439. if (this.$alpha == value) {
  7440. return;
  7441. }
  7442. this.$alpha = value;
  7443. this.invalidate();
  7444. },
  7445. enumerable: true,
  7446. configurable: true
  7447. });
  7448. Object.defineProperty(GlowFilter.prototype, "blurX", {
  7449. /**
  7450. * @language en_US
  7451. * The amount of horizontal blur.
  7452. * @version Egret 3.1.4
  7453. * @platform Web
  7454. */
  7455. /**
  7456. * @language zh_CN
  7457. * 水平模糊量。
  7458. * @version Egret 3.1.4
  7459. * @platform Web
  7460. */
  7461. get: function () {
  7462. return this.$blurX;
  7463. },
  7464. set: function (value) {
  7465. if (this.$blurX == value) {
  7466. return;
  7467. }
  7468. this.$blurX = value;
  7469. this.invalidate();
  7470. },
  7471. enumerable: true,
  7472. configurable: true
  7473. });
  7474. Object.defineProperty(GlowFilter.prototype, "blurY", {
  7475. /**
  7476. * @language en_US
  7477. * The amount of vertical blur.
  7478. * @version Egret 3.1.4
  7479. * @platform Web
  7480. */
  7481. /**
  7482. * @language zh_CN
  7483. * 垂直模糊量。
  7484. * @version Egret 3.1.4
  7485. * @platform Web
  7486. */
  7487. get: function () {
  7488. return this.$blurY;
  7489. },
  7490. set: function (value) {
  7491. if (this.$blurY == value) {
  7492. return;
  7493. }
  7494. this.$blurY = value;
  7495. this.invalidate();
  7496. },
  7497. enumerable: true,
  7498. configurable: true
  7499. });
  7500. Object.defineProperty(GlowFilter.prototype, "strength", {
  7501. /**
  7502. * @language en_US
  7503. * The strength of the imprint or spread.
  7504. * @version Egret 3.1.4
  7505. * @platform Web
  7506. */
  7507. /**
  7508. * @language zh_CN
  7509. * 印记或跨页的强度。
  7510. * @version Egret 3.1.4
  7511. * @platform Web
  7512. */
  7513. get: function () {
  7514. return this.$strength;
  7515. },
  7516. set: function (value) {
  7517. if (this.$strength == value) {
  7518. return;
  7519. }
  7520. this.$strength = value;
  7521. this.invalidate();
  7522. },
  7523. enumerable: true,
  7524. configurable: true
  7525. });
  7526. Object.defineProperty(GlowFilter.prototype, "quality", {
  7527. /**
  7528. * @language en_US
  7529. * The number of times to apply the filter.
  7530. * @version Egret 3.1.4
  7531. * @platform Web
  7532. */
  7533. /**
  7534. * @language zh_CN
  7535. * 应用滤镜的次数。
  7536. * @version Egret 3.1.4
  7537. * @platform Web
  7538. */
  7539. get: function () {
  7540. return this.$quality;
  7541. },
  7542. set: function (value) {
  7543. if (this.$quality == value) {
  7544. return;
  7545. }
  7546. this.$quality = value;
  7547. this.invalidate();
  7548. },
  7549. enumerable: true,
  7550. configurable: true
  7551. });
  7552. Object.defineProperty(GlowFilter.prototype, "inner", {
  7553. /**
  7554. * @language en_US
  7555. * Specifies whether the glow is an inner glow.
  7556. * @version Egret 3.1.4
  7557. * @platform Web
  7558. */
  7559. /**
  7560. * @language zh_CN
  7561. * 指定发光是否为内侧发光。
  7562. * @version Egret 3.1.4
  7563. * @platform Web
  7564. */
  7565. get: function () {
  7566. return this.$inner;
  7567. },
  7568. set: function (value) {
  7569. if (this.$inner == value) {
  7570. return;
  7571. }
  7572. this.$inner = value;
  7573. this.invalidate();
  7574. },
  7575. enumerable: true,
  7576. configurable: true
  7577. });
  7578. Object.defineProperty(GlowFilter.prototype, "knockout", {
  7579. /**
  7580. * @language en_US
  7581. * Specifies whether the object has a knockout effect.
  7582. * @version Egret 3.1.4
  7583. * @platform Web
  7584. */
  7585. /**
  7586. * @language zh_CN
  7587. * 指定对象是否具有挖空效果。
  7588. * @version Egret 3.1.4
  7589. * @platform Web
  7590. */
  7591. get: function () {
  7592. return this.$knockout;
  7593. },
  7594. set: function (value) {
  7595. if (this.$knockout == value) {
  7596. return;
  7597. }
  7598. this.$knockout = value;
  7599. this.invalidate();
  7600. },
  7601. enumerable: true,
  7602. configurable: true
  7603. });
  7604. /**
  7605. * @private
  7606. */
  7607. GlowFilter.prototype.$toJson = function () {
  7608. return '{"color": ' + this.$color + ', "red": ' + this.$red + ', "green": ' + this.$green + ', "blue": ' + this.$blue + ', "alpha": ' + this.$alpha + ', "blurX": ' + this.$blurX + ', "blurY": ' + this.blurY + ', "strength": ' + this.$strength + ', "quality": ' + this.$quality + ', "inner": ' + this.$inner + ', "knockout": ' + this.$knockout + '}';
  7609. };
  7610. return GlowFilter;
  7611. }(egret.Filter));
  7612. egret.GlowFilter = GlowFilter;
  7613. __reflect(GlowFilter.prototype, "egret.GlowFilter");
  7614. })(egret || (egret = {}));
  7615. //////////////////////////////////////////////////////////////////////////////////////
  7616. //
  7617. // Copyright (c) 2014-present, Egret Technology.
  7618. // All rights reserved.
  7619. // Redistribution and use in source and binary forms, with or without
  7620. // modification, are permitted provided that the following conditions are met:
  7621. //
  7622. // * Redistributions of source code must retain the above copyright
  7623. // notice, this list of conditions and the following disclaimer.
  7624. // * Redistributions in binary form must reproduce the above copyright
  7625. // notice, this list of conditions and the following disclaimer in the
  7626. // documentation and/or other materials provided with the distribution.
  7627. // * Neither the name of the Egret nor the
  7628. // names of its contributors may be used to endorse or promote products
  7629. // derived from this software without specific prior written permission.
  7630. //
  7631. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  7632. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  7633. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  7634. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  7635. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  7636. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  7637. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  7638. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  7639. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  7640. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7641. //
  7642. //////////////////////////////////////////////////////////////////////////////////////
  7643. var egret;
  7644. (function (egret) {
  7645. /**
  7646. * @language en_US
  7647. * The CapsStyle class is an enumeration of constant values that specify the caps style to use in drawing lines.
  7648. * The constants are provided for use as values in the caps parameter of the egret.Graphics.lineStyle() method.
  7649. * @see egret.Graphics#lineStyle()
  7650. * @version Egret 2.5
  7651. * @platform Web,Native
  7652. */
  7653. /**
  7654. * @language zh_CN
  7655. * CapsStyle 类是可指定在绘制线条中使用的端点样式的常量值枚举。常量可用作 egret.Graphics.lineStyle() 方法的 caps 参数中的值。
  7656. * @see egret.Graphics#lineStyle()
  7657. * @version Egret 2.5
  7658. * @platform Web,Native
  7659. */
  7660. egret.CapsStyle = {
  7661. /**
  7662. * @language en_US
  7663. * Used to specify no caps in the caps parameter of the egret.Graphics.lineStyle() method.
  7664. * @version Egret 2.5
  7665. * @platform Web,Native
  7666. */
  7667. /**
  7668. * @language zh_CN
  7669. * 用于在 egret.Graphics.lineStyle() 方法的 caps 参数中指定没有端点。
  7670. * @version Egret 2.5
  7671. * @platform Web,Native
  7672. */
  7673. NONE: "none",
  7674. /**
  7675. * @language en_US
  7676. * Used to specify round caps in the caps parameter of the egret.Graphics.lineStyle() method.
  7677. * @version Egret 2.5
  7678. * @platform Web,Native
  7679. */
  7680. /**
  7681. * @language zh_CN
  7682. * 用于在 egret.Graphics.lineStyle() 方法的 caps 参数中指定圆头端点。
  7683. * @version Egret 2.5
  7684. * @platform Web,Native
  7685. */
  7686. ROUND: "round",
  7687. /**
  7688. * @language en_US
  7689. * Used to specify square caps in the caps parameter of the egret.Graphics.lineStyle() method.
  7690. * @version Egret 2.5
  7691. * @platform Web,Native
  7692. */
  7693. /**
  7694. * @language zh_CN
  7695. * 用于在 egret.Graphics.lineStyle() 方法的 caps 参数中指定方头端点。
  7696. * @version Egret 2.5
  7697. * @platform Web,Native
  7698. */
  7699. SQUARE: "square"
  7700. };
  7701. })(egret || (egret = {}));
  7702. //////////////////////////////////////////////////////////////////////////////////////
  7703. //
  7704. // Copyright (c) 2014-present, Egret Technology.
  7705. // All rights reserved.
  7706. // Redistribution and use in source and binary forms, with or without
  7707. // modification, are permitted provided that the following conditions are met:
  7708. //
  7709. // * Redistributions of source code must retain the above copyright
  7710. // notice, this list of conditions and the following disclaimer.
  7711. // * Redistributions in binary form must reproduce the above copyright
  7712. // notice, this list of conditions and the following disclaimer in the
  7713. // documentation and/or other materials provided with the distribution.
  7714. // * Neither the name of the Egret nor the
  7715. // names of its contributors may be used to endorse or promote products
  7716. // derived from this software without specific prior written permission.
  7717. //
  7718. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  7719. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  7720. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  7721. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  7722. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  7723. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  7724. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  7725. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  7726. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  7727. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7728. //
  7729. //////////////////////////////////////////////////////////////////////////////////////
  7730. var egret;
  7731. (function (egret) {
  7732. /**
  7733. * @language en_US
  7734. * Values for the dirty region policy
  7735. * @version Egret 2.5
  7736. * @platform Web,Native
  7737. */
  7738. /**
  7739. * @language zh_CN
  7740. * 脏矩形策略常量。
  7741. * @version Egret 3.0
  7742. * @platform Web,Native
  7743. */
  7744. egret.DirtyRegionPolicy = {
  7745. /**
  7746. * @language en_US
  7747. * Close automatic detection of dirty region
  7748. * @version Egret 3.0
  7749. * @platform Web,Native
  7750. */
  7751. /**
  7752. * @language zh_CN
  7753. * 关闭自动脏矩形检测
  7754. * @version Egret 3.0
  7755. * @platform Web,Native
  7756. */
  7757. OFF: "off",
  7758. /**
  7759. * @language en_US
  7760. * Open automatic detection of dirty region
  7761. * @version Egret 3.0
  7762. * @platform Web,Native
  7763. */
  7764. /**
  7765. * @language zh_CN
  7766. * 开启自动脏矩形检测
  7767. * @version Egret 3.0
  7768. * @platform Web,Native
  7769. */
  7770. ON: "on"
  7771. };
  7772. })(egret || (egret = {}));
  7773. //////////////////////////////////////////////////////////////////////////////////////
  7774. //
  7775. // Copyright (c) 2014-present, Egret Technology.
  7776. // All rights reserved.
  7777. // Redistribution and use in source and binary forms, with or without
  7778. // modification, are permitted provided that the following conditions are met:
  7779. //
  7780. // * Redistributions of source code must retain the above copyright
  7781. // notice, this list of conditions and the following disclaimer.
  7782. // * Redistributions in binary form must reproduce the above copyright
  7783. // notice, this list of conditions and the following disclaimer in the
  7784. // documentation and/or other materials provided with the distribution.
  7785. // * Neither the name of the Egret nor the
  7786. // names of its contributors may be used to endorse or promote products
  7787. // derived from this software without specific prior written permission.
  7788. //
  7789. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  7790. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  7791. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  7792. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  7793. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  7794. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  7795. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  7796. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  7797. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  7798. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7799. //
  7800. //////////////////////////////////////////////////////////////////////////////////////
  7801. var egret;
  7802. (function (egret) {
  7803. /**
  7804. * @private
  7805. */
  7806. var WebGLUtils = (function () {
  7807. function WebGLUtils() {
  7808. }
  7809. WebGLUtils.compileProgram = function (gl, vertexSrc, fragmentSrc) {
  7810. var fragmentShader = WebGLUtils.compileFragmentShader(gl, fragmentSrc);
  7811. var vertexShader = WebGLUtils.compileVertexShader(gl, vertexSrc);
  7812. var shaderProgram = gl.createProgram();
  7813. gl.attachShader(shaderProgram, vertexShader);
  7814. gl.attachShader(shaderProgram, fragmentShader);
  7815. gl.linkProgram(shaderProgram);
  7816. if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
  7817. egret.$warn(1020);
  7818. }
  7819. return shaderProgram;
  7820. };
  7821. WebGLUtils.compileFragmentShader = function (gl, shaderSrc) {
  7822. return WebGLUtils._compileShader(gl, shaderSrc, gl.FRAGMENT_SHADER);
  7823. };
  7824. WebGLUtils.compileVertexShader = function (gl, shaderSrc) {
  7825. return WebGLUtils._compileShader(gl, shaderSrc, gl.VERTEX_SHADER);
  7826. };
  7827. WebGLUtils._compileShader = function (gl, shaderSrc, shaderType) {
  7828. var shader = gl.createShader(shaderType);
  7829. gl.shaderSource(shader, shaderSrc);
  7830. gl.compileShader(shader);
  7831. if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
  7832. //egret.info(gl.getShaderInfoLog(shader));
  7833. return null;
  7834. }
  7835. return shader;
  7836. };
  7837. WebGLUtils.checkCanUseWebGL = function () {
  7838. if (WebGLUtils.canUseWebGL == undefined) {
  7839. try {
  7840. var canvas = document.createElement("canvas");
  7841. WebGLUtils.canUseWebGL = !!window["WebGLRenderingContext"]
  7842. && !!(canvas.getContext("webgl") || canvas.getContext("experimental-webgl"));
  7843. }
  7844. catch (e) {
  7845. WebGLUtils.canUseWebGL = false;
  7846. }
  7847. }
  7848. return WebGLUtils.canUseWebGL;
  7849. };
  7850. WebGLUtils.deleteWebGLTexture = function (bitmapData) {
  7851. if (bitmapData) {
  7852. var gl = bitmapData.glContext;
  7853. if (gl) {
  7854. gl.deleteTexture(bitmapData);
  7855. }
  7856. }
  7857. };
  7858. return WebGLUtils;
  7859. }());
  7860. egret.WebGLUtils = WebGLUtils;
  7861. __reflect(WebGLUtils.prototype, "egret.WebGLUtils");
  7862. })(egret || (egret = {}));
  7863. //////////////////////////////////////////////////////////////////////////////////////
  7864. //
  7865. // Copyright (c) 2014-present, Egret Technology.
  7866. // All rights reserved.
  7867. // Redistribution and use in source and binary forms, with or without
  7868. // modification, are permitted provided that the following conditions are met:
  7869. //
  7870. // * Redistributions of source code must retain the above copyright
  7871. // notice, this list of conditions and the following disclaimer.
  7872. // * Redistributions in binary form must reproduce the above copyright
  7873. // notice, this list of conditions and the following disclaimer in the
  7874. // documentation and/or other materials provided with the distribution.
  7875. // * Neither the name of the Egret nor the
  7876. // names of its contributors may be used to endorse or promote products
  7877. // derived from this software without specific prior written permission.
  7878. //
  7879. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  7880. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  7881. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  7882. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  7883. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  7884. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  7885. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  7886. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  7887. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  7888. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7889. //
  7890. //////////////////////////////////////////////////////////////////////////////////////
  7891. //////////////////////////////////////////////////////////////////////////////////////
  7892. //
  7893. // Copyright (c) 2014-present, Egret Technology.
  7894. // All rights reserved.
  7895. // Redistribution and use in source and binary forms, with or without
  7896. // modification, are permitted provided that the following conditions are met:
  7897. //
  7898. // * Redistributions of source code must retain the above copyright
  7899. // notice, this list of conditions and the following disclaimer.
  7900. // * Redistributions in binary form must reproduce the above copyright
  7901. // notice, this list of conditions and the following disclaimer in the
  7902. // documentation and/or other materials provided with the distribution.
  7903. // * Neither the name of the Egret nor the
  7904. // names of its contributors may be used to endorse or promote products
  7905. // derived from this software without specific prior written permission.
  7906. //
  7907. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  7908. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  7909. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  7910. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  7911. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  7912. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  7913. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  7914. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  7915. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  7916. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7917. //
  7918. //////////////////////////////////////////////////////////////////////////////////////
  7919. var egret;
  7920. (function (egret) {
  7921. /**
  7922. * @language en_US
  7923. * When the user changes the focus from one object in the display list to another object, the object dispatches a FocusEvent object. Currently only supports input text.
  7924. * Focus events: FocusEvent.FOCUS_IN FocusEvent.FOCUS_OUT
  7925. * @version Egret 2.4
  7926. * @platform Web,Native
  7927. */
  7928. /**
  7929. * @language zh_CN
  7930. * 用户将焦点从显示列表中的一个对象更改到另一个对象时,对象将调度 FocusEvent 对象。目前只支持输入文本。
  7931. * 焦点事件:FocusEvent.FOCUS_IN FocusEvent.FOCUS_OUT
  7932. * @version Egret 2.4
  7933. * @platform Web,Native
  7934. */
  7935. var FocusEvent = (function (_super) {
  7936. __extends(FocusEvent, _super);
  7937. /**
  7938. * @language en_US
  7939. * Create a egret.FocusEvent objects
  7940. * @param type The type of the event, accessible as Event.type.
  7941. * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false.
  7942. * @param cancelable Determines whether the Event object can be canceled. The default values is false.
  7943. * @version Egret 2.4
  7944. * @platform Web,Native
  7945. */
  7946. /**
  7947. * @language zh_CN
  7948. * 创建一个 egret.FocusEvent 对象
  7949. * @param type 事件的类型,可以作为 Event.type 访问。
  7950. * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。
  7951. * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。
  7952. * @version Egret 2.4
  7953. * @platform Web,Native
  7954. */
  7955. function FocusEvent(type, bubbles, cancelable) {
  7956. if (bubbles === void 0) { bubbles = false; }
  7957. if (cancelable === void 0) { cancelable = false; }
  7958. return _super.call(this, type, bubbles, cancelable) || this;
  7959. }
  7960. return FocusEvent;
  7961. }(egret.Event));
  7962. /**
  7963. * @language en_US
  7964. * Gets focus
  7965. * @version Egret 2.4
  7966. * @platform Web,Native
  7967. */
  7968. /**
  7969. * @language zh_CN
  7970. * 获得焦点
  7971. * @version Egret 2.4
  7972. * @platform Web,Native
  7973. */
  7974. FocusEvent.FOCUS_IN = "focusIn";
  7975. /**
  7976. * @language en_US
  7977. * Loses focus
  7978. * @version Egret 2.4
  7979. * @platform Web,Native
  7980. */
  7981. /**
  7982. * @language zh_CN
  7983. * 失去焦点
  7984. * @version Egret 2.4
  7985. * @platform Web,Native
  7986. */
  7987. FocusEvent.FOCUS_OUT = "focusOut";
  7988. egret.FocusEvent = FocusEvent;
  7989. __reflect(FocusEvent.prototype, "egret.FocusEvent");
  7990. })(egret || (egret = {}));
  7991. //////////////////////////////////////////////////////////////////////////////////////
  7992. //
  7993. // Copyright (c) 2014-present, Egret Technology.
  7994. // All rights reserved.
  7995. // Redistribution and use in source and binary forms, with or without
  7996. // modification, are permitted provided that the following conditions are met:
  7997. //
  7998. // * Redistributions of source code must retain the above copyright
  7999. // notice, this list of conditions and the following disclaimer.
  8000. // * Redistributions in binary form must reproduce the above copyright
  8001. // notice, this list of conditions and the following disclaimer in the
  8002. // documentation and/or other materials provided with the distribution.
  8003. // * Neither the name of the Egret nor the
  8004. // names of its contributors may be used to endorse or promote products
  8005. // derived from this software without specific prior written permission.
  8006. //
  8007. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  8008. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  8009. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  8010. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  8011. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  8012. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  8013. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  8014. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  8015. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  8016. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8017. //
  8018. //////////////////////////////////////////////////////////////////////////////////////
  8019. var egret;
  8020. (function (egret) {
  8021. /**
  8022. * @language en_US
  8023. * The GeolocationEvent represents the position and altitude of the device on Earth,
  8024. * and show errors occurred while getting the location of the device.
  8025. * @version Egret 2.4
  8026. * @platform Web,Native
  8027. * @includeExample egret/sensor/Geolocation.ts
  8028. * @see http://edn.egret.com/cn/docs/page/662 获取位置信息
  8029. */
  8030. /**
  8031. * @language zh_CN
  8032. * GeolocationEvent 提供设备的地理位置信息和获取位置时发生的错误信息
  8033. * @version Egret 2.4
  8034. * @platform Web,Native
  8035. * @includeExample egret/sensor/Geolocation.ts
  8036. * @see http://edn.egret.com/cn/docs/page/662 获取位置信息
  8037. */
  8038. var GeolocationEvent = (function (_super) {
  8039. __extends(GeolocationEvent, _super);
  8040. function GeolocationEvent() {
  8041. return _super.apply(this, arguments) || this;
  8042. }
  8043. return GeolocationEvent;
  8044. }(egret.Event));
  8045. /**
  8046. * @language en_US
  8047. * The acquisition of the location information failed because of app don't have permission.
  8048. * @version Egret 2.4
  8049. * @platform Web,Native
  8050. */
  8051. /**
  8052. * @language zh_CN
  8053. * 由于用户拒绝访问位置信息,获取位置信息失败
  8054. * @version Egret 2.4
  8055. * @platform Web,Native
  8056. */
  8057. GeolocationEvent.PERMISSION_DENIED = "permissionDenied";
  8058. /**
  8059. * @language en_US
  8060. * The acquisition of the location failed because at least one internal source of position returned an internal error.
  8061. * @version Egret 2.4
  8062. * @platform Web,Native
  8063. */
  8064. /**
  8065. * @language zh_CN
  8066. * 设备位置服务不可用或者超时等原因没有得到位置信息
  8067. * @version Egret 2.4
  8068. * @platform Web,Native
  8069. */
  8070. GeolocationEvent.UNAVAILABLE = "unavailable";
  8071. egret.GeolocationEvent = GeolocationEvent;
  8072. __reflect(GeolocationEvent.prototype, "egret.GeolocationEvent");
  8073. })(egret || (egret = {}));
  8074. //////////////////////////////////////////////////////////////////////////////////////
  8075. //
  8076. // Copyright (c) 2014-present, Egret Technology.
  8077. // All rights reserved.
  8078. // Redistribution and use in source and binary forms, with or without
  8079. // modification, are permitted provided that the following conditions are met:
  8080. //
  8081. // * Redistributions of source code must retain the above copyright
  8082. // notice, this list of conditions and the following disclaimer.
  8083. // * Redistributions in binary form must reproduce the above copyright
  8084. // notice, this list of conditions and the following disclaimer in the
  8085. // documentation and/or other materials provided with the distribution.
  8086. // * Neither the name of the Egret nor the
  8087. // names of its contributors may be used to endorse or promote products
  8088. // derived from this software without specific prior written permission.
  8089. //
  8090. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  8091. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  8092. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  8093. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  8094. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  8095. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  8096. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  8097. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  8098. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  8099. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8100. //
  8101. //////////////////////////////////////////////////////////////////////////////////////
  8102. var egret;
  8103. (function (egret) {
  8104. /**
  8105. * @language en_US
  8106. * When a network request returns an HTTP status code, the application dispatches HTTPStatusEvent objects.
  8107. * Before error or completion events will always send HTTPStatusEvent object. HTTPStatusEvent object does not necessarily indicate an error condition; it simply reflects the HTTP status code provided by the network stack (if any).
  8108. * @version Egret 2.4
  8109. * @platform Web,Native
  8110. */
  8111. /**
  8112. * @language zh_CN
  8113. * 在网络请求返回 HTTP 状态代码时,应用程序将调度 HTTPStatusEvent 对象。
  8114. * 在错误或完成事件之前,将始终发送 HTTPStatusEvent 对象。HTTPStatusEvent 对象不一定表示错误条件;它仅反映网络堆栈提供的 HTTP 状态代码(如果有的话)。
  8115. * @version Egret 2.4
  8116. * @platform Web,Native
  8117. */
  8118. var HTTPStatusEvent = (function (_super) {
  8119. __extends(HTTPStatusEvent, _super);
  8120. /**
  8121. * @language en_US
  8122. * Create a egret.HTTPStatusEvent objects
  8123. * @param type The type of the event, accessible as Event.type.
  8124. * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false.
  8125. * @param cancelable Determines whether the Event object can be canceled. The default values is false.
  8126. * @version Egret 2.4
  8127. * @platform Web,Native
  8128. */
  8129. /**
  8130. * @language zh_CN
  8131. * 创建一个 egret.HTTPStatusEvent 对象
  8132. * @param type 事件的类型,可以作为 Event.type 访问。
  8133. * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。
  8134. * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。
  8135. * @version Egret 2.4
  8136. * @platform Web,Native
  8137. */
  8138. function HTTPStatusEvent(type, bubbles, cancelable) {
  8139. if (bubbles === void 0) { bubbles = false; }
  8140. if (cancelable === void 0) { cancelable = false; }
  8141. var _this = _super.call(this, type, bubbles, cancelable) || this;
  8142. /**
  8143. * @private
  8144. */
  8145. _this._status = 0;
  8146. return _this;
  8147. }
  8148. Object.defineProperty(HTTPStatusEvent.prototype, "status", {
  8149. /**
  8150. * @language en_US
  8151. * he server returns the HTTP status code.
  8152. * @version Egret 2.4
  8153. * @platform Web,Native
  8154. */
  8155. /**
  8156. * @language zh_CN
  8157. * 由服务器返回的 HTTP 状态代码。
  8158. * @version Egret 2.4
  8159. * @platform Web,Native
  8160. */
  8161. get: function () {
  8162. return this._status;
  8163. },
  8164. enumerable: true,
  8165. configurable: true
  8166. });
  8167. /**
  8168. * @language en_US
  8169. * EventDispatcher object using the specified event object thrown Event. The objects will be thrown in the object cache pool for the next round robin.
  8170. * @param target {egret.IEventDispatcher} Distribute event target
  8171. * @param status {number} The server returns the HTTP status code
  8172. * @version Egret 2.4
  8173. * @platform Web,Native
  8174. */
  8175. /**
  8176. * @language zh_CN
  8177. * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。
  8178. * @param target {egret.IEventDispatcher} 派发事件目标
  8179. * @param status {number} 由服务器返回的 HTTP 状态代码
  8180. * @version Egret 2.4
  8181. * @platform Web,Native
  8182. */
  8183. HTTPStatusEvent.dispatchHTTPStatusEvent = function (target, status) {
  8184. var event = egret.Event.create(HTTPStatusEvent, HTTPStatusEvent.HTTP_STATUS);
  8185. event._status = status;
  8186. var result = target.dispatchEvent(event);
  8187. egret.Event.release(event);
  8188. return result;
  8189. };
  8190. return HTTPStatusEvent;
  8191. }(egret.Event));
  8192. /**
  8193. * @language en_US
  8194. * HTTPStatusEvent.HTTP_STATUS constant defines the value of the type property httpStatus event object.
  8195. * @version Egret 2.4
  8196. * @platform Web,Native
  8197. */
  8198. /**
  8199. * @language zh_CN
  8200. * HTTPStatusEvent.HTTP_STATUS 常量定义 httpStatus 事件对象的 type 属性值。
  8201. * @version Egret 2.4
  8202. * @platform Web,Native
  8203. */
  8204. HTTPStatusEvent.HTTP_STATUS = "httpStatus";
  8205. egret.HTTPStatusEvent = HTTPStatusEvent;
  8206. __reflect(HTTPStatusEvent.prototype, "egret.HTTPStatusEvent");
  8207. })(egret || (egret = {}));
  8208. //////////////////////////////////////////////////////////////////////////////////////
  8209. //
  8210. // Copyright (c) 2014-present, Egret Technology.
  8211. // All rights reserved.
  8212. // Redistribution and use in source and binary forms, with or without
  8213. // modification, are permitted provided that the following conditions are met:
  8214. //
  8215. // * Redistributions of source code must retain the above copyright
  8216. // notice, this list of conditions and the following disclaimer.
  8217. // * Redistributions in binary form must reproduce the above copyright
  8218. // notice, this list of conditions and the following disclaimer in the
  8219. // documentation and/or other materials provided with the distribution.
  8220. // * Neither the name of the Egret nor the
  8221. // names of its contributors may be used to endorse or promote products
  8222. // derived from this software without specific prior written permission.
  8223. //
  8224. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  8225. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  8226. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  8227. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  8228. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  8229. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  8230. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  8231. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  8232. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  8233. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8234. //
  8235. //////////////////////////////////////////////////////////////////////////////////////
  8236. //////////////////////////////////////////////////////////////////////////////////////
  8237. //
  8238. // Copyright (c) 2014-present, Egret Technology.
  8239. // All rights reserved.
  8240. // Redistribution and use in source and binary forms, with or without
  8241. // modification, are permitted provided that the following conditions are met:
  8242. //
  8243. // * Redistributions of source code must retain the above copyright
  8244. // notice, this list of conditions and the following disclaimer.
  8245. // * Redistributions in binary form must reproduce the above copyright
  8246. // notice, this list of conditions and the following disclaimer in the
  8247. // documentation and/or other materials provided with the distribution.
  8248. // * Neither the name of the Egret nor the
  8249. // names of its contributors may be used to endorse or promote products
  8250. // derived from this software without specific prior written permission.
  8251. //
  8252. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  8253. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  8254. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  8255. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  8256. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  8257. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  8258. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  8259. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  8260. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  8261. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8262. //
  8263. //////////////////////////////////////////////////////////////////////////////////////
  8264. var egret;
  8265. (function (egret) {
  8266. /**
  8267. * @language en_US
  8268. * @classdesc IO流事件,当错误导致输入或输出操作失败时调度 IOErrorEvent 对象。
  8269. * @version Egret 2.4
  8270. * @platform Web,Native
  8271. * @includeExample egret/events/IOErrorEvent.ts
  8272. */
  8273. /**
  8274. * @language zh_CN
  8275. * @classdesc IO流事件,当错误导致输入或输出操作失败时调度 IOErrorEvent 对象。
  8276. * @version Egret 2.4
  8277. * @platform Web,Native
  8278. * @includeExample egret/events/IOErrorEvent.ts
  8279. */
  8280. var IOErrorEvent = (function (_super) {
  8281. __extends(IOErrorEvent, _super);
  8282. /**
  8283. * @language en_US
  8284. * Create a egret.IOErrorEvent objects
  8285. * @param type {string} Type of event, accessible as Event.type.
  8286. * @param bubbles {boolean} Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false.
  8287. * @param cancelable {boolean} Determine whether the Event object can be canceled. The default value is false.
  8288. * @version Egret 2.4
  8289. * @platform Web,Native
  8290. */
  8291. /**
  8292. * @language zh_CN
  8293. * 创建一个 egret.IOErrorEvent 对象
  8294. * @param type {string} 事件的类型,可以作为 Event.type 访问。
  8295. * @param bubbles {boolean} 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。
  8296. * @param cancelable {boolean} 确定是否可以取消 Event 对象。默认值为 false。
  8297. * @version Egret 2.4
  8298. * @platform Web,Native
  8299. */
  8300. function IOErrorEvent(type, bubbles, cancelable) {
  8301. if (bubbles === void 0) { bubbles = false; }
  8302. if (cancelable === void 0) { cancelable = false; }
  8303. return _super.call(this, type, bubbles, cancelable) || this;
  8304. }
  8305. /**
  8306. * @language en_US
  8307. * EventDispatcher object using the specified event object thrown Event. The objects will be thrown in the object cache pool for the next round robin.
  8308. * @param target {egret.IEventDispatcher} Distribute event target
  8309. * @version Egret 2.4
  8310. * @platform Web,Native
  8311. */
  8312. /**
  8313. * @language zh_CN
  8314. * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。
  8315. * @param target {egret.IEventDispatcher} 派发事件目标
  8316. * @version Egret 2.4
  8317. * @platform Web,Native
  8318. */
  8319. IOErrorEvent.dispatchIOErrorEvent = function (target) {
  8320. var event = egret.Event.create(IOErrorEvent, IOErrorEvent.IO_ERROR);
  8321. var result = target.dispatchEvent(event);
  8322. egret.Event.release(event);
  8323. return result;
  8324. };
  8325. return IOErrorEvent;
  8326. }(egret.Event));
  8327. /**
  8328. * @language en_US
  8329. * io error
  8330. * @version Egret 2.4
  8331. * @platform Web,Native
  8332. */
  8333. /**
  8334. * @language zh_CN
  8335. * io发生错误
  8336. * @version Egret 2.4
  8337. * @platform Web,Native
  8338. */
  8339. IOErrorEvent.IO_ERROR = "ioError";
  8340. egret.IOErrorEvent = IOErrorEvent;
  8341. __reflect(IOErrorEvent.prototype, "egret.IOErrorEvent");
  8342. })(egret || (egret = {}));
  8343. //////////////////////////////////////////////////////////////////////////////////////
  8344. //
  8345. // Copyright (c) 2014-present, Egret Technology.
  8346. // All rights reserved.
  8347. // Redistribution and use in source and binary forms, with or without
  8348. // modification, are permitted provided that the following conditions are met:
  8349. //
  8350. // * Redistributions of source code must retain the above copyright
  8351. // notice, this list of conditions and the following disclaimer.
  8352. // * Redistributions in binary form must reproduce the above copyright
  8353. // notice, this list of conditions and the following disclaimer in the
  8354. // documentation and/or other materials provided with the distribution.
  8355. // * Neither the name of the Egret nor the
  8356. // names of its contributors may be used to endorse or promote products
  8357. // derived from this software without specific prior written permission.
  8358. //
  8359. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  8360. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  8361. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  8362. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  8363. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  8364. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  8365. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  8366. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  8367. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  8368. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8369. //
  8370. //////////////////////////////////////////////////////////////////////////////////////
  8371. var egret;
  8372. (function (egret) {
  8373. /**
  8374. * @language en_US
  8375. * MotionEvent represents the device's movement
  8376. * Acceleration and accelerationIncludingGravity to represents the device's acceleration
  8377. * RotationRate to represents the device's rotation
  8378. * @version Egret 2.4
  8379. * @platform Web,Native
  8380. * @includeExample egret/sensor/Motion.ts
  8381. */
  8382. /**
  8383. * @language zh_CN
  8384. * MotionEvent 类呈现设备运动的具体信息
  8385. * Acceleration 和 accelerationIncludingGravity 呈现设备三个维度的加速度信息
  8386. * RotationRate 呈现设备的旋转状态信息
  8387. * @version Egret 2.4
  8388. * @platform Web,Native
  8389. * @includeExample egret/sensor/Motion.ts
  8390. */
  8391. var MotionEvent = (function (_super) {
  8392. __extends(MotionEvent, _super);
  8393. function MotionEvent() {
  8394. return _super.apply(this, arguments) || this;
  8395. }
  8396. return MotionEvent;
  8397. }(egret.Event));
  8398. egret.MotionEvent = MotionEvent;
  8399. __reflect(MotionEvent.prototype, "egret.MotionEvent");
  8400. })(egret || (egret = {}));
  8401. //////////////////////////////////////////////////////////////////////////////////////
  8402. //
  8403. // Copyright (c) 2014-present, Egret Technology.
  8404. // All rights reserved.
  8405. // Redistribution and use in source and binary forms, with or without
  8406. // modification, are permitted provided that the following conditions are met:
  8407. //
  8408. // * Redistributions of source code must retain the above copyright
  8409. // notice, this list of conditions and the following disclaimer.
  8410. // * Redistributions in binary form must reproduce the above copyright
  8411. // notice, this list of conditions and the following disclaimer in the
  8412. // documentation and/or other materials provided with the distribution.
  8413. // * Neither the name of the Egret nor the
  8414. // names of its contributors may be used to endorse or promote products
  8415. // derived from this software without specific prior written permission.
  8416. //
  8417. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  8418. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  8419. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  8420. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  8421. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  8422. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  8423. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  8424. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  8425. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  8426. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8427. //
  8428. //////////////////////////////////////////////////////////////////////////////////////
  8429. var egret;
  8430. (function (egret) {
  8431. /**
  8432. * @language en_US
  8433. * The OrientationEvent provides information from the physical orientation of the device.
  8434. * Note: Currently, Browsers on the iOS and Android does not handle the coordinates the same way.
  8435. * Take care about this while using them.
  8436. * @version Egret 2.4
  8437. * @platform Web,Native
  8438. * @includeExample egret/sensor/DeviceOrientation.ts
  8439. */
  8440. /**
  8441. * @language zh_CN
  8442. * OrientationEvent 提供设备的方向信息
  8443. * 注意: 目前各个浏览器和操作系统处理方向的方式不完全相同,请根据使用场景做相应的校正,
  8444. * 比如使用两次方向数据的变化而不是直接使用方向的值
  8445. * @version Egret 2.4
  8446. * @platform Web,Native
  8447. * @includeExample egret/sensor/DeviceOrientation.ts
  8448. */
  8449. var OrientationEvent = (function (_super) {
  8450. __extends(OrientationEvent, _super);
  8451. function OrientationEvent() {
  8452. return _super.apply(this, arguments) || this;
  8453. }
  8454. return OrientationEvent;
  8455. }(egret.Event));
  8456. egret.OrientationEvent = OrientationEvent;
  8457. __reflect(OrientationEvent.prototype, "egret.OrientationEvent");
  8458. })(egret || (egret = {}));
  8459. //////////////////////////////////////////////////////////////////////////////////////
  8460. //
  8461. // Copyright (c) 2014-present, Egret Technology.
  8462. // All rights reserved.
  8463. // Redistribution and use in source and binary forms, with or without
  8464. // modification, are permitted provided that the following conditions are met:
  8465. //
  8466. // * Redistributions of source code must retain the above copyright
  8467. // notice, this list of conditions and the following disclaimer.
  8468. // * Redistributions in binary form must reproduce the above copyright
  8469. // notice, this list of conditions and the following disclaimer in the
  8470. // documentation and/or other materials provided with the distribution.
  8471. // * Neither the name of the Egret nor the
  8472. // names of its contributors may be used to endorse or promote products
  8473. // derived from this software without specific prior written permission.
  8474. //
  8475. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  8476. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  8477. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  8478. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  8479. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  8480. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  8481. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  8482. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  8483. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  8484. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8485. //
  8486. //////////////////////////////////////////////////////////////////////////////////////
  8487. var egret;
  8488. (function (egret) {
  8489. /**
  8490. * @language en_US
  8491. * When a load operation has begun or a socket has received data, ProgressEvent object is dispatched.
  8492. * There are two types of progress events: ProgressEvent.PROGRESS and ProgressEvent.SOCKET_DATA.
  8493. * @version Egret 2.4
  8494. * @platform Web,Native
  8495. */
  8496. /**
  8497. * @language zh_CN
  8498. * 当加载操作已开始或套接字已接收到数据时,将调度 ProgressEvent 对象。
  8499. * 有两种类型的进程事件:ProgressEvent.PROGRESS 和 ProgressEvent.SOCKET_DATA。
  8500. * @version Egret 2.4
  8501. * @platform Web,Native
  8502. */
  8503. var ProgressEvent = (function (_super) {
  8504. __extends(ProgressEvent, _super);
  8505. /**
  8506. * @language en_US
  8507. * 创建一个 egret.ProgressEvent 对象
  8508. * @param type The type of the event, accessible as Event.type.
  8509. * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false.
  8510. * @param cancelable Determines whether the Event object can be canceled. The default values is false.
  8511. * @param bytesLoaded {number} Number of items or bytes loaded
  8512. * @param bytesTotal {number} The total number of items or bytes loaded
  8513. * @version Egret 2.4
  8514. * @platform Web,Native
  8515. */
  8516. /**
  8517. * @language zh_CN
  8518. * 创建一个 egret.ProgressEvent 对象
  8519. * @param type 事件的类型,可以作为 Event.type 访问。
  8520. * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。
  8521. * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。
  8522. * @param bytesLoaded {number} 加载的项数或字节数
  8523. * @param bytesTotal {number} 加载的总项数或总字节数
  8524. * @version Egret 2.4
  8525. * @platform Web,Native
  8526. */
  8527. function ProgressEvent(type, bubbles, cancelable, bytesLoaded, bytesTotal) {
  8528. if (bubbles === void 0) { bubbles = false; }
  8529. if (cancelable === void 0) { cancelable = false; }
  8530. if (bytesLoaded === void 0) { bytesLoaded = 0; }
  8531. if (bytesTotal === void 0) { bytesTotal = 0; }
  8532. var _this = _super.call(this, type, bubbles, cancelable) || this;
  8533. /**
  8534. * @language en_US
  8535. * Number of items or bytes when the listener processes the event。
  8536. * @version Egret 2.4
  8537. * @platform Web,Native
  8538. */
  8539. /**
  8540. * @language zh_CN
  8541. * 在侦听器处理事件时加载的项数或字节数。
  8542. * @version Egret 2.4
  8543. * @platform Web,Native
  8544. */
  8545. _this.bytesLoaded = 0;
  8546. /**
  8547. * @language en_US
  8548. * If the loading process succeeds, the total number or the total number of bytes that will be loaded term.
  8549. * @version Egret 2.4
  8550. * @platform Web,Native
  8551. */
  8552. /**
  8553. * @language zh_CN
  8554. * 如果加载过程成功,将加载的总项数或总字节数。
  8555. * @version Egret 2.4
  8556. * @platform Web,Native
  8557. */
  8558. _this.bytesTotal = 0;
  8559. _this.bytesLoaded = bytesLoaded;
  8560. _this.bytesTotal = bytesTotal;
  8561. return _this;
  8562. }
  8563. /**
  8564. * @language en_US
  8565. * EventDispatcher object using the specified event object thrown Event. The objects will be thrown in the object cache pool for the next round robin.
  8566. * @param target {egret.IEventDispatcher} Distribute event target
  8567. * @param type The type of the event, accessible as Event.type.
  8568. * @param bytesLoaded {number} Number of items or bytes loaded
  8569. * @param bytesTotal {number} The total number of items or bytes loaded
  8570. * @version Egret 2.4
  8571. * @platform Web,Native
  8572. */
  8573. /**
  8574. * @language zh_CN
  8575. * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。
  8576. * @param target {egret.IEventDispatcher} 派发事件目标
  8577. * @param type {string} 事件类型
  8578. * @param bytesLoaded {number} 加载的项数或字节数
  8579. * @param bytesTotal {number} 加载的总项数或总字节数
  8580. * @version Egret 2.4
  8581. * @platform Web,Native
  8582. */
  8583. ProgressEvent.dispatchProgressEvent = function (target, type, bytesLoaded, bytesTotal) {
  8584. if (bytesLoaded === void 0) { bytesLoaded = 0; }
  8585. if (bytesTotal === void 0) { bytesTotal = 0; }
  8586. var event = egret.Event.create(ProgressEvent, type);
  8587. event.bytesLoaded = bytesLoaded;
  8588. event.bytesTotal = bytesTotal;
  8589. var result = target.dispatchEvent(event);
  8590. egret.Event.release(event);
  8591. return result;
  8592. };
  8593. return ProgressEvent;
  8594. }(egret.Event));
  8595. /**
  8596. * @language en_US
  8597. * Changes in the loading progress
  8598. * @version Egret 2.4
  8599. * @platform Web,Native
  8600. */
  8601. /**
  8602. * @language zh_CN
  8603. * 加载进度发生变化
  8604. * @version Egret 2.4
  8605. * @platform Web,Native
  8606. */
  8607. ProgressEvent.PROGRESS = "progress";
  8608. /**
  8609. * @language en_US
  8610. * Get the data
  8611. * @version Egret 2.4
  8612. * @platform Web,Native
  8613. */
  8614. /**
  8615. * @language zh_CN
  8616. * 获取到数据
  8617. * @version Egret 2.4
  8618. * @platform Web,Native
  8619. */
  8620. ProgressEvent.SOCKET_DATA = "socketData";
  8621. egret.ProgressEvent = ProgressEvent;
  8622. __reflect(ProgressEvent.prototype, "egret.ProgressEvent");
  8623. })(egret || (egret = {}));
  8624. //////////////////////////////////////////////////////////////////////////////////////
  8625. //
  8626. // Copyright (c) 2014-present, Egret Technology.
  8627. // All rights reserved.
  8628. // Redistribution and use in source and binary forms, with or without
  8629. // modification, are permitted provided that the following conditions are met:
  8630. //
  8631. // * Redistributions of source code must retain the above copyright
  8632. // notice, this list of conditions and the following disclaimer.
  8633. // * Redistributions in binary form must reproduce the above copyright
  8634. // notice, this list of conditions and the following disclaimer in the
  8635. // documentation and/or other materials provided with the distribution.
  8636. // * Neither the name of the Egret nor the
  8637. // names of its contributors may be used to endorse or promote products
  8638. // derived from this software without specific prior written permission.
  8639. //
  8640. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  8641. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  8642. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  8643. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  8644. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  8645. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  8646. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  8647. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  8648. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  8649. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8650. //
  8651. //////////////////////////////////////////////////////////////////////////////////////
  8652. var egret;
  8653. (function (egret) {
  8654. /**
  8655. * @language en_US
  8656. * When the direction of the stage of change, Stage object dispatches StageOrientationEvent object.
  8657. * @version Egret 2.4
  8658. * @platform Web,Native
  8659. * @includeExample egret/events/StageOrientationEvent.ts
  8660. */
  8661. /**
  8662. * @language zh_CN
  8663. * 当舞台的方向更改时,Stage 对象将调度 StageOrientationEvent 对象。
  8664. * @version Egret 2.4
  8665. * @platform Web,Native
  8666. * @includeExample egret/events/StageOrientationEvent.ts
  8667. */
  8668. var StageOrientationEvent = (function (_super) {
  8669. __extends(StageOrientationEvent, _super);
  8670. /**
  8671. * @language en_US
  8672. * Creating contains specific information related to the event and the stage direction of StageOrientationEvent object.
  8673. * @param type Event types:StageOrientationEvent.ORIENTATION_CHANGE
  8674. * @param bubbles It indicates whether the Event object participates in the bubbling stage of the event flow.
  8675. * @param cancelable It indicates whether the Event object can be canceled.
  8676. * @version Egret 2.4
  8677. * @platform Web,Native
  8678. */
  8679. /**
  8680. * @language zh_CN
  8681. * 创建包含与舞台方向事件相关的特定信息的 StageOrientationEvent 对象。
  8682. * @param type 事件的类型:StageOrientationEvent.ORIENTATION_CHANGE
  8683. * @param bubbles 表示 Event 对象是否参与事件流的冒泡阶段。
  8684. * @param cancelable 表示是否可以取消 Event 对象。
  8685. * @version Egret 2.4
  8686. * @platform Web,Native
  8687. */
  8688. function StageOrientationEvent(type, bubbles, cancelable) {
  8689. if (bubbles === void 0) { bubbles = false; }
  8690. if (cancelable === void 0) { cancelable = false; }
  8691. return _super.call(this, type, bubbles, cancelable) || this;
  8692. }
  8693. /**
  8694. * @language en_US
  8695. * 派发一个屏幕旋转的事件。
  8696. * @param target {egret.IEventDispatcher} 派发事件目标
  8697. * @param type {egret.IEventDispatcher} 派发事件类型
  8698. * @version Egret 2.4
  8699. * @platform Web,Native
  8700. */
  8701. /**
  8702. * @language zh_CN
  8703. * 派发一个屏幕旋转的事件。
  8704. * @param target {egret.IEventDispatcher} Distribute event target
  8705. * @param type {egret.IEventDispatcher} Distribute event type
  8706. * @version Egret 2.4
  8707. * @platform Web,Native
  8708. */
  8709. StageOrientationEvent.dispatchStageOrientationEvent = function (target, type) {
  8710. var event = egret.Event.create(StageOrientationEvent, type);
  8711. var result = target.dispatchEvent(event);
  8712. egret.Event.release(event);
  8713. return result;
  8714. };
  8715. return StageOrientationEvent;
  8716. }(egret.Event));
  8717. /**
  8718. * @language en_US
  8719. * After screen rotation distribute events.
  8720. * @version Egret 2.4
  8721. * @platform Web,Native
  8722. */
  8723. /**
  8724. * @language zh_CN
  8725. * 屏幕旋转后派发的事件。
  8726. * @version Egret 2.4
  8727. * @platform Web,Native
  8728. */
  8729. StageOrientationEvent.ORIENTATION_CHANGE = "orientationChange";
  8730. egret.StageOrientationEvent = StageOrientationEvent;
  8731. __reflect(StageOrientationEvent.prototype, "egret.StageOrientationEvent");
  8732. })(egret || (egret = {}));
  8733. //////////////////////////////////////////////////////////////////////////////////////
  8734. //
  8735. // Copyright (c) 2014-present, Egret Technology.
  8736. // All rights reserved.
  8737. // Redistribution and use in source and binary forms, with or without
  8738. // modification, are permitted provided that the following conditions are met:
  8739. //
  8740. // * Redistributions of source code must retain the above copyright
  8741. // notice, this list of conditions and the following disclaimer.
  8742. // * Redistributions in binary form must reproduce the above copyright
  8743. // notice, this list of conditions and the following disclaimer in the
  8744. // documentation and/or other materials provided with the distribution.
  8745. // * Neither the name of the Egret nor the
  8746. // names of its contributors may be used to endorse or promote products
  8747. // derived from this software without specific prior written permission.
  8748. //
  8749. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  8750. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  8751. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  8752. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  8753. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  8754. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  8755. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  8756. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  8757. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  8758. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8759. //
  8760. //////////////////////////////////////////////////////////////////////////////////////
  8761. var egret;
  8762. (function (egret) {
  8763. /**
  8764. * @language en_US
  8765. * When a user clicks a hyperlink rich text object dispatches TextEvent object. Text Event Type: TextEvent.LINK.
  8766. * @version Egret 2.4
  8767. * @platform Web,Native
  8768. * @includeExample egret/events/TextEvent.ts
  8769. */
  8770. /**
  8771. * @language zh_CN
  8772. * 用户在富文本中单击超链接时,对象将调度 TextEvent 对象。文本事件类型:TextEvent.LINK。
  8773. * @version Egret 2.4
  8774. * @platform Web,Native
  8775. * @includeExample egret/events/TextEvent.ts
  8776. */
  8777. var TextEvent = (function (_super) {
  8778. __extends(TextEvent, _super);
  8779. /**
  8780. * @language en_US
  8781. * TextEvent create an object that contains information about text events.
  8782. * @param type Type of event, you can access the TextEvent.type.
  8783. * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false.
  8784. * @param cancelable Determine whether the Event object can be canceled. The default value is false.
  8785. * @param text One or more characters of text entered by the user. Event listeners can access this information through the text property.
  8786. * @version Egret 2.4
  8787. * @platform Web,Native
  8788. */
  8789. /**
  8790. * @language zh_CN
  8791. * 创建一个 TextEvent 对象,其中包含有关文本事件的信息。
  8792. * @param type 事件的类型,可以作为 TextEvent.type 访问。
  8793. * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。
  8794. * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。
  8795. * @param text 用户输入的一个或多个文本字符。事件侦听器可以通过 text 属性访问此信息。
  8796. * @version Egret 2.4
  8797. * @platform Web,Native
  8798. */
  8799. function TextEvent(type, bubbles, cancelable, text) {
  8800. if (bubbles === void 0) { bubbles = false; }
  8801. if (cancelable === void 0) { cancelable = false; }
  8802. if (text === void 0) { text = ""; }
  8803. var _this = _super.call(this, type, bubbles, cancelable) || this;
  8804. _this.text = text;
  8805. return _this;
  8806. }
  8807. /**
  8808. * @language en_US
  8809. * EventDispatcher object using the specified event object thrown TextEvent. The objects will be thrown in the object cache pool for the next round robin.
  8810. * @param type The type of the event, accessible as Event.type.
  8811. * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false.
  8812. * @param text Text TextEvent object assignment
  8813. * @version Egret 2.4
  8814. * @platform Web,Native
  8815. */
  8816. /**
  8817. * @language zh_CN
  8818. * 使用指定的EventDispatcher对象来抛出TextEvent事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。
  8819. * @param target 派发事件目标
  8820. * @param type 事件类型
  8821. * @param text TextEvent对象的text赋值
  8822. * @version Egret 2.4
  8823. * @platform Web,Native
  8824. */
  8825. TextEvent.dispatchTextEvent = function (target, type, text) {
  8826. var event = egret.Event.create(TextEvent, type);
  8827. event.text = text;
  8828. var result = target.dispatchEvent(event);
  8829. egret.Event.release(event);
  8830. return result;
  8831. };
  8832. return TextEvent;
  8833. }(egret.Event));
  8834. /**
  8835. * @language en_US
  8836. * It defines the value of the type property of a link event object.
  8837. * @version Egret 2.4
  8838. * @platform Web,Native
  8839. */
  8840. /**
  8841. * @language zh_CN
  8842. * 定义 link 事件对象的 type 属性值。
  8843. * @version Egret 2.4
  8844. * @platform Web,Native
  8845. */
  8846. TextEvent.LINK = "link";
  8847. egret.TextEvent = TextEvent;
  8848. __reflect(TextEvent.prototype, "egret.TextEvent");
  8849. })(egret || (egret = {}));
  8850. //////////////////////////////////////////////////////////////////////////////////////
  8851. //
  8852. // Copyright (c) 2014-present, Egret Technology.
  8853. // All rights reserved.
  8854. // Redistribution and use in source and binary forms, with or without
  8855. // modification, are permitted provided that the following conditions are met:
  8856. //
  8857. // * Redistributions of source code must retain the above copyright
  8858. // notice, this list of conditions and the following disclaimer.
  8859. // * Redistributions in binary form must reproduce the above copyright
  8860. // notice, this list of conditions and the following disclaimer in the
  8861. // documentation and/or other materials provided with the distribution.
  8862. // * Neither the name of the Egret nor the
  8863. // names of its contributors may be used to endorse or promote products
  8864. // derived from this software without specific prior written permission.
  8865. //
  8866. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  8867. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  8868. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  8869. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  8870. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  8871. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  8872. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  8873. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  8874. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  8875. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8876. //
  8877. //////////////////////////////////////////////////////////////////////////////////////
  8878. var egret;
  8879. (function (egret) {
  8880. /**
  8881. * @language en_US
  8882. * A Timer object dispatches a TimerEvent objects whenever the Timer object reaches the interval specified by the Timer.delay property.
  8883. * @see egret.Timer
  8884. * @version Egret 2.4
  8885. * @platform Web,Native
  8886. * @includeExample egret/events/TimerEvent.ts
  8887. */
  8888. /**
  8889. * @language zh_CN
  8890. * 每当 Timer 对象达到由 Timer.delay 属性指定的间隔时,Timer 对象即会调度 TimerEvent 对象。
  8891. * @see egret.Timer
  8892. * @version Egret 2.4
  8893. * @platform Web,Native
  8894. * @includeExample egret/events/TimerEvent.ts
  8895. */
  8896. var TimerEvent = (function (_super) {
  8897. __extends(TimerEvent, _super);
  8898. /**
  8899. * @language en_US
  8900. * Creates an Event object with specific information relevant to timer events.
  8901. * @param type The type of the event. Event listeners can access this information through the inherited type property.
  8902. * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through
  8903. * the inherited bubbles property.
  8904. * @param cancelable Determines whether the Event object can be canceled. Event listeners can access this information
  8905. * through the inherited cancelable property.
  8906. * @version Egret 2.4
  8907. * @platform Web,Native
  8908. */
  8909. /**
  8910. * @language zh_CN
  8911. * 创建一个 Event 对象,其中包含有关 timer 事件的特定信息。
  8912. * @param type 事件的类型。事件侦听器可以通过继承的 type 属性访问此信息。
  8913. * @param bubbles 确定 Event 对象是否冒泡。事件侦听器可以通过继承的 bubbles 属性访问此信息。
  8914. * @param cancelable 确定是否可以取消 Event 对象。事件侦听器可以通过继承的 cancelable 属性访问此信息。
  8915. * @version Egret 2.4
  8916. * @platform Web,Native
  8917. */
  8918. function TimerEvent(type, bubbles, cancelable) {
  8919. return _super.call(this, type, bubbles, cancelable) || this;
  8920. }
  8921. /**
  8922. * @language en_US
  8923. * Instructs Egret runtime to render after processing of this event completes, if the display list has been modified.
  8924. * @example
  8925. * <pre>
  8926. * function onTimer(event:TimerEvent):void {
  8927. * if (40 < mySp.x && mySp.x < 375) {
  8928. * mySp.x-= 50;
  8929. * } else {
  8930. * mySp.x=374;
  8931. * }
  8932. * event.updateAfterEvent();
  8933. * }
  8934. *
  8935. * let moveTimer:Timer=new Timer(50,250);
  8936. * moveTimer.addEventListener(TimerEvent.TIMER,onTimer);
  8937. * moveTimer.start();
  8938. * </pre>
  8939. * @version Egret 2.4
  8940. * @platform Web,Native
  8941. */
  8942. /**
  8943. * @language zh_CN
  8944. * 如果已修改显示列表,调用此方法将会忽略帧频限制,在此事件处理完成后立即重绘屏幕。
  8945. * @example
  8946. * <pre>
  8947. * function onTimer(event:TimerEvent):void {
  8948. * if (40 < mySp.x && mySp.x < 375) {
  8949. * mySp.x-= 50;
  8950. * } else {
  8951. * mySp.x=374;
  8952. * }
  8953. * event.updateAfterEvent();
  8954. * }
  8955. *
  8956. * let moveTimer:Timer=new Timer(50,250);
  8957. * moveTimer.addEventListener(TimerEvent.TIMER,onTimer);
  8958. * moveTimer.start();
  8959. * </pre>
  8960. * @version Egret 2.4
  8961. * @platform Web,Native
  8962. */
  8963. TimerEvent.prototype.updateAfterEvent = function () {
  8964. egret.sys.$requestRenderingFlag = true;
  8965. };
  8966. /**
  8967. * @language en_US
  8968. * uses a specified target to dispatchEvent an event. Using this method can reduce the number of
  8969. * reallocate event objects, which allows you to get better code execution performance.
  8970. * @param target the event target
  8971. * @param type The type of the event. Event listeners can access this information through the inherited type property.
  8972. * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through
  8973. * the inherited bubbles property.
  8974. * @param cancelable Determines whether the Event object can be canceled. Event listeners can access this information
  8975. * through the inherited cancelable property.
  8976. * @see egret.Event.create()
  8977. * @see egret.Event.release()
  8978. * @version Egret 2.4
  8979. * @platform Web,Native
  8980. */
  8981. /**
  8982. * @language zh_CN
  8983. * 使用指定的EventDispatcher对象来抛出事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。
  8984. * @param target 事件派发目标
  8985. * @param type 事件的类型。事件侦听器可以通过继承的 type 属性访问此信息。
  8986. * @param bubbles 确定 Event 对象是否冒泡。事件侦听器可以通过继承的 bubbles 属性访问此信息。
  8987. * @param cancelable 确定是否可以取消 Event 对象。事件侦听器可以通过继承的 cancelable 属性访问此信息。
  8988. * @see egret.Event.create()
  8989. * @see egret.Event.release()
  8990. * @version Egret 2.4
  8991. * @platform Web,Native
  8992. */
  8993. TimerEvent.dispatchTimerEvent = function (target, type, bubbles, cancelable) {
  8994. var event = egret.Event.create(TimerEvent, type, bubbles, cancelable);
  8995. var result = target.dispatchEvent(event);
  8996. egret.Event.release(event);
  8997. return result;
  8998. };
  8999. return TimerEvent;
  9000. }(egret.Event));
  9001. /**
  9002. * @language en_US
  9003. * Dispatched whenever a Timer object reaches an interval specified according to the Timer.delay property.
  9004. * @version Egret 2.4
  9005. * @platform Web,Native
  9006. */
  9007. /**
  9008. * @language zh_CN
  9009. * 每当 Timer 对象达到根据 Timer.delay 属性指定的间隔时调度。
  9010. * @version Egret 2.4
  9011. * @platform Web,Native
  9012. */
  9013. TimerEvent.TIMER = "timer";
  9014. /**
  9015. * @language en_US
  9016. * Dispatched whenever it has completed the number of requests set by Timer.repeatCount.
  9017. * @version Egret 2.4
  9018. * @platform Web,Native
  9019. */
  9020. /**
  9021. * @language zh_CN
  9022. * 每当它完成 Timer.repeatCount 设置的请求数后调度。
  9023. * @version Egret 2.4
  9024. * @platform Web,Native
  9025. */
  9026. TimerEvent.TIMER_COMPLETE = "timerComplete";
  9027. egret.TimerEvent = TimerEvent;
  9028. __reflect(TimerEvent.prototype, "egret.TimerEvent");
  9029. })(egret || (egret = {}));
  9030. //////////////////////////////////////////////////////////////////////////////////////
  9031. //
  9032. // Copyright (c) 2014-present, Egret Technology.
  9033. // All rights reserved.
  9034. // Redistribution and use in source and binary forms, with or without
  9035. // modification, are permitted provided that the following conditions are met:
  9036. //
  9037. // * Redistributions of source code must retain the above copyright
  9038. // notice, this list of conditions and the following disclaimer.
  9039. // * Redistributions in binary form must reproduce the above copyright
  9040. // notice, this list of conditions and the following disclaimer in the
  9041. // documentation and/or other materials provided with the distribution.
  9042. // * Neither the name of the Egret nor the
  9043. // names of its contributors may be used to endorse or promote products
  9044. // derived from this software without specific prior written permission.
  9045. //
  9046. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  9047. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  9048. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  9049. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  9050. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9051. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  9052. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  9053. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  9054. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  9055. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9056. //
  9057. //////////////////////////////////////////////////////////////////////////////////////
  9058. var egret;
  9059. (function (egret) {
  9060. /**
  9061. * @language en_US
  9062. * A BitmapData object contains an array of pixel data. This data can represent either a fully opaque bitmap or a
  9063. * transparent bitmap that contains alpha channel data. Either type of BitmapData object is stored as a buffer of 32-bit
  9064. * integers. Each 32-bit integer determines the properties of a single pixel in the bitmap.<br/>
  9065. * Each 32-bit integer is a combination of four 8-bit channel values (from 0 to 255) that describe the alpha transparency
  9066. * and the red, green, and blue (ARGB) values of the pixel. (For ARGB values, the most significant byte represents the
  9067. * alpha channel value, followed by red, green, and blue.)
  9068. * @see egret.Bitmap
  9069. * @version Egret 2.4
  9070. * @platform Web,Native
  9071. */
  9072. /**
  9073. * @language zh_CN
  9074. * BitmapData 对象是一个包含像素数据的数组。此数据可以表示完全不透明的位图,或表示包含 Alpha 通道数据的透明位图。
  9075. * 以上任一类型的 BitmapData 对象都作为 32 位整数的缓冲区进行存储。每个 32 位整数确定位图中单个像素的属性。<br/>
  9076. * 每个 32 位整数都是四个 8 位通道值(从 0 到 255)的组合,这些值描述像素的 Alpha 透明度以及红色、绿色、蓝色 (ARGB) 值。
  9077. * (对于 ARGB 值,最高有效字节代表 Alpha 通道值,其后的有效字节分别代表红色、绿色和蓝色通道值。)
  9078. * @see egret.Bitmap
  9079. * @version Egret 2.4
  9080. * @platform Web,Native
  9081. */
  9082. var BitmapData = (function (_super) {
  9083. __extends(BitmapData, _super);
  9084. function BitmapData(source) {
  9085. var _this = _super.call(this) || this;
  9086. /**
  9087. * @language en_US
  9088. * Texture format.
  9089. * @version Egret 2.4
  9090. * @platform Web,Native
  9091. */
  9092. /**
  9093. * @language zh_CN
  9094. * 纹理格式。
  9095. * @version Egret 2.4
  9096. * @platform Web,Native
  9097. */
  9098. _this.format = "image";
  9099. /**
  9100. * @private
  9101. * webgl纹理生成后,是否删掉原始图像数据
  9102. */
  9103. _this.$deleteSource = true;
  9104. _this.source = source;
  9105. _this.width = source.width;
  9106. _this.height = source.height;
  9107. return _this;
  9108. }
  9109. BitmapData.prototype.$dispose = function () {
  9110. if (egret.Capabilities.runtimeType == egret.RuntimeType.WEB && egret.Capabilities.renderMode == "webgl" && this.webGLTexture) {
  9111. egret.WebGLUtils.deleteWebGLTexture(this.webGLTexture);
  9112. this.webGLTexture = null;
  9113. }
  9114. //native
  9115. if (this.source && this.source.dispose) {
  9116. this.source.dispose();
  9117. }
  9118. this.source = null;
  9119. BitmapData.$dispose(this);
  9120. };
  9121. BitmapData.$addDisplayObject = function (displayObject, bitmapData) {
  9122. var hashCode;
  9123. if (bitmapData._bitmapData && bitmapData._bitmapData.hashCode) {
  9124. hashCode = bitmapData._bitmapData.hashCode;
  9125. }
  9126. else {
  9127. hashCode = bitmapData.hashCode;
  9128. }
  9129. if (!hashCode) {
  9130. return;
  9131. }
  9132. if (!BitmapData._displayList[hashCode]) {
  9133. BitmapData._displayList[hashCode] = [displayObject];
  9134. return;
  9135. }
  9136. var tempList = BitmapData._displayList[hashCode];
  9137. if (tempList.indexOf(displayObject) < 0) {
  9138. tempList.push(displayObject);
  9139. }
  9140. };
  9141. BitmapData.$removeDisplayObject = function (displayObject, bitmapData) {
  9142. var hashCode;
  9143. if (bitmapData._bitmapData && bitmapData._bitmapData.hashCode) {
  9144. hashCode = bitmapData._bitmapData.hashCode;
  9145. }
  9146. else {
  9147. hashCode = bitmapData.hashCode;
  9148. }
  9149. if (!hashCode) {
  9150. return;
  9151. }
  9152. if (!BitmapData._displayList[hashCode]) {
  9153. return;
  9154. }
  9155. var tempList = BitmapData._displayList[hashCode];
  9156. var index = tempList.indexOf(displayObject);
  9157. if (index >= 0) {
  9158. tempList.splice(index);
  9159. }
  9160. };
  9161. BitmapData.$invalidate = function (bitmapData) {
  9162. var hashCode;
  9163. if (bitmapData._bitmapData && bitmapData._bitmapData.hashCode) {
  9164. hashCode = bitmapData._bitmapData.hashCode;
  9165. }
  9166. else {
  9167. hashCode = bitmapData.hashCode;
  9168. }
  9169. if (!hashCode) {
  9170. return;
  9171. }
  9172. if (!BitmapData._displayList[hashCode]) {
  9173. return;
  9174. }
  9175. var tempList = BitmapData._displayList[hashCode];
  9176. for (var i = 0; i < tempList.length; i++) {
  9177. if (tempList[i] instanceof egret.Bitmap) {
  9178. tempList[i].$refreshImageData();
  9179. }
  9180. tempList[i].$invalidateContentBounds();
  9181. }
  9182. };
  9183. BitmapData.$dispose = function (bitmapData) {
  9184. var hashCode;
  9185. if (bitmapData._bitmapData && bitmapData._bitmapData.hashCode) {
  9186. hashCode = bitmapData._bitmapData.hashCode;
  9187. }
  9188. else {
  9189. hashCode = bitmapData.hashCode;
  9190. }
  9191. if (!hashCode) {
  9192. return;
  9193. }
  9194. if (!BitmapData._displayList[hashCode]) {
  9195. return;
  9196. }
  9197. var tempList = BitmapData._displayList[hashCode];
  9198. for (var i = 0; i < tempList.length; i++) {
  9199. if (tempList[i] instanceof egret.Bitmap) {
  9200. tempList[i].$Bitmap[1 /* image */] = null;
  9201. }
  9202. tempList[i].$invalidateContentBounds();
  9203. }
  9204. delete BitmapData._displayList[hashCode];
  9205. };
  9206. return BitmapData;
  9207. }(egret.HashObject));
  9208. BitmapData._displayList = egret.createMap();
  9209. egret.BitmapData = BitmapData;
  9210. __reflect(BitmapData.prototype, "egret.BitmapData");
  9211. })(egret || (egret = {}));
  9212. //////////////////////////////////////////////////////////////////////////////////////
  9213. //
  9214. // Copyright (c) 2014-present, Egret Technology.
  9215. // All rights reserved.
  9216. // Redistribution and use in source and binary forms, with or without
  9217. // modification, are permitted provided that the following conditions are met:
  9218. //
  9219. // * Redistributions of source code must retain the above copyright
  9220. // notice, this list of conditions and the following disclaimer.
  9221. // * Redistributions in binary form must reproduce the above copyright
  9222. // notice, this list of conditions and the following disclaimer in the
  9223. // documentation and/or other materials provided with the distribution.
  9224. // * Neither the name of the Egret nor the
  9225. // names of its contributors may be used to endorse or promote products
  9226. // derived from this software without specific prior written permission.
  9227. //
  9228. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  9229. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  9230. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  9231. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  9232. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9233. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  9234. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  9235. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  9236. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  9237. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9238. //
  9239. //////////////////////////////////////////////////////////////////////////////////////
  9240. /// <reference path="../geom/Point.ts" />
  9241. var egret;
  9242. (function (egret) {
  9243. var localPoint = new egret.Point();
  9244. /**
  9245. * @language en_US
  9246. * The TouchEvent class lets you handle events on devices that detect user contact with the device (such as a finger
  9247. * on a touch screen).When a user interacts with a device such as a mobile phone or tablet with a touch screen, the
  9248. * user typically touches the screen with his or her fingers or a pointing device. You can develop applications that
  9249. * respond to basic touch events (such as a single finger tap) with the TouchEvent class. Create event listeners using
  9250. * the event types defined in this class.
  9251. * Note: When objects are nested on the display list, touch events target the deepest possible nested object that is
  9252. * visible in the display list. This object is called the target node. To have a target node's ancestor (an object
  9253. * containing the target node in the display list) receive notification of a touch event, use EventDispatcher.addEventListener()
  9254. * on the ancestor node with the type parameter set to the specific touch event you want to detect.
  9255. *
  9256. * @version Egret 2.4
  9257. * @platform Web,Native
  9258. * @includeExample egret/events/TouchEvent.ts
  9259. */
  9260. /**
  9261. * @language zh_CN
  9262. * 使用 TouchEvent 类,您可以处理设备上那些检测用户与设备之间的接触的事件。
  9263. * 当用户与带有触摸屏的移动电话或平板电脑等设备交互时,用户通常使用手指或指针设备接触屏幕。可使用 TouchEvent
  9264. * 类开发响应基本触摸事件(如单个手指点击)的应用程序。使用此类中定义的事件类型创建事件侦听器。
  9265. * 注意:当对象嵌套在显示列表中时,触摸事件的目标将是显示列表中可见的最深的可能嵌套对象。
  9266. * 此对象称为目标节点。要使目标节点的祖代(祖代是一个包含显示列表中所有目标节点的对象,从舞台到目标节点的父节点均包括在内)
  9267. * 接收触摸事件的通知,请对祖代节点使用 EventDispatcher.on() 并将 type 参数设置为要检测的特定触摸事件。
  9268. *
  9269. * @version Egret 2.4
  9270. * @platform Web,Native
  9271. * @includeExample egret/events/TouchEvent.ts
  9272. */
  9273. var TouchEvent = (function (_super) {
  9274. __extends(TouchEvent, _super);
  9275. /**
  9276. * @language en_US
  9277. * Creates an Event object that contains information about touch events.
  9278. * @param type The type of the event, accessible as Event.type.
  9279. * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false.
  9280. * @param cancelable Determines whether the Event object can be canceled. The default values is false.
  9281. * @param stageX The horizontal coordinate at which the event occurred in global Stage coordinates.
  9282. * @param stageY The vertical coordinate at which the event occurred in global Stage coordinates.
  9283. * @param touchPointID A unique identification number assigned to the touch point.
  9284. * @version Egret 2.4
  9285. * @platform Web,Native
  9286. */
  9287. /**
  9288. * @language zh_CN
  9289. * 创建一个 TouchEvent 对象,其中包含有关Touch事件的信息
  9290. * @param type 事件的类型,可以作为 Event.type 访问。
  9291. * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。
  9292. * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。
  9293. * @param stageX 事件发生点在全局舞台坐标系中的水平坐标
  9294. * @param stageY 事件发生点在全局舞台坐标系中的垂直坐标
  9295. * @param touchPointID 分配给触摸点的唯一标识号
  9296. * @version Egret 2.4
  9297. * @platform Web,Native
  9298. */
  9299. function TouchEvent(type, bubbles, cancelable, stageX, stageY, touchPointID) {
  9300. var _this = _super.call(this, type, bubbles, cancelable) || this;
  9301. _this.targetChanged = true;
  9302. /**
  9303. * @language en_US
  9304. * Whether the touch is pressed (true) or not pressed (false).
  9305. * @version Egret 2.4
  9306. * @platform Web,Native
  9307. */
  9308. /**
  9309. * @language zh_CN
  9310. * 表示触摸已按下 (true) 还是未按下 (false)。
  9311. * @version Egret 2.4
  9312. * @platform Web,Native
  9313. */
  9314. _this.touchDown = false;
  9315. _this.$initTo(stageX, stageY, touchPointID);
  9316. return _this;
  9317. }
  9318. /**
  9319. * @private
  9320. */
  9321. TouchEvent.prototype.$initTo = function (stageX, stageY, touchPointID) {
  9322. this.touchPointID = +touchPointID || 0;
  9323. this.$stageX = +stageX || 0;
  9324. this.$stageY = +stageY || 0;
  9325. };
  9326. Object.defineProperty(TouchEvent.prototype, "stageX", {
  9327. /**
  9328. * @language en_US
  9329. * The horizontal coordinate at which the event occurred in global Stage coordinates.
  9330. * @version Egret 2.4
  9331. * @platform Web,Native
  9332. */
  9333. /**
  9334. * @language zh_CN
  9335. * 事件发生点在全局舞台坐标中的水平坐标。
  9336. * @version Egret 2.4
  9337. * @platform Web,Native
  9338. */
  9339. get: function () {
  9340. return this.$stageX;
  9341. },
  9342. enumerable: true,
  9343. configurable: true
  9344. });
  9345. Object.defineProperty(TouchEvent.prototype, "stageY", {
  9346. /**
  9347. * @language en_US
  9348. * The vertical coordinate at which the event occurred in global Stage coordinates.
  9349. * @version Egret 2.4
  9350. * @platform Web,Native
  9351. */
  9352. /**
  9353. * @language zh_CN
  9354. * 事件发生点在全局舞台坐标中的垂直坐标。
  9355. * @version Egret 2.4
  9356. * @platform Web,Native
  9357. */
  9358. get: function () {
  9359. return this.$stageY;
  9360. },
  9361. enumerable: true,
  9362. configurable: true
  9363. });
  9364. Object.defineProperty(TouchEvent.prototype, "localX", {
  9365. /**
  9366. * @language en_US
  9367. * The horizontal coordinate at which the event occurred relative to the display object.
  9368. * @version Egret 2.4
  9369. * @platform Web,Native
  9370. */
  9371. /**
  9372. * @language zh_CN
  9373. * 事件发生点相对于所属显示对象的水平坐标。
  9374. * @version Egret 2.4
  9375. * @platform Web,Native
  9376. */
  9377. get: function () {
  9378. if (this.targetChanged) {
  9379. this.getLocalXY();
  9380. }
  9381. return this._localX;
  9382. },
  9383. enumerable: true,
  9384. configurable: true
  9385. });
  9386. Object.defineProperty(TouchEvent.prototype, "localY", {
  9387. /**
  9388. * @language en_US
  9389. * The vertical coordinate at which the event occurred relative to the display object.
  9390. * @version Egret 2.4
  9391. * @platform Web,Native
  9392. */
  9393. /**
  9394. * @language zh_CN
  9395. * 事件发生点相对于所属显示对象的垂直坐标。
  9396. * @version Egret 2.4
  9397. * @platform Web,Native
  9398. */
  9399. get: function () {
  9400. if (this.targetChanged) {
  9401. this.getLocalXY();
  9402. }
  9403. return this._localY;
  9404. },
  9405. enumerable: true,
  9406. configurable: true
  9407. });
  9408. /**
  9409. * @private
  9410. */
  9411. TouchEvent.prototype.getLocalXY = function () {
  9412. this.targetChanged = false;
  9413. var m = this.$target.$getInvertedConcatenatedMatrix();
  9414. m.transformPoint(this.$stageX, this.$stageY, localPoint);
  9415. this._localX = localPoint.x;
  9416. this._localY = localPoint.y;
  9417. };
  9418. TouchEvent.prototype.$setTarget = function (target) {
  9419. this.$target = target;
  9420. this.targetChanged = !!target;
  9421. return true;
  9422. };
  9423. /**
  9424. * @language en_US
  9425. * Instructs Egret runtime to render after processing of this event completes, if the display list has been modified.
  9426. * @version Egret 2.4
  9427. * @platform Web,Native
  9428. */
  9429. /**
  9430. * @language zh_CN
  9431. * 如果已修改显示列表,调用此方法将会忽略帧频限制,在此事件处理完成后立即重绘屏幕。
  9432. * @version Egret 2.4
  9433. * @platform Web,Native
  9434. */
  9435. TouchEvent.prototype.updateAfterEvent = function () {
  9436. egret.sys.$requestRenderingFlag = true;
  9437. };
  9438. /**
  9439. * @language en_US
  9440. * uses a specified target to dispatchEvent an event. Using this method can reduce the number of
  9441. * reallocate event objects, which allows you to get better code execution performance.
  9442. * @param target the event target
  9443. * @param type The type of the event, accessible as Event.type.
  9444. * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false.
  9445. * @param cancelable Determines whether the Event object can be canceled. The default values is false.
  9446. * @param stageX The horizontal coordinate at which the event occurred in global Stage coordinates.
  9447. * @param stageY The vertical coordinate at which the event occurred in global Stage coordinates.
  9448. * @param touchPointID A unique identification number (as an int) assigned to the touch point.
  9449. *
  9450. * @see egret.Event.create()
  9451. * @see egret.Event.release()
  9452. *
  9453. * @version Egret 2.4
  9454. * @platform Web,Native
  9455. */
  9456. /**
  9457. * @language zh_CN
  9458. * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。
  9459. * @param target 派发事件目标
  9460. * @param type 事件的类型,可以作为 Event.type 访问。
  9461. * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。
  9462. * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。
  9463. * @param stageX 事件发生点在全局舞台坐标系中的水平坐标
  9464. * @param stageY 事件发生点在全局舞台坐标系中的垂直坐标
  9465. * @param touchPointID 分配给触摸点的唯一标识号
  9466. *
  9467. * @see egret.Event.create()
  9468. * @see egret.Event.release()
  9469. *
  9470. * @version Egret 2.4
  9471. * @platform Web,Native
  9472. */
  9473. TouchEvent.dispatchTouchEvent = function (target, type, bubbles, cancelable, stageX, stageY, touchPointID, touchDown) {
  9474. if (touchDown === void 0) { touchDown = false; }
  9475. if (!bubbles && !target.hasEventListener(type)) {
  9476. return true;
  9477. }
  9478. var event = egret.Event.create(TouchEvent, type, bubbles, cancelable);
  9479. event.$initTo(stageX, stageY, touchPointID);
  9480. event.touchDown = touchDown;
  9481. var result = target.dispatchEvent(event);
  9482. egret.Event.release(event);
  9483. return result;
  9484. };
  9485. return TouchEvent;
  9486. }(egret.Event));
  9487. /**
  9488. * @language en_US
  9489. * Dispatched when the user touches the device, and is continuously dispatched until the point of contact is removed.
  9490. * @version Egret 2.4
  9491. * @platform Web,Native
  9492. */
  9493. /**
  9494. * @language zh_CN
  9495. * 当用户触碰设备时进行调度,而且会连续调度,直到接触点被删除。
  9496. * @version Egret 2.4
  9497. * @platform Web,Native
  9498. */
  9499. TouchEvent.TOUCH_MOVE = "touchMove";
  9500. /**
  9501. * @language en_US
  9502. * Dispatched when the user first contacts a touch-enabled device (such as touches a finger to a mobile phone or tablet with a touch screen).
  9503. * @version Egret 2.4
  9504. * @platform Web,Native
  9505. */
  9506. /**
  9507. * @language zh_CN
  9508. * 当用户第一次触摸启用触摸的设备时(例如,用手指触摸配有触摸屏的移动电话或平板电脑)调度。
  9509. * @version Egret 2.4
  9510. * @platform Web,Native
  9511. */
  9512. TouchEvent.TOUCH_BEGIN = "touchBegin";
  9513. /**
  9514. * @language en_US
  9515. * Dispatched when the user removes contact with a touch-enabled device (such as lifts a finger off a mobile phone
  9516. * or tablet with a touch screen).
  9517. * @version Egret 2.4
  9518. * @platform Web,Native
  9519. */
  9520. /**
  9521. * @language zh_CN
  9522. * 当用户移除与启用触摸的设备的接触时(例如,将手指从配有触摸屏的移动电话或平板电脑上抬起)调度。
  9523. * @version Egret 2.4
  9524. * @platform Web,Native
  9525. */
  9526. TouchEvent.TOUCH_END = "touchEnd";
  9527. /**
  9528. * @language en_US
  9529. * Dispatched when an event of some kind occurred that canceled the touch.
  9530. * Such as the eui.Scroller will dispatch 'TOUCH_CANCEL' when it start move, the 'TOUCH_END' and 'TOUCH_TAP' will not be triggered.
  9531. * @version Egret 3.0.1
  9532. * @platform Web,Native
  9533. */
  9534. /**
  9535. * @language zh_CN
  9536. * 由于某个事件取消了触摸时触发。比如 eui.Scroller 在开始滚动后会触发 'TOUCH_CANCEL' 事件,不再触发后续的 'TOUCH_END' 和 'TOUCH_TAP' 事件
  9537. * @version Egret 3.0.1
  9538. * @platform Web,Native
  9539. */
  9540. TouchEvent.TOUCH_CANCEL = "touchcancel";
  9541. /**
  9542. * @language en_US
  9543. * Dispatched when the user lifts the point of contact over the same DisplayObject instance on which the contact
  9544. * was initiated on a touch-enabled device.
  9545. * @version Egret 2.4
  9546. * @platform Web,Native
  9547. */
  9548. /**
  9549. * @language zh_CN
  9550. * 当用户在触摸设备上与开始触摸的同一 DisplayObject 实例上抬起接触点时调度。
  9551. * @version Egret 2.4
  9552. * @platform Web,Native
  9553. */
  9554. TouchEvent.TOUCH_TAP = "touchTap";
  9555. /**
  9556. * @language en_US
  9557. * Dispatched when the user lifts the point of contact over the different DisplayObject instance on which the contact
  9558. * was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display
  9559. * object on a mobile phone or tablet with a touch screen).
  9560. * @version Egret 2.4
  9561. * @platform Web,Native
  9562. */
  9563. /**
  9564. * @language zh_CN
  9565. * 当用户在触摸设备上与开始触摸的不同 DisplayObject 实例上抬起接触点时调度。
  9566. * @version Egret 2.4
  9567. * @platform Web,Native
  9568. */
  9569. TouchEvent.TOUCH_RELEASE_OUTSIDE = "touchReleaseOutside";
  9570. /**
  9571. * @deprecated
  9572. * @version Egret 2.4
  9573. * @platform Web,Native
  9574. */
  9575. TouchEvent.TOUCH_ROLL_OUT = "touchRollOut";
  9576. /**
  9577. * @deprecated
  9578. * @version Egret 2.4
  9579. * @platform Web,Native
  9580. */
  9581. TouchEvent.TOUCH_ROLL_OVER = "touchRollOver";
  9582. egret.TouchEvent = TouchEvent;
  9583. __reflect(TouchEvent.prototype, "egret.TouchEvent");
  9584. if (true) {
  9585. egret.$markReadOnly(TouchEvent, "stageX");
  9586. egret.$markReadOnly(TouchEvent, "stageY");
  9587. egret.$markReadOnly(TouchEvent, "localX");
  9588. egret.$markReadOnly(TouchEvent, "localY");
  9589. }
  9590. })(egret || (egret = {}));
  9591. //////////////////////////////////////////////////////////////////////////////////////
  9592. //
  9593. // Copyright (c) 2014-present, Egret Technology.
  9594. // All rights reserved.
  9595. // Redistribution and use in source and binary forms, with or without
  9596. // modification, are permitted provided that the following conditions are met:
  9597. //
  9598. // * Redistributions of source code must retain the above copyright
  9599. // notice, this list of conditions and the following disclaimer.
  9600. // * Redistributions in binary form must reproduce the above copyright
  9601. // notice, this list of conditions and the following disclaimer in the
  9602. // documentation and/or other materials provided with the distribution.
  9603. // * Neither the name of the Egret nor the
  9604. // names of its contributors may be used to endorse or promote products
  9605. // derived from this software without specific prior written permission.
  9606. //
  9607. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  9608. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  9609. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  9610. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  9611. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9612. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  9613. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  9614. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  9615. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  9616. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9617. //
  9618. //////////////////////////////////////////////////////////////////////////////////////
  9619. var egret;
  9620. (function (egret) {
  9621. })(egret || (egret = {}));
  9622. //////////////////////////////////////////////////////////////////////////////////////
  9623. //
  9624. // Copyright (c) 2014-present, Egret Technology.
  9625. // All rights reserved.
  9626. // Redistribution and use in source and binary forms, with or without
  9627. // modification, are permitted provided that the following conditions are met:
  9628. //
  9629. // * Redistributions of source code must retain the above copyright
  9630. // notice, this list of conditions and the following disclaimer.
  9631. // * Redistributions in binary form must reproduce the above copyright
  9632. // notice, this list of conditions and the following disclaimer in the
  9633. // documentation and/or other materials provided with the distribution.
  9634. // * Neither the name of the Egret nor the
  9635. // names of its contributors may be used to endorse or promote products
  9636. // derived from this software without specific prior written permission.
  9637. //
  9638. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  9639. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  9640. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  9641. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  9642. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9643. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  9644. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  9645. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  9646. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  9647. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9648. //
  9649. //////////////////////////////////////////////////////////////////////////////////////
  9650. //////////////////////////////////////////////////////////////////////////////////////
  9651. //
  9652. // Copyright (c) 2014-present, Egret Technology.
  9653. // All rights reserved.
  9654. // Redistribution and use in source and binary forms, with or without
  9655. // modification, are permitted provided that the following conditions are met:
  9656. //
  9657. // * Redistributions of source code must retain the above copyright
  9658. // notice, this list of conditions and the following disclaimer.
  9659. // * Redistributions in binary form must reproduce the above copyright
  9660. // notice, this list of conditions and the following disclaimer in the
  9661. // documentation and/or other materials provided with the distribution.
  9662. // * Neither the name of the Egret nor the
  9663. // names of its contributors may be used to endorse or promote products
  9664. // derived from this software without specific prior written permission.
  9665. //
  9666. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  9667. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  9668. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  9669. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  9670. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9671. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  9672. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  9673. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  9674. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  9675. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9676. //
  9677. //////////////////////////////////////////////////////////////////////////////////////
  9678. var egret;
  9679. (function (egret) {
  9680. /**
  9681. * @language en_US
  9682. * The BlurFilter class lets you apply a blur visual effect to display objects. A blur effect softens the details of an image.
  9683. * You can produce blurs that range from a softly unfocused look to a Gaussian blur, a hazy appearance like viewing an image through semi-opaque glass.
  9684. * @version Egret 3.0.1
  9685. * @platform Web
  9686. * @see http://edn.egret.com/cn/docs/page/947#模糊滤镜 模糊滤镜
  9687. */
  9688. /**
  9689. * @language zh_CN
  9690. * 可使用 BlurFilter 类将模糊视觉效果应用于显示对象。模糊效果可以柔化图像的细节。
  9691. * 您可以生成一些模糊效果,范围从创建一个柔化的、未聚焦的外观到高斯模糊(就像通过半透明玻璃查看图像一样的朦胧的外观)。
  9692. * @version Egret 3.1.0
  9693. * @platform Web
  9694. * @see http://edn.egret.com/cn/docs/page/947#模糊滤镜 模糊滤镜
  9695. */
  9696. var BlurFilter = (function (_super) {
  9697. __extends(BlurFilter, _super);
  9698. /**
  9699. * @language en_US
  9700. * Initializes a BlurFilter object.
  9701. * @param blurX {number} The amount of horizontal blur. Valid values are 0 to 255 (floating point).
  9702. * @param blurY {number} The amount of vertical blur. Valid values are 0 to 255 (floating point).
  9703. * @param quality {number} The number of times to apply the filter.
  9704. * @version Egret 3.1.0
  9705. * @platform Web
  9706. */
  9707. /**
  9708. * @language zh_CN
  9709. * 创建一个 BlurFilter 对象。
  9710. * @param blurX {number} 水平模糊量。有效值为 0 到 255(浮点)。
  9711. * @param blurY {number} 垂直模糊量。有效值为 0 到 255(浮点)。
  9712. * @param quality {number} 应用滤镜的次数。暂未实现。
  9713. * @version Egret 3.1.0
  9714. * @platform Web
  9715. */
  9716. function BlurFilter(blurX, blurY, quality) {
  9717. if (blurX === void 0) { blurX = 4; }
  9718. if (blurY === void 0) { blurY = 4; }
  9719. if (quality === void 0) { quality = 1; }
  9720. var _this = _super.call(this) || this;
  9721. _this.type = "blur";
  9722. _this.$blurX = blurX;
  9723. _this.$blurY = blurY;
  9724. _this.$quality = quality;
  9725. return _this;
  9726. }
  9727. Object.defineProperty(BlurFilter.prototype, "blurX", {
  9728. /**
  9729. * @language en_US
  9730. * The amount of horizontal blur.
  9731. * @version Egret 3.1.0
  9732. * @platform Web
  9733. */
  9734. /**
  9735. * @language zh_CN
  9736. * 水平模糊量。
  9737. * @version Egret 3.1.0
  9738. * @platform Web
  9739. */
  9740. get: function () {
  9741. return this.$blurX;
  9742. },
  9743. set: function (value) {
  9744. if (this.$blurX == value) {
  9745. return;
  9746. }
  9747. this.$blurX = value;
  9748. this.invalidate();
  9749. },
  9750. enumerable: true,
  9751. configurable: true
  9752. });
  9753. Object.defineProperty(BlurFilter.prototype, "blurY", {
  9754. /**
  9755. * @language en_US
  9756. * The amount of vertical blur.
  9757. * @version Egret 3.1.0
  9758. * @platform Web
  9759. */
  9760. /**
  9761. * @language zh_CN
  9762. * 垂直模糊量。
  9763. * @version Egret 3.1.0
  9764. * @platform Web
  9765. */
  9766. get: function () {
  9767. return this.$blurY;
  9768. },
  9769. set: function (value) {
  9770. if (this.$blurY == value) {
  9771. return;
  9772. }
  9773. this.$blurY = value;
  9774. this.invalidate();
  9775. },
  9776. enumerable: true,
  9777. configurable: true
  9778. });
  9779. /**
  9780. * @private
  9781. */
  9782. BlurFilter.prototype.$toJson = function () {
  9783. return '{"blurX": ' + this.$blurX + ', "blurY": ' + this.$blurY + ', "quality": 1}';
  9784. };
  9785. return BlurFilter;
  9786. }(egret.Filter));
  9787. egret.BlurFilter = BlurFilter;
  9788. __reflect(BlurFilter.prototype, "egret.BlurFilter");
  9789. })(egret || (egret = {}));
  9790. //////////////////////////////////////////////////////////////////////////////////////
  9791. //
  9792. // Copyright (c) 2014-present, Egret Technology.
  9793. // All rights reserved.
  9794. // Redistribution and use in source and binary forms, with or without
  9795. // modification, are permitted provided that the following conditions are met:
  9796. //
  9797. // * Redistributions of source code must retain the above copyright
  9798. // notice, this list of conditions and the following disclaimer.
  9799. // * Redistributions in binary form must reproduce the above copyright
  9800. // notice, this list of conditions and the following disclaimer in the
  9801. // documentation and/or other materials provided with the distribution.
  9802. // * Neither the name of the Egret nor the
  9803. // names of its contributors may be used to endorse or promote products
  9804. // derived from this software without specific prior written permission.
  9805. //
  9806. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  9807. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  9808. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  9809. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  9810. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9811. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  9812. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  9813. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  9814. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  9815. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9816. //
  9817. //////////////////////////////////////////////////////////////////////////////////////
  9818. var egret;
  9819. (function (egret) {
  9820. /**
  9821. * @language en_US
  9822. * The ColorMatrixFilter class lets you apply a 4 x 5 matrix transformation on the RGBA color and alpha values of every pixel in the input image to produce a result with a new set of RGBA color and alpha values.
  9823. * It allows saturation changes, hue rotation, luminance to alpha, and various other effects.
  9824. * @version Egret 3.1.0
  9825. * @platform Web
  9826. * @see http://edn.egret.com/cn/docs/page/947 颜色矩阵滤镜
  9827. */
  9828. /**
  9829. * @language zh_CN
  9830. * 使用 ColorMatrixFilter 类可以将 4 x 5 矩阵转换应用于输入图像上的每个像素的 RGBA 颜色和 Alpha 值,以生成具有一组新的 RGBA 颜色和 Alpha 值的结果。
  9831. * 该类允许饱和度更改、色相旋转、亮度为 Alpha 以及各种其他效果。
  9832. * @version Egret 3.1.0
  9833. * @platform Web
  9834. * @see http://edn.egret.com/cn/docs/page/947 颜色矩阵滤镜
  9835. */
  9836. var ColorMatrixFilter = (function (_super) {
  9837. __extends(ColorMatrixFilter, _super);
  9838. /**
  9839. * @language en_US
  9840. * Initializes a ColorMatrixFilter object.
  9841. * @version Egret 3.1.0
  9842. * @platform Web
  9843. */
  9844. /**
  9845. * @language zh_CN
  9846. * 创建一个 ColorMatrixFilter 对象。
  9847. * @version Egret 3.1.0
  9848. * @platform Web
  9849. */
  9850. function ColorMatrixFilter(matrix) {
  9851. if (matrix === void 0) { matrix = null; }
  9852. var _this = _super.call(this) || this;
  9853. /**
  9854. * @private
  9855. */
  9856. _this.$matrix = [];
  9857. /**
  9858. * @private
  9859. */
  9860. _this.matrix2 = [];
  9861. _this.type = "colorTransform";
  9862. _this.setMatrix(matrix);
  9863. return _this;
  9864. }
  9865. Object.defineProperty(ColorMatrixFilter.prototype, "matrix", {
  9866. /**
  9867. * @language en_US
  9868. * A comma delimited list of 20 doubles that comprise a 4x5 matrix applied to the rendered element.
  9869. * The matrix is in row major order -- that is, the first five elements are multipled by the vector [srcR,srcG,srcB,srcA,1] to determine the output red value, the second five determine the output green value, etc.
  9870. * The value must either be an array or comma delimited string of 20 numbers.
  9871. * @version Egret 3.1.0
  9872. * @platform Web
  9873. */
  9874. /**
  9875. * @language zh_CN
  9876. * 构成应用于所呈示的元素的一个 4x5 矩阵的、以逗号分隔的 20 个双精度数的列表。
  9877. * 矩阵以行作为主要顺序,即用第一行五个元素乘以矢量 [srcR,srcG,srcB,srcA,1] 以确定输出的红色值,用第二行的五个元素确定输出的绿色值,等等。
  9878. * 该值必须为 20 个数字组成的数组或以逗号分隔的字符串。
  9879. * @version Egret 3.1.0
  9880. * @platform Web
  9881. */
  9882. get: function () {
  9883. for (var i = 0; i < 20; i++) {
  9884. this.matrix2[i] = this.$matrix[i];
  9885. }
  9886. return this.matrix2;
  9887. },
  9888. set: function (value) {
  9889. this.setMatrix(value);
  9890. this.invalidate();
  9891. },
  9892. enumerable: true,
  9893. configurable: true
  9894. });
  9895. /**
  9896. * @private
  9897. */
  9898. ColorMatrixFilter.prototype.setMatrix = function (value) {
  9899. if (value) {
  9900. for (var i = 0; i < 20; i++) {
  9901. this.$matrix[i] = value[i];
  9902. }
  9903. }
  9904. else {
  9905. for (var i = 0; i < 20; i++) {
  9906. this.$matrix[i] = (i == 0 || i == 6 || i == 12 || i == 18) ? 1 : 0;
  9907. }
  9908. }
  9909. };
  9910. /**
  9911. * @private
  9912. */
  9913. ColorMatrixFilter.prototype.$toJson = function () {
  9914. return '{"matrix": [' + this.$matrix.toString() + ']}';
  9915. };
  9916. return ColorMatrixFilter;
  9917. }(egret.Filter));
  9918. egret.ColorMatrixFilter = ColorMatrixFilter;
  9919. __reflect(ColorMatrixFilter.prototype, "egret.ColorMatrixFilter");
  9920. })(egret || (egret = {}));
  9921. //////////////////////////////////////////////////////////////////////////////////////
  9922. //
  9923. // Copyright (c) 2014-present, Egret Technology.
  9924. // All rights reserved.
  9925. // Redistribution and use in source and binary forms, with or without
  9926. // modification, are permitted provided that the following conditions are met:
  9927. //
  9928. // * Redistributions of source code must retain the above copyright
  9929. // notice, this list of conditions and the following disclaimer.
  9930. // * Redistributions in binary form must reproduce the above copyright
  9931. // notice, this list of conditions and the following disclaimer in the
  9932. // documentation and/or other materials provided with the distribution.
  9933. // * Neither the name of the Egret nor the
  9934. // names of its contributors may be used to endorse or promote products
  9935. // derived from this software without specific prior written permission.
  9936. //
  9937. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  9938. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  9939. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  9940. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  9941. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9942. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  9943. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  9944. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  9945. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  9946. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9947. //
  9948. //////////////////////////////////////////////////////////////////////////////////////
  9949. var egret;
  9950. (function (egret) {
  9951. /**
  9952. * @class egret.DropShadowFilter
  9953. * @classdesc
  9954. * 可使用 DropShadowFilter 类向显示对象添加投影。
  9955. * @extends egret.GlowFilter
  9956. * @version Egret 3.1.4
  9957. * @platform Web,Native
  9958. */
  9959. var DropShadowFilter = (function (_super) {
  9960. __extends(DropShadowFilter, _super);
  9961. /**
  9962. * @language en_US
  9963. * Initializes a new DropShadowFilter instance.
  9964. * @method egret.DropShadowFilter#constructor
  9965. * @param distance {number} The offset distance of the bevel. Valid values are in pixels (floating point).
  9966. * @param angle {number} The angle of the bevel. Valid values are from 0 to 360°.
  9967. * @param color {number} The color of the glow. Valid values are in the hexadecimal format 0xRRGGBB. The default value is 0xFF0000.
  9968. * @param alpha {number} The alpha transparency value for the color. Valid values are 0 to 1. For example, .25 sets a transparency value of 25%. The default value is 1.
  9969. * @param blurX {number} The amount of horizontal blur. Valid values are 0 to 255 (floating point).
  9970. * @param blurY {number} The amount of vertical blur. Valid values are 0 to 255 (floating point).
  9971. * @param strength {number} The strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the glow and the background. Valid values are 0 to 255.
  9972. * @param quality {number} The number of times to apply the filter.
  9973. * @param inner {boolean} Specifies whether the glow is an inner glow. The value true indicates an inner glow. The default is false, an outer glow (a glow around the outer edges of the object).
  9974. * @param knockout {number} Specifies whether the object has a knockout effect. A value of true makes the object's fill transparent and reveals the background color of the document. The default value is false (no knockout effect).
  9975. * @param hideObject {number} Indicates whether or not the object is hidden. The value true indicates that the object itself is not drawn; only the shadow is visible. The default is false, meaning that the object is shown.
  9976. * @version Egret 3.1.4
  9977. * @platform Web
  9978. */
  9979. /**
  9980. * @language zh_CN
  9981. * 初始化 DropShadowFilter 对象
  9982. * @method egret.DropShadowFilter#constructor
  9983. * @param distance {number} 阴影的偏移距离,以像素为单位。
  9984. * @param angle {number} 阴影的角度,0 到 360 度(浮点)。
  9985. * @param color {number} 光晕颜色,采用十六进制格式 0xRRGGBB。默认值为 0xFF0000。
  9986. * @param alpha {number} 颜色的 Alpha 透明度值。有效值为 0 到 1。例如,0.25 设置透明度值为 25%。
  9987. * @param blurX {number} 水平模糊量。有效值为 0 到 255(浮点)。
  9988. * @param blurY {number} 垂直模糊量。有效值为 0 到 255(浮点)。
  9989. * @param strength {number} 印记或跨页的强度。该值越高,压印的颜色越深,而且发光与背景之间的对比度也越强。有效值为 0 到 255。
  9990. * @param quality {number} 应用滤镜的次数。暂未实现。
  9991. * @param inner {boolean} 指定发光是否为内侧发光。值 true 指定发光是内侧发光。值 false 指定发光是外侧发光(对象外缘周围的发光)。
  9992. * @param knockout {number} 指定对象是否具有挖空效果。值为 true 将使对象的填充变为透明,并显示文档的背景颜色。
  9993. * @param hideObject {number} 表示是否隐藏对象。如果值为 true,则表示没有绘制对象本身,只有阴影是可见的。默认值为 false(显示对象)。
  9994. * @version Egret 3.1.4
  9995. * @platform Web
  9996. */
  9997. function DropShadowFilter(distance, angle, color, alpha, blurX, blurY, strength, quality, inner, knockout, hideObject) {
  9998. if (distance === void 0) { distance = 4.0; }
  9999. if (angle === void 0) { angle = 45; }
  10000. if (color === void 0) { color = 0; }
  10001. if (alpha === void 0) { alpha = 1.0; }
  10002. if (blurX === void 0) { blurX = 4.0; }
  10003. if (blurY === void 0) { blurY = 4.0; }
  10004. if (strength === void 0) { strength = 1.0; }
  10005. if (quality === void 0) { quality = 1; }
  10006. if (inner === void 0) { inner = false; }
  10007. if (knockout === void 0) { knockout = false; }
  10008. if (hideObject === void 0) { hideObject = false; }
  10009. var _this = _super.call(this, color, alpha, blurX, blurY, strength, quality, inner, knockout) || this;
  10010. _this.$distance = distance;
  10011. _this.$angle = angle;
  10012. _this.$hideObject = hideObject;
  10013. return _this;
  10014. }
  10015. Object.defineProperty(DropShadowFilter.prototype, "distance", {
  10016. /**
  10017. * @language en_US
  10018. * The offset distance of the bevel.
  10019. * @version Egret 3.1.4
  10020. * @platform Web
  10021. */
  10022. /**
  10023. * @language zh_CN
  10024. * 阴影的偏移距离,以像素为单位。
  10025. * @version Egret 3.1.4
  10026. * @platform Web
  10027. */
  10028. get: function () {
  10029. return this.$distance;
  10030. },
  10031. set: function (value) {
  10032. if (this.$distance == value) {
  10033. return;
  10034. }
  10035. this.$distance = value;
  10036. this.invalidate();
  10037. },
  10038. enumerable: true,
  10039. configurable: true
  10040. });
  10041. Object.defineProperty(DropShadowFilter.prototype, "angle", {
  10042. /**
  10043. * @language en_US
  10044. * The angle of the bevel.
  10045. * @version Egret 3.1.4
  10046. * @platform Web
  10047. */
  10048. /**
  10049. * @language zh_CN
  10050. * 阴影的角度。
  10051. * @version Egret 3.1.4
  10052. * @platform Web
  10053. */
  10054. get: function () {
  10055. return this.$angle;
  10056. },
  10057. set: function (value) {
  10058. if (this.$angle == value) {
  10059. return;
  10060. }
  10061. this.$angle = value;
  10062. this.invalidate();
  10063. },
  10064. enumerable: true,
  10065. configurable: true
  10066. });
  10067. Object.defineProperty(DropShadowFilter.prototype, "hideObject", {
  10068. /**
  10069. * @language en_US
  10070. * Indicates whether or not the object is hidden.
  10071. * @version Egret 3.1.4
  10072. * @platform Web
  10073. */
  10074. /**
  10075. * @language zh_CN
  10076. * 表示是否隐藏对象。
  10077. * @version Egret 3.1.4
  10078. * @platform Web
  10079. */
  10080. get: function () {
  10081. return this.$hideObject;
  10082. },
  10083. set: function (value) {
  10084. if (this.$hideObject == value) {
  10085. return;
  10086. }
  10087. this.$hideObject = value;
  10088. this.invalidate();
  10089. },
  10090. enumerable: true,
  10091. configurable: true
  10092. });
  10093. /**
  10094. * @private
  10095. */
  10096. DropShadowFilter.prototype.$toJson = function () {
  10097. return '{"distance": ' + this.$distance + ', "angle": ' + this.$angle + ', "color": ' + this.$color + ', "red": ' + this.$red + ', "green": ' + this.$green + ', "blue": ' + this.$blue + ', "alpha": ' + this.$alpha + ', "blurX": ' + this.$blurX + ', "blurY": ' + this.blurY + ', "strength": ' + this.$strength + ', "quality": ' + this.$quality + ', "inner": ' + this.$inner + ', "knockout": ' + this.$knockout + ', "hideObject": ' + this.$hideObject + '}';
  10098. };
  10099. return DropShadowFilter;
  10100. }(egret.GlowFilter));
  10101. egret.DropShadowFilter = DropShadowFilter;
  10102. __reflect(DropShadowFilter.prototype, "egret.DropShadowFilter");
  10103. })(egret || (egret = {}));
  10104. var egret;
  10105. (function (egret) {
  10106. /**
  10107. * @language en_US
  10108. * The GradientType class provides values for the type parameter in the beginGradientFill() methods of the egret.Graphics class.
  10109. *
  10110. * @see egret.Graphics#beginGradientFill()
  10111. * @version Egret 2.4
  10112. * @platform Web,Native
  10113. */
  10114. /**
  10115. * @language zh_CN
  10116. * GradientType 类为 egret.Graphics 类的 beginGradientFill() 方法中的 type 参数提供值。
  10117. *
  10118. * @see egret.Graphics#beginGradientFill()
  10119. * @version Egret 2.4
  10120. * @platform Web,Native
  10121. */
  10122. var GradientType = (function () {
  10123. function GradientType() {
  10124. }
  10125. return GradientType;
  10126. }());
  10127. /**
  10128. * @language en_US
  10129. * Value used to specify a linear gradient fill.
  10130. * @version Egret 2.4
  10131. * @platform Web,Native
  10132. */
  10133. /**
  10134. * @language zh_CN
  10135. * 用于指定线性渐变填充的值
  10136. * @version Egret 2.4
  10137. * @platform Web,Native
  10138. */
  10139. GradientType.LINEAR = "linear";
  10140. /**
  10141. * @language en_US
  10142. * Value used to specify a radial gradient fill.
  10143. * @version Egret 2.4
  10144. * @platform Web,Native
  10145. */
  10146. /**
  10147. * @language zh_CN
  10148. * 用于指定放射状渐变填充的值
  10149. * @version Egret 2.4
  10150. * @platform Web,Native
  10151. */
  10152. GradientType.RADIAL = "radial";
  10153. egret.GradientType = GradientType;
  10154. __reflect(GradientType.prototype, "egret.GradientType");
  10155. })(egret || (egret = {}));
  10156. //////////////////////////////////////////////////////////////////////////////////////
  10157. //
  10158. // Copyright (c) 2014-present, Egret Technology.
  10159. // All rights reserved.
  10160. // Redistribution and use in source and binary forms, with or without
  10161. // modification, are permitted provided that the following conditions are met:
  10162. //
  10163. // * Redistributions of source code must retain the above copyright
  10164. // notice, this list of conditions and the following disclaimer.
  10165. // * Redistributions in binary form must reproduce the above copyright
  10166. // notice, this list of conditions and the following disclaimer in the
  10167. // documentation and/or other materials provided with the distribution.
  10168. // * Neither the name of the Egret nor the
  10169. // names of its contributors may be used to endorse or promote products
  10170. // derived from this software without specific prior written permission.
  10171. //
  10172. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  10173. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  10174. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  10175. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  10176. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  10177. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  10178. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  10179. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  10180. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  10181. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10182. //
  10183. //////////////////////////////////////////////////////////////////////////////////////
  10184. var egret;
  10185. (function (egret) {
  10186. /**
  10187. * @private
  10188. * 格式化弧线角度的值
  10189. */
  10190. function clampAngle(value) {
  10191. value %= Math.PI * 2;
  10192. if (value < 0) {
  10193. value += Math.PI * 2;
  10194. }
  10195. return value;
  10196. }
  10197. /**
  10198. * @language en_US
  10199. * The Graphics class contains a set of methods for creating vector shape. Display objects that support drawing include Sprite and Shape objects. Each class in these classes includes the graphics attribute that is a Graphics object.
  10200. * The following auxiliary functions are provided for ease of use: drawRect(), drawRoundRect(), drawCircle(), and drawEllipse().
  10201. * @see http://edn.egret.com/cn/docs/page/136 Draw Rectangle
  10202. * @version Egret 2.4
  10203. * @platform Web,Native
  10204. * @includeExample egret/display/Graphics.ts
  10205. */
  10206. /**
  10207. * @language zh_CN
  10208. * Graphics 类包含一组可用来创建矢量形状的方法。支持绘制的显示对象包括 Sprite 和 Shape 对象。这些类中的每一个类都包括 graphics 属性,该属性是一个 Graphics 对象。
  10209. * 以下是为便于使用而提供的一些辅助函数:drawRect()、drawRoundRect()、drawCircle() 和 drawEllipse()。
  10210. * @see http://edn.egret.com/cn/docs/page/136 绘制矩形
  10211. * @version Egret 2.4
  10212. * @platform Web,Native
  10213. * @includeExample egret/display/Graphics.ts
  10214. */
  10215. var Graphics = (function (_super) {
  10216. __extends(Graphics, _super);
  10217. /**
  10218. * @version Egret 2.4
  10219. * @platform Web,Native
  10220. */
  10221. function Graphics() {
  10222. var _this = _super.call(this) || this;
  10223. /**
  10224. * 当前移动到的坐标X
  10225. */
  10226. _this.lastX = 0;
  10227. /**
  10228. * 当前移动到的坐标Y
  10229. */
  10230. _this.lastY = 0;
  10231. /**
  10232. * 当前正在绘制的填充
  10233. */
  10234. _this.fillPath = null;
  10235. /**
  10236. * 当前正在绘制的线条
  10237. */
  10238. _this.strokePath = null;
  10239. /**
  10240. * 线条的左上方宽度
  10241. */
  10242. _this.topLeftStrokeWidth = 0;
  10243. /**
  10244. * 线条的右下方宽度
  10245. */
  10246. _this.bottomRightStrokeWidth = 0;
  10247. /**
  10248. * @private
  10249. */
  10250. _this.minX = Infinity;
  10251. /**
  10252. * @private
  10253. */
  10254. _this.minY = Infinity;
  10255. /**
  10256. * @private
  10257. */
  10258. _this.maxX = -Infinity;
  10259. /**
  10260. * @private
  10261. */
  10262. _this.maxY = -Infinity;
  10263. /**
  10264. * 是否已经包含上一次moveTo的坐标点
  10265. */
  10266. _this.includeLastPosition = true;
  10267. _this.$renderNode = new egret.sys.GraphicsNode();
  10268. return _this;
  10269. }
  10270. /**
  10271. * @private
  10272. * 设置绑定到的目标显示对象
  10273. */
  10274. Graphics.prototype.$setTarget = function (target) {
  10275. if (this.targetDisplay) {
  10276. this.targetDisplay.$renderNode = null;
  10277. }
  10278. target.$renderNode = this.$renderNode;
  10279. this.targetDisplay = target;
  10280. };
  10281. /**
  10282. * 对1像素和3像素特殊处理,向右下角偏移0.5像素,以显示清晰锐利的线条。
  10283. */
  10284. Graphics.prototype.setStrokeWidth = function (width) {
  10285. switch (width) {
  10286. case 1:
  10287. this.topLeftStrokeWidth = 0;
  10288. this.bottomRightStrokeWidth = 1;
  10289. break;
  10290. case 3:
  10291. this.topLeftStrokeWidth = 1;
  10292. this.bottomRightStrokeWidth = 2;
  10293. break;
  10294. default:
  10295. var half = Math.ceil(width * 0.5) | 0;
  10296. this.topLeftStrokeWidth = half;
  10297. this.bottomRightStrokeWidth = half;
  10298. break;
  10299. }
  10300. };
  10301. /**
  10302. * @language en_US
  10303. * Specify a simple single color fill that will be used for subsequent calls to other Graphics methods (for example, lineTo() and drawCircle()) when drawing.
  10304. * Calling the clear() method will clear the fill.
  10305. * @param color Filled color
  10306. * @param alpha Filled Alpha value
  10307. * @version Egret 2.4
  10308. * @platform Web,Native
  10309. */
  10310. /**
  10311. * @language zh_CN
  10312. * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。
  10313. * 调用 clear() 方法会清除填充。
  10314. * @param color 填充的颜色
  10315. * @param alpha 填充的 Alpha 值
  10316. * @version Egret 2.4
  10317. * @platform Web,Native
  10318. */
  10319. Graphics.prototype.beginFill = function (color, alpha) {
  10320. if (alpha === void 0) { alpha = 1; }
  10321. color = +color || 0;
  10322. alpha = +alpha || 0;
  10323. this.fillPath = this.$renderNode.beginFill(color, alpha, this.strokePath);
  10324. if (this.$renderNode.drawData.length > 1) {
  10325. this.fillPath.moveTo(this.lastX, this.lastY);
  10326. }
  10327. };
  10328. /**
  10329. * @language en_US
  10330. * Specifies a gradient fill used by subsequent calls to other Graphics methods (such as lineTo() or drawCircle()) for the object.
  10331. * Calling the clear() method clears the fill.
  10332. * @param type A value from the GradientType class that specifies which gradient type to use: GradientType.LINEAR or GradientType.RADIAL.
  10333. * @param colors An array of RGB hexadecimal color values used in the gradient; for example, red is 0xFF0000, blue is 0x0000FF, and so on. You can specify up to 15 colors. For each color, specify a corresponding value in the alphas and ratios parameters.
  10334. * @param alphas An array of alpha values for the corresponding colors in the colors array;
  10335. * @param ratios An array of color distribution ratios; valid values are 0-255.
  10336. * @param matrix A transformation matrix as defined by the egret.Matrix class. The egret.Matrix class includes a createGradientBox() method, which lets you conveniently set up the matrix for use with the beginGradientFill() method.
  10337. * @platform Web,Native
  10338. * @version Egret 2.4
  10339. */
  10340. /**
  10341. * @language zh_CN
  10342. * 指定一种渐变填充,用于随后调用对象的其他 Graphics 方法(如 lineTo() 或 drawCircle())。
  10343. * 调用 clear() 方法会清除填充。
  10344. * @param type 用于指定要使用哪种渐变类型的 GradientType 类的值:GradientType.LINEAR 或 GradientType.RADIAL。
  10345. * @param colors 渐变中使用的 RGB 十六进制颜色值的数组(例如,红色为 0xFF0000,蓝色为 0x0000FF,等等)。对于每种颜色,请在 alphas 和 ratios 参数中指定对应值。
  10346. * @param alphas colors 数组中对应颜色的 alpha 值数组。
  10347. * @param ratios 颜色分布比率的数组。有效值为 0 到 255。
  10348. * @param matrix 一个由 egret.Matrix 类定义的转换矩阵。egret.Matrix 类包括 createGradientBox() 方法,通过该方法可以方便地设置矩阵,以便与 beginGradientFill() 方法一起使用
  10349. * @platform Web,Native
  10350. * @version Egret 2.4
  10351. */
  10352. Graphics.prototype.beginGradientFill = function (type, colors, alphas, ratios, matrix) {
  10353. if (matrix === void 0) { matrix = null; }
  10354. this.fillPath = this.$renderNode.beginGradientFill(type, colors, alphas, ratios, matrix, this.strokePath);
  10355. if (this.$renderNode.drawData.length > 1) {
  10356. this.fillPath.moveTo(this.lastX, this.lastY);
  10357. }
  10358. };
  10359. /**
  10360. * @language en_US
  10361. * Apply fill to the lines and curves added after the previous calling to the beginFill() method.
  10362. * @version Egret 2.4
  10363. * @platform Web,Native
  10364. */
  10365. /**
  10366. * @language zh_CN
  10367. * 对从上一次调用 beginFill()方法之后添加的直线和曲线应用填充。
  10368. * @version Egret 2.4
  10369. * @platform Web,Native
  10370. */
  10371. Graphics.prototype.endFill = function () {
  10372. this.fillPath = null;
  10373. };
  10374. /**
  10375. * @language en_US
  10376. * Specify a line style that will be used for subsequent calls to Graphics methods such as lineTo() and drawCircle().
  10377. * @param thickness An integer, indicating the thickness of the line in points. Valid values are 0 to 255. If a number is not specified, or if the parameter is undefined, a line is not drawn. If a value less than 0 is passed, the default value is 0. Value 0 indicates hairline thickness; the maximum thickness is 255. If a value greater than 255 is passed, the default value is 255.
  10378. * @param color A hexadecimal color value of the line (for example, red is 0xFF0000, and blue is 0x0000FF, etc.). If no value is specified, the default value is 0x000000 (black). Optional.
  10379. * @param alpha Indicates Alpha value of the line's color. Valid values are 0 to 1. If no value is specified, the default value is 1 (solid). If the value is less than 0, the default value is 0. If the value is greater than 1, the default value is 1.
  10380. * @param pixelHinting A boolean value that specifies whether to hint strokes to full pixels. This affects both the position of anchors of a curve and the line stroke size itself. With pixelHinting set to true, the line width is adjusted to full pixel width. With pixelHinting set to false, disjoints can appear for curves and straight lines.
  10381. * @param scaleMode Specifies the scale mode to be used
  10382. * @param caps Specifies the value of the CapsStyle class of the endpoint type at the end of the line. (default = CapsStyle.ROUND)
  10383. * @param joints Specifies the type of joint appearance of corner. (default = JointStyle.ROUND)
  10384. * @param miterLimit Indicates the limit number of cut miter.
  10385. * @version Egret 2.4
  10386. * @platform Web,Native
  10387. */
  10388. /**
  10389. * @language zh_CN
  10390. * 指定一种线条样式以用于随后对 lineTo() 或 drawCircle() 等 Graphics 方法的调用。
  10391. * @param thickness 一个整数,以点为单位表示线条的粗细,有效值为 0 到 255。如果未指定数字,或者未定义该参数,则不绘制线条。如果传递的值小于 0,则默认值为 0。值 0 表示极细的粗细;最大粗细为 255。如果传递的值大于 255,则默认值为 255。
  10392. * @param color 线条的十六进制颜色值(例如,红色为 0xFF0000,蓝色为 0x0000FF 等)。如果未指明值,则默认值为 0x000000(黑色)。可选。
  10393. * @param alpha 表示线条颜色的 Alpha 值的数字;有效值为 0 到 1。如果未指明值,则默认值为 1(纯色)。如果值小于 0,则默认值为 0。如果值大于 1,则默认值为 1。
  10394. * @param pixelHinting 布尔型值,指定是否提示笔触采用完整像素。它同时影响曲线锚点的位置以及线条笔触大小本身。在 pixelHinting 设置为 true 的情况下,线条宽度会调整到完整像素宽度。在 pixelHinting 设置为 false 的情况下,对于曲线和直线可能会出现脱节。
  10395. * @param scaleMode 用于指定要使用的比例模式
  10396. * @param caps 用于指定线条末端处端点类型的 CapsStyle 类的值。默认值:CapsStyle.ROUND
  10397. * @param joints 指定用于拐角的连接外观的类型。默认值:JointStyle.ROUND
  10398. * @param miterLimit 用于表示剪切斜接的极限值的数字。
  10399. * @version Egret 2.4
  10400. * @platform Web,Native
  10401. */
  10402. Graphics.prototype.lineStyle = function (thickness, color, alpha, pixelHinting, scaleMode, caps, joints, miterLimit) {
  10403. if (thickness === void 0) { thickness = NaN; }
  10404. if (color === void 0) { color = 0; }
  10405. if (alpha === void 0) { alpha = 1.0; }
  10406. if (pixelHinting === void 0) { pixelHinting = false; }
  10407. if (scaleMode === void 0) { scaleMode = "normal"; }
  10408. if (caps === void 0) { caps = null; }
  10409. if (joints === void 0) { joints = null; }
  10410. if (miterLimit === void 0) { miterLimit = 3; }
  10411. thickness = +thickness || 0;
  10412. if (thickness <= 0) {
  10413. this.strokePath = null;
  10414. this.setStrokeWidth(0);
  10415. }
  10416. else {
  10417. color = +color || 0;
  10418. alpha = +alpha || 0;
  10419. miterLimit = +miterLimit || 0;
  10420. this.setStrokeWidth(thickness);
  10421. this.strokePath = this.$renderNode.lineStyle(thickness, color, alpha, caps, joints, miterLimit);
  10422. if (this.$renderNode.drawData.length > 1) {
  10423. this.strokePath.moveTo(this.lastX, this.lastY);
  10424. }
  10425. }
  10426. };
  10427. /**
  10428. * @language en_US
  10429. * Draw a rectangle
  10430. * @param x x position of the center, relative to the registration point of the parent display object (in pixels).
  10431. * @param y y position of the center, relative to the registration point of the parent display object (in pixels).
  10432. * @param width Width of the rectangle (in pixels).
  10433. * @param height Height of the rectangle (in pixels).
  10434. * @version Egret 2.4
  10435. * @platform Web,Native
  10436. */
  10437. /**
  10438. * @language zh_CN
  10439. * 绘制一个矩形
  10440. * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。
  10441. * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。
  10442. * @param width 矩形的宽度(以像素为单位)。
  10443. * @param height 矩形的高度(以像素为单位)。
  10444. * @version Egret 2.4
  10445. * @platform Web,Native
  10446. */
  10447. Graphics.prototype.drawRect = function (x, y, width, height) {
  10448. x = +x || 0;
  10449. y = +y || 0;
  10450. width = +width || 0;
  10451. height = +height || 0;
  10452. var fillPath = this.fillPath;
  10453. var strokePath = this.strokePath;
  10454. fillPath && fillPath.drawRect(x, y, width, height);
  10455. strokePath && strokePath.drawRect(x, y, width, height);
  10456. this.extendBoundsByPoint(x + width, y + height);
  10457. this.updatePosition(x, y);
  10458. this.$renderNode.dirtyRender = true;
  10459. };
  10460. /**
  10461. * @language en_US
  10462. * Draw a rectangle with rounded corners.
  10463. * @param x x position of the center, relative to the registration point of the parent display object (in pixels).
  10464. * @param y y position of the center, relative to the registration point of the parent display object (in pixels).
  10465. * @param width Width of the rectangle (in pixels).
  10466. * @param height Height of the rectangle (in pixels).
  10467. * @param ellipseWidth Width used to draw an ellipse with rounded corners (in pixels).
  10468. * @param ellipseHeight Height used to draw an ellipse with rounded corners (in pixels). (Optional) If no value is specified, the default value matches the value of the ellipseWidth parameter.
  10469. * @version Egret 2.4
  10470. * @platform Web,Native
  10471. */
  10472. /**
  10473. * @language zh_CN
  10474. * 绘制一个圆角矩形。
  10475. * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。
  10476. * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。
  10477. * @param width 矩形的宽度(以像素为单位)。
  10478. * @param height 矩形的高度(以像素为单位)。
  10479. * @param ellipseWidth 用于绘制圆角的椭圆的宽度(以像素为单位)。
  10480. * @param ellipseHeight 用于绘制圆角的椭圆的高度(以像素为单位)。 (可选)如果未指定值,则默认值与为 ellipseWidth 参数提供的值相匹配。
  10481. * @version Egret 2.4
  10482. * @platform Web,Native
  10483. */
  10484. Graphics.prototype.drawRoundRect = function (x, y, width, height, ellipseWidth, ellipseHeight) {
  10485. x = +x || 0;
  10486. y = +y || 0;
  10487. width = +width || 0;
  10488. height = +height || 0;
  10489. ellipseWidth = +ellipseWidth || 0;
  10490. ellipseHeight = +ellipseHeight || 0;
  10491. var fillPath = this.fillPath;
  10492. var strokePath = this.strokePath;
  10493. fillPath && fillPath.drawRoundRect(x, y, width, height, ellipseWidth, ellipseHeight);
  10494. strokePath && strokePath.drawRoundRect(x, y, width, height, ellipseWidth, ellipseHeight);
  10495. var radiusX = (ellipseWidth * 0.5) | 0;
  10496. var radiusY = ellipseHeight ? (ellipseHeight * 0.5) | 0 : radiusX;
  10497. var right = x + width;
  10498. var bottom = y + height;
  10499. var ybw = bottom - radiusY;
  10500. this.extendBoundsByPoint(x, y);
  10501. this.extendBoundsByPoint(right, bottom);
  10502. this.updatePosition(right, ybw);
  10503. this.$renderNode.dirtyRender = true;
  10504. };
  10505. /**
  10506. * @language en_US
  10507. * Draw a circle.
  10508. * @param x x position of the center, relative to the registration point of the parent display object (in pixels).
  10509. * @param y y position of the center, relative to the registration point of the parent display object (in pixels).
  10510. * @param r Radius of the circle (in pixels).
  10511. * @version Egret 2.4
  10512. * @platform Web,Native
  10513. */
  10514. /**
  10515. * @language zh_CN
  10516. * 绘制一个圆。
  10517. * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。
  10518. * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。
  10519. * @param radius 圆的半径(以像素为单位)。
  10520. * @version Egret 2.4
  10521. * @platform Web,Native
  10522. */
  10523. Graphics.prototype.drawCircle = function (x, y, radius) {
  10524. x = +x || 0;
  10525. y = +y || 0;
  10526. radius = +radius || 0;
  10527. var fillPath = this.fillPath;
  10528. var strokePath = this.strokePath;
  10529. fillPath && fillPath.drawCircle(x, y, radius);
  10530. strokePath && strokePath.drawCircle(x, y, radius);
  10531. this.extendBoundsByPoint(x - radius, y - radius);
  10532. this.extendBoundsByPoint(x + radius, y + radius);
  10533. this.updatePosition(x + radius, y);
  10534. this.$renderNode.dirtyRender = true;
  10535. };
  10536. /**
  10537. * @language en_US
  10538. * Draw an ellipse.
  10539. * @param x A number indicating the horizontal position, relative to the registration point of the parent display object (in pixels).
  10540. * @param y A number indicating the vertical position, relative to the registration point of the parent display object (in pixels).
  10541. * @param width Width of the rectangle (in pixels).
  10542. * @param height Height of the rectangle (in pixels).
  10543. * @version Egret 2.4
  10544. * @platform Web,Native
  10545. */
  10546. /**
  10547. * @language zh_CN
  10548. * 绘制一个椭圆。
  10549. * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。
  10550. * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。
  10551. * @param width 矩形的宽度(以像素为单位)。
  10552. * @param height 矩形的高度(以像素为单位)。
  10553. * @version Egret 2.4
  10554. * @platform Web,Native
  10555. */
  10556. Graphics.prototype.drawEllipse = function (x, y, width, height) {
  10557. x = +x || 0;
  10558. y = +y || 0;
  10559. width = +width || 0;
  10560. height = +height || 0;
  10561. var fillPath = this.fillPath;
  10562. var strokePath = this.strokePath;
  10563. fillPath && fillPath.drawEllipse(x, y, width, height);
  10564. strokePath && strokePath.drawEllipse(x, y, width, height);
  10565. this.extendBoundsByPoint(x, y);
  10566. this.extendBoundsByPoint(x + width, y + height);
  10567. this.updatePosition(x + width, y + height * 0.5);
  10568. this.$renderNode.dirtyRender = true;
  10569. };
  10570. /**
  10571. * @language en_US
  10572. * Move the current drawing position to (x, y). If any of these parameters is missed, calling this method will fail and the current drawing position keeps unchanged.
  10573. * @param x A number indicating the horizontal position, relative to the registration point of the parent display object (in pixels).
  10574. * @param y A number indicating the vertical position, relative to the registration point of the parent display object (in pixels).
  10575. * @version Egret 2.4
  10576. * @platform Web,Native
  10577. */
  10578. /**
  10579. * @language zh_CN
  10580. * 将当前绘图位置移动到 (x, y)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。
  10581. * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。
  10582. * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。
  10583. * @version Egret 2.4
  10584. * @platform Web,Native
  10585. */
  10586. Graphics.prototype.moveTo = function (x, y) {
  10587. x = +x || 0;
  10588. y = +y || 0;
  10589. var fillPath = this.fillPath;
  10590. var strokePath = this.strokePath;
  10591. fillPath && fillPath.moveTo(x, y);
  10592. strokePath && strokePath.moveTo(x, y);
  10593. this.includeLastPosition = false;
  10594. this.lastX = x;
  10595. this.lastY = y;
  10596. this.$renderNode.dirtyRender = true;
  10597. };
  10598. /**
  10599. * @language en_US
  10600. * Draw a straight line from the current drawing position to (x, y) using the current line style; the current drawing position is then set to (x, y).
  10601. * @param x A number indicating the horizontal position, relative to the registration point of the parent display object (in pixels).
  10602. * @param y A number indicating the vertical position, relative to the registration point of the parent display object (in pixels).
  10603. * @version Egret 2.4
  10604. * @platform Web,Native
  10605. */
  10606. /**
  10607. * @language zh_CN
  10608. * 使用当前线条样式绘制一条从当前绘图位置开始到 (x, y) 结束的直线;当前绘图位置随后会设置为 (x, y)。
  10609. * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。
  10610. * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。
  10611. * @version Egret 2.4
  10612. * @platform Web,Native
  10613. */
  10614. Graphics.prototype.lineTo = function (x, y) {
  10615. x = +x || 0;
  10616. y = +y || 0;
  10617. var fillPath = this.fillPath;
  10618. var strokePath = this.strokePath;
  10619. fillPath && fillPath.lineTo(x, y);
  10620. strokePath && strokePath.lineTo(x, y);
  10621. this.updatePosition(x, y);
  10622. this.$renderNode.dirtyRender = true;
  10623. };
  10624. /**
  10625. * @language en_US
  10626. * Draw a quadratic Bezier curve from the current drawing position to (anchorX, anchorY) using the current line style according to the control points specified by (controlX, controlY). The current drawing position is then set to (anchorX, anchorY).
  10627. * If the curveTo() method is called before the moveTo() method, the default value of the current drawing position is (0, 0). If any of these parameters is missed, calling this method will fail and the current drawing position keeps unchanged.
  10628. * The drawn curve is a quadratic Bezier curve. A quadratic Bezier curve contains two anchor points and one control point. The curve interpolates the two anchor points and bends to the control point.
  10629. * @param controlX A number indicating the horizontal position of the control point, relative to the registration point of the parent display object.
  10630. * @param controlY A number indicating the vertical position of the control point, relative to the registration point of the parent display object.
  10631. * @param anchorX A number indicating the horizontal position of the next anchor point, relative to the registration point of the parent display object.
  10632. * @param anchorY A number indicating the vertical position of the next anchor point, relative to the registration point of the parent display object.
  10633. * @version Egret 2.4
  10634. * @platform Web,Native
  10635. */
  10636. /**
  10637. * @language zh_CN
  10638. * 使用当前线条样式和由 (controlX, controlY) 指定的控制点绘制一条从当前绘图位置开始到 (anchorX, anchorY) 结束的二次贝塞尔曲线。当前绘图位置随后设置为 (anchorX, anchorY)。
  10639. * 如果在调用 moveTo() 方法之前调用了 curveTo() 方法,则当前绘图位置的默认值为 (0, 0)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。
  10640. * 绘制的曲线是二次贝塞尔曲线。二次贝塞尔曲线包含两个锚点和一个控制点。该曲线内插这两个锚点,并向控制点弯曲。
  10641. * @param controlX 一个数字,指定控制点相对于父显示对象注册点的水平位置。
  10642. * @param controlY 一个数字,指定控制点相对于父显示对象注册点的垂直位置。
  10643. * @param anchorX 一个数字,指定下一个锚点相对于父显示对象注册点的水平位置。
  10644. * @param anchorY 一个数字,指定下一个锚点相对于父显示对象注册点的垂直位置。
  10645. * @version Egret 2.4
  10646. * @platform Web,Native
  10647. */
  10648. Graphics.prototype.curveTo = function (controlX, controlY, anchorX, anchorY) {
  10649. controlX = +controlX || 0;
  10650. controlY = +controlY || 0;
  10651. anchorX = +anchorX || 0;
  10652. anchorY = +anchorY || 0;
  10653. var fillPath = this.fillPath;
  10654. var strokePath = this.strokePath;
  10655. fillPath && fillPath.curveTo(controlX, controlY, anchorX, anchorY);
  10656. strokePath && strokePath.curveTo(controlX, controlY, anchorX, anchorY);
  10657. this.extendBoundsByPoint(controlX, controlY);
  10658. this.extendBoundsByPoint(anchorX, anchorY);
  10659. this.updatePosition(anchorX, anchorY);
  10660. this.$renderNode.dirtyRender = true;
  10661. };
  10662. /**
  10663. * @language en_US
  10664. * Draws a cubic Bezier curve from the current drawing position to the specified anchor. Cubic Bezier curves consist of two anchor points and two control points. The curve interpolates the two anchor points and two control points to the curve.
  10665. * @param controlX1 Specifies the first control point relative to the registration point of the parent display the horizontal position of the object.
  10666. * @param controlY1 Specifies the first control point relative to the registration point of the parent display the vertical position of the object.
  10667. * @param controlX2 Specify the second control point relative to the registration point of the parent display the horizontal position of the object.
  10668. * @param controlY2 Specify the second control point relative to the registration point of the parent display the vertical position of the object.
  10669. * @param anchorX Specifies the anchor point relative to the registration point of the parent display the horizontal position of the object.
  10670. * @param anchorY Specifies the anchor point relative to the registration point of the parent display the vertical position of the object.
  10671. * @version Egret 2.4
  10672. * @platform Web,Native
  10673. */
  10674. /**
  10675. * @language zh_CN
  10676. * 从当前绘图位置到指定的锚点绘制一条三次贝塞尔曲线。三次贝塞尔曲线由两个锚点和两个控制点组成。该曲线内插这两个锚点,并向两个控制点弯曲。
  10677. * @param controlX1 指定首个控制点相对于父显示对象的注册点的水平位置。
  10678. * @param controlY1 指定首个控制点相对于父显示对象的注册点的垂直位置。
  10679. * @param controlX2 指定第二个控制点相对于父显示对象的注册点的水平位置。
  10680. * @param controlY2 指定第二个控制点相对于父显示对象的注册点的垂直位置。
  10681. * @param anchorX 指定锚点相对于父显示对象的注册点的水平位置。
  10682. * @param anchorY 指定锚点相对于父显示对象的注册点的垂直位置。
  10683. * @version Egret 2.4
  10684. * @platform Web,Native
  10685. */
  10686. Graphics.prototype.cubicCurveTo = function (controlX1, controlY1, controlX2, controlY2, anchorX, anchorY) {
  10687. controlX1 = +controlX1 || 0;
  10688. controlY1 = +controlY1 || 0;
  10689. controlX2 = +controlX2 || 0;
  10690. controlY2 = +controlY2 || 0;
  10691. anchorX = +anchorX || 0;
  10692. anchorY = +anchorY || 0;
  10693. var fillPath = this.fillPath;
  10694. var strokePath = this.strokePath;
  10695. fillPath && fillPath.cubicCurveTo(controlX1, controlY1, controlX2, controlY2, anchorX, anchorY);
  10696. strokePath && strokePath.cubicCurveTo(controlX1, controlY1, controlX2, controlY2, anchorX, anchorY);
  10697. this.extendBoundsByPoint(controlX1, controlY1);
  10698. this.extendBoundsByPoint(controlX2, controlY2);
  10699. this.extendBoundsByPoint(anchorX, anchorY);
  10700. this.updatePosition(anchorX, anchorY);
  10701. this.$renderNode.dirtyRender = true;
  10702. };
  10703. /**
  10704. * @language en_US
  10705. * adds an arc to the path which is centered at (x, y) position with radius r starting at startAngle and ending
  10706. * at endAngle going in the given direction by anticlockwise (defaulting to clockwise).
  10707. * @param x The x coordinate of the arc's center.
  10708. * @param y The y coordinate of the arc's center.
  10709. * @param radius The arc's radius.
  10710. * @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians.
  10711. * @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians.
  10712. * @param anticlockwise if true, causes the arc to be drawn counter-clockwise between the two angles. By default it is drawn clockwise.
  10713. * @version Egret 2.4
  10714. * @platform Web,Native
  10715. */
  10716. /**
  10717. * @language zh_CN
  10718. * 绘制一段圆弧路径。圆弧路径的圆心在 (x, y) 位置,半径为 r ,根据anticlockwise (默认为顺时针)指定的方向从 startAngle 开始绘制,到 endAngle 结束。
  10719. * @param x 圆弧中心(圆心)的 x 轴坐标。
  10720. * @param y 圆弧中心(圆心)的 y 轴坐标。
  10721. * @param radius 圆弧的半径。
  10722. * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。
  10723. * @param endAngle 圆弧的终点, 单位以弧度表示。
  10724. * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。
  10725. * @version Egret 2.4
  10726. * @platform Web,Native
  10727. */
  10728. Graphics.prototype.drawArc = function (x, y, radius, startAngle, endAngle, anticlockwise) {
  10729. if (radius < 0 || startAngle === endAngle) {
  10730. return;
  10731. }
  10732. x = +x || 0;
  10733. y = +y || 0;
  10734. radius = +radius || 0;
  10735. startAngle = +startAngle || 0;
  10736. endAngle = +endAngle || 0;
  10737. anticlockwise = !!anticlockwise;
  10738. startAngle = clampAngle(startAngle);
  10739. endAngle = clampAngle(endAngle);
  10740. var fillPath = this.fillPath;
  10741. var strokePath = this.strokePath;
  10742. if (fillPath) {
  10743. fillPath.$lastX = this.lastX;
  10744. fillPath.$lastY = this.lastY;
  10745. fillPath.drawArc(x, y, radius, startAngle, endAngle, anticlockwise);
  10746. }
  10747. if (strokePath) {
  10748. strokePath.$lastX = this.lastX;
  10749. strokePath.$lastY = this.lastY;
  10750. strokePath.drawArc(x, y, radius, startAngle, endAngle, anticlockwise);
  10751. }
  10752. if (anticlockwise) {
  10753. this.arcBounds(x, y, radius, endAngle, startAngle);
  10754. }
  10755. else {
  10756. this.arcBounds(x, y, radius, startAngle, endAngle);
  10757. }
  10758. var endX = x + Math.cos(endAngle) * radius;
  10759. var endY = y + Math.sin(endAngle) * radius;
  10760. this.updatePosition(endX, endY);
  10761. this.$renderNode.dirtyRender = true;
  10762. };
  10763. /**
  10764. * @private
  10765. * 测量圆弧的矩形大小
  10766. */
  10767. Graphics.prototype.arcBounds = function (x, y, radius, startAngle, endAngle) {
  10768. var PI = Math.PI;
  10769. if (Math.abs(startAngle - endAngle) < 0.01) {
  10770. this.extendBoundsByPoint(x - radius, y - radius);
  10771. this.extendBoundsByPoint(x + radius, y + radius);
  10772. return;
  10773. }
  10774. if (startAngle > endAngle) {
  10775. endAngle += PI * 2;
  10776. }
  10777. var startX = Math.cos(startAngle) * radius;
  10778. var endX = Math.cos(endAngle) * radius;
  10779. var xMin = Math.min(startX, endX);
  10780. var xMax = Math.max(startX, endX);
  10781. var startY = Math.sin(startAngle) * radius;
  10782. var endY = Math.sin(endAngle) * radius;
  10783. var yMin = Math.min(startY, endY);
  10784. var yMax = Math.max(startY, endY);
  10785. var startRange = startAngle / (PI * 0.5);
  10786. var endRange = endAngle / (PI * 0.5);
  10787. for (var i = Math.ceil(startRange); i <= endRange; i++) {
  10788. switch (i % 4) {
  10789. case 0:
  10790. xMax = radius;
  10791. break;
  10792. case 1:
  10793. yMax = radius;
  10794. break;
  10795. case 2:
  10796. xMin = -radius;
  10797. break;
  10798. case 3:
  10799. yMin = -radius;
  10800. break;
  10801. }
  10802. }
  10803. xMin = Math.floor(xMin);
  10804. yMin = Math.floor(yMin);
  10805. xMax = Math.ceil(xMax);
  10806. yMax = Math.ceil(yMax);
  10807. this.extendBoundsByPoint(xMin + x, yMin + y);
  10808. this.extendBoundsByPoint(xMax + x, yMax + y);
  10809. };
  10810. /**
  10811. * @language en_US
  10812. * Clear graphics that are drawn to this Graphics object, and reset fill and line style settings.
  10813. * @version Egret 2.4
  10814. * @platform Web,Native
  10815. */
  10816. /**
  10817. * @language zh_CN
  10818. * 清除绘制到此 Graphics 对象的图形,并重置填充和线条样式设置。
  10819. * @version Egret 2.4
  10820. * @platform Web,Native
  10821. */
  10822. Graphics.prototype.clear = function () {
  10823. this.$renderNode.clear();
  10824. this.updatePosition(0, 0);
  10825. this.minX = Infinity;
  10826. this.minY = Infinity;
  10827. this.maxX = -Infinity;
  10828. this.maxY = -Infinity;
  10829. };
  10830. /**
  10831. * @private
  10832. */
  10833. Graphics.prototype.extendBoundsByPoint = function (x, y) {
  10834. this.extendBoundsByX(x);
  10835. this.extendBoundsByY(y);
  10836. };
  10837. /**
  10838. * @private
  10839. */
  10840. Graphics.prototype.extendBoundsByX = function (x) {
  10841. this.minX = Math.min(this.minX, x - this.topLeftStrokeWidth);
  10842. this.maxX = Math.max(this.maxX, x + this.bottomRightStrokeWidth);
  10843. this.updateNodeBounds();
  10844. };
  10845. /**
  10846. * @private
  10847. */
  10848. Graphics.prototype.extendBoundsByY = function (y) {
  10849. this.minY = Math.min(this.minY, y - this.topLeftStrokeWidth);
  10850. this.maxY = Math.max(this.maxY, y + this.bottomRightStrokeWidth);
  10851. this.updateNodeBounds();
  10852. };
  10853. /**
  10854. * @private
  10855. */
  10856. Graphics.prototype.updateNodeBounds = function () {
  10857. var node = this.$renderNode;
  10858. node.x = this.minX;
  10859. node.y = this.minY;
  10860. node.width = Math.ceil(this.maxX - this.minX);
  10861. node.height = Math.ceil(this.maxY - this.minY);
  10862. };
  10863. /**
  10864. * 更新当前的lineX和lineY值,并标记尺寸失效。
  10865. * @private
  10866. */
  10867. Graphics.prototype.updatePosition = function (x, y) {
  10868. if (!this.includeLastPosition) {
  10869. this.extendBoundsByPoint(this.lastX, this.lastY);
  10870. this.includeLastPosition = true;
  10871. }
  10872. this.lastX = x;
  10873. this.lastY = y;
  10874. this.extendBoundsByPoint(x, y);
  10875. this.targetDisplay.$invalidateContentBounds();
  10876. };
  10877. /**
  10878. * @private
  10879. */
  10880. Graphics.prototype.$measureContentBounds = function (bounds) {
  10881. if (this.minX === Infinity) {
  10882. bounds.setEmpty();
  10883. }
  10884. else {
  10885. bounds.setTo(this.minX, this.minY, this.maxX - this.minX, this.maxY - this.minY);
  10886. }
  10887. };
  10888. /**
  10889. * @private
  10890. *
  10891. */
  10892. Graphics.prototype.$hitTest = function (stageX, stageY) {
  10893. var target = this.targetDisplay;
  10894. var m = target.$getInvertedConcatenatedMatrix();
  10895. var localX = m.a * stageX + m.c * stageY + m.tx;
  10896. var localY = m.b * stageX + m.d * stageY + m.ty;
  10897. var buffer = egret.sys.canvasHitTestBuffer;
  10898. buffer.resize(3, 3);
  10899. var node = this.$renderNode;
  10900. var matrix = egret.Matrix.create();
  10901. matrix.identity();
  10902. matrix.translate(1 - localX, 1 - localY);
  10903. egret.sys.canvasRenderer.drawNodeToBuffer(node, buffer, matrix, true);
  10904. egret.Matrix.release(matrix);
  10905. try {
  10906. var data = buffer.getPixels(1, 1);
  10907. if (data[3] === 0) {
  10908. return null;
  10909. }
  10910. }
  10911. catch (e) {
  10912. throw new Error(egret.sys.tr(1039));
  10913. }
  10914. return target;
  10915. };
  10916. /**
  10917. * @private
  10918. */
  10919. Graphics.prototype.$onRemoveFromStage = function () {
  10920. if (this.$renderNode) {
  10921. this.$renderNode.clean();
  10922. }
  10923. };
  10924. return Graphics;
  10925. }(egret.HashObject));
  10926. egret.Graphics = Graphics;
  10927. __reflect(Graphics.prototype, "egret.Graphics");
  10928. })(egret || (egret = {}));
  10929. //////////////////////////////////////////////////////////////////////////////////////
  10930. //
  10931. // Copyright (c) 2014-present, Egret Technology.
  10932. // All rights reserved.
  10933. // Redistribution and use in source and binary forms, with or without
  10934. // modification, are permitted provided that the following conditions are met:
  10935. //
  10936. // * Redistributions of source code must retain the above copyright
  10937. // notice, this list of conditions and the following disclaimer.
  10938. // * Redistributions in binary form must reproduce the above copyright
  10939. // notice, this list of conditions and the following disclaimer in the
  10940. // documentation and/or other materials provided with the distribution.
  10941. // * Neither the name of the Egret nor the
  10942. // names of its contributors may be used to endorse or promote products
  10943. // derived from this software without specific prior written permission.
  10944. //
  10945. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  10946. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  10947. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  10948. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  10949. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  10950. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  10951. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  10952. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  10953. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  10954. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10955. //
  10956. //////////////////////////////////////////////////////////////////////////////////////
  10957. var egret;
  10958. (function (egret) {
  10959. var PI = Math.PI;
  10960. var TwoPI = PI * 2;
  10961. var DEG_TO_RAD = PI / 180;
  10962. var matrixPool = [];
  10963. /**
  10964. * @language en_US
  10965. * The Matrix class represents a transformation matrix that determines how to map points from one coordinate space to
  10966. * another. You can perform various graphical transformations on a display object by setting the properties of a Matrix
  10967. * object, applying that Matrix object to the matrix property of a display object, These transformation functions include
  10968. * translation (x and y repositioning), rotation, scaling, and skewing.
  10969. * @version Egret 2.4
  10970. * @platform Web,Native
  10971. * @includeExample egret/geom/Matrix.ts
  10972. */
  10973. /**
  10974. * @language zh_CN
  10975. * Matrix 类表示一个转换矩阵,它确定如何将点从一个坐标空间映射到另一个坐标空间。
  10976. * 您可以对一个显示对象执行不同的图形转换,方法是设置 Matrix 对象的属性,将该 Matrix
  10977. * 对象应用于显示对象的 matrix 属性。这些转换函数包括平移(x 和 y 重新定位)、旋转、缩放和倾斜。
  10978. * @version Egret 2.4
  10979. * @platform Web,Native
  10980. * @includeExample egret/geom/Matrix.ts
  10981. */
  10982. var Matrix = (function (_super) {
  10983. __extends(Matrix, _super);
  10984. /**
  10985. * @language en_US
  10986. * Creates a new Matrix object with the specified parameters.
  10987. * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image.
  10988. * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image.
  10989. * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image.
  10990. * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image..
  10991. * @param tx The distance by which to translate each point along the x axis.
  10992. * @param ty The distance by which to translate each point along the y axis.
  10993. * @version Egret 2.4
  10994. * @platform Web,Native
  10995. */
  10996. /**
  10997. * @language zh_CN
  10998. * 使用指定参数创建一个 Matrix 对象
  10999. * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值。
  11000. * @param b 旋转或倾斜图像时影响像素沿 y 轴定位的值。
  11001. * @param c 旋转或倾斜图像时影响像素沿 x 轴定位的值。
  11002. * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值。
  11003. * @param tx 沿 x 轴平移每个点的距离。
  11004. * @param ty 沿 y 轴平移每个点的距离。
  11005. * @version Egret 2.4
  11006. * @platform Web,Native
  11007. */
  11008. function Matrix(a, b, c, d, tx, ty) {
  11009. if (a === void 0) { a = 1; }
  11010. if (b === void 0) { b = 0; }
  11011. if (c === void 0) { c = 0; }
  11012. if (d === void 0) { d = 1; }
  11013. if (tx === void 0) { tx = 0; }
  11014. if (ty === void 0) { ty = 0; }
  11015. var _this = _super.call(this) || this;
  11016. _this.a = a;
  11017. _this.b = b;
  11018. _this.c = c;
  11019. _this.d = d;
  11020. _this.tx = tx;
  11021. _this.ty = ty;
  11022. return _this;
  11023. }
  11024. /**
  11025. * @language en_US
  11026. * Releases a matrix instance to the object pool
  11027. * @param matrix matrix that Needs to be recycled
  11028. * @version Egret 2.4
  11029. * @platform Web,Native
  11030. */
  11031. /**
  11032. * @language zh_CN
  11033. * 释放一个Matrix实例到对象池
  11034. * @param matrix 需要回收的 matrix
  11035. * @version Egret 2.4
  11036. * @platform Web,Native
  11037. */
  11038. Matrix.release = function (matrix) {
  11039. if (!matrix) {
  11040. return;
  11041. }
  11042. matrixPool.push(matrix);
  11043. };
  11044. /**
  11045. * @language en_US
  11046. * get a matrix instance from the object pool or create a new one.
  11047. * @version Egret 2.4
  11048. * @platform Web,Native
  11049. */
  11050. /**
  11051. * @language zh_CN
  11052. * 从对象池中取出或创建一个新的Matrix对象。
  11053. * @version Egret 2.4
  11054. * @platform Web,Native
  11055. */
  11056. Matrix.create = function () {
  11057. var matrix = matrixPool.pop();
  11058. if (!matrix) {
  11059. matrix = new Matrix();
  11060. }
  11061. return matrix;
  11062. };
  11063. /**
  11064. * @language en_US
  11065. * Returns a new Matrix object that is a clone of this matrix, with an exact copy of the contained object.
  11066. * @version Egret 2.4
  11067. * @platform Web,Native
  11068. */
  11069. /**
  11070. * @language zh_CN
  11071. * 返回一个新的 Matrix 对象,它是此矩阵的克隆,带有与所含对象完全相同的副本。
  11072. * @version Egret 2.4
  11073. * @platform Web,Native
  11074. */
  11075. Matrix.prototype.clone = function () {
  11076. return new Matrix(this.a, this.b, this.c, this.d, this.tx, this.ty);
  11077. };
  11078. /**
  11079. * @language en_US
  11080. * Concatenates a matrix with the current matrix, effectively combining the geometric effects of the two. In mathematical
  11081. * terms, concatenating two matrixes is the same as combining them using matrix multiplication.
  11082. * @param other The matrix to be concatenated to the source matrix.
  11083. * @version Egret 2.4
  11084. * @platform Web,Native
  11085. */
  11086. /**
  11087. * @language zh_CN
  11088. * 将某个矩阵与当前矩阵连接,从而将这两个矩阵的几何效果有效地结合在一起。在数学术语中,将两个矩阵连接起来与使用矩阵乘法将它们结合起来是相同的。
  11089. * @param other 要连接到源矩阵的矩阵。
  11090. * @version Egret 2.4
  11091. * @platform Web,Native
  11092. */
  11093. Matrix.prototype.concat = function (other) {
  11094. var a = this.a * other.a;
  11095. var b = 0.0;
  11096. var c = 0.0;
  11097. var d = this.d * other.d;
  11098. var tx = this.tx * other.a + other.tx;
  11099. var ty = this.ty * other.d + other.ty;
  11100. if (this.b !== 0.0 || this.c !== 0.0 || other.b !== 0.0 || other.c !== 0.0) {
  11101. a += this.b * other.c;
  11102. d += this.c * other.b;
  11103. b += this.a * other.b + this.b * other.d;
  11104. c += this.c * other.a + this.d * other.c;
  11105. tx += this.ty * other.c;
  11106. ty += this.tx * other.b;
  11107. }
  11108. this.a = a;
  11109. this.b = b;
  11110. this.c = c;
  11111. this.d = d;
  11112. this.tx = tx;
  11113. this.ty = ty;
  11114. };
  11115. /**
  11116. * @language en_US
  11117. * Copies all of the matrix data from the source Point object into the calling Matrix object.
  11118. * @param other The Matrix object from which to copy the data.
  11119. * @version Egret 2.4
  11120. * @platform Web,Native
  11121. */
  11122. /**
  11123. * @language zh_CN
  11124. * 将源 Matrix 对象中的所有矩阵数据复制到调用方 Matrix 对象中。
  11125. * @param other 要拷贝的目标矩阵
  11126. * @version Egret 2.4
  11127. * @platform Web,Native
  11128. */
  11129. Matrix.prototype.copyFrom = function (other) {
  11130. this.a = other.a;
  11131. this.b = other.b;
  11132. this.c = other.c;
  11133. this.d = other.d;
  11134. this.tx = other.tx;
  11135. this.ty = other.ty;
  11136. return this;
  11137. };
  11138. /**
  11139. * @language en_US
  11140. * Sets each matrix property to a value that causes a null transformation. An object transformed by applying an
  11141. * identity matrix will be identical to the original. After calling the identity() method, the resulting matrix
  11142. * has the following properties: a=1, b=0, c=0, d=1, tx=0, ty=0.
  11143. * @version Egret 2.4
  11144. * @platform Web,Native
  11145. */
  11146. /**
  11147. * @language zh_CN
  11148. * 为每个矩阵属性设置一个值,该值将导致矩阵无转换。通过应用恒等矩阵转换的对象将与原始对象完全相同。
  11149. * 调用 identity() 方法后,生成的矩阵具有以下属性:a=1、b=0、c=0、d=1、tx=0 和 ty=0。
  11150. * @version Egret 2.4
  11151. * @platform Web,Native
  11152. */
  11153. Matrix.prototype.identity = function () {
  11154. this.a = this.d = 1;
  11155. this.b = this.c = this.tx = this.ty = 0;
  11156. };
  11157. /**
  11158. * @language en_US
  11159. * Performs the opposite transformation of the original matrix. You can apply an inverted matrix to an object to
  11160. * undo the transformation performed when applying the original matrix.
  11161. * @version Egret 2.4
  11162. * @platform Web,Native
  11163. */
  11164. /**
  11165. * @language zh_CN
  11166. * 执行原始矩阵的逆转换。
  11167. * 您可以将一个逆矩阵应用于对象来撤消在应用原始矩阵时执行的转换。
  11168. * @version Egret 2.4
  11169. * @platform Web,Native
  11170. */
  11171. Matrix.prototype.invert = function () {
  11172. this.$invertInto(this);
  11173. };
  11174. /**
  11175. * @private
  11176. */
  11177. Matrix.prototype.$invertInto = function (target) {
  11178. var a = this.a;
  11179. var b = this.b;
  11180. var c = this.c;
  11181. var d = this.d;
  11182. var tx = this.tx;
  11183. var ty = this.ty;
  11184. if (b == 0 && c == 0) {
  11185. target.b = target.c = 0;
  11186. if (a == 0 || d == 0) {
  11187. target.a = target.d = target.tx = target.ty = 0;
  11188. }
  11189. else {
  11190. a = target.a = 1 / a;
  11191. d = target.d = 1 / d;
  11192. target.tx = -a * tx;
  11193. target.ty = -d * ty;
  11194. }
  11195. return;
  11196. }
  11197. var determinant = a * d - b * c;
  11198. if (determinant == 0) {
  11199. target.identity();
  11200. return;
  11201. }
  11202. determinant = 1 / determinant;
  11203. var k = target.a = d * determinant;
  11204. b = target.b = -b * determinant;
  11205. c = target.c = -c * determinant;
  11206. d = target.d = a * determinant;
  11207. target.tx = -(k * tx + c * ty);
  11208. target.ty = -(b * tx + d * ty);
  11209. };
  11210. /**
  11211. * @language en_US
  11212. * Applies a rotation transformation to the Matrix object.
  11213. * The rotate() method alters the a, b, c, and d properties of the Matrix object.
  11214. * @param angle The rotation angle in radians.
  11215. * @version Egret 2.4
  11216. * @platform Web,Native
  11217. */
  11218. /**
  11219. * @language zh_CN
  11220. * 对 Matrix 对象应用旋转转换。
  11221. * rotate() 方法将更改 Matrix 对象的 a、b、c 和 d 属性。
  11222. * @param angle 以弧度为单位的旋转角度。
  11223. * @version Egret 2.4
  11224. * @platform Web,Native
  11225. */
  11226. Matrix.prototype.rotate = function (angle) {
  11227. angle = +angle;
  11228. if (angle !== 0) {
  11229. angle = angle / DEG_TO_RAD;
  11230. var u = egret.NumberUtils.cos(angle);
  11231. var v = egret.NumberUtils.sin(angle);
  11232. var ta = this.a;
  11233. var tb = this.b;
  11234. var tc = this.c;
  11235. var td = this.d;
  11236. var ttx = this.tx;
  11237. var tty = this.ty;
  11238. this.a = ta * u - tb * v;
  11239. this.b = ta * v + tb * u;
  11240. this.c = tc * u - td * v;
  11241. this.d = tc * v + td * u;
  11242. this.tx = ttx * u - tty * v;
  11243. this.ty = ttx * v + tty * u;
  11244. }
  11245. };
  11246. /**
  11247. * @language en_US
  11248. * Applies a scaling transformation to the matrix. The x axis is multiplied by sx, and the y axis it is multiplied by sy.
  11249. * The scale() method alters the a and d properties of the Matrix object.
  11250. * @param sx A multiplier used to scale the object along the x axis.
  11251. * @param sy A multiplier used to scale the object along the y axis.
  11252. * @version Egret 2.4
  11253. * @platform Web,Native
  11254. */
  11255. /**
  11256. * @language zh_CN
  11257. * 对矩阵应用缩放转换。x 轴乘以 sx,y 轴乘以 sy。
  11258. * scale() 方法将更改 Matrix 对象的 a 和 d 属性。
  11259. * @param sx 用于沿 x 轴缩放对象的乘数。
  11260. * @param sy 用于沿 y 轴缩放对象的乘数。
  11261. * @version Egret 2.4
  11262. * @platform Web,Native
  11263. */
  11264. Matrix.prototype.scale = function (sx, sy) {
  11265. if (sx !== 1) {
  11266. this.a *= sx;
  11267. this.c *= sx;
  11268. this.tx *= sx;
  11269. }
  11270. if (sy !== 1) {
  11271. this.b *= sy;
  11272. this.d *= sy;
  11273. this.ty *= sy;
  11274. }
  11275. };
  11276. /**
  11277. * @language en_US
  11278. * Sets the members of Matrix to the specified values
  11279. * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image.
  11280. * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image.
  11281. * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image.
  11282. * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image..
  11283. * @param tx The distance by which to translate each point along the x axis.
  11284. * @param ty The distance by which to translate each point along the y axis.
  11285. * @version Egret 2.4
  11286. * @platform Web,Native
  11287. */
  11288. /**
  11289. * @language zh_CN
  11290. * 将 Matrix 的成员设置为指定值
  11291. * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值。
  11292. * @param b 旋转或倾斜图像时影响像素沿 y 轴定位的值。
  11293. * @param c 旋转或倾斜图像时影响像素沿 x 轴定位的值。
  11294. * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值。
  11295. * @param tx 沿 x 轴平移每个点的距离。
  11296. * @param ty 沿 y 轴平移每个点的距离。
  11297. * @version Egret 2.4
  11298. * @platform Web,Native
  11299. */
  11300. Matrix.prototype.setTo = function (a, b, c, d, tx, ty) {
  11301. this.a = a;
  11302. this.b = b;
  11303. this.c = c;
  11304. this.d = d;
  11305. this.tx = tx;
  11306. this.ty = ty;
  11307. return this;
  11308. };
  11309. /**
  11310. * @language en_US
  11311. * Returns the result of applying the geometric transformation represented by the Matrix object to the specified point.
  11312. * @param pointX The x coordinate for which you want to get the result of the Matrix transformation.
  11313. * @param pointY The y coordinate for which you want to get the result of the Matrix transformation.
  11314. * @param resultPoint A reusable instance of Point for saving the results. Passing this parameter can reduce the
  11315. * number of reallocate objects, which allows you to get better code execution performance.
  11316. * @returns The point resulting from applying the Matrix transformation.
  11317. * @version Egret 2.4
  11318. * @platform Web,Native
  11319. */
  11320. /**
  11321. * @language zh_CN
  11322. * 返回将 Matrix 对象表示的几何转换应用于指定点所产生的结果。
  11323. * @param pointX 想要获得其矩阵转换结果的点的x坐标。
  11324. * @param pointY 想要获得其矩阵转换结果的点的y坐标。
  11325. * @param resultPoint 框架建议尽可能减少创建对象次数来优化性能,可以从外部传入一个复用的Point对象来存储结果,若不传入将创建一个新的Point对象返回。
  11326. * @returns 由应用矩阵转换所产生的点。
  11327. * @version Egret 2.4
  11328. * @platform Web,Native
  11329. */
  11330. Matrix.prototype.transformPoint = function (pointX, pointY, resultPoint) {
  11331. var x = this.a * pointX + this.c * pointY + this.tx;
  11332. var y = this.b * pointX + this.d * pointY + this.ty;
  11333. if (resultPoint) {
  11334. resultPoint.setTo(x, y);
  11335. return resultPoint;
  11336. }
  11337. return new egret.Point(x, y);
  11338. };
  11339. /**
  11340. * @language en_US
  11341. * Translates the matrix along the x and y axes, as specified by the dx and dy parameters.
  11342. * @param dx The amount of movement along the x axis to the right, in pixels.
  11343. * @param dy The amount of movement down along the y axis, in pixels.
  11344. * @version Egret 2.4
  11345. * @platform Web,Native
  11346. */
  11347. /**
  11348. * @language zh_CN
  11349. * 沿 x 和 y 轴平移矩阵,由 dx 和 dy 参数指定。
  11350. * @param dx 沿 x 轴向右移动的量(以像素为单位)。
  11351. * @param dy 沿 y 轴向下移动的量(以像素为单位)。
  11352. * @version Egret 2.4
  11353. * @platform Web,Native
  11354. */
  11355. Matrix.prototype.translate = function (dx, dy) {
  11356. this.tx += dx;
  11357. this.ty += dy;
  11358. };
  11359. /**
  11360. * @language en_US
  11361. * Determines whether two matrixes are equal.
  11362. * @param other The matrix to be compared.
  11363. * @returns A value of true if the object is equal to this Matrix object; false if it is not equal.
  11364. * @version Egret 2.4
  11365. * @platform Web,Native
  11366. */
  11367. /**
  11368. * @language zh_CN
  11369. * 是否与另一个矩阵数据相等
  11370. * @param other 要比较的另一个矩阵对象。
  11371. * @returns 是否相等,ture表示相等。
  11372. * @version Egret 2.4
  11373. * @platform Web,Native
  11374. */
  11375. Matrix.prototype.equals = function (other) {
  11376. return this.a == other.a && this.b == other.b &&
  11377. this.c == other.c && this.d == other.d &&
  11378. this.tx == other.tx && this.ty == other.ty;
  11379. };
  11380. /**
  11381. * @language en_US
  11382. * prepend matrix
  11383. * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image.
  11384. * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image.
  11385. * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image.
  11386. * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image..
  11387. * @param tx The distance by which to translate each point along the x axis.
  11388. * @param ty The distance by which to translate each point along the y axis.
  11389. * @returns matrix
  11390. * @version Egret 2.4
  11391. * @platform Web,Native
  11392. */
  11393. /**
  11394. * @language zh_CN
  11395. * 前置矩阵
  11396. * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值
  11397. * @param b 缩放或旋转图像时影响像素沿 y 轴定位的值
  11398. * @param c 缩放或旋转图像时影响像素沿 x 轴定位的值
  11399. * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值
  11400. * @param tx 沿 x 轴平移每个点的距离
  11401. * @param ty 沿 y 轴平移每个点的距离
  11402. * @returns 矩阵自身
  11403. * @version Egret 2.4
  11404. * @platform Web,Native
  11405. */
  11406. Matrix.prototype.prepend = function (a, b, c, d, tx, ty) {
  11407. var tx1 = this.tx;
  11408. if (a != 1 || b != 0 || c != 0 || d != 1) {
  11409. var a1 = this.a;
  11410. var c1 = this.c;
  11411. this.a = a1 * a + this.b * c;
  11412. this.b = a1 * b + this.b * d;
  11413. this.c = c1 * a + this.d * c;
  11414. this.d = c1 * b + this.d * d;
  11415. }
  11416. this.tx = tx1 * a + this.ty * c + tx;
  11417. this.ty = tx1 * b + this.ty * d + ty;
  11418. return this;
  11419. };
  11420. /**
  11421. * @language en_US
  11422. * append matrix
  11423. * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image.
  11424. * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image.
  11425. * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image.
  11426. * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image..
  11427. * @param tx The distance by which to translate each point along the x axis.
  11428. * @param ty The distance by which to translate each point along the y axis.
  11429. * @returns matrix
  11430. * @version Egret 2.4
  11431. * @platform Web,Native
  11432. */
  11433. /**
  11434. * @language zh_CN
  11435. * 后置矩阵
  11436. * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值
  11437. * @param b 缩放或旋转图像时影响像素沿 y 轴定位的值
  11438. * @param c 缩放或旋转图像时影响像素沿 x 轴定位的值
  11439. * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值
  11440. * @param tx 沿 x 轴平移每个点的距离
  11441. * @param ty 沿 y 轴平移每个点的距离
  11442. * @returns 矩阵自身
  11443. * @version Egret 2.4
  11444. * @platform Web,Native
  11445. */
  11446. Matrix.prototype.append = function (a, b, c, d, tx, ty) {
  11447. var a1 = this.a;
  11448. var b1 = this.b;
  11449. var c1 = this.c;
  11450. var d1 = this.d;
  11451. if (a != 1 || b != 0 || c != 0 || d != 1) {
  11452. this.a = a * a1 + b * c1;
  11453. this.b = a * b1 + b * d1;
  11454. this.c = c * a1 + d * c1;
  11455. this.d = c * b1 + d * d1;
  11456. }
  11457. this.tx = tx * a1 + ty * c1 + this.tx;
  11458. this.ty = tx * b1 + ty * d1 + this.ty;
  11459. return this;
  11460. };
  11461. /**
  11462. * @language en_US
  11463. * Given a point in the pretransform coordinate space, returns the coordinates of that point after the transformation occurs.
  11464. * Unlike the standard transformation applied using the transformPoint() method, the deltaTransformPoint() method's transformation does not consider the translation parameters tx and ty.
  11465. * @param point The point for which you want to get the result of the matrix transformation.
  11466. * @returns The point resulting from applying the matrix transformation.
  11467. * @version Egret 2.4
  11468. * @platform Web,Native
  11469. */
  11470. /**
  11471. * @language zh_CN
  11472. * 如果给定预转换坐标空间中的点,则此方法返回发生转换后该点的坐标。
  11473. * 与使用 transformPoint() 方法应用的标准转换不同,deltaTransformPoint() 方法的转换不考虑转换参数 tx 和 ty。
  11474. * @param point 想要获得其矩阵转换结果的点
  11475. * @returns 由应用矩阵转换所产生的点
  11476. * @version Egret 2.4
  11477. * @platform Web,Native
  11478. */
  11479. Matrix.prototype.deltaTransformPoint = function (point) {
  11480. var self = this;
  11481. var x = self.a * point.x + self.c * point.y;
  11482. var y = self.b * point.x + self.d * point.y;
  11483. return new egret.Point(x, y);
  11484. };
  11485. /**
  11486. * @language en_US
  11487. * Returns a text value listing the properties of the Matrix object.
  11488. * @returns A string containing the values of the properties of the Matrix object: a, b, c, d, tx, and ty.
  11489. * @version Egret 2.4
  11490. * @platform Web,Native
  11491. */
  11492. /**
  11493. * @language zh_CN
  11494. * 返回将 Matrix 对象表示的几何转换应用于指定点所产生的结果。
  11495. * @returns 一个字符串,它包含 Matrix 对象的属性值:a、b、c、d、tx 和 ty。
  11496. * @version Egret 2.4
  11497. * @platform Web,Native
  11498. */
  11499. Matrix.prototype.toString = function () {
  11500. return "(a=" + this.a + ", b=" + this.b + ", c=" + this.c + ", d=" + this.d + ", tx=" + this.tx + ", ty=" + this.ty + ")";
  11501. };
  11502. /**
  11503. * @language en_US
  11504. * Includes parameters for scaling, rotation, and translation. When applied to a matrix it sets the matrix's values based on those parameters.
  11505. * @param scaleX The factor by which to scale horizontally.
  11506. * @param scaleY The factor by which scale vertically.
  11507. * @param rotation The amount to rotate, in radians.
  11508. * @param tx The number of pixels to translate (move) to the right along the x axis.
  11509. * @param ty The number of pixels to translate (move) down along the y axis.
  11510. * @version Egret 2.4
  11511. * @platform Web,Native
  11512. */
  11513. /**
  11514. * @language zh_CN
  11515. * 包括用于缩放、旋转和转换的参数。当应用于矩阵时,该方法会基于这些参数设置矩阵的值。
  11516. * @param scaleX 水平缩放所用的系数
  11517. * @param scaleY 垂直缩放所用的系数
  11518. * @param rotation 旋转量(以弧度为单位)
  11519. * @param tx 沿 x 轴向右平移(移动)的像素数
  11520. * @param ty 沿 y 轴向下平移(移动)的像素数
  11521. * @version Egret 2.4
  11522. * @platform Web,Native
  11523. */
  11524. Matrix.prototype.createBox = function (scaleX, scaleY, rotation, tx, ty) {
  11525. if (rotation === void 0) { rotation = 0; }
  11526. if (tx === void 0) { tx = 0; }
  11527. if (ty === void 0) { ty = 0; }
  11528. var self = this;
  11529. if (rotation !== 0) {
  11530. rotation = rotation / DEG_TO_RAD;
  11531. var u = egret.NumberUtils.cos(rotation);
  11532. var v = egret.NumberUtils.sin(rotation);
  11533. self.a = u * scaleX;
  11534. self.b = v * scaleY;
  11535. self.c = -v * scaleX;
  11536. self.d = u * scaleY;
  11537. }
  11538. else {
  11539. self.a = scaleX;
  11540. self.b = 0;
  11541. self.c = 0;
  11542. self.d = scaleY;
  11543. }
  11544. self.tx = tx;
  11545. self.ty = ty;
  11546. };
  11547. /**
  11548. * @language en_US
  11549. * Creates the specific style of matrix expected by the beginGradientFill() and lineGradientStyle() methods of the Graphics class.
  11550. * Width and height are scaled to a scaleX/scaleY pair and the tx/ty values are offset by half the width and height.
  11551. * @param width The width of the gradient box.
  11552. * @param height The height of the gradient box.
  11553. * @param rotation The amount to rotate, in radians.
  11554. * @param tx The distance, in pixels, to translate to the right along the x axis. This value is offset by half of the width parameter.
  11555. * @param ty The distance, in pixels, to translate down along the y axis. This value is offset by half of the height parameter.
  11556. * @version Egret 2.4
  11557. * @platform Web,Native
  11558. */
  11559. /**
  11560. * @language zh_CN
  11561. * 创建 Graphics 类的 beginGradientFill() 和 lineGradientStyle() 方法所需的矩阵的特定样式。
  11562. * 宽度和高度被缩放为 scaleX/scaleY 对,而 tx/ty 值偏移了宽度和高度的一半。
  11563. * @param width 渐变框的宽度
  11564. * @param height 渐变框的高度
  11565. * @param rotation 旋转量(以弧度为单位)
  11566. * @param tx 沿 x 轴向右平移的距离(以像素为单位)。此值将偏移 width 参数的一半
  11567. * @param ty 沿 y 轴向下平移的距离(以像素为单位)。此值将偏移 height 参数的一半
  11568. * @version Egret 2.4
  11569. * @platform Web,Native
  11570. */
  11571. Matrix.prototype.createGradientBox = function (width, height, rotation, tx, ty) {
  11572. if (rotation === void 0) { rotation = 0; }
  11573. if (tx === void 0) { tx = 0; }
  11574. if (ty === void 0) { ty = 0; }
  11575. this.createBox(width / 1638.4, height / 1638.4, rotation, tx + width / 2, ty + height / 2);
  11576. };
  11577. /**
  11578. * @private
  11579. */
  11580. Matrix.prototype.$transformBounds = function (bounds) {
  11581. var a = this.a;
  11582. var b = this.b;
  11583. var c = this.c;
  11584. var d = this.d;
  11585. var tx = this.tx;
  11586. var ty = this.ty;
  11587. var x = bounds.x;
  11588. var y = bounds.y;
  11589. var xMax = x + bounds.width;
  11590. var yMax = y + bounds.height;
  11591. var x0 = a * x + c * y + tx;
  11592. var y0 = b * x + d * y + ty;
  11593. var x1 = a * xMax + c * y + tx;
  11594. var y1 = b * xMax + d * y + ty;
  11595. var x2 = a * xMax + c * yMax + tx;
  11596. var y2 = b * xMax + d * yMax + ty;
  11597. var x3 = a * x + c * yMax + tx;
  11598. var y3 = b * x + d * yMax + ty;
  11599. var tmp = 0;
  11600. if (x0 > x1) {
  11601. tmp = x0;
  11602. x0 = x1;
  11603. x1 = tmp;
  11604. }
  11605. if (x2 > x3) {
  11606. tmp = x2;
  11607. x2 = x3;
  11608. x3 = tmp;
  11609. }
  11610. bounds.x = Math.floor(x0 < x2 ? x0 : x2);
  11611. bounds.width = Math.ceil((x1 > x3 ? x1 : x3) - bounds.x);
  11612. if (y0 > y1) {
  11613. tmp = y0;
  11614. y0 = y1;
  11615. y1 = tmp;
  11616. }
  11617. if (y2 > y3) {
  11618. tmp = y2;
  11619. y2 = y3;
  11620. y3 = tmp;
  11621. }
  11622. bounds.y = Math.floor(y0 < y2 ? y0 : y2);
  11623. bounds.height = Math.ceil((y1 > y3 ? y1 : y3) - bounds.y);
  11624. };
  11625. /**
  11626. * @private
  11627. */
  11628. Matrix.prototype.getDeterminant = function () {
  11629. return this.a * this.d - this.b * this.c;
  11630. };
  11631. /**
  11632. * @private
  11633. */
  11634. Matrix.prototype.$getScaleX = function () {
  11635. var m = this;
  11636. if (m.a == 1 && m.b == 0) {
  11637. return 1;
  11638. }
  11639. var result = Math.sqrt(m.a * m.a + m.b * m.b);
  11640. return this.getDeterminant() < 0 ? -result : result;
  11641. };
  11642. /**
  11643. * @private
  11644. */
  11645. Matrix.prototype.$getScaleY = function () {
  11646. var m = this;
  11647. if (m.c == 0 && m.d == 1) {
  11648. return 1;
  11649. }
  11650. var result = Math.sqrt(m.c * m.c + m.d * m.d);
  11651. return this.getDeterminant() < 0 ? -result : result;
  11652. };
  11653. /**
  11654. * @private
  11655. */
  11656. Matrix.prototype.$getSkewX = function () {
  11657. return Math.atan2(this.d, this.c) - (PI / 2);
  11658. };
  11659. /**
  11660. * @private
  11661. */
  11662. Matrix.prototype.$getSkewY = function () {
  11663. return Math.atan2(this.b, this.a);
  11664. };
  11665. /**
  11666. * @private
  11667. */
  11668. Matrix.prototype.$updateScaleAndRotation = function (scaleX, scaleY, skewX, skewY) {
  11669. if ((skewX == 0 || skewX == TwoPI) && (skewY == 0 || skewY == TwoPI)) {
  11670. this.a = scaleX;
  11671. this.b = this.c = 0;
  11672. this.d = scaleY;
  11673. return;
  11674. }
  11675. skewX = skewX / DEG_TO_RAD;
  11676. skewY = skewY / DEG_TO_RAD;
  11677. var u = egret.NumberUtils.cos(skewX);
  11678. var v = egret.NumberUtils.sin(skewX);
  11679. if (skewX == skewY) {
  11680. this.a = u * scaleX;
  11681. this.b = v * scaleX;
  11682. }
  11683. else {
  11684. this.a = egret.NumberUtils.cos(skewY) * scaleX;
  11685. this.b = egret.NumberUtils.sin(skewY) * scaleX;
  11686. }
  11687. this.c = -v * scaleY;
  11688. this.d = u * scaleY;
  11689. };
  11690. /**
  11691. * @private
  11692. * target = other * this
  11693. */
  11694. Matrix.prototype.$preMultiplyInto = function (other, target) {
  11695. var a = other.a * this.a;
  11696. var b = 0.0;
  11697. var c = 0.0;
  11698. var d = other.d * this.d;
  11699. var tx = other.tx * this.a + this.tx;
  11700. var ty = other.ty * this.d + this.ty;
  11701. if (other.b !== 0.0 || other.c !== 0.0 || this.b !== 0.0 || this.c !== 0.0) {
  11702. a += other.b * this.c;
  11703. d += other.c * this.b;
  11704. b += other.a * this.b + other.b * this.d;
  11705. c += other.c * this.a + other.d * this.c;
  11706. tx += other.ty * this.c;
  11707. ty += other.tx * this.b;
  11708. }
  11709. target.a = a;
  11710. target.b = b;
  11711. target.c = c;
  11712. target.d = d;
  11713. target.tx = tx;
  11714. target.ty = ty;
  11715. };
  11716. return Matrix;
  11717. }(egret.HashObject));
  11718. egret.Matrix = Matrix;
  11719. __reflect(Matrix.prototype, "egret.Matrix");
  11720. /**
  11721. * @private
  11722. * 仅供框架内复用,要防止暴露引用到外部。
  11723. */
  11724. egret.$TempMatrix = new Matrix();
  11725. })(egret || (egret = {}));
  11726. //////////////////////////////////////////////////////////////////////////////////////
  11727. //
  11728. // Copyright (c) 2014-present, Egret Technology.
  11729. // All rights reserved.
  11730. // Redistribution and use in source and binary forms, with or without
  11731. // modification, are permitted provided that the following conditions are met:
  11732. //
  11733. // * Redistributions of source code must retain the above copyright
  11734. // notice, this list of conditions and the following disclaimer.
  11735. // * Redistributions in binary form must reproduce the above copyright
  11736. // notice, this list of conditions and the following disclaimer in the
  11737. // documentation and/or other materials provided with the distribution.
  11738. // * Neither the name of the Egret nor the
  11739. // names of its contributors may be used to endorse or promote products
  11740. // derived from this software without specific prior written permission.
  11741. //
  11742. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  11743. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  11744. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  11745. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  11746. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11747. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  11748. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  11749. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  11750. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  11751. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11752. //
  11753. //////////////////////////////////////////////////////////////////////////////////////
  11754. var egret;
  11755. (function (egret) {
  11756. /**
  11757. * @language en_US
  11758. * The JointStyle class is an enumeration of constant values that specify the joint style to use in drawing lines.
  11759. * These constants are provided for use as values in the joints parameter of the egret.Graphics.lineStyle() method.
  11760. * @see egret.Graphics#lineStyle()
  11761. * @version Egret 2.5
  11762. * @platform Web,Native
  11763. */
  11764. /**
  11765. * @language zh_CN
  11766. * JointStyle 类是指定要在绘制线条中使用的联接点样式的常量值枚举。提供的这些常量用作 egret.Graphics.lineStyle() 方法的 joints 参数中的值。
  11767. * @see egret.Graphics#lineStyle()
  11768. * @version Egret 2.5
  11769. * @platform Web,Native
  11770. */
  11771. egret.JointStyle = {
  11772. /**
  11773. * @language en_US
  11774. * Specifies beveled joints in the joints parameter of the egret.Graphics.lineStyle() method.
  11775. * @version Egret 2.5
  11776. * @platform Web,Native
  11777. */
  11778. /**
  11779. * @language zh_CN
  11780. * 在 egret.Graphics.lineStyle() 方法的 joints 参数中指定斜角连接。
  11781. * @version Egret 2.5
  11782. * @platform Web,Native
  11783. */
  11784. BEVEL: "bevel",
  11785. /**
  11786. * @language en_US
  11787. * Specifies mitered joints in the joints parameter of the egret.Graphics.lineStyle() method.
  11788. * @version Egret 2.5
  11789. * @platform Web,Native
  11790. */
  11791. /**
  11792. * @language zh_CN
  11793. * 在 egret.Graphics.lineStyle() 方法的 joints 参数中指定尖角连接。
  11794. * @version Egret 2.5
  11795. * @platform Web,Native
  11796. */
  11797. MITER: "miter",
  11798. /**
  11799. * @language en_US
  11800. * Specifies round joints in the joints parameter of the egret.Graphics.lineStyle() method.
  11801. * @version Egret 2.5
  11802. * @platform Web,Native
  11803. */
  11804. /**
  11805. * @language zh_CN
  11806. * 在 egret.Graphics.lineStyle() 方法的 joints 参数中指定圆角连接。
  11807. * @version Egret 2.5
  11808. * @platform Web,Native
  11809. */
  11810. ROUND: "round"
  11811. };
  11812. })(egret || (egret = {}));
  11813. var egret;
  11814. (function (egret) {
  11815. egret.$locale_strings = egret.$locale_strings || {};
  11816. egret.$locale_strings["en_US"] = egret.$locale_strings["en_US"] || {};
  11817. var locale_strings = egret.$locale_strings["en_US"];
  11818. //core 1000-1999
  11819. locale_strings[1001] = "Could not find Egret entry class: {0}。";
  11820. locale_strings[1002] = "Egret entry class '{0}' must inherit from egret.DisplayObject.";
  11821. locale_strings[1003] = "Parameter {0} must be non-null.";
  11822. locale_strings[1004] = "An object cannot be added as a child to one of it's children (or children's children, etc.).";
  11823. locale_strings[1005] = "An object cannot be added as a child of itself.";
  11824. locale_strings[1006] = "The supplied DisplayObject must be a child of the caller.";
  11825. locale_strings[1007] = "An index specified for a parameter was out of range.";
  11826. locale_strings[1008] = "Instantiate singleton error,singleton class {0} can not create multiple instances.";
  11827. locale_strings[1009] = "the Class {0} cannot use the property \"{1}\"";
  11828. locale_strings[1010] = "the property \"{1}\" of the Class \"{0}\" is readonly";
  11829. locale_strings[1011] = "Stream Error. URL: {0}";
  11830. locale_strings[1012] = "The type of parameter {0} must be Class.";
  11831. locale_strings[1013] = "Variable assignment is NaN, please see the code!";
  11832. locale_strings[1014] = "the constant \"{1}\" of the Class \"{0}\" is read-only";
  11833. locale_strings[1015] = "xml not found!";
  11834. locale_strings[1016] = "{0}has been obsoleted";
  11835. locale_strings[1017] = "The format of JSON file is incorrect: {0}\ndata: {1}";
  11836. locale_strings[1018] = "the scale9Grid is not correct";
  11837. locale_strings[1019] = "Network ab:{0}";
  11838. locale_strings[1020] = "Cannot initialize Shader";
  11839. locale_strings[1021] = "Current browser does not support webgl";
  11840. locale_strings[1022] = "{0} ArgumentError";
  11841. locale_strings[1023] = "This method is not available in the ScrollView!";
  11842. locale_strings[1025] = "end of the file";
  11843. locale_strings[1026] = "! EncodingError The code point {0} could not be encoded.";
  11844. locale_strings[1027] = "DecodingError";
  11845. locale_strings[1028] = ". called injection is not configured rule: {0}, please specify configuration during its initial years of injection rule, and then call the corresponding single case.";
  11846. locale_strings[1029] = "Function.prototype.bind - what is trying to be bound is not callable";
  11847. locale_strings[1033] = "Photos can not be used across domains toDataURL to convert base64";
  11848. locale_strings[1034] = "Music file decoding failed: \"{0}\", please use the standard conversion tool reconversion under mp3.";
  11849. locale_strings[1035] = "Native does not support this feature!";
  11850. locale_strings[1036] = "Sound has stopped, please recall Sound.play () to play the sound!";
  11851. locale_strings[1037] = "Non-load the correct blob!";
  11852. locale_strings[1038] = "XML format error!";
  11853. locale_strings[1039] = "Cross domains pictures can not get pixel information!";
  11854. locale_strings[1040] = "hitTestPoint can not detect crossOrigin images! Please check if the display object has crossOrigin elements.";
  11855. locale_strings[1041] = "{0} is deprecated, please use {1} replace";
  11856. locale_strings[1042] = "The parameters passed in the region needs is an integer in drawToTexture method. Otherwise, some browsers will draw abnormal.";
  11857. locale_strings[1043] = "Compile errors in {0}, the attribute name: {1}, the attribute value: {2}.";
  11858. locale_strings[1044] = "The current version of the Runtime does not support video playback, please use the latest version";
  11859. locale_strings[1045] = "The resource url is not found";
  11860. locale_strings[1046] = "BitmapText no corresponding characters: {0}, please check the configuration file";
  11861. locale_strings[1047] = "egret.localStorage.setItem save failed,key={0}&value={1}";
  11862. locale_strings[1048] = "Video loading failed";
  11863. locale_strings[1049] = "In the absence of sound is not allowed to play after loading";
  11864. locale_strings[1050] = "ExternalInterface calls the method without js registration: {0}";
  11865. //gui 3000-3099
  11866. locale_strings[3000] = "Theme configuration file failed to load: {0}";
  11867. locale_strings[3001] = "Cannot find the skin name which is configured in Theme: {0}";
  11868. locale_strings[3002] = "Index:\"{0}\" is out of the collection element index range";
  11869. locale_strings[3003] = "Cannot be available in this component. If this component is container, please continue to use";
  11870. locale_strings[3004] = "addChild(){0}addElement() replace";
  11871. locale_strings[3005] = "addChildAt(){0}addElementAt() replace";
  11872. locale_strings[3006] = "removeChild(){0}removeElement() replace";
  11873. locale_strings[3007] = "removeChildAt(){0}removeElementAt() replace";
  11874. locale_strings[3008] = "setChildIndex(){0}setElementIndex() replace";
  11875. locale_strings[3009] = "swapChildren(){0}swapElements() replace";
  11876. locale_strings[3010] = "swapChildrenAt(){0}swapElementsAt() replace";
  11877. locale_strings[3011] = "Index:\"{0}\" is out of the visual element index range";
  11878. locale_strings[3012] = "This method is not available in Scroller component!";
  11879. locale_strings[3013] = "UIStage is GUI root container, and only one such instant is in the display list!";
  11880. locale_strings[3014] = "set fullscreen error";
  11881. //socket 3100-3199
  11882. locale_strings[3100] = "Current browser does not support WebSocket";
  11883. locale_strings[3101] = "Please connect Socket firstly";
  11884. locale_strings[3102] = "Please set the type of binary type";
  11885. //db 4000-4299
  11886. locale_strings[4000] = "An Bone cannot be added as a child to itself or one of its children (or children's children, etc.)";
  11887. locale_strings[4001] = "Abstract class can not be instantiated!";
  11888. locale_strings[4002] = "Unnamed data!";
  11889. locale_strings[4003] = "Nonsupport version!";
  11890. })(egret || (egret = {}));
  11891. //////////////////////////////////////////////////////////////////////////////////////
  11892. //
  11893. // Copyright (c) 2014-present, Egret Technology.
  11894. // All rights reserved.
  11895. // Redistribution and use in source and binary forms, with or without
  11896. // modification, are permitted provided that the following conditions are met:
  11897. //
  11898. // * Redistributions of source code must retain the above copyright
  11899. // notice, this list of conditions and the following disclaimer.
  11900. // * Redistributions in binary form must reproduce the above copyright
  11901. // notice, this list of conditions and the following disclaimer in the
  11902. // documentation and/or other materials provided with the distribution.
  11903. // * Neither the name of the Egret nor the
  11904. // names of its contributors may be used to endorse or promote products
  11905. // derived from this software without specific prior written permission.
  11906. //
  11907. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  11908. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  11909. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  11910. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  11911. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11912. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  11913. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  11914. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  11915. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  11916. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11917. //
  11918. //////////////////////////////////////////////////////////////////////////////////////
  11919. var egret;
  11920. (function (egret) {
  11921. /**
  11922. * @private
  11923. */
  11924. var Mesh = (function (_super) {
  11925. __extends(Mesh, _super);
  11926. function Mesh(value) {
  11927. var _this = _super.call(this, value) || this;
  11928. /**
  11929. * @private
  11930. */
  11931. _this._verticesDirty = true;
  11932. _this._bounds = new egret.Rectangle();
  11933. _this.$renderNode = new egret.sys.MeshNode();
  11934. return _this;
  11935. }
  11936. /**
  11937. * @private
  11938. */
  11939. Mesh.prototype.$render = function () {
  11940. var values = this.$Bitmap;
  11941. var image = values[1 /* image */];
  11942. if (!image) {
  11943. return;
  11944. }
  11945. var scale = egret.$TextureScaleFactor;
  11946. var node = this.$renderNode;
  11947. node.smoothing = values[10 /* smoothing */];
  11948. node.image = image;
  11949. node.imageWidth = values[13 /* sourceWidth */];
  11950. node.imageHeight = values[14 /* sourceHeight */];
  11951. var destW = !isNaN(values[11 /* explicitBitmapWidth */]) ? values[11 /* explicitBitmapWidth */] : values[8 /* textureWidth */];
  11952. var destH = !isNaN(values[12 /* explicitBitmapHeight */]) ? values[12 /* explicitBitmapHeight */] : values[9 /* textureHeight */];
  11953. var tsX = destW / values[8 /* textureWidth */];
  11954. var tsY = destH / values[9 /* textureHeight */];
  11955. var bitmapWidth = values[4 /* bitmapWidth */];
  11956. var bitmapHeight = values[5 /* bitmapHeight */];
  11957. node.drawMesh(values[2 /* bitmapX */], values[3 /* bitmapY */], bitmapWidth, bitmapHeight, values[6 /* offsetX */] * tsX, values[7 /* offsetY */] * tsY, tsX * bitmapWidth, tsY * bitmapHeight);
  11958. };
  11959. /**
  11960. * @private
  11961. */
  11962. Mesh.prototype.$updateVertices = function () {
  11963. this._verticesDirty = true;
  11964. this.$invalidateContentBounds();
  11965. };
  11966. /**
  11967. * @private
  11968. */
  11969. Mesh.prototype.$measureContentBounds = function (bounds) {
  11970. if (this._verticesDirty) {
  11971. this._verticesDirty = false;
  11972. var node = this.$renderNode;
  11973. var vertices = node.vertices;
  11974. if (vertices.length) {
  11975. this._bounds.setTo(Number.MAX_VALUE, Number.MAX_VALUE, Number.MIN_VALUE, Number.MIN_VALUE);
  11976. for (var i = 0, l = vertices.length; i < l; i += 2) {
  11977. var x = vertices[i];
  11978. var y = vertices[i + 1];
  11979. if (this._bounds.x > x)
  11980. this._bounds.x = x;
  11981. if (this._bounds.width < x)
  11982. this._bounds.width = x;
  11983. if (this._bounds.y > y)
  11984. this._bounds.y = y;
  11985. if (this._bounds.height < y)
  11986. this._bounds.height = y;
  11987. }
  11988. this._bounds.width -= this._bounds.x;
  11989. this._bounds.height -= this._bounds.y;
  11990. }
  11991. else {
  11992. this._bounds.setTo(0, 0, 0, 0);
  11993. }
  11994. node.bounds.copyFrom(this._bounds);
  11995. }
  11996. bounds.copyFrom(this._bounds);
  11997. };
  11998. return Mesh;
  11999. }(egret.Bitmap));
  12000. egret.Mesh = Mesh;
  12001. __reflect(Mesh.prototype, "egret.Mesh");
  12002. })(egret || (egret = {}));
  12003. var egret;
  12004. (function (egret) {
  12005. egret.$locale_strings = egret.$locale_strings || {};
  12006. egret.$locale_strings["zh_CN"] = egret.$locale_strings["zh_CN"] || {};
  12007. var locale_strings = egret.$locale_strings["zh_CN"];
  12008. //eui 2000-2999
  12009. //RES 3200-3299
  12010. //core 1000-1999
  12011. locale_strings[1001] = "找不到Egret入口类: {0}。";
  12012. locale_strings[1002] = "Egret入口类 {0} 必须继承自egret.DisplayObject。";
  12013. locale_strings[1003] = "参数 {0} 不能为 null。";
  12014. locale_strings[1004] = "无法将对象添加为它的一个子对象(或子对象的子对象等)的子对象。";
  12015. locale_strings[1005] = "不能将对象添加为其自身的子对象。";
  12016. locale_strings[1006] = "提供的 DisplayObject 必须是调用者的子级。";
  12017. locale_strings[1007] = "为参数指定的索引不在范围内。";
  12018. locale_strings[1008] = "实例化单例出错,不允许实例化多个 {0} 对象。";
  12019. locale_strings[1009] = "类 {0} 不可以使用属性 {1}";
  12020. locale_strings[1010] = "类 {0} 属性 {1} 是只读的";
  12021. locale_strings[1011] = "流错误。URL: {0}";
  12022. locale_strings[1012] = "参数 {0} 的类型必须为 Class。";
  12023. locale_strings[1013] = "变量赋值为NaN,请查看代码!";
  12024. locale_strings[1014] = "类 {0} 常量 {1} 是只读的";
  12025. locale_strings[1015] = "xml not found!";
  12026. locale_strings[1016] = "{0}已经废弃";
  12027. locale_strings[1017] = "JSON文件格式不正确: {0}\ndata: {1}";
  12028. locale_strings[1018] = "9宫格设置错误";
  12029. locale_strings[1019] = "网络异常:{0}";
  12030. locale_strings[1020] = "无法初始化着色器";
  12031. locale_strings[1021] = "当前浏览器不支持webgl";
  12032. locale_strings[1022] = "{0} ArgumentError";
  12033. locale_strings[1023] = "此方法在ScrollView内不可用!";
  12034. locale_strings[1025] = "遇到文件尾";
  12035. locale_strings[1026] = "EncodingError! The code point {0} could not be encoded.";
  12036. locale_strings[1027] = "DecodingError";
  12037. locale_strings[1028] = "调用了未配置的注入规则:{0}。 请先在项目初始化里配置指定的注入规则,再调用对应单例。";
  12038. locale_strings[1029] = "Function.prototype.bind - what is trying to be bound is not callable";
  12039. locale_strings[1033] = "跨域图片不可以使用toDataURL来转换成base64";
  12040. locale_strings[1034] = "音乐文件解码失败:\"{0}\",请使用标准的转换工具重新转换下mp3。";
  12041. locale_strings[1035] = "Native 下暂未实现此功能!";
  12042. locale_strings[1036] = "声音已停止,请重新调用 Sound.play() 来播放声音!";
  12043. locale_strings[1037] = "非正确的blob加载!";
  12044. locale_strings[1038] = "XML 格式错误!";
  12045. locale_strings[1039] = "跨域图片不能获取像素信息!";
  12046. locale_strings[1040] = "hitTestPoint 不能对跨域图片进行检测! 请检查该显示对象内是否含有跨域元素";
  12047. locale_strings[1041] = "{0} 已废弃,请使用 {1} 代替";
  12048. locale_strings[1042] = "drawToTexture方法传入的区域各个参数需要为整数,否则某些浏览器绘制会出现异常";
  12049. locale_strings[1043] = "{0} 中存在编译错误,属性名 : {1},属性值 : {2}";
  12050. locale_strings[1044] = "当前的 runtime 版本不支持视频播放,请使用最新的版本";
  12051. locale_strings[1045] = "没有设置要加载的资源地址";
  12052. locale_strings[1046] = "BitmapText 找不到对应字符:{0},请检查配置文件";
  12053. locale_strings[1047] = "egret.localStorage.setItem保存失败,key={0}&value={1}";
  12054. locale_strings[1048] = "视频加载失败";
  12055. locale_strings[1049] = "声音在没有加载完之前不允许播放";
  12056. locale_strings[1050] = "ExternalInterface调用了js没有注册的方法: {0}";
  12057. //gui 3000-3099
  12058. locale_strings[3000] = "主题配置文件加载失败: {0}";
  12059. locale_strings[3001] = "找不到主题中所配置的皮肤类名: {0}";
  12060. locale_strings[3002] = "索引:\"{0}\"超出集合元素索引范围";
  12061. locale_strings[3003] = "在此组件中不可用,若此组件为容器类,请使用";
  12062. locale_strings[3004] = "addChild(){0}addElement()代替";
  12063. locale_strings[3005] = "addChildAt(){0}addElementAt()代替";
  12064. locale_strings[3006] = "removeChild(){0}removeElement()代替";
  12065. locale_strings[3007] = "removeChildAt(){0}removeElementAt()代替";
  12066. locale_strings[3008] = "setChildIndex(){0}setElementIndex()代替";
  12067. locale_strings[3009] = "swapChildren(){0}swapElements()代替";
  12068. locale_strings[3010] = "swapChildrenAt(){0}swapElementsAt()代替";
  12069. locale_strings[3011] = "索引:\"{0}\"超出可视元素索引范围";
  12070. locale_strings[3012] = "此方法在Scroller组件内不可用!";
  12071. locale_strings[3013] = "UIStage是GUI根容器,只能有一个此实例在显示列表中!";
  12072. locale_strings[3014] = "设置全屏模式失败";
  12073. //socket 3100-3199
  12074. locale_strings[3100] = "当前浏览器不支持WebSocket";
  12075. locale_strings[3101] = "请先连接WebSocket";
  12076. locale_strings[3102] = "请先设置type为二进制类型";
  12077. //db 4000-4299
  12078. locale_strings[4000] = "An Bone cannot be added as a child to itself or one of its children (or children's children, etc.)";
  12079. locale_strings[4001] = "Abstract class can not be instantiated!";
  12080. locale_strings[4002] = "Unnamed data!";
  12081. locale_strings[4003] = "Nonsupport version!";
  12082. })(egret || (egret = {}));
  12083. //////////////////////////////////////////////////////////////////////////////////////
  12084. //
  12085. // Copyright (c) 2014-present, Egret Technology.
  12086. // All rights reserved.
  12087. // Redistribution and use in source and binary forms, with or without
  12088. // modification, are permitted provided that the following conditions are met:
  12089. //
  12090. // * Redistributions of source code must retain the above copyright
  12091. // notice, this list of conditions and the following disclaimer.
  12092. // * Redistributions in binary form must reproduce the above copyright
  12093. // notice, this list of conditions and the following disclaimer in the
  12094. // documentation and/or other materials provided with the distribution.
  12095. // * Neither the name of the Egret nor the
  12096. // names of its contributors may be used to endorse or promote products
  12097. // derived from this software without specific prior written permission.
  12098. //
  12099. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  12100. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  12101. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  12102. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  12103. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  12104. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  12105. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  12106. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  12107. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  12108. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12109. //
  12110. //////////////////////////////////////////////////////////////////////////////////////
  12111. /**
  12112. * @version Egret 2.4
  12113. * @platform Web,Native
  12114. * @includeExample egret/localStorage/localStorage.ts
  12115. */
  12116. var egret;
  12117. (function (egret) {
  12118. var localStorage;
  12119. (function (localStorage) {
  12120. })(localStorage = egret.localStorage || (egret.localStorage = {}));
  12121. })(egret || (egret = {}));
  12122. //////////////////////////////////////////////////////////////////////////////////////
  12123. //
  12124. // Copyright (c) 2014-present, Egret Technology.
  12125. // All rights reserved.
  12126. // Redistribution and use in source and binary forms, with or without
  12127. // modification, are permitted provided that the following conditions are met:
  12128. //
  12129. // * Redistributions of source code must retain the above copyright
  12130. // notice, this list of conditions and the following disclaimer.
  12131. // * Redistributions in binary form must reproduce the above copyright
  12132. // notice, this list of conditions and the following disclaimer in the
  12133. // documentation and/or other materials provided with the distribution.
  12134. // * Neither the name of the Egret nor the
  12135. // names of its contributors may be used to endorse or promote products
  12136. // derived from this software without specific prior written permission.
  12137. //
  12138. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  12139. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  12140. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  12141. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  12142. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  12143. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  12144. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  12145. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  12146. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  12147. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12148. //
  12149. //////////////////////////////////////////////////////////////////////////////////////
  12150. var egret;
  12151. (function (egret) {
  12152. var sys;
  12153. (function (sys) {
  12154. var usingChannel = [];
  12155. /**
  12156. * @private
  12157. * @param channel
  12158. */
  12159. function $pushSoundChannel(channel) {
  12160. if (usingChannel.indexOf(channel) < 0) {
  12161. usingChannel.push(channel);
  12162. }
  12163. }
  12164. sys.$pushSoundChannel = $pushSoundChannel;
  12165. /**
  12166. * @private
  12167. * @param channel
  12168. */
  12169. function $popSoundChannel(channel) {
  12170. var index = usingChannel.indexOf(channel);
  12171. if (index >= 0) {
  12172. usingChannel.splice(index, 1);
  12173. return true;
  12174. }
  12175. return false;
  12176. }
  12177. sys.$popSoundChannel = $popSoundChannel;
  12178. })(sys = egret.sys || (egret.sys = {}));
  12179. })(egret || (egret = {}));
  12180. (function (egret) {
  12181. })(egret || (egret = {}));
  12182. //////////////////////////////////////////////////////////////////////////////////////
  12183. //
  12184. // Copyright (c) 2014-present, Egret Technology.
  12185. // All rights reserved.
  12186. // Redistribution and use in source and binary forms, with or without
  12187. // modification, are permitted provided that the following conditions are met:
  12188. //
  12189. // * Redistributions of source code must retain the above copyright
  12190. // notice, this list of conditions and the following disclaimer.
  12191. // * Redistributions in binary form must reproduce the above copyright
  12192. // notice, this list of conditions and the following disclaimer in the
  12193. // documentation and/or other materials provided with the distribution.
  12194. // * Neither the name of the Egret nor the
  12195. // names of its contributors may be used to endorse or promote products
  12196. // derived from this software without specific prior written permission.
  12197. //
  12198. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  12199. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  12200. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  12201. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  12202. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  12203. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  12204. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  12205. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  12206. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  12207. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12208. //
  12209. //////////////////////////////////////////////////////////////////////////////////////
  12210. //////////////////////////////////////////////////////////////////////////////////////
  12211. //
  12212. // Copyright (c) 2014-present, Egret Technology.
  12213. // All rights reserved.
  12214. // Redistribution and use in source and binary forms, with or without
  12215. // modification, are permitted provided that the following conditions are met:
  12216. //
  12217. // * Redistributions of source code must retain the above copyright
  12218. // notice, this list of conditions and the following disclaimer.
  12219. // * Redistributions in binary form must reproduce the above copyright
  12220. // notice, this list of conditions and the following disclaimer in the
  12221. // documentation and/or other materials provided with the distribution.
  12222. // * Neither the name of the Egret nor the
  12223. // names of its contributors may be used to endorse or promote products
  12224. // derived from this software without specific prior written permission.
  12225. //
  12226. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  12227. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  12228. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  12229. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  12230. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  12231. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  12232. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  12233. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  12234. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  12235. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12236. //
  12237. //////////////////////////////////////////////////////////////////////////////////////
  12238. var egret;
  12239. (function (egret) {
  12240. })(egret || (egret = {}));
  12241. //////////////////////////////////////////////////////////////////////////////////////
  12242. //
  12243. // Copyright (c) 2014-present, Egret Technology.
  12244. // All rights reserved.
  12245. // Redistribution and use in source and binary forms, with or without
  12246. // modification, are permitted provided that the following conditions are met:
  12247. //
  12248. // * Redistributions of source code must retain the above copyright
  12249. // notice, this list of conditions and the following disclaimer.
  12250. // * Redistributions in binary form must reproduce the above copyright
  12251. // notice, this list of conditions and the following disclaimer in the
  12252. // documentation and/or other materials provided with the distribution.
  12253. // * Neither the name of the Egret nor the
  12254. // names of its contributors may be used to endorse or promote products
  12255. // derived from this software without specific prior written permission.
  12256. //
  12257. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  12258. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  12259. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  12260. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  12261. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  12262. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  12263. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  12264. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  12265. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  12266. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12267. //
  12268. //////////////////////////////////////////////////////////////////////////////////////
  12269. //////////////////////////////////////////////////////////////////////////////////////
  12270. //
  12271. // Copyright (c) 2014-present, Egret Technology.
  12272. // All rights reserved.
  12273. // Redistribution and use in source and binary forms, with or without
  12274. // modification, are permitted provided that the following conditions are met:
  12275. //
  12276. // * Redistributions of source code must retain the above copyright
  12277. // notice, this list of conditions and the following disclaimer.
  12278. // * Redistributions in binary form must reproduce the above copyright
  12279. // notice, this list of conditions and the following disclaimer in the
  12280. // documentation and/or other materials provided with the distribution.
  12281. // * Neither the name of the Egret nor the
  12282. // names of its contributors may be used to endorse or promote products
  12283. // derived from this software without specific prior written permission.
  12284. //
  12285. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  12286. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  12287. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  12288. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  12289. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  12290. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  12291. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  12292. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  12293. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  12294. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12295. //
  12296. //////////////////////////////////////////////////////////////////////////////////////
  12297. var egret;
  12298. (function (egret) {
  12299. /**
  12300. * @private
  12301. * @version Egret 2.4
  12302. * @platform Web,Native
  12303. */
  12304. var PromiseObject = (function () {
  12305. /**
  12306. * @version Egret 2.4
  12307. * @platform Web,Native
  12308. */
  12309. function PromiseObject() {
  12310. /**
  12311. * @version Egret 2.4
  12312. * @platform Web,Native
  12313. */
  12314. this.onSuccessFunc = null;
  12315. /**
  12316. * @version Egret 2.4
  12317. * @platform Web,Native
  12318. */
  12319. this.onSuccessThisObject = null;
  12320. /**
  12321. * @version Egret 2.4
  12322. * @platform Web,Native
  12323. */
  12324. this.onErrorFunc = null;
  12325. /**
  12326. * @version Egret 2.4
  12327. * @platform Web,Native
  12328. */
  12329. this.onErrorThisObject = null;
  12330. /**
  12331. * @version Egret 2.4
  12332. * @platform Web,Native
  12333. */
  12334. this.downloadingSizeFunc = null;
  12335. /**
  12336. * @version Egret 2.4
  12337. * @platform Web,Native
  12338. */
  12339. this.downloadingSizeThisObject = null;
  12340. /**
  12341. * @version Egret 2.4
  12342. * @platform Web,Native
  12343. */
  12344. this.onResponseHeaderFunc = null;
  12345. /**
  12346. * @version Egret 2.4
  12347. * @platform Web,Native
  12348. */
  12349. this.onResponseHeaderThisObject = null;
  12350. }
  12351. /**
  12352. *
  12353. * @version Egret 2.4
  12354. * @platform Web,Native
  12355. */
  12356. PromiseObject.create = function () {
  12357. if (PromiseObject.promiseObjectList.length) {
  12358. return PromiseObject.promiseObjectList.pop();
  12359. }
  12360. else {
  12361. return new egret.PromiseObject();
  12362. }
  12363. };
  12364. /**
  12365. * @private
  12366. *
  12367. * @param args
  12368. */
  12369. PromiseObject.prototype.onSuccess = function () {
  12370. var args = [];
  12371. for (var _i = 0; _i < arguments.length; _i++) {
  12372. args[_i] = arguments[_i];
  12373. }
  12374. if (this.onSuccessFunc) {
  12375. this.onSuccessFunc.apply(this.onSuccessThisObject, args);
  12376. }
  12377. this.destroy();
  12378. };
  12379. /**
  12380. * @private
  12381. *
  12382. * @param args
  12383. */
  12384. PromiseObject.prototype.onError = function () {
  12385. var args = [];
  12386. for (var _i = 0; _i < arguments.length; _i++) {
  12387. args[_i] = arguments[_i];
  12388. }
  12389. if (this.onErrorFunc) {
  12390. this.onErrorFunc.apply(this.onErrorThisObject, args);
  12391. }
  12392. this.destroy();
  12393. };
  12394. /**
  12395. * @private
  12396. *
  12397. * @param args
  12398. */
  12399. PromiseObject.prototype.downloadingSize = function () {
  12400. var args = [];
  12401. for (var _i = 0; _i < arguments.length; _i++) {
  12402. args[_i] = arguments[_i];
  12403. }
  12404. if (this.downloadingSizeFunc) {
  12405. this.downloadingSizeFunc.apply(this.downloadingSizeThisObject, args);
  12406. }
  12407. };
  12408. /**
  12409. * @private
  12410. *
  12411. * @param args
  12412. */
  12413. PromiseObject.prototype.onResponseHeader = function () {
  12414. var args = [];
  12415. for (var _i = 0; _i < arguments.length; _i++) {
  12416. args[_i] = arguments[_i];
  12417. }
  12418. if (this.onResponseHeaderFunc) {
  12419. this.onResponseHeaderFunc.apply(this.onResponseHeaderThisObject, args);
  12420. }
  12421. };
  12422. /**
  12423. * @private
  12424. *
  12425. */
  12426. PromiseObject.prototype.destroy = function () {
  12427. this.onSuccessFunc = undefined;
  12428. this.onSuccessThisObject = undefined;
  12429. this.onErrorFunc = undefined;
  12430. this.onErrorThisObject = undefined;
  12431. this.downloadingSizeFunc = undefined;
  12432. this.downloadingSizeThisObject = undefined;
  12433. this.onResponseHeaderFunc = undefined;
  12434. this.onResponseHeaderThisObject = undefined;
  12435. PromiseObject.promiseObjectList.push(this);
  12436. };
  12437. return PromiseObject;
  12438. }());
  12439. /**
  12440. * @private
  12441. */
  12442. PromiseObject.promiseObjectList = [];
  12443. egret.PromiseObject = PromiseObject;
  12444. __reflect(PromiseObject.prototype, "egret.PromiseObject");
  12445. })(egret || (egret = {}));
  12446. //////////////////////////////////////////////////////////////////////////////////////
  12447. //
  12448. // Copyright (c) 2014-present, Egret Technology.
  12449. // All rights reserved.
  12450. // Redistribution and use in source and binary forms, with or without
  12451. // modification, are permitted provided that the following conditions are met:
  12452. //
  12453. // * Redistributions of source code must retain the above copyright
  12454. // notice, this list of conditions and the following disclaimer.
  12455. // * Redistributions in binary form must reproduce the above copyright
  12456. // notice, this list of conditions and the following disclaimer in the
  12457. // documentation and/or other materials provided with the distribution.
  12458. // * Neither the name of the Egret nor the
  12459. // names of its contributors may be used to endorse or promote products
  12460. // derived from this software without specific prior written permission.
  12461. //
  12462. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  12463. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  12464. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  12465. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  12466. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  12467. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  12468. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  12469. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  12470. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  12471. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12472. //
  12473. //////////////////////////////////////////////////////////////////////////////////////
  12474. var egret;
  12475. (function (egret) {
  12476. /**
  12477. * @language en_US
  12478. * The HttpMethod class provides values that specify whether the HttpRequest object should use the POST method
  12479. * or the GET method when sending data to a server.
  12480. * @see egret.HttpRequest
  12481. * @version Egret 2.4
  12482. * @platform Web,Native
  12483. */
  12484. /**
  12485. * @language zh_CN
  12486. * HttpRequestMethod 类提供了一些值,这些值可指定在将数据发送到服务器时,
  12487. * HttpRequest 对象应使用 POST 方法还是 GET 方法。
  12488. * @see egret.HttpRequest
  12489. * @version Egret 2.4
  12490. * @platform Web,Native
  12491. */
  12492. var HttpMethod = (function () {
  12493. function HttpMethod() {
  12494. }
  12495. return HttpMethod;
  12496. }());
  12497. /**
  12498. * @language en_US
  12499. * Specifies that the HttpRequest object is a GET.
  12500. * @version Egret 2.4
  12501. * @platform Web,Native
  12502. */
  12503. /**
  12504. * @language zh_CN
  12505. * 表示 HttpRequest 对象是一个 GET。
  12506. * @version Egret 2.4
  12507. * @platform Web,Native
  12508. */
  12509. HttpMethod.GET = "GET";
  12510. /**
  12511. * @language en_US
  12512. * Specifies that the HttpRequest object is a POST.
  12513. * @version Egret 2.4
  12514. * @platform Web,Native
  12515. */
  12516. /**
  12517. * @language zh_CN
  12518. * 表示 HttpRequest 对象是一个 POST。
  12519. * @version Egret 2.4
  12520. * @platform Web,Native
  12521. */
  12522. HttpMethod.POST = "POST";
  12523. egret.HttpMethod = HttpMethod;
  12524. __reflect(HttpMethod.prototype, "egret.HttpMethod");
  12525. })(egret || (egret = {}));
  12526. //////////////////////////////////////////////////////////////////////////////////////
  12527. //
  12528. // Copyright (c) 2014-present, Egret Technology.
  12529. // All rights reserved.
  12530. // Redistribution and use in source and binary forms, with or without
  12531. // modification, are permitted provided that the following conditions are met:
  12532. //
  12533. // * Redistributions of source code must retain the above copyright
  12534. // notice, this list of conditions and the following disclaimer.
  12535. // * Redistributions in binary form must reproduce the above copyright
  12536. // notice, this list of conditions and the following disclaimer in the
  12537. // documentation and/or other materials provided with the distribution.
  12538. // * Neither the name of the Egret nor the
  12539. // names of its contributors may be used to endorse or promote products
  12540. // derived from this software without specific prior written permission.
  12541. //
  12542. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  12543. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  12544. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  12545. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  12546. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  12547. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  12548. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  12549. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  12550. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  12551. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12552. //
  12553. //////////////////////////////////////////////////////////////////////////////////////
  12554. var egret;
  12555. (function (egret) {
  12556. })(egret || (egret = {}));
  12557. //////////////////////////////////////////////////////////////////////////////////////
  12558. //
  12559. // Copyright (c) 2014-present, Egret Technology.
  12560. // All rights reserved.
  12561. // Redistribution and use in source and binary forms, with or without
  12562. // modification, are permitted provided that the following conditions are met:
  12563. //
  12564. // * Redistributions of source code must retain the above copyright
  12565. // notice, this list of conditions and the following disclaimer.
  12566. // * Redistributions in binary form must reproduce the above copyright
  12567. // notice, this list of conditions and the following disclaimer in the
  12568. // documentation and/or other materials provided with the distribution.
  12569. // * Neither the name of the Egret nor the
  12570. // names of its contributors may be used to endorse or promote products
  12571. // derived from this software without specific prior written permission.
  12572. //
  12573. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  12574. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  12575. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  12576. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  12577. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  12578. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  12579. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  12580. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  12581. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  12582. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12583. //
  12584. //////////////////////////////////////////////////////////////////////////////////////
  12585. var egret;
  12586. (function (egret) {
  12587. /**
  12588. * @language en_US
  12589. * The HttpResponseType class provides values that specify how downloaded data is received.
  12590. * @see egret.HttpRequest
  12591. * @version Egret 2.4
  12592. * @platform Web,Native
  12593. */
  12594. /**
  12595. * @language zh_CN
  12596. * URLLoaderDataFormat 类提供了一些用于指定如何接收已下载数据的值。
  12597. * @see egret.HttpRequest
  12598. * @version Egret 2.4
  12599. * @platform Web,Native
  12600. */
  12601. var HttpResponseType = (function () {
  12602. function HttpResponseType() {
  12603. }
  12604. return HttpResponseType;
  12605. }());
  12606. /**
  12607. * @language en_US
  12608. * Specifies that downloaded data is received as text. This is the default value of HttpRequest.responseType
  12609. * @version Egret 2.4
  12610. * @platform Web,Native
  12611. */
  12612. /**
  12613. * @language zh_CN
  12614. * 返回字符串。HttpRequest.responseType属性的默认值。
  12615. * @version Egret 2.4
  12616. * @platform Web,Native
  12617. */
  12618. HttpResponseType.TEXT = "text";
  12619. /**
  12620. * @language en_US
  12621. * Specifies that downloaded data is received as raw binary data.
  12622. * @version Egret 2.4
  12623. * @platform Web,Native
  12624. */
  12625. /**
  12626. * @language zh_CN
  12627. * 返回二进制的ArrayBuffer对象。
  12628. * @version Egret 2.4
  12629. * @platform Web,Native
  12630. */
  12631. HttpResponseType.ARRAY_BUFFER = "arraybuffer";
  12632. egret.HttpResponseType = HttpResponseType;
  12633. __reflect(HttpResponseType.prototype, "egret.HttpResponseType");
  12634. })(egret || (egret = {}));
  12635. //////////////////////////////////////////////////////////////////////////////////////
  12636. //
  12637. // Copyright (c) 2014-present, Egret Technology.
  12638. // All rights reserved.
  12639. // Redistribution and use in source and binary forms, with or without
  12640. // modification, are permitted provided that the following conditions are met:
  12641. //
  12642. // * Redistributions of source code must retain the above copyright
  12643. // notice, this list of conditions and the following disclaimer.
  12644. // * Redistributions in binary form must reproduce the above copyright
  12645. // notice, this list of conditions and the following disclaimer in the
  12646. // documentation and/or other materials provided with the distribution.
  12647. // * Neither the name of the Egret nor the
  12648. // names of its contributors may be used to endorse or promote products
  12649. // derived from this software without specific prior written permission.
  12650. //
  12651. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  12652. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  12653. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  12654. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  12655. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  12656. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  12657. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  12658. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  12659. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  12660. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12661. //
  12662. //////////////////////////////////////////////////////////////////////////////////////
  12663. var egret;
  12664. (function (egret) {
  12665. })(egret || (egret = {}));
  12666. //////////////////////////////////////////////////////////////////////////////////////
  12667. //
  12668. // Copyright (c) 2014-present, Egret Technology.
  12669. // All rights reserved.
  12670. // Redistribution and use in source and binary forms, with or without
  12671. // modification, are permitted provided that the following conditions are met:
  12672. //
  12673. // * Redistributions of source code must retain the above copyright
  12674. // notice, this list of conditions and the following disclaimer.
  12675. // * Redistributions in binary form must reproduce the above copyright
  12676. // notice, this list of conditions and the following disclaimer in the
  12677. // documentation and/or other materials provided with the distribution.
  12678. // * Neither the name of the Egret nor the
  12679. // names of its contributors may be used to endorse or promote products
  12680. // derived from this software without specific prior written permission.
  12681. //
  12682. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  12683. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  12684. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  12685. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  12686. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  12687. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  12688. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  12689. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  12690. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  12691. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12692. //
  12693. //////////////////////////////////////////////////////////////////////////////////////
  12694. var egret;
  12695. (function (egret) {
  12696. var sys;
  12697. (function (sys) {
  12698. if (true) {
  12699. function isF(num) {
  12700. return num % 1 !== 0;
  12701. }
  12702. }
  12703. /**
  12704. * @private
  12705. */
  12706. function unionArea(r1, r2) {
  12707. var minX = r1.minX < r2.minX ? r1.minX : r2.minX;
  12708. var minY = r1.minY < r2.minY ? r1.minY : r2.minY;
  12709. var maxX = r1.maxX > r2.maxX ? r1.maxX : r2.maxX;
  12710. var maxY = r1.maxY > r2.maxY ? r1.maxY : r2.maxY;
  12711. return (maxX - minX) * (maxY - minY);
  12712. }
  12713. /**
  12714. * @private
  12715. * 脏矩形计算工具类
  12716. */
  12717. var DirtyRegion = (function () {
  12718. function DirtyRegion(root) {
  12719. /**
  12720. * @private
  12721. */
  12722. this.dirtyList = [];
  12723. /**
  12724. * @private
  12725. */
  12726. this.hasClipRect = false;
  12727. /**
  12728. * @private
  12729. */
  12730. this.clipWidth = 0;
  12731. /**
  12732. * @private
  12733. */
  12734. this.clipHeight = 0;
  12735. /**
  12736. * @private
  12737. */
  12738. this.clipArea = 0;
  12739. /**
  12740. * @private
  12741. */
  12742. this.clipRectChanged = false;
  12743. this.$dirtyRegionPolicy = egret.DirtyRegionPolicy.ON;
  12744. this.root = root;
  12745. }
  12746. /**
  12747. * @private
  12748. * 设置剪裁边界,超过边界的节点将跳过绘制。
  12749. */
  12750. DirtyRegion.prototype.setClipRect = function (width, height) {
  12751. this.hasClipRect = true;
  12752. this.clipRectChanged = true;
  12753. this.clipWidth = Math.ceil(width);
  12754. this.clipHeight = Math.ceil(height);
  12755. this.clipArea = this.clipWidth * this.clipHeight;
  12756. };
  12757. /**
  12758. * @private
  12759. * 添加一个脏矩形区域,返回是否添加成功,当矩形为空或者在屏幕之外时返回false。
  12760. */
  12761. DirtyRegion.prototype.addRegion = function (target) {
  12762. var minX = target.minX, minY = target.minY, maxX = target.maxX, maxY = target.maxY;
  12763. if (this.hasClipRect) {
  12764. if (minX < 0) {
  12765. minX = 0;
  12766. }
  12767. if (minY < 0) {
  12768. minY = 0;
  12769. }
  12770. if (maxX > this.clipWidth) {
  12771. maxX = this.clipWidth;
  12772. }
  12773. if (maxY > this.clipHeight) {
  12774. maxY = this.clipHeight;
  12775. }
  12776. }
  12777. if (minX >= maxX || minY >= maxY) {
  12778. return false;
  12779. }
  12780. if (this.clipRectChanged) {
  12781. return true;
  12782. }
  12783. var dirtyList = this.dirtyList;
  12784. var region = sys.Region.create();
  12785. dirtyList.push(region.setTo(minX, minY, maxX, maxY));
  12786. if (this.$dirtyRegionPolicy != egret.DirtyRegionPolicy.OFF) {
  12787. this.mergeDirtyList(dirtyList);
  12788. }
  12789. return true;
  12790. };
  12791. /**
  12792. * @private
  12793. */
  12794. DirtyRegion.prototype.clear = function () {
  12795. var dirtyList = this.dirtyList;
  12796. var length = dirtyList.length;
  12797. for (var i = 0; i < length; i++) {
  12798. sys.Region.release(dirtyList[i]);
  12799. }
  12800. dirtyList.length = 0;
  12801. };
  12802. /**
  12803. * @private
  12804. * 获取最终的脏矩形列表
  12805. */
  12806. DirtyRegion.prototype.getDirtyRegions = function () {
  12807. var dirtyList = this.dirtyList;
  12808. if (this.$dirtyRegionPolicy == egret.DirtyRegionPolicy.OFF || (egret.Capabilities.runtimeType == egret.RuntimeType.NATIVE && !egret["native"]["$supportCanvas" + ""])) {
  12809. this.clipRectChanged = true; //阻止所有的addRegion()
  12810. this.clear();
  12811. var region = sys.Region.create();
  12812. if (this.hasClipRect) {
  12813. dirtyList.push(region.setTo(0, 0, this.clipWidth, this.clipHeight));
  12814. }
  12815. else {
  12816. var bounds = this.root.$getOriginalBounds();
  12817. dirtyList.push(region.setTo(bounds.x, bounds.y, bounds.width, bounds.height));
  12818. }
  12819. }
  12820. else if (this.clipRectChanged) {
  12821. this.clipRectChanged = false;
  12822. this.clear();
  12823. var region = sys.Region.create();
  12824. dirtyList.push(region.setTo(0, 0, this.clipWidth, this.clipHeight));
  12825. }
  12826. else {
  12827. while (this.mergeDirtyList(dirtyList)) {
  12828. }
  12829. }
  12830. var numDirty = this.dirtyList.length;
  12831. if (numDirty > 0) {
  12832. for (var i = 0; i < numDirty; i++) {
  12833. this.dirtyList[i].intValues();
  12834. }
  12835. }
  12836. return this.dirtyList;
  12837. };
  12838. /**
  12839. * @private
  12840. * 合并脏矩形列表
  12841. */
  12842. DirtyRegion.prototype.mergeDirtyList = function (dirtyList) {
  12843. var length = dirtyList.length;
  12844. if (length < 2) {
  12845. return false;
  12846. }
  12847. var hasClipRect = this.hasClipRect;
  12848. var bestDelta = length > 3 ? Number.POSITIVE_INFINITY : 0;
  12849. var mergeA = 0;
  12850. var mergeB = 0;
  12851. var totalArea = 0;
  12852. for (var i = 0; i < length - 1; i++) {
  12853. var regionA = dirtyList[i];
  12854. hasClipRect && (totalArea += regionA.area);
  12855. for (var j = i + 1; j < length; j++) {
  12856. var regionB = dirtyList[j];
  12857. var delta = unionArea(regionA, regionB) - regionA.area - regionB.area;
  12858. if (bestDelta > delta) {
  12859. mergeA = i;
  12860. mergeB = j;
  12861. bestDelta = delta;
  12862. }
  12863. }
  12864. }
  12865. if (hasClipRect && (totalArea / this.clipArea) > 0.95) {
  12866. this.clipRectChanged = true;
  12867. }
  12868. if (mergeA != mergeB) {
  12869. var region = dirtyList[mergeB];
  12870. dirtyList[mergeA].union(region);
  12871. sys.Region.release(region);
  12872. dirtyList.splice(mergeB, 1);
  12873. return true;
  12874. }
  12875. return false;
  12876. };
  12877. DirtyRegion.prototype.setDirtyRegionPolicy = function (policy) {
  12878. this.$dirtyRegionPolicy = policy;
  12879. };
  12880. return DirtyRegion;
  12881. }());
  12882. sys.DirtyRegion = DirtyRegion;
  12883. __reflect(DirtyRegion.prototype, "egret.sys.DirtyRegion");
  12884. })(sys = egret.sys || (egret.sys = {}));
  12885. })(egret || (egret = {}));
  12886. //////////////////////////////////////////////////////////////////////////////////////
  12887. //
  12888. // Copyright (c) 2014-present, Egret Technology.
  12889. // All rights reserved.
  12890. // Redistribution and use in source and binary forms, with or without
  12891. // modification, are permitted provided that the following conditions are met:
  12892. //
  12893. // * Redistributions of source code must retain the above copyright
  12894. // notice, this list of conditions and the following disclaimer.
  12895. // * Redistributions in binary form must reproduce the above copyright
  12896. // notice, this list of conditions and the following disclaimer in the
  12897. // documentation and/or other materials provided with the distribution.
  12898. // * Neither the name of the Egret nor the
  12899. // names of its contributors may be used to endorse or promote products
  12900. // derived from this software without specific prior written permission.
  12901. //
  12902. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  12903. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  12904. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  12905. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  12906. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  12907. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  12908. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  12909. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  12910. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  12911. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12912. //
  12913. //////////////////////////////////////////////////////////////////////////////////////
  12914. var egret;
  12915. (function (egret) {
  12916. var sys;
  12917. (function (sys) {
  12918. var displayListPool = [];
  12919. var blendModes = ["source-over", "lighter", "destination-out"];
  12920. var defaultCompositeOp = "source-over";
  12921. /**
  12922. * @private
  12923. * 显示列表
  12924. */
  12925. var DisplayList = (function (_super) {
  12926. __extends(DisplayList, _super);
  12927. /**
  12928. * @private
  12929. * 创建一个DisplayList对象
  12930. */
  12931. function DisplayList(root) {
  12932. var _this = _super.call(this) || this;
  12933. _this.isStage = false;
  12934. /**
  12935. * 位图渲染节点
  12936. */
  12937. _this.$renderNode = new sys.BitmapNode();
  12938. /**
  12939. * @private
  12940. */
  12941. _this.renderBuffer = null;
  12942. /**
  12943. * @private
  12944. */
  12945. _this.offsetX = 0;
  12946. /**
  12947. * @private
  12948. */
  12949. _this.offsetY = 0;
  12950. /**
  12951. * @private
  12952. */
  12953. _this.offsetMatrix = new egret.Matrix();
  12954. /**
  12955. * @private
  12956. */
  12957. _this.isDirty = false;
  12958. _this.needUpdateRegions = false;
  12959. /**
  12960. * @private
  12961. */
  12962. _this.dirtyNodeList = [];
  12963. /**
  12964. * @private
  12965. */
  12966. _this.dirtyList = null;
  12967. /**
  12968. * @private
  12969. */
  12970. _this.sizeChanged = false;
  12971. _this.$dirtyRegionPolicy = egret.DirtyRegionPolicy.ON;
  12972. _this.root = root;
  12973. _this.dirtyRegion = new sys.DirtyRegion(root);
  12974. _this.isStage = (root instanceof egret.Stage);
  12975. _this.dirtyNodes = egret.createMap();
  12976. return _this;
  12977. }
  12978. /**
  12979. * 创建一个DisplayList对象,若内存不足或无法创建RenderBuffer,将会返回null。
  12980. */
  12981. DisplayList.create = function (target) {
  12982. var displayList = new egret.sys.DisplayList(target);
  12983. try {
  12984. var buffer = new sys.RenderBuffer();
  12985. displayList.renderBuffer = buffer;
  12986. }
  12987. catch (e) {
  12988. return null;
  12989. }
  12990. displayList.root = target;
  12991. return displayList;
  12992. };
  12993. /**
  12994. * @private
  12995. * 获取渲染节点
  12996. */
  12997. DisplayList.prototype.$getRenderNode = function () {
  12998. return this.$renderNode;
  12999. };
  13000. /**
  13001. * @private
  13002. * 更新对象在舞台上的显示区域和透明度,返回显示区域是否发生改变。
  13003. */
  13004. DisplayList.prototype.$update = function (dirtyRegionPolicy) {
  13005. var target = this.root;
  13006. //当cache对象的显示列表已经加入dirtyList,对象又取消cache的时候,root为空
  13007. if (target == null) {
  13008. return false;
  13009. }
  13010. target.$removeFlagsUp(768 /* Dirty */);
  13011. var node = this.$renderNode;
  13012. //这里不需要更新node.renderAlpha。因为alpha已经写入到缓存的内部
  13013. //必须在访问moved属性前调用以下两个方法,因为moved属性在以下两个方法内重置。
  13014. var concatenatedMatrix = target.$getConcatenatedMatrix();
  13015. if (dirtyRegionPolicy == egret.DirtyRegionPolicy.OFF) {
  13016. var displayList = target.$parentDisplayList;
  13017. if (this.needUpdateRegions) {
  13018. this.updateDirtyRegions();
  13019. }
  13020. if (!displayList) {
  13021. return false;
  13022. }
  13023. var matrix = node.renderMatrix;
  13024. matrix.copyFrom(concatenatedMatrix);
  13025. var root = displayList.root;
  13026. if (root !== target.$stage) {
  13027. target.$getConcatenatedMatrixAt(root, matrix);
  13028. }
  13029. }
  13030. else {
  13031. var bounds = target.$getOriginalBounds();
  13032. var displayList = target.$parentDisplayList;
  13033. var region = node.renderRegion;
  13034. if (this.needUpdateRegions) {
  13035. this.updateDirtyRegions();
  13036. }
  13037. if (!displayList) {
  13038. region.setTo(0, 0, 0, 0);
  13039. node.moved = false;
  13040. return false;
  13041. }
  13042. if (!node.moved) {
  13043. return false;
  13044. }
  13045. node.moved = false;
  13046. var matrix = node.renderMatrix;
  13047. matrix.copyFrom(concatenatedMatrix);
  13048. var root = displayList.root;
  13049. if (root !== target.$stage) {
  13050. target.$getConcatenatedMatrixAt(root, matrix);
  13051. }
  13052. region.updateRegion(bounds, matrix);
  13053. }
  13054. return true;
  13055. };
  13056. /**
  13057. * @private
  13058. * 设置剪裁边界,不再绘制完整目标对象,画布尺寸由外部决定,超过边界的节点将跳过绘制。
  13059. */
  13060. DisplayList.prototype.setClipRect = function (width, height) {
  13061. this.dirtyRegion.setClipRect(width, height);
  13062. this.renderBuffer.resize(width, height);
  13063. };
  13064. /**
  13065. * @private
  13066. * 标记一个节点需要重新渲染
  13067. */
  13068. DisplayList.prototype.markDirty = function (node) {
  13069. var key = node.$hashCode;
  13070. if (this.dirtyNodes[key]) {
  13071. return;
  13072. }
  13073. this.dirtyNodes[key] = true;
  13074. this.dirtyNodeList.push(node);
  13075. if (!this.needUpdateRegions) {
  13076. this.needUpdateRegions = true;
  13077. this.isDirty = true;
  13078. var parentCache = this.root.$parentDisplayList;
  13079. if (parentCache) {
  13080. parentCache.markDirty(this);
  13081. }
  13082. }
  13083. };
  13084. /**
  13085. * @private
  13086. * 更新节点属性并返回脏矩形列表。
  13087. */
  13088. DisplayList.prototype.updateDirtyRegions = function () {
  13089. var dirtyNodeList = this.dirtyNodeList;
  13090. this.dirtyNodeList = [];
  13091. this.dirtyNodes = egret.createMap();
  13092. this.needUpdateRegions = false;
  13093. var dirtyRegion = this.dirtyRegion;
  13094. var length = dirtyNodeList.length;
  13095. for (var i = 0; i < length; i++) {
  13096. var display = dirtyNodeList[i];
  13097. var node = display.$getRenderNode();
  13098. //有可能 markDirty 之后,显示对象自身改变,变的没有renderNode
  13099. if (node) {
  13100. node.needRedraw = false; //先清空上次缓存的标记,防止上次没遍历到的节点 needRedraw 始终为 true.
  13101. if (this.isStage) {
  13102. if (node.renderAlpha > 0 && node.renderVisible) {
  13103. if (dirtyRegion.addRegion(node.renderRegion)) {
  13104. node.needRedraw = true;
  13105. }
  13106. }
  13107. var moved = display.$update(this.$dirtyRegionPolicy);
  13108. if (node.renderAlpha > 0 && node.renderVisible && (moved || !node.needRedraw)) {
  13109. if (dirtyRegion.addRegion(node.renderRegion)) {
  13110. node.needRedraw = true;
  13111. }
  13112. }
  13113. }
  13114. else {
  13115. if (dirtyRegion.addRegion(node.renderRegion)) {
  13116. node.needRedraw = true;
  13117. }
  13118. var moved = display.$update(this.$dirtyRegionPolicy);
  13119. if (moved || !node.needRedraw) {
  13120. if (dirtyRegion.addRegion(node.renderRegion)) {
  13121. node.needRedraw = true;
  13122. }
  13123. }
  13124. }
  13125. }
  13126. }
  13127. this.dirtyList = dirtyRegion.getDirtyRegions();
  13128. return this.dirtyList;
  13129. };
  13130. /**
  13131. * @private
  13132. * 绘制根节点显示对象到目标画布,返回draw的次数。
  13133. */
  13134. DisplayList.prototype.drawToSurface = function () {
  13135. var drawCalls = 0;
  13136. var dirtyList = this.dirtyList;
  13137. if (dirtyList && dirtyList.length > 0) {
  13138. if (!this.isStage) {
  13139. this.changeSurfaceSize();
  13140. }
  13141. var buffer = this.renderBuffer;
  13142. buffer.beginClip(this.dirtyList, this.offsetX, this.offsetY);
  13143. dirtyList = this.$dirtyRegionPolicy == egret.DirtyRegionPolicy.OFF ? null : this.dirtyList;
  13144. drawCalls = sys.systemRenderer.render(this.root, buffer, this.offsetMatrix, dirtyList);
  13145. buffer.endClip();
  13146. if (!this.isStage) {
  13147. var surface = buffer.surface;
  13148. var renderNode = this.$renderNode;
  13149. renderNode.drawData.length = 0;
  13150. var width = surface.width;
  13151. var height = surface.height;
  13152. if (!this.bitmapData) {
  13153. this.bitmapData = new egret.BitmapData(surface);
  13154. }
  13155. else {
  13156. this.bitmapData.source = surface;
  13157. this.bitmapData.width = width;
  13158. this.bitmapData.height = height;
  13159. }
  13160. renderNode.image = this.bitmapData;
  13161. renderNode.imageWidth = width;
  13162. renderNode.imageHeight = height;
  13163. renderNode.drawImage(0, 0, width, height, -this.offsetX, -this.offsetY, width, height);
  13164. }
  13165. }
  13166. this.dirtyList = null;
  13167. this.dirtyRegion.clear();
  13168. this.isDirty = false;
  13169. return drawCalls;
  13170. };
  13171. /**
  13172. * @private
  13173. * 改变画布的尺寸,由于画布尺寸修改会清空原始画布。所以这里将原始画布绘制到一个新画布上,再与原始画布交换。
  13174. */
  13175. DisplayList.prototype.changeSurfaceSize = function () {
  13176. var root = this.root;
  13177. var oldOffsetX = this.offsetX;
  13178. var oldOffsetY = this.offsetY;
  13179. var bounds = this.root.$getOriginalBounds();
  13180. this.offsetX = -bounds.x;
  13181. this.offsetY = -bounds.y;
  13182. this.offsetMatrix.setTo(1, 0, 0, 1, this.offsetX, this.offsetY);
  13183. var buffer = this.renderBuffer;
  13184. //在chrome里,小等于256*256的canvas会不启用GPU加速。
  13185. var width = Math.max(257, bounds.width);
  13186. var height = Math.max(257, bounds.height);
  13187. if (this.offsetX == oldOffsetX &&
  13188. this.offsetY == oldOffsetY &&
  13189. buffer.surface.width == width &&
  13190. buffer.surface.height == height) {
  13191. return;
  13192. }
  13193. if (!this.sizeChanged) {
  13194. this.sizeChanged = true;
  13195. buffer.resize(width, height);
  13196. }
  13197. else {
  13198. buffer.resizeTo(width, height, this.offsetX - oldOffsetX, this.offsetY - oldOffsetY);
  13199. }
  13200. };
  13201. DisplayList.prototype.setDirtyRegionPolicy = function (policy) {
  13202. //todo 这里还可以做更多优化
  13203. this.$dirtyRegionPolicy = policy;
  13204. this.dirtyRegion.setDirtyRegionPolicy(policy);
  13205. this.renderBuffer.setDirtyRegionPolicy(policy);
  13206. };
  13207. return DisplayList;
  13208. }(egret.HashObject));
  13209. sys.DisplayList = DisplayList;
  13210. __reflect(DisplayList.prototype, "egret.sys.DisplayList", ["egret.sys.Renderable"]);
  13211. })(sys = egret.sys || (egret.sys = {}));
  13212. })(egret || (egret = {}));
  13213. //////////////////////////////////////////////////////////////////////////////////////
  13214. //
  13215. // Copyright (c) 2014-present, Egret Technology.
  13216. // All rights reserved.
  13217. // Redistribution and use in source and binary forms, with or without
  13218. // modification, are permitted provided that the following conditions are met:
  13219. //
  13220. // * Redistributions of source code must retain the above copyright
  13221. // notice, this list of conditions and the following disclaimer.
  13222. // * Redistributions in binary form must reproduce the above copyright
  13223. // notice, this list of conditions and the following disclaimer in the
  13224. // documentation and/or other materials provided with the distribution.
  13225. // * Neither the name of the Egret nor the
  13226. // names of its contributors may be used to endorse or promote products
  13227. // derived from this software without specific prior written permission.
  13228. //
  13229. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  13230. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  13231. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  13232. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  13233. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  13234. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  13235. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  13236. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  13237. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  13238. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13239. //
  13240. //////////////////////////////////////////////////////////////////////////////////////
  13241. var egret;
  13242. (function (egret) {
  13243. })(egret || (egret = {}));
  13244. //////////////////////////////////////////////////////////////////////////////////////
  13245. //
  13246. // Copyright (c) 2014-present, Egret Technology.
  13247. // All rights reserved.
  13248. // Redistribution and use in source and binary forms, with or without
  13249. // modification, are permitted provided that the following conditions are met:
  13250. //
  13251. // * Redistributions of source code must retain the above copyright
  13252. // notice, this list of conditions and the following disclaimer.
  13253. // * Redistributions in binary form must reproduce the above copyright
  13254. // notice, this list of conditions and the following disclaimer in the
  13255. // documentation and/or other materials provided with the distribution.
  13256. // * Neither the name of the Egret nor the
  13257. // names of its contributors may be used to endorse or promote products
  13258. // derived from this software without specific prior written permission.
  13259. //
  13260. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  13261. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  13262. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  13263. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  13264. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  13265. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  13266. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  13267. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  13268. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  13269. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13270. //
  13271. //////////////////////////////////////////////////////////////////////////////////////
  13272. var egret;
  13273. (function (egret) {
  13274. })(egret || (egret = {}));
  13275. //////////////////////////////////////////////////////////////////////////////////////
  13276. //
  13277. // Copyright (c) 2014-present, Egret Technology.
  13278. // All rights reserved.
  13279. // Redistribution and use in source and binary forms, with or without
  13280. // modification, are permitted provided that the following conditions are met:
  13281. //
  13282. // * Redistributions of source code must retain the above copyright
  13283. // notice, this list of conditions and the following disclaimer.
  13284. // * Redistributions in binary form must reproduce the above copyright
  13285. // notice, this list of conditions and the following disclaimer in the
  13286. // documentation and/or other materials provided with the distribution.
  13287. // * Neither the name of the Egret nor the
  13288. // names of its contributors may be used to endorse or promote products
  13289. // derived from this software without specific prior written permission.
  13290. //
  13291. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  13292. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  13293. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  13294. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  13295. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  13296. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  13297. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  13298. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  13299. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  13300. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13301. //
  13302. //////////////////////////////////////////////////////////////////////////////////////
  13303. /// <reference path="../display/Sprite.ts" />
  13304. var egret;
  13305. (function (egret) {
  13306. var sys;
  13307. (function (sys) {
  13308. /**
  13309. * @private
  13310. * Egret播放器
  13311. */
  13312. var Player = (function (_super) {
  13313. __extends(Player, _super);
  13314. /**
  13315. * @private
  13316. * 实例化一个播放器对象。
  13317. */
  13318. function Player(buffer, stage, entryClassName) {
  13319. var _this = _super.call(this) || this;
  13320. /**
  13321. * @private
  13322. */
  13323. _this.isPlaying = false;
  13324. if (true && !buffer) {
  13325. egret.$error(1003, "buffer");
  13326. }
  13327. _this.entryClassName = entryClassName;
  13328. _this.stage = stage;
  13329. _this.screenDisplayList = _this.createDisplayList(stage, buffer);
  13330. _this.showFPS = false;
  13331. _this.showLog = false;
  13332. _this._showPaintRect = false;
  13333. _this.stageDisplayList = null;
  13334. _this.paintList = [];
  13335. _this.displayFPS = displayFPS;
  13336. _this.showPaintRect = showPaintRect;
  13337. _this.drawPaintRect = drawPaintRect;
  13338. _this.drawDirtyRect = drawDirtyRect;
  13339. return _this;
  13340. }
  13341. /**
  13342. * @private
  13343. */
  13344. Player.prototype.createDisplayList = function (stage, buffer) {
  13345. var displayList = new sys.DisplayList(stage);
  13346. displayList.renderBuffer = buffer;
  13347. stage.$displayList = displayList;
  13348. //displayList.setClipRect(stage.$stageWidth, stage.$stageHeight);
  13349. return displayList;
  13350. };
  13351. /**
  13352. * @private
  13353. * 启动播放器
  13354. */
  13355. Player.prototype.start = function () {
  13356. if (this.isPlaying || !this.stage) {
  13357. return;
  13358. }
  13359. sys.$TempStage = sys.$TempStage || this.stage;
  13360. this.isPlaying = true;
  13361. if (!this.root) {
  13362. this.initialize();
  13363. }
  13364. sys.$ticker.$addPlayer(this);
  13365. };
  13366. /**
  13367. * @private
  13368. *
  13369. */
  13370. Player.prototype.initialize = function () {
  13371. var rootClass;
  13372. if (this.entryClassName) {
  13373. rootClass = egret.getDefinitionByName(this.entryClassName);
  13374. }
  13375. if (rootClass) {
  13376. var rootContainer = new rootClass();
  13377. this.root = rootContainer;
  13378. if (rootContainer instanceof egret.DisplayObject) {
  13379. this.stage.addChild(rootContainer);
  13380. }
  13381. else {
  13382. true && egret.$error(1002, this.entryClassName);
  13383. }
  13384. }
  13385. else {
  13386. true && egret.$error(1001, this.entryClassName);
  13387. }
  13388. };
  13389. /**
  13390. * @private
  13391. * 停止播放器,停止后将不能重新启动。
  13392. */
  13393. Player.prototype.stop = function () {
  13394. this.pause();
  13395. this.stage = null;
  13396. };
  13397. /**
  13398. * @private
  13399. * 暂停播放器,后续可以通过调用start()重新启动播放器。
  13400. */
  13401. Player.prototype.pause = function () {
  13402. if (!this.isPlaying) {
  13403. return;
  13404. }
  13405. this.isPlaying = false;
  13406. sys.$ticker.$removePlayer(this);
  13407. };
  13408. /**
  13409. * @private
  13410. * 渲染屏幕
  13411. */
  13412. Player.prototype.$render = function (triggerByFrame, costTicker) {
  13413. if (this.showFPS || this.showLog) {
  13414. this.stage.addChild(this.fps);
  13415. }
  13416. var stage = this.stage;
  13417. var t = egret.getTimer();
  13418. var dirtyList = stage.$displayList.updateDirtyRegions();
  13419. var t1 = egret.getTimer();
  13420. dirtyList = dirtyList.concat();
  13421. var drawCalls = stage.$displayList.drawToSurface();
  13422. if (this._showPaintRect) {
  13423. this.drawPaintRect(dirtyList);
  13424. }
  13425. var t2 = egret.getTimer();
  13426. if (triggerByFrame && this.showFPS) {
  13427. var dirtyRatio = 0;
  13428. if (drawCalls > 0) {
  13429. var length_5 = dirtyList.length;
  13430. var dirtyArea = 0;
  13431. for (var i = 0; i < length_5; i++) {
  13432. dirtyArea += dirtyList[i].area;
  13433. }
  13434. dirtyRatio = Math.ceil(dirtyArea * 1000 / (stage.stageWidth * stage.stageHeight)) / 10;
  13435. }
  13436. this.fps.update(drawCalls, dirtyRatio, t1 - t, t2 - t1, costTicker);
  13437. }
  13438. };
  13439. /**
  13440. * @private
  13441. * 更新舞台尺寸
  13442. * @param stageWidth 舞台宽度(以像素为单位)
  13443. * @param stageHeight 舞台高度(以像素为单位)
  13444. */
  13445. Player.prototype.updateStageSize = function (stageWidth, stageHeight) {
  13446. var stage = this.stage;
  13447. //if (stageWidth !== stage.$stageWidth || stageHeight !== stage.$stageHeight) {
  13448. stage.$stageWidth = stageWidth;
  13449. stage.$stageHeight = stageHeight;
  13450. this.screenDisplayList.setClipRect(stageWidth, stageHeight);
  13451. if (this.stageDisplayList) {
  13452. this.stageDisplayList.setClipRect(stageWidth, stageHeight);
  13453. }
  13454. stage.dispatchEventWith(egret.Event.RESIZE);
  13455. stage.$invalidate(true);
  13456. //}
  13457. };
  13458. return Player;
  13459. }(egret.HashObject));
  13460. sys.Player = Player;
  13461. __reflect(Player.prototype, "egret.sys.Player");
  13462. var infoLines = [];
  13463. var fpsDisplay;
  13464. var fpsStyle;
  13465. sys.$logToFPS = function (info) {
  13466. if (!fpsDisplay) {
  13467. infoLines.push(info);
  13468. return;
  13469. }
  13470. fpsDisplay.updateInfo(info);
  13471. };
  13472. function displayFPS(showFPS, showLog, logFilter, styles) {
  13473. if (showLog) {
  13474. egret.log = function () {
  13475. var length = arguments.length;
  13476. var info = "";
  13477. for (var i = 0; i < length; i++) {
  13478. info += arguments[i] + " ";
  13479. }
  13480. sys.$logToFPS(info);
  13481. console.log.apply(console, toArray(arguments));
  13482. };
  13483. }
  13484. fpsStyle = styles ? {} : styles;
  13485. showLog = !!showLog;
  13486. this.showFPS = !!showFPS;
  13487. this.showLog = showLog;
  13488. if (!this.fps) {
  13489. var x = styles["x"] === undefined ? 0 : styles["x"];
  13490. var y = styles["y"] === undefined ? 0 : styles["y"];
  13491. fpsDisplay = this.fps = new FPS(this.stage, showFPS, showLog, logFilter, styles);
  13492. fpsDisplay.x = x;
  13493. fpsDisplay.y = y;
  13494. var length_6 = infoLines.length;
  13495. for (var i = 0; i < length_6; i++) {
  13496. fpsDisplay.updateInfo(infoLines[i]);
  13497. }
  13498. infoLines = null;
  13499. }
  13500. }
  13501. function showPaintRect(value) {
  13502. value = !!value;
  13503. if (this._showPaintRect == value) {
  13504. return;
  13505. }
  13506. this._showPaintRect = value;
  13507. if (value) {
  13508. if (!this.stageDisplayList) {
  13509. this.stageDisplayList = sys.DisplayList.create(this.stage);
  13510. }
  13511. this.stage.$displayList = this.stageDisplayList;
  13512. }
  13513. else {
  13514. this.stage.$displayList = this.screenDisplayList;
  13515. }
  13516. }
  13517. function drawPaintRect(dirtyList) {
  13518. var length = dirtyList.length;
  13519. var list = [];
  13520. for (var i = 0; i < length; i++) {
  13521. var region = dirtyList[i];
  13522. list[i] = [region.minX, region.minY, region.width, region.height];
  13523. region.width -= 1;
  13524. region.height -= 1;
  13525. }
  13526. var repaintList = this.paintList;
  13527. repaintList.push(list);
  13528. if (repaintList.length > 1) {
  13529. repaintList.shift();
  13530. }
  13531. var renderBuffer = this.screenDisplayList.renderBuffer;
  13532. var context = renderBuffer.context;
  13533. context.setTransform(1, 0, 0, 1, 0, 0);
  13534. context.clearRect(0, 0, renderBuffer.surface.width, renderBuffer.surface.height);
  13535. context.drawImage(this.stageDisplayList.renderBuffer.surface, 0, 0);
  13536. length = repaintList.length;
  13537. for (var i = 0; i < length; i++) {
  13538. list = repaintList[i];
  13539. for (var j = list.length - 1; j >= 0; j--) {
  13540. var r = list[j];
  13541. this.drawDirtyRect(r[0], r[1], r[2], r[3], context);
  13542. }
  13543. }
  13544. context.save();
  13545. context.beginPath();
  13546. length = dirtyList.length;
  13547. for (var i = 0; i < length; i++) {
  13548. var region = dirtyList[i];
  13549. context.clearRect(region.minX, region.minY, region.width, region.height);
  13550. context.rect(region.minX, region.minY, region.width, region.height);
  13551. }
  13552. context.clip();
  13553. context.drawImage(this.stageDisplayList.renderBuffer.surface, 0, 0);
  13554. context.restore();
  13555. }
  13556. /**
  13557. * 绘制一个脏矩形显示区域,在显示重绘区功能开启时调用。
  13558. */
  13559. function drawDirtyRect(x, y, width, height, context) {
  13560. context.strokeStyle = 'rgb(255,0,0)';
  13561. context.lineWidth = 5;
  13562. context.strokeRect(x - 0.5, y - 0.5, width, height);
  13563. }
  13564. /**
  13565. * FPS显示对象
  13566. */
  13567. FPS = (function (_super) {
  13568. __extends(FPSImpl, _super);
  13569. function FPSImpl(stage, showFPS, showLog, logFilter, styles) {
  13570. _super.call(this);
  13571. this["isFPS"] = true;
  13572. this.infoLines = [];
  13573. this.totalTime = 0;
  13574. this.totalTick = 0;
  13575. this.lastTime = 0;
  13576. this.drawCalls = 0;
  13577. this.dirtyRatio = 0;
  13578. this.costDirty = 0;
  13579. this.costRender = 0;
  13580. this.costTicker = 0;
  13581. this._stage = stage;
  13582. this.showFPS = showFPS;
  13583. this.showLog = showLog;
  13584. this.logFilter = logFilter;
  13585. this.touchChildren = false;
  13586. this.touchEnabled = false;
  13587. this.styles = styles;
  13588. this.fpsDisplay = new egret.FPSDisplay(stage, showFPS, showLog, logFilter, styles);
  13589. this.addChild(this.fpsDisplay);
  13590. var logFilterRegExp;
  13591. try {
  13592. logFilterRegExp = logFilter ? new RegExp(logFilter) : null;
  13593. }
  13594. catch (e) {
  13595. egret.log(e);
  13596. }
  13597. this.filter = function (message) {
  13598. if (logFilterRegExp)
  13599. return logFilterRegExp.test(message);
  13600. return !logFilter || message.indexOf(logFilter) == 0;
  13601. };
  13602. }
  13603. FPSImpl.prototype.update = function (drawCalls, dirtyRatio, costDirty, costRender, costTicker) {
  13604. var current = egret.getTimer();
  13605. this.totalTime += current - this.lastTime;
  13606. this.lastTime = current;
  13607. this.totalTick++;
  13608. this.drawCalls += drawCalls;
  13609. this.dirtyRatio += dirtyRatio;
  13610. this.costDirty += costDirty;
  13611. this.costRender += costRender;
  13612. this.costTicker += costTicker;
  13613. if (this.totalTime >= 1000) {
  13614. var lastFPS = Math.min(Math.ceil(this.totalTick * 1000 / this.totalTime), sys.$ticker.$frameRate);
  13615. var lastDrawCalls = Math.round(this.drawCalls / this.totalTick);
  13616. var lastDirtyRatio = Math.round(this.dirtyRatio / this.totalTick);
  13617. var lastCostDirty = Math.round(this.costDirty / this.totalTick);
  13618. var lastCostRender = Math.round(this.costRender / this.totalTick);
  13619. var lastCostTicker = Math.round(this.costTicker / this.totalTick);
  13620. this.fpsDisplay.update({
  13621. fps: lastFPS,
  13622. draw: lastDrawCalls,
  13623. dirty: lastDirtyRatio,
  13624. costTicker: lastCostTicker,
  13625. costDirty: lastCostDirty,
  13626. costRender: lastCostRender
  13627. });
  13628. this.totalTick = 0;
  13629. this.totalTime = this.totalTime % 1000;
  13630. this.drawCalls = 0;
  13631. this.dirtyRatio = 0;
  13632. this.costDirty = 0;
  13633. this.costRender = 0;
  13634. this.costTicker = 0;
  13635. }
  13636. };
  13637. FPSImpl.prototype.updateInfo = function (info) {
  13638. if (!info) {
  13639. return;
  13640. }
  13641. if (!this.showLog) {
  13642. return;
  13643. }
  13644. if (!this.filter(info)) {
  13645. return;
  13646. }
  13647. this.fpsDisplay.updateInfo(info);
  13648. };
  13649. return FPSImpl;
  13650. })(egret.Sprite);
  13651. function toArray(argument) {
  13652. var args = [];
  13653. for (var i = 0; i < argument.length; i++) {
  13654. args.push(argument[i]);
  13655. }
  13656. return args;
  13657. }
  13658. egret.warn = function () {
  13659. console.warn.apply(console, toArray(arguments));
  13660. };
  13661. egret.error = function () {
  13662. console.error.apply(console, toArray(arguments));
  13663. };
  13664. egret.assert = function () {
  13665. console.assert.apply(console, toArray(arguments));
  13666. };
  13667. egret.log = function () {
  13668. console.log.apply(console, toArray(arguments));
  13669. };
  13670. })(sys = egret.sys || (egret.sys = {}));
  13671. })(egret || (egret = {}));
  13672. //////////////////////////////////////////////////////////////////////////////////////
  13673. //
  13674. // Copyright (c) 2014-present, Egret Technology.
  13675. // All rights reserved.
  13676. // Redistribution and use in source and binary forms, with or without
  13677. // modification, are permitted provided that the following conditions are met:
  13678. //
  13679. // * Redistributions of source code must retain the above copyright
  13680. // notice, this list of conditions and the following disclaimer.
  13681. // * Redistributions in binary form must reproduce the above copyright
  13682. // notice, this list of conditions and the following disclaimer in the
  13683. // documentation and/or other materials provided with the distribution.
  13684. // * Neither the name of the Egret nor the
  13685. // names of its contributors may be used to endorse or promote products
  13686. // derived from this software without specific prior written permission.
  13687. //
  13688. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  13689. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  13690. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  13691. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  13692. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  13693. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  13694. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  13695. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  13696. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  13697. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13698. //
  13699. //////////////////////////////////////////////////////////////////////////////////////
  13700. var egret;
  13701. (function (egret) {
  13702. /**
  13703. * OrientationMode 类为舞台初始旋转模式提供值。
  13704. */
  13705. egret.OrientationMode = {
  13706. /**
  13707. * 适配屏幕
  13708. */
  13709. AUTO: "auto",
  13710. /**
  13711. * 默认竖屏
  13712. */
  13713. PORTRAIT: "portrait",
  13714. /**
  13715. * 默认横屏,舞台顺时针旋转90度
  13716. */
  13717. LANDSCAPE: "landscape",
  13718. /**
  13719. * 默认横屏,舞台逆时针旋转90度
  13720. */
  13721. LANDSCAPE_FLIPPED: "landscapeFlipped"
  13722. };
  13723. })(egret || (egret = {}));
  13724. //////////////////////////////////////////////////////////////////////////////////////
  13725. //
  13726. // Copyright (c) 2014-present, Egret Technology.
  13727. // All rights reserved.
  13728. // Redistribution and use in source and binary forms, with or without
  13729. // modification, are permitted provided that the following conditions are met:
  13730. //
  13731. // * Redistributions of source code must retain the above copyright
  13732. // notice, this list of conditions and the following disclaimer.
  13733. // * Redistributions in binary form must reproduce the above copyright
  13734. // notice, this list of conditions and the following disclaimer in the
  13735. // documentation and/or other materials provided with the distribution.
  13736. // * Neither the name of the Egret nor the
  13737. // names of its contributors may be used to endorse or promote products
  13738. // derived from this software without specific prior written permission.
  13739. //
  13740. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  13741. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  13742. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  13743. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  13744. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  13745. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  13746. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  13747. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  13748. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  13749. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13750. //
  13751. //////////////////////////////////////////////////////////////////////////////////////
  13752. var egret;
  13753. (function (egret) {
  13754. var sys;
  13755. (function (sys) {
  13756. var regionPool = [];
  13757. /**
  13758. * @private
  13759. */
  13760. var Region = (function () {
  13761. function Region() {
  13762. /**
  13763. * @private
  13764. */
  13765. this.minX = 0;
  13766. /**
  13767. * @private
  13768. */
  13769. this.minY = 0;
  13770. /**
  13771. * @private
  13772. */
  13773. this.maxX = 0;
  13774. /**
  13775. * @private
  13776. */
  13777. this.maxY = 0;
  13778. /**
  13779. * @private
  13780. */
  13781. this.width = 0;
  13782. /**
  13783. * @private
  13784. */
  13785. this.height = 0;
  13786. /**
  13787. * @private
  13788. */
  13789. this.area = 0;
  13790. /**
  13791. * @private
  13792. * 是否发生移动
  13793. */
  13794. this.moved = false;
  13795. }
  13796. /**
  13797. * @private
  13798. * 释放一个Region实例到对象池
  13799. */
  13800. Region.release = function (region) {
  13801. regionPool.push(region);
  13802. };
  13803. /**
  13804. * @private
  13805. * 从对象池中取出或创建一个新的Region对象。
  13806. * 建议对于一次性使用的对象,均使用此方法创建,而不是直接new一个。
  13807. * 使用完后调用对应的release()静态方法回收对象,能有效减少对象创建数量造成的性能开销。
  13808. */
  13809. Region.create = function () {
  13810. var region = regionPool.pop();
  13811. if (!region) {
  13812. region = new Region();
  13813. }
  13814. return region;
  13815. };
  13816. /**
  13817. * @private
  13818. */
  13819. Region.prototype.setTo = function (minX, minY, maxX, maxY) {
  13820. this.minX = minX;
  13821. this.minY = minY;
  13822. this.maxX = maxX;
  13823. this.maxY = maxY;
  13824. this.updateArea();
  13825. return this;
  13826. };
  13827. /**
  13828. * @private
  13829. * 把所有值都取整
  13830. */
  13831. Region.prototype.intValues = function () {
  13832. this.minX = Math.floor(this.minX);
  13833. this.minY = Math.floor(this.minY);
  13834. this.maxX = Math.ceil(this.maxX);
  13835. this.maxY = Math.ceil(this.maxY);
  13836. this.updateArea();
  13837. };
  13838. /**
  13839. * @private
  13840. */
  13841. Region.prototype.updateArea = function () {
  13842. this.width = this.maxX - this.minX;
  13843. this.height = this.maxY - this.minY;
  13844. this.area = this.width * this.height;
  13845. };
  13846. /**
  13847. * @private
  13848. * 注意!由于性能优化,此方法不判断自身是否为空,必须在外部确认自身和目标区域都不为空再调用合并。否则结果始终从0,0点开始。
  13849. */
  13850. Region.prototype.union = function (target) {
  13851. if (this.minX > target.minX) {
  13852. this.minX = target.minX;
  13853. }
  13854. if (this.minY > target.minY) {
  13855. this.minY = target.minY;
  13856. }
  13857. if (this.maxX < target.maxX) {
  13858. this.maxX = target.maxX;
  13859. }
  13860. if (this.maxY < target.maxY) {
  13861. this.maxY = target.maxY;
  13862. }
  13863. this.updateArea();
  13864. };
  13865. /**
  13866. * @private
  13867. * 注意!由于性能优化,此方法不判断自身是否为空,必须在外部确认自身和目标区域都不为空再调用合并。否则结果始终从0,0点开始。
  13868. */
  13869. Region.prototype.intersect = function (target) {
  13870. if (this.minX < target.minX) {
  13871. this.minX = target.minX;
  13872. }
  13873. if (this.maxX > target.maxX) {
  13874. this.maxX = target.maxX;
  13875. }
  13876. if (this.minX >= this.maxX) {
  13877. this.setEmpty();
  13878. return;
  13879. }
  13880. if (this.minY < target.minY) {
  13881. this.minY = target.minY;
  13882. }
  13883. if (this.maxY > target.maxY) {
  13884. this.maxY = target.maxY;
  13885. }
  13886. if (this.minY >= this.maxY) {
  13887. this.setEmpty();
  13888. return;
  13889. }
  13890. this.updateArea();
  13891. };
  13892. /**
  13893. * @private
  13894. */
  13895. Region.prototype.setEmpty = function () {
  13896. this.minX = 0;
  13897. this.minY = 0;
  13898. this.maxX = 0;
  13899. this.maxY = 0;
  13900. this.width = 0;
  13901. this.height = 0;
  13902. this.area = 0;
  13903. };
  13904. /**
  13905. * @private
  13906. * 确定此 Region 对象是否为空。
  13907. */
  13908. Region.prototype.isEmpty = function () {
  13909. return this.width <= 0 || this.height <= 0;
  13910. };
  13911. /**
  13912. * @private
  13913. */
  13914. Region.prototype.intersects = function (target) {
  13915. if (this.isEmpty()) {
  13916. return false;
  13917. }
  13918. var max = this.minX > target.minX ? this.minX : target.minX;
  13919. var min = this.maxX < target.maxX ? this.maxX : target.maxX;
  13920. if (max > min) {
  13921. return false;
  13922. }
  13923. max = this.minY > target.minY ? this.minY : target.minY;
  13924. min = this.maxY < target.maxY ? this.maxY : target.maxY;
  13925. return max <= min;
  13926. };
  13927. /**
  13928. * @private
  13929. */
  13930. Region.prototype.updateRegion = function (bounds, matrix) {
  13931. if (bounds.width == 0 || bounds.height == 0) {
  13932. //todo 理论上应该是空
  13933. this.setEmpty();
  13934. return;
  13935. }
  13936. var m = matrix;
  13937. var a = m.a;
  13938. var b = m.b;
  13939. var c = m.c;
  13940. var d = m.d;
  13941. var tx = m.tx;
  13942. var ty = m.ty;
  13943. var x = bounds.x;
  13944. var y = bounds.y;
  13945. var xMax = x + bounds.width;
  13946. var yMax = y + bounds.height;
  13947. var minX, minY, maxX, maxY;
  13948. //优化,通常情况下不缩放旋转的对象占多数,直接加上偏移量即可。
  13949. if (a == 1.0 && b == 0.0 && c == 0.0 && d == 1.0) {
  13950. minX = x + tx - 1;
  13951. minY = y + ty - 1;
  13952. maxX = xMax + tx + 1;
  13953. maxY = yMax + ty + 1;
  13954. }
  13955. else {
  13956. var x0 = a * x + c * y + tx;
  13957. var y0 = b * x + d * y + ty;
  13958. var x1 = a * xMax + c * y + tx;
  13959. var y1 = b * xMax + d * y + ty;
  13960. var x2 = a * xMax + c * yMax + tx;
  13961. var y2 = b * xMax + d * yMax + ty;
  13962. var x3 = a * x + c * yMax + tx;
  13963. var y3 = b * x + d * yMax + ty;
  13964. var tmp = 0;
  13965. if (x0 > x1) {
  13966. tmp = x0;
  13967. x0 = x1;
  13968. x1 = tmp;
  13969. }
  13970. if (x2 > x3) {
  13971. tmp = x2;
  13972. x2 = x3;
  13973. x3 = tmp;
  13974. }
  13975. minX = (x0 < x2 ? x0 : x2) - 1;
  13976. maxX = (x1 > x3 ? x1 : x3) + 1;
  13977. if (y0 > y1) {
  13978. tmp = y0;
  13979. y0 = y1;
  13980. y1 = tmp;
  13981. }
  13982. if (y2 > y3) {
  13983. tmp = y2;
  13984. y2 = y3;
  13985. y3 = tmp;
  13986. }
  13987. minY = (y0 < y2 ? y0 : y2) - 1;
  13988. maxY = (y1 > y3 ? y1 : y3) + 1;
  13989. }
  13990. this.minX = minX;
  13991. this.minY = minY;
  13992. this.maxX = maxX;
  13993. this.maxY = maxY;
  13994. this.width = maxX - minX;
  13995. this.height = maxY - minY;
  13996. this.area = this.width * this.height;
  13997. };
  13998. return Region;
  13999. }());
  14000. sys.Region = Region;
  14001. __reflect(Region.prototype, "egret.sys.Region");
  14002. })(sys = egret.sys || (egret.sys = {}));
  14003. })(egret || (egret = {}));
  14004. //////////////////////////////////////////////////////////////////////////////////////
  14005. //
  14006. // Copyright (c) 2014-present, Egret Technology.
  14007. // All rights reserved.
  14008. // Redistribution and use in source and binary forms, with or without
  14009. // modification, are permitted provided that the following conditions are met:
  14010. //
  14011. // * Redistributions of source code must retain the above copyright
  14012. // notice, this list of conditions and the following disclaimer.
  14013. // * Redistributions in binary form must reproduce the above copyright
  14014. // notice, this list of conditions and the following disclaimer in the
  14015. // documentation and/or other materials provided with the distribution.
  14016. // * Neither the name of the Egret nor the
  14017. // names of its contributors may be used to endorse or promote products
  14018. // derived from this software without specific prior written permission.
  14019. //
  14020. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  14021. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  14022. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14023. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  14024. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  14025. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  14026. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  14027. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  14028. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  14029. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14030. //
  14031. //////////////////////////////////////////////////////////////////////////////////////
  14032. var egret;
  14033. (function (egret) {
  14034. var sys;
  14035. (function (sys) {
  14036. })(sys = egret.sys || (egret.sys = {}));
  14037. })(egret || (egret = {}));
  14038. //////////////////////////////////////////////////////////////////////////////////////
  14039. //
  14040. // Copyright (c) 2014-present, Egret Technology.
  14041. // All rights reserved.
  14042. // Redistribution and use in source and binary forms, with or without
  14043. // modification, are permitted provided that the following conditions are met:
  14044. //
  14045. // * Redistributions of source code must retain the above copyright
  14046. // notice, this list of conditions and the following disclaimer.
  14047. // * Redistributions in binary form must reproduce the above copyright
  14048. // notice, this list of conditions and the following disclaimer in the
  14049. // documentation and/or other materials provided with the distribution.
  14050. // * Neither the name of the Egret nor the
  14051. // names of its contributors may be used to endorse or promote products
  14052. // derived from this software without specific prior written permission.
  14053. //
  14054. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  14055. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  14056. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14057. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  14058. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  14059. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  14060. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  14061. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  14062. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  14063. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14064. //
  14065. //////////////////////////////////////////////////////////////////////////////////////
  14066. //////////////////////////////////////////////////////////////////////////////////////
  14067. //
  14068. // Copyright (c) 2014-present, Egret Technology.
  14069. // All rights reserved.
  14070. // Redistribution and use in source and binary forms, with or without
  14071. // modification, are permitted provided that the following conditions are met:
  14072. //
  14073. // * Redistributions of source code must retain the above copyright
  14074. // notice, this list of conditions and the following disclaimer.
  14075. // * Redistributions in binary form must reproduce the above copyright
  14076. // notice, this list of conditions and the following disclaimer in the
  14077. // documentation and/or other materials provided with the distribution.
  14078. // * Neither the name of the Egret nor the
  14079. // names of its contributors may be used to endorse or promote products
  14080. // derived from this software without specific prior written permission.
  14081. //
  14082. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  14083. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  14084. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14085. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  14086. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  14087. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  14088. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  14089. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  14090. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  14091. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14092. //
  14093. //////////////////////////////////////////////////////////////////////////////////////
  14094. //////////////////////////////////////////////////////////////////////////////////////
  14095. //
  14096. // Copyright (c) 2014-present, Egret Technology.
  14097. // All rights reserved.
  14098. // Redistribution and use in source and binary forms, with or without
  14099. // modification, are permitted provided that the following conditions are met:
  14100. //
  14101. // * Redistributions of source code must retain the above copyright
  14102. // notice, this list of conditions and the following disclaimer.
  14103. // * Redistributions in binary form must reproduce the above copyright
  14104. // notice, this list of conditions and the following disclaimer in the
  14105. // documentation and/or other materials provided with the distribution.
  14106. // * Neither the name of the Egret nor the
  14107. // names of its contributors may be used to endorse or promote products
  14108. // derived from this software without specific prior written permission.
  14109. //
  14110. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  14111. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  14112. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14113. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  14114. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  14115. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  14116. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  14117. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  14118. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  14119. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14120. //
  14121. //////////////////////////////////////////////////////////////////////////////////////
  14122. var egret;
  14123. (function (egret) {
  14124. var sys;
  14125. (function (sys) {
  14126. /**
  14127. * @private
  14128. * 屏幕适配器默认实现,开发者可以实现自定义规则的屏幕适配器。并在初始化加载时将适配器的实例赋值给egret.sys.screenAdapter上,从而替换掉默认适配器。
  14129. */
  14130. var DefaultScreenAdapter = (function (_super) {
  14131. __extends(DefaultScreenAdapter, _super);
  14132. /**
  14133. * @private
  14134. */
  14135. function DefaultScreenAdapter() {
  14136. return _super.call(this) || this;
  14137. }
  14138. /**
  14139. * @private
  14140. * 计算舞台显示尺寸
  14141. * @param scaleMode 当前的缩放模式
  14142. * @param screenWidth 播放器视口宽度
  14143. * @param screenHeight 播放器视口高度
  14144. * @param contentWidth 初始化内容宽度
  14145. * @param contentHeight 初始化内容高度
  14146. */
  14147. DefaultScreenAdapter.prototype.calculateStageSize = function (scaleMode, screenWidth, screenHeight, contentWidth, contentHeight) {
  14148. var displayWidth = screenWidth;
  14149. var displayHeight = screenHeight;
  14150. var stageWidth = contentWidth;
  14151. var stageHeight = contentHeight;
  14152. var scaleX = (screenWidth / stageWidth) || 0;
  14153. var scaleY = (screenHeight / stageHeight) || 0;
  14154. switch (scaleMode) {
  14155. case egret.StageScaleMode.EXACT_FIT:
  14156. break;
  14157. case egret.StageScaleMode.FIXED_HEIGHT:
  14158. stageWidth = Math.round(screenWidth / scaleY);
  14159. break;
  14160. case egret.StageScaleMode.FIXED_WIDTH:
  14161. stageHeight = Math.round(screenHeight / scaleX);
  14162. break;
  14163. case egret.StageScaleMode.NO_BORDER:
  14164. if (scaleX > scaleY) {
  14165. displayHeight = Math.round(stageHeight * scaleX);
  14166. }
  14167. else {
  14168. displayWidth = Math.round(stageWidth * scaleY);
  14169. }
  14170. break;
  14171. case egret.StageScaleMode.SHOW_ALL:
  14172. if (scaleX > scaleY) {
  14173. displayWidth = Math.round(stageWidth * scaleY);
  14174. }
  14175. else {
  14176. displayHeight = Math.round(stageHeight * scaleX);
  14177. }
  14178. break;
  14179. case egret.StageScaleMode.FIXED_NARROW:
  14180. if (scaleX > scaleY) {
  14181. stageWidth = Math.round(screenWidth / scaleY);
  14182. }
  14183. else {
  14184. stageHeight = Math.round(screenHeight / scaleX);
  14185. }
  14186. break;
  14187. case egret.StageScaleMode.FIXED_WIDE:
  14188. if (scaleX > scaleY) {
  14189. stageHeight = Math.round(screenHeight / scaleX);
  14190. }
  14191. else {
  14192. stageWidth = Math.round(screenWidth / scaleY);
  14193. }
  14194. break;
  14195. default:
  14196. stageWidth = screenWidth;
  14197. stageHeight = screenHeight;
  14198. break;
  14199. }
  14200. //宽高不是2的整数倍会导致图片绘制出现问题
  14201. if (displayWidth % 2 != 0) {
  14202. displayWidth += 1;
  14203. }
  14204. if (displayHeight % 2 != 0) {
  14205. displayHeight += 1;
  14206. }
  14207. return {
  14208. stageWidth: stageWidth,
  14209. stageHeight: stageHeight,
  14210. displayWidth: displayWidth,
  14211. displayHeight: displayHeight
  14212. };
  14213. };
  14214. return DefaultScreenAdapter;
  14215. }(egret.HashObject));
  14216. sys.DefaultScreenAdapter = DefaultScreenAdapter;
  14217. __reflect(DefaultScreenAdapter.prototype, "egret.sys.DefaultScreenAdapter", ["egret.sys.IScreenAdapter"]);
  14218. })(sys = egret.sys || (egret.sys = {}));
  14219. })(egret || (egret = {}));
  14220. //////////////////////////////////////////////////////////////////////////////////////
  14221. //
  14222. // Copyright (c) 2014-present, Egret Technology.
  14223. // All rights reserved.
  14224. // Redistribution and use in source and binary forms, with or without
  14225. // modification, are permitted provided that the following conditions are met:
  14226. //
  14227. // * Redistributions of source code must retain the above copyright
  14228. // notice, this list of conditions and the following disclaimer.
  14229. // * Redistributions in binary form must reproduce the above copyright
  14230. // notice, this list of conditions and the following disclaimer in the
  14231. // documentation and/or other materials provided with the distribution.
  14232. // * Neither the name of the Egret nor the
  14233. // names of its contributors may be used to endorse or promote products
  14234. // derived from this software without specific prior written permission.
  14235. //
  14236. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  14237. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  14238. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14239. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  14240. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  14241. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  14242. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  14243. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  14244. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  14245. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14246. //
  14247. //////////////////////////////////////////////////////////////////////////////////////
  14248. var egret;
  14249. (function (egret) {
  14250. /**
  14251. * @language en_US
  14252. * StageScaleMode class provides values for the stage zoom mode.
  14253. * @version Egret 2.4
  14254. * @platform Web,Native
  14255. * @includeExample egret/player/StageScaleMode.ts
  14256. */
  14257. /**
  14258. * @language zh_CN
  14259. * StageScaleMode 类为舞台缩放模式提供值。
  14260. * @version Egret 2.4
  14261. * @platform Web,Native
  14262. * @includeExample egret/player/StageScaleMode.ts
  14263. */
  14264. var StageScaleMode = (function () {
  14265. function StageScaleMode() {
  14266. }
  14267. return StageScaleMode;
  14268. }());
  14269. /**
  14270. * @language en_US
  14271. * Do not scale application content. Even when you change the player viewport size, it remains unchanged. If the player is smaller than the viewport content, possibly with some cropping.<br/>
  14272. * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) always with the player viewport size consistent.
  14273. */
  14274. /**
  14275. * @language zh_CN
  14276. * 不缩放应用程序内容。即使在更改播放器视口大小时,它仍然保持不变。如果播放器视口比内容小,则可能进行一些裁切。<br/>
  14277. * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终跟播放器视口大小保持一致。
  14278. */
  14279. StageScaleMode.NO_SCALE = "noScale";
  14280. /**
  14281. * @language en_US
  14282. * Keep the original aspect ratio scaling application content, after scaling a wide directions application content to fill the viewport players on both sides in the other direction may not be wide enough and left black bars.<br/>
  14283. * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size.
  14284. */
  14285. /**
  14286. * @language zh_CN
  14287. * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较宽方向填满播放器视口,另一个方向的两侧可能会不够宽而留有黑边。<br/>
  14288. * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。
  14289. */
  14290. StageScaleMode.SHOW_ALL = "showAll";
  14291. /**
  14292. * @language en_US
  14293. * Keep the original aspect ratio scaling application content, after scaling a narrow direction of application content to fill the viewport players on both sides in the other direction may exceed the viewport and the player is cut.<br/>
  14294. * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size.
  14295. */
  14296. /**
  14297. * @language zh_CN
  14298. * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较窄方向填满播放器视口,另一个方向的两侧可能会超出播放器视口而被裁切。<br/>
  14299. * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。
  14300. */
  14301. StageScaleMode.NO_BORDER = "noBorder";
  14302. /**
  14303. * @language en_US
  14304. * Do not keep the original aspect ratio scaling application content, after scaling application content just fill the player viewport.<br/>
  14305. * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size.
  14306. */
  14307. /**
  14308. * @language zh_CN
  14309. * 不保持原始宽高比缩放应用程序内容,缩放后应用程序内容正好填满播放器视口。<br/>
  14310. * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。
  14311. */
  14312. StageScaleMode.EXACT_FIT = "exactFit";
  14313. /**
  14314. * @language en_US
  14315. * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant width, height may change.<br/>
  14316. * In this mode, the stage width (Stage.stageWidth) is always equal to initialize external incoming application content width. Stage height (Stage.stageHeight) by the current scale with the player viewport height decision.
  14317. */
  14318. /**
  14319. * @language zh_CN
  14320. * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始宽度不变,高度可能会改变。<br/>
  14321. * 在此模式下,舞台宽度(Stage.stageWidth)始终等于初始化时外部传入的应用程序内容宽度。舞台高度(Stage.stageHeight)由当前的缩放比例与播放器视口高度决定。
  14322. */
  14323. StageScaleMode.FIXED_WIDTH = "fixedWidth";
  14324. /**
  14325. * @language en_US
  14326. * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant height, width may change.<br/>
  14327. * In this mode, the stage height (Stage.stageHeight) is always equal to initialize external incoming application content height. Stage width (Stage.stageWidth) by the current scale with the player viewport width decision.
  14328. */
  14329. /**
  14330. * @language zh_CN
  14331. * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始高度不变,宽度可能会改变。<br/>
  14332. * 在此模式下,舞台高度(Stage.stageHeight)始终等于初始化时外部传入的应用程序内容高度。舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽度决定。
  14333. */
  14334. StageScaleMode.FIXED_HEIGHT = "fixedHeight";
  14335. /**
  14336. * @language en_US
  14337. * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player,a narrow direction may not be wide enough and fill.<br/>
  14338. * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size.
  14339. */
  14340. /**
  14341. * @language zh_CN
  14342. * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较窄方向可能会不够宽而填充。<br/>
  14343. * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。
  14344. */
  14345. StageScaleMode.FIXED_NARROW = "fixedNarrow";
  14346. /**
  14347. * @language en_US
  14348. * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, a wide direction may exceed the viewport and the player is cut.<br/>
  14349. * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size.
  14350. */
  14351. /**
  14352. * @language zh_CN
  14353. * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较宽方向的两侧可能会超出播放器视口而被裁切。<br/>
  14354. * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。
  14355. */
  14356. StageScaleMode.FIXED_WIDE = "fixedWide";
  14357. egret.StageScaleMode = StageScaleMode;
  14358. __reflect(StageScaleMode.prototype, "egret.StageScaleMode");
  14359. })(egret || (egret = {}));
  14360. //////////////////////////////////////////////////////////////////////////////////////
  14361. //
  14362. // Copyright (c) 2014-present, Egret Technology.
  14363. // All rights reserved.
  14364. // Redistribution and use in source and binary forms, with or without
  14365. // modification, are permitted provided that the following conditions are met:
  14366. //
  14367. // * Redistributions of source code must retain the above copyright
  14368. // notice, this list of conditions and the following disclaimer.
  14369. // * Redistributions in binary form must reproduce the above copyright
  14370. // notice, this list of conditions and the following disclaimer in the
  14371. // documentation and/or other materials provided with the distribution.
  14372. // * Neither the name of the Egret nor the
  14373. // names of its contributors may be used to endorse or promote products
  14374. // derived from this software without specific prior written permission.
  14375. //
  14376. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  14377. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  14378. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14379. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  14380. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  14381. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  14382. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  14383. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  14384. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  14385. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14386. //
  14387. //////////////////////////////////////////////////////////////////////////////////////
  14388. var egret;
  14389. (function (egret) {
  14390. var sys;
  14391. (function (sys) {
  14392. })(sys = egret.sys || (egret.sys = {}));
  14393. })(egret || (egret = {}));
  14394. //////////////////////////////////////////////////////////////////////////////////////
  14395. //
  14396. // Copyright (c) 2014-present, Egret Technology.
  14397. // All rights reserved.
  14398. // Redistribution and use in source and binary forms, with or without
  14399. // modification, are permitted provided that the following conditions are met:
  14400. //
  14401. // * Redistributions of source code must retain the above copyright
  14402. // notice, this list of conditions and the following disclaimer.
  14403. // * Redistributions in binary form must reproduce the above copyright
  14404. // notice, this list of conditions and the following disclaimer in the
  14405. // documentation and/or other materials provided with the distribution.
  14406. // * Neither the name of the Egret nor the
  14407. // names of its contributors may be used to endorse or promote products
  14408. // derived from this software without specific prior written permission.
  14409. //
  14410. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  14411. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  14412. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14413. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  14414. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  14415. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  14416. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  14417. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  14418. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  14419. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14420. //
  14421. //////////////////////////////////////////////////////////////////////////////////////
  14422. var egret;
  14423. (function (egret) {
  14424. var sys;
  14425. (function (sys) {
  14426. /**
  14427. * @private
  14428. */
  14429. sys.$START_TIME = 0;
  14430. /**
  14431. * @private
  14432. * 是否要广播Event.RENDER事件的标志。
  14433. */
  14434. sys.$invalidateRenderFlag = false;
  14435. /**
  14436. * @private
  14437. * 需要立即刷新屏幕的标志
  14438. */
  14439. sys.$requestRenderingFlag = false;
  14440. /**
  14441. * @private
  14442. * Egret心跳计时器
  14443. */
  14444. var SystemTicker = (function () {
  14445. /**
  14446. * @private
  14447. */
  14448. function SystemTicker() {
  14449. /**
  14450. * @private
  14451. */
  14452. this.playerList = [];
  14453. /**
  14454. * @private
  14455. */
  14456. this.callBackList = [];
  14457. /**
  14458. * @private
  14459. */
  14460. this.thisObjectList = [];
  14461. /**
  14462. * @private
  14463. * 全局帧率
  14464. */
  14465. this.$frameRate = 30;
  14466. this.lastTimeStamp = 0;
  14467. /**
  14468. * @private
  14469. * ticker 花销的时间
  14470. */
  14471. this.costEnterFrame = 0;
  14472. if (true && sys.$ticker) {
  14473. egret.$error(1008, "egret.sys.SystemTicker");
  14474. }
  14475. sys.$START_TIME = Date.now();
  14476. this.frameDeltaTime = 1000 / this.$frameRate;
  14477. this.lastCount = this.frameInterval = Math.round(60000 / this.$frameRate);
  14478. }
  14479. /**
  14480. * @private
  14481. * 注册一个播放器实例并运行
  14482. */
  14483. SystemTicker.prototype.$addPlayer = function (player) {
  14484. if (this.playerList.indexOf(player) != -1) {
  14485. return;
  14486. }
  14487. if (true) {
  14488. egret_stages.push(player.stage);
  14489. }
  14490. this.playerList = this.playerList.concat();
  14491. this.playerList.push(player);
  14492. };
  14493. /**
  14494. * @private
  14495. * 停止一个播放器实例的运行。
  14496. */
  14497. SystemTicker.prototype.$removePlayer = function (player) {
  14498. var index = this.playerList.indexOf(player);
  14499. if (index !== -1) {
  14500. if (true) {
  14501. var i = egret_stages.indexOf(player.stage);
  14502. egret_stages.splice(i, 1);
  14503. }
  14504. this.playerList = this.playerList.concat();
  14505. this.playerList.splice(index, 1);
  14506. }
  14507. };
  14508. /**
  14509. * @private
  14510. */
  14511. SystemTicker.prototype.$startTick = function (callBack, thisObject) {
  14512. var index = this.getTickIndex(callBack, thisObject);
  14513. if (index != -1) {
  14514. return;
  14515. }
  14516. this.concatTick();
  14517. this.callBackList.push(callBack);
  14518. this.thisObjectList.push(thisObject);
  14519. };
  14520. /**
  14521. * @private
  14522. */
  14523. SystemTicker.prototype.$stopTick = function (callBack, thisObject) {
  14524. var index = this.getTickIndex(callBack, thisObject);
  14525. if (index == -1) {
  14526. return;
  14527. }
  14528. this.concatTick();
  14529. this.callBackList.splice(index, 1);
  14530. this.thisObjectList.splice(index, 1);
  14531. };
  14532. /**
  14533. * @private
  14534. */
  14535. SystemTicker.prototype.getTickIndex = function (callBack, thisObject) {
  14536. var callBackList = this.callBackList;
  14537. var thisObjectList = this.thisObjectList;
  14538. for (var i = callBackList.length - 1; i >= 0; i--) {
  14539. if (callBackList[i] == callBack &&
  14540. thisObjectList[i] == thisObject) {
  14541. return i;
  14542. }
  14543. }
  14544. return -1;
  14545. };
  14546. /**
  14547. * @private
  14548. *
  14549. */
  14550. SystemTicker.prototype.concatTick = function () {
  14551. this.callBackList = this.callBackList.concat();
  14552. this.thisObjectList = this.thisObjectList.concat();
  14553. };
  14554. /**
  14555. * @private
  14556. * 设置全局帧率
  14557. */
  14558. SystemTicker.prototype.$setFrameRate = function (value) {
  14559. value = +value || 0;
  14560. if (value <= 0) {
  14561. return false;
  14562. }
  14563. if (this.$frameRate == value) {
  14564. return false;
  14565. }
  14566. this.$frameRate = value;
  14567. if (value > 60) {
  14568. value = 60;
  14569. }
  14570. //todo
  14571. if (egret.Capabilities.runtimeType == egret.RuntimeType.NATIVE) {
  14572. egret_native.setFrameRate(value);
  14573. value = 60;
  14574. }
  14575. this.frameDeltaTime = 1000 / value;
  14576. //这里用60*1000来避免浮点数计算不准确的问题。
  14577. this.lastCount = this.frameInterval = Math.round(60000 / value);
  14578. return true;
  14579. };
  14580. /**
  14581. * @private
  14582. * 执行一次刷新
  14583. */
  14584. SystemTicker.prototype.update = function () {
  14585. var t1 = egret.getTimer();
  14586. var callBackList = this.callBackList;
  14587. var thisObjectList = this.thisObjectList;
  14588. var length = callBackList.length;
  14589. var requestRenderingFlag = sys.$requestRenderingFlag;
  14590. var timeStamp = egret.getTimer();
  14591. this.callLaterAsyncs();
  14592. for (var i = 0; i < length; i++) {
  14593. if (callBackList[i].call(thisObjectList[i], timeStamp)) {
  14594. requestRenderingFlag = true;
  14595. }
  14596. }
  14597. var t2 = egret.getTimer();
  14598. var deltaTime = timeStamp - this.lastTimeStamp;
  14599. this.lastTimeStamp = timeStamp;
  14600. if (deltaTime >= this.frameDeltaTime) {
  14601. this.lastCount = this.frameInterval;
  14602. }
  14603. else {
  14604. this.lastCount -= 1000;
  14605. if (this.lastCount > 0) {
  14606. if (requestRenderingFlag) {
  14607. this.render(false, this.costEnterFrame + t2 - t1);
  14608. }
  14609. return;
  14610. }
  14611. this.lastCount += this.frameInterval;
  14612. }
  14613. this.render(true, this.costEnterFrame + t2 - t1);
  14614. var t3 = egret.getTimer();
  14615. this.broadcastEnterFrame();
  14616. var t4 = egret.getTimer();
  14617. this.costEnterFrame = t4 - t3;
  14618. };
  14619. /**
  14620. * @private
  14621. * 执行一次屏幕渲染
  14622. */
  14623. SystemTicker.prototype.render = function (triggerByFrame, costTicker) {
  14624. var playerList = this.playerList;
  14625. var length = playerList.length;
  14626. if (length == 0) {
  14627. return;
  14628. }
  14629. this.callLaters();
  14630. if (sys.$invalidateRenderFlag) {
  14631. this.broadcastRender();
  14632. sys.$invalidateRenderFlag = false;
  14633. }
  14634. for (var i = 0; i < length; i++) {
  14635. playerList[i].$render(triggerByFrame, costTicker);
  14636. }
  14637. sys.$requestRenderingFlag = false;
  14638. };
  14639. /**
  14640. * @private
  14641. * 广播EnterFrame事件。
  14642. */
  14643. SystemTicker.prototype.broadcastEnterFrame = function () {
  14644. var list = egret.DisplayObject.$enterFrameCallBackList;
  14645. var length = list.length;
  14646. if (length == 0) {
  14647. return;
  14648. }
  14649. list = list.concat();
  14650. for (var i = 0; i < length; i++) {
  14651. list[i].dispatchEventWith(egret.Event.ENTER_FRAME);
  14652. }
  14653. };
  14654. /**
  14655. * @private
  14656. * 广播Render事件。
  14657. */
  14658. SystemTicker.prototype.broadcastRender = function () {
  14659. var list = egret.DisplayObject.$renderCallBackList;
  14660. var length = list.length;
  14661. if (length == 0) {
  14662. return;
  14663. }
  14664. list = list.concat();
  14665. for (var i = 0; i < length; i++) {
  14666. list[i].dispatchEventWith(egret.Event.RENDER);
  14667. }
  14668. };
  14669. /**
  14670. * @private
  14671. */
  14672. SystemTicker.prototype.callLaters = function () {
  14673. var functionList;
  14674. var thisList;
  14675. var argsList;
  14676. if (egret.$callLaterFunctionList.length > 0) {
  14677. functionList = egret.$callLaterFunctionList;
  14678. egret.$callLaterFunctionList = [];
  14679. thisList = egret.$callLaterThisList;
  14680. egret.$callLaterThisList = [];
  14681. argsList = egret.$callLaterArgsList;
  14682. egret.$callLaterArgsList = [];
  14683. }
  14684. if (functionList) {
  14685. var length_7 = functionList.length;
  14686. for (var i = 0; i < length_7; i++) {
  14687. var func = functionList[i];
  14688. if (func != null) {
  14689. func.apply(thisList[i], argsList[i]);
  14690. }
  14691. }
  14692. }
  14693. };
  14694. /**
  14695. * @private
  14696. */
  14697. SystemTicker.prototype.callLaterAsyncs = function () {
  14698. if (egret.$callAsyncFunctionList.length > 0) {
  14699. var locCallAsyncFunctionList = egret.$callAsyncFunctionList;
  14700. var locCallAsyncThisList = egret.$callAsyncThisList;
  14701. var locCallAsyncArgsList = egret.$callAsyncArgsList;
  14702. egret.$callAsyncFunctionList = [];
  14703. egret.$callAsyncThisList = [];
  14704. egret.$callAsyncArgsList = [];
  14705. for (var i = 0; i < locCallAsyncFunctionList.length; i++) {
  14706. var func = locCallAsyncFunctionList[i];
  14707. if (func != null) {
  14708. func.apply(locCallAsyncThisList[i], locCallAsyncArgsList[i]);
  14709. }
  14710. }
  14711. }
  14712. };
  14713. return SystemTicker;
  14714. }());
  14715. sys.SystemTicker = SystemTicker;
  14716. __reflect(SystemTicker.prototype, "egret.sys.SystemTicker");
  14717. /**
  14718. * @private
  14719. * 心跳计时器单例
  14720. */
  14721. sys.$ticker = new sys.SystemTicker();
  14722. })(sys = egret.sys || (egret.sys = {}));
  14723. })(egret || (egret = {}));
  14724. if (true) {
  14725. egret_stages = [];
  14726. }
  14727. //////////////////////////////////////////////////////////////////////////////////////
  14728. //
  14729. // Copyright (c) 2014-present, Egret Technology.
  14730. // All rights reserved.
  14731. // Redistribution and use in source and binary forms, with or without
  14732. // modification, are permitted provided that the following conditions are met:
  14733. //
  14734. // * Redistributions of source code must retain the above copyright
  14735. // notice, this list of conditions and the following disclaimer.
  14736. // * Redistributions in binary form must reproduce the above copyright
  14737. // notice, this list of conditions and the following disclaimer in the
  14738. // documentation and/or other materials provided with the distribution.
  14739. // * Neither the name of the Egret nor the
  14740. // names of its contributors may be used to endorse or promote products
  14741. // derived from this software without specific prior written permission.
  14742. //
  14743. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  14744. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  14745. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14746. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  14747. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  14748. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  14749. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  14750. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  14751. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  14752. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14753. //
  14754. //////////////////////////////////////////////////////////////////////////////////////
  14755. var egret;
  14756. (function (egret) {
  14757. var sys;
  14758. (function (sys) {
  14759. /**
  14760. * @private
  14761. * 用户交互操作管理器
  14762. */
  14763. var TouchHandler = (function (_super) {
  14764. __extends(TouchHandler, _super);
  14765. /**
  14766. * @private
  14767. */
  14768. function TouchHandler(stage) {
  14769. var _this = _super.call(this) || this;
  14770. _this.maxTouches = 0;
  14771. _this.useTouchesCount = 0;
  14772. /**
  14773. * @private
  14774. */
  14775. _this.touchDownTarget = {};
  14776. /**
  14777. * @private
  14778. */
  14779. _this.lastTouchX = -1;
  14780. /**
  14781. * @private
  14782. */
  14783. _this.lastTouchY = -1;
  14784. _this.stage = stage;
  14785. return _this;
  14786. }
  14787. /**
  14788. * @private
  14789. * 设置同时触摸数量
  14790. */
  14791. TouchHandler.prototype.$initMaxTouches = function () {
  14792. this.maxTouches = this.stage.$maxTouches;
  14793. };
  14794. /**
  14795. * @private
  14796. * 触摸开始(按下)
  14797. * @param x 事件发生处相对于舞台的坐标x
  14798. * @param y 事件发生处相对于舞台的坐标y
  14799. * @param touchPointID 分配给触摸点的唯一标识号
  14800. */
  14801. TouchHandler.prototype.onTouchBegin = function (x, y, touchPointID) {
  14802. if (this.useTouchesCount >= this.maxTouches) {
  14803. return;
  14804. }
  14805. this.lastTouchX = x;
  14806. this.lastTouchY = y;
  14807. var target = this.findTarget(x, y);
  14808. if (this.touchDownTarget[touchPointID] == null) {
  14809. this.touchDownTarget[touchPointID] = target;
  14810. this.useTouchesCount++;
  14811. }
  14812. egret.TouchEvent.dispatchTouchEvent(target, egret.TouchEvent.TOUCH_BEGIN, true, true, x, y, touchPointID, true);
  14813. };
  14814. /**
  14815. * @private
  14816. * 触摸移动
  14817. * @param x 事件发生处相对于舞台的坐标x
  14818. * @param y 事件发生处相对于舞台的坐标y
  14819. * @param touchPointID 分配给触摸点的唯一标识号
  14820. */
  14821. TouchHandler.prototype.onTouchMove = function (x, y, touchPointID) {
  14822. if (this.touchDownTarget[touchPointID] == null) {
  14823. return;
  14824. }
  14825. if (this.lastTouchX == x && this.lastTouchY == y) {
  14826. return;
  14827. }
  14828. this.lastTouchX = x;
  14829. this.lastTouchY = y;
  14830. var target = this.findTarget(x, y);
  14831. egret.TouchEvent.dispatchTouchEvent(target, egret.TouchEvent.TOUCH_MOVE, true, true, x, y, touchPointID, true);
  14832. };
  14833. /**
  14834. * @private
  14835. * 触摸结束(弹起)
  14836. * @param x 事件发生处相对于舞台的坐标x
  14837. * @param y 事件发生处相对于舞台的坐标y
  14838. * @param touchPointID 分配给触摸点的唯一标识号
  14839. */
  14840. TouchHandler.prototype.onTouchEnd = function (x, y, touchPointID) {
  14841. if (this.touchDownTarget[touchPointID] == null) {
  14842. return;
  14843. }
  14844. var target = this.findTarget(x, y);
  14845. var oldTarget = this.touchDownTarget[touchPointID];
  14846. delete this.touchDownTarget[touchPointID];
  14847. this.useTouchesCount--;
  14848. egret.TouchEvent.dispatchTouchEvent(target, egret.TouchEvent.TOUCH_END, true, true, x, y, touchPointID, false);
  14849. if (oldTarget == target) {
  14850. egret.TouchEvent.dispatchTouchEvent(target, egret.TouchEvent.TOUCH_TAP, true, true, x, y, touchPointID, false);
  14851. }
  14852. else {
  14853. egret.TouchEvent.dispatchTouchEvent(oldTarget, egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, true, true, x, y, touchPointID, false);
  14854. }
  14855. };
  14856. /**
  14857. * @private
  14858. * 获取舞台坐标下的触摸对象
  14859. */
  14860. TouchHandler.prototype.findTarget = function (stageX, stageY) {
  14861. var target = this.stage.$hitTest(stageX, stageY);
  14862. if (!target) {
  14863. target = this.stage;
  14864. }
  14865. return target;
  14866. };
  14867. return TouchHandler;
  14868. }(egret.HashObject));
  14869. sys.TouchHandler = TouchHandler;
  14870. __reflect(TouchHandler.prototype, "egret.sys.TouchHandler");
  14871. })(sys = egret.sys || (egret.sys = {}));
  14872. })(egret || (egret = {}));
  14873. //////////////////////////////////////////////////////////////////////////////////////
  14874. //
  14875. // Copyright (c) 2014-present, Egret Technology.
  14876. // All rights reserved.
  14877. // Redistribution and use in source and binary forms, with or without
  14878. // modification, are permitted provided that the following conditions are met:
  14879. //
  14880. // * Redistributions of source code must retain the above copyright
  14881. // notice, this list of conditions and the following disclaimer.
  14882. // * Redistributions in binary form must reproduce the above copyright
  14883. // notice, this list of conditions and the following disclaimer in the
  14884. // documentation and/or other materials provided with the distribution.
  14885. // * Neither the name of the Egret nor the
  14886. // names of its contributors may be used to endorse or promote products
  14887. // derived from this software without specific prior written permission.
  14888. //
  14889. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  14890. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  14891. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14892. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  14893. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  14894. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  14895. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  14896. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  14897. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  14898. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14899. //
  14900. //////////////////////////////////////////////////////////////////////////////////////
  14901. var egret;
  14902. (function (egret) {
  14903. var sys;
  14904. (function (sys) {
  14905. /**
  14906. * @private
  14907. * 位图渲染节点
  14908. */
  14909. var BitmapNode = (function (_super) {
  14910. __extends(BitmapNode, _super);
  14911. function BitmapNode() {
  14912. var _this = _super.call(this) || this;
  14913. /**
  14914. * 要绘制的位图
  14915. */
  14916. _this.image = null;
  14917. /**
  14918. * 控制在缩放时是否对位图进行平滑处理。
  14919. */
  14920. _this.smoothing = true;
  14921. /**
  14922. * 使用的混合模式
  14923. */
  14924. _this.blendMode = null;
  14925. /**
  14926. * 相对透明度
  14927. */
  14928. _this.alpha = NaN;
  14929. /**
  14930. * 相对透明度
  14931. */
  14932. _this.filter = null;
  14933. _this.type = 1 /* BitmapNode */;
  14934. return _this;
  14935. }
  14936. /**
  14937. * 绘制一次位图
  14938. */
  14939. BitmapNode.prototype.drawImage = function (sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH) {
  14940. this.drawData.push(sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH);
  14941. this.renderCount++;
  14942. };
  14943. /**
  14944. * 在显示对象的$render()方法被调用前,自动清空自身的drawData数据。
  14945. */
  14946. BitmapNode.prototype.cleanBeforeRender = function () {
  14947. _super.prototype.cleanBeforeRender.call(this);
  14948. this.image = null;
  14949. this.matrix = null;
  14950. this.blendMode = null;
  14951. this.alpha = NaN;
  14952. this.filter = null;
  14953. };
  14954. BitmapNode.$updateTextureData = function (node, image, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, destW, destH, sourceWidth, sourceHeight, scale9Grid, fillMode, smoothing) {
  14955. if (!image) {
  14956. return;
  14957. }
  14958. var scale = egret.$TextureScaleFactor;
  14959. node.smoothing = smoothing;
  14960. node.image = image;
  14961. node.imageWidth = sourceWidth;
  14962. node.imageHeight = sourceHeight;
  14963. if (scale9Grid) {
  14964. BitmapNode.$updateTextureDataWithScale9Grid(node, scale9Grid, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, destW, destH);
  14965. }
  14966. else if (fillMode == egret.BitmapFillMode.SCALE) {
  14967. var tsX = destW / textureWidth * scale;
  14968. var tsY = destH / textureHeight * scale;
  14969. node.drawImage(bitmapX, bitmapY, bitmapWidth, bitmapHeight, tsX * offsetX, tsY * offsetY, tsX * bitmapWidth, tsY * bitmapHeight);
  14970. }
  14971. else if (fillMode == egret.BitmapFillMode.CLIP) {
  14972. var displayW = Math.min(textureWidth, destW);
  14973. var displayH = Math.min(textureHeight, destH);
  14974. var scaledBitmapW = bitmapWidth * scale;
  14975. var scaledBitmapH = bitmapHeight * scale;
  14976. BitmapNode.drawClipImage(node, scale, bitmapX, bitmapY, scaledBitmapW, scaledBitmapH, offsetX, offsetY, displayW, displayH);
  14977. }
  14978. else {
  14979. var scaledBitmapW = bitmapWidth * scale;
  14980. var scaledBitmapH = bitmapHeight * scale;
  14981. for (var startX = 0; startX < destW; startX += textureWidth) {
  14982. for (var startY = 0; startY < destH; startY += textureHeight) {
  14983. var displayW = Math.min(destW - startX, textureWidth);
  14984. var displayH = Math.min(destH - startY, textureHeight);
  14985. BitmapNode.drawClipImage(node, scale, bitmapX, bitmapY, scaledBitmapW, scaledBitmapH, offsetX, offsetY, displayW, displayH, startX, startY);
  14986. }
  14987. }
  14988. }
  14989. };
  14990. /**
  14991. * @private
  14992. * 绘制九宫格位图
  14993. */
  14994. BitmapNode.$updateTextureDataWithScale9Grid = function (node, scale9Grid, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, destW, destH) {
  14995. var imageWidth = bitmapWidth;
  14996. var imageHeight = bitmapHeight;
  14997. destW = destW - (textureWidth - bitmapWidth * egret.$TextureScaleFactor);
  14998. destH = destH - (textureHeight - bitmapHeight * egret.$TextureScaleFactor);
  14999. var targetW0 = scale9Grid.x - offsetX;
  15000. var targetH0 = scale9Grid.y - offsetY;
  15001. var sourceW0 = targetW0 / egret.$TextureScaleFactor;
  15002. var sourceH0 = targetH0 / egret.$TextureScaleFactor;
  15003. var sourceW1 = scale9Grid.width / egret.$TextureScaleFactor;
  15004. var sourceH1 = scale9Grid.height / egret.$TextureScaleFactor;
  15005. //防止空心的情况出现。
  15006. if (sourceH1 == 0) {
  15007. sourceH1 = 1;
  15008. if (sourceH0 >= imageHeight) {
  15009. sourceH0--;
  15010. }
  15011. }
  15012. if (sourceW1 == 0) {
  15013. sourceW1 = 1;
  15014. if (sourceW0 >= imageWidth) {
  15015. sourceW0--;
  15016. }
  15017. }
  15018. var sourceX0 = bitmapX;
  15019. var sourceX1 = sourceX0 + sourceW0;
  15020. var sourceX2 = sourceX1 + sourceW1;
  15021. var sourceW2 = imageWidth - sourceW0 - sourceW1;
  15022. var sourceY0 = bitmapY;
  15023. var sourceY1 = sourceY0 + sourceH0;
  15024. var sourceY2 = sourceY1 + sourceH1;
  15025. var sourceH2 = imageHeight - sourceH0 - sourceH1;
  15026. var targetW2 = sourceW2 * egret.$TextureScaleFactor;
  15027. var targetH2 = sourceH2 * egret.$TextureScaleFactor;
  15028. if ((sourceW0 + sourceW2) * egret.$TextureScaleFactor > destW || (sourceH0 + sourceH2) * egret.$TextureScaleFactor > destH) {
  15029. node.drawImage(bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, destW, destH);
  15030. return;
  15031. }
  15032. var targetX0 = offsetX;
  15033. var targetX1 = targetX0 + targetW0;
  15034. var targetX2 = targetX0 + (destW - targetW2);
  15035. var targetW1 = destW - targetW0 - targetW2;
  15036. var targetY0 = offsetY;
  15037. var targetY1 = targetY0 + targetH0;
  15038. var targetY2 = targetY0 + destH - targetH2;
  15039. var targetH1 = destH - targetH0 - targetH2;
  15040. //
  15041. // x0 x1 x2
  15042. // y0 +------+------+------+
  15043. // | | | | h0
  15044. // | | | |
  15045. // y1 +------+------+------+
  15046. // | | | | h1
  15047. // | | | |
  15048. // y2 +------+------+------+
  15049. // | | | | h2
  15050. // | | | |
  15051. // +------+------+------+
  15052. // w0 w1 w2
  15053. //
  15054. if (sourceH0 > 0) {
  15055. if (sourceW0 > 0)
  15056. node.drawImage(sourceX0, sourceY0, sourceW0, sourceH0, targetX0, targetY0, targetW0, targetH0);
  15057. if (sourceW1 > 0)
  15058. node.drawImage(sourceX1, sourceY0, sourceW1, sourceH0, targetX1, targetY0, targetW1, targetH0);
  15059. if (sourceW2 > 0)
  15060. node.drawImage(sourceX2, sourceY0, sourceW2, sourceH0, targetX2, targetY0, targetW2, targetH0);
  15061. }
  15062. if (sourceH1 > 0) {
  15063. if (sourceW0 > 0)
  15064. node.drawImage(sourceX0, sourceY1, sourceW0, sourceH1, targetX0, targetY1, targetW0, targetH1);
  15065. if (sourceW1 > 0)
  15066. node.drawImage(sourceX1, sourceY1, sourceW1, sourceH1, targetX1, targetY1, targetW1, targetH1);
  15067. if (sourceW2 > 0)
  15068. node.drawImage(sourceX2, sourceY1, sourceW2, sourceH1, targetX2, targetY1, targetW2, targetH1);
  15069. }
  15070. if (sourceH2 > 0) {
  15071. if (sourceW0 > 0)
  15072. node.drawImage(sourceX0, sourceY2, sourceW0, sourceH2, targetX0, targetY2, targetW0, targetH2);
  15073. if (sourceW1 > 0)
  15074. node.drawImage(sourceX1, sourceY2, sourceW1, sourceH2, targetX1, targetY2, targetW1, targetH2);
  15075. if (sourceW2 > 0)
  15076. node.drawImage(sourceX2, sourceY2, sourceW2, sourceH2, targetX2, targetY2, targetW2, targetH2);
  15077. }
  15078. };
  15079. /**
  15080. * @private
  15081. */
  15082. BitmapNode.drawClipImage = function (node, scale, bitmapX, bitmapY, scaledBitmapW, scaledBitmapH, offsetX, offsetY, destW, destH, startX, startY) {
  15083. if (startX === void 0) { startX = 0; }
  15084. if (startY === void 0) { startY = 0; }
  15085. var offset = offsetX + scaledBitmapW - destW;
  15086. if (offset > 0) {
  15087. scaledBitmapW -= offset;
  15088. }
  15089. offset = offsetY + scaledBitmapH - destH;
  15090. if (offset > 0) {
  15091. scaledBitmapH -= offset;
  15092. }
  15093. node.drawImage(bitmapX, bitmapY, scaledBitmapW / scale, scaledBitmapH / scale, startX + offsetX, startY + offsetY, scaledBitmapW, scaledBitmapH);
  15094. };
  15095. return BitmapNode;
  15096. }(sys.RenderNode));
  15097. sys.BitmapNode = BitmapNode;
  15098. __reflect(BitmapNode.prototype, "egret.sys.BitmapNode");
  15099. })(sys = egret.sys || (egret.sys = {}));
  15100. })(egret || (egret = {}));
  15101. //////////////////////////////////////////////////////////////////////////////////////
  15102. //
  15103. // Copyright (c) 2014-present, Egret Technology.
  15104. // All rights reserved.
  15105. // Redistribution and use in source and binary forms, with or without
  15106. // modification, are permitted provided that the following conditions are met:
  15107. //
  15108. // * Redistributions of source code must retain the above copyright
  15109. // notice, this list of conditions and the following disclaimer.
  15110. // * Redistributions in binary form must reproduce the above copyright
  15111. // notice, this list of conditions and the following disclaimer in the
  15112. // documentation and/or other materials provided with the distribution.
  15113. // * Neither the name of the Egret nor the
  15114. // names of its contributors may be used to endorse or promote products
  15115. // derived from this software without specific prior written permission.
  15116. //
  15117. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  15118. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  15119. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15120. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  15121. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  15122. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  15123. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  15124. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  15125. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  15126. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15127. //
  15128. //////////////////////////////////////////////////////////////////////////////////////
  15129. var egret;
  15130. (function (egret) {
  15131. var sys;
  15132. (function (sys) {
  15133. var CAPS_STYLES = ["none", "round", "square"];
  15134. var JOINT_STYLES = ["bevel", "miter", "round"];
  15135. /**
  15136. * @private
  15137. * 矢量渲染节点
  15138. */
  15139. var GraphicsNode = (function (_super) {
  15140. __extends(GraphicsNode, _super);
  15141. function GraphicsNode() {
  15142. var _this = _super.call(this) || this;
  15143. /**
  15144. * 脏渲染标记
  15145. * 暂时调用lineStyle,beginFill,beginGradientFill标记,实际应该draw时候标记在Path2D
  15146. */
  15147. _this.dirtyRender = true;
  15148. _this.type = 3 /* GraphicsNode */;
  15149. return _this;
  15150. }
  15151. /**
  15152. * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。
  15153. * @param color 填充的颜色
  15154. * @param alpha 填充的 Alpha 值
  15155. * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。
  15156. */
  15157. GraphicsNode.prototype.beginFill = function (color, alpha, beforePath) {
  15158. if (alpha === void 0) { alpha = 1; }
  15159. var path = new sys.FillPath();
  15160. path.fillColor = color;
  15161. path.fillAlpha = alpha;
  15162. if (beforePath) {
  15163. var index = this.drawData.lastIndexOf(beforePath);
  15164. this.drawData.splice(index, 0, path);
  15165. }
  15166. else {
  15167. this.drawData.push(path);
  15168. }
  15169. return path;
  15170. };
  15171. /**
  15172. * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。
  15173. * 调用 clear() 方法会清除填充。
  15174. * @param type 用于指定要使用哪种渐变类型的 GradientType 类的值:GradientType.LINEAR 或 GradientType.RADIAL。
  15175. * @param colors 渐变中使用的 RGB 十六进制颜色值的数组(例如,红色为 0xFF0000,蓝色为 0x0000FF,等等)。对于每种颜色,请在 alphas 和 ratios 参数中指定对应值。
  15176. * @param alphas colors 数组中对应颜色的 alpha 值数组。
  15177. * @param ratios 颜色分布比率的数组。有效值为 0 到 255。
  15178. * @param matrix 一个由 egret.Matrix 类定义的转换矩阵。egret.Matrix 类包括 createGradientBox() 方法,通过该方法可以方便地设置矩阵,以便与 beginGradientFill() 方法一起使用
  15179. * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。
  15180. */
  15181. GraphicsNode.prototype.beginGradientFill = function (type, colors, alphas, ratios, matrix, beforePath) {
  15182. var m = new egret.Matrix();
  15183. if (matrix) {
  15184. m.a = matrix.a * 819.2;
  15185. m.b = matrix.b * 819.2;
  15186. m.c = matrix.c * 819.2;
  15187. m.d = matrix.d * 819.2;
  15188. m.tx = matrix.tx;
  15189. m.ty = matrix.ty;
  15190. }
  15191. else {
  15192. //默认值
  15193. m.a = 100;
  15194. m.d = 100;
  15195. }
  15196. var path = new sys.GradientFillPath();
  15197. path.gradientType = type;
  15198. path.colors = colors;
  15199. path.alphas = alphas;
  15200. path.ratios = ratios;
  15201. path.matrix = m;
  15202. if (beforePath) {
  15203. var index = this.drawData.lastIndexOf(beforePath);
  15204. this.drawData.splice(index, 0, path);
  15205. }
  15206. else {
  15207. this.drawData.push(path);
  15208. }
  15209. return path;
  15210. };
  15211. /**
  15212. * 指定一种线条样式以用于随后对 lineTo() 或 drawCircle() 等 Graphics 方法的调用。
  15213. * @param thickness 一个整数,以点为单位表示线条的粗细,有效值为 0 到 255。如果未指定数字,或者未定义该参数,则不绘制线条。如果传递的值小于 0,则默认值为 0。值 0 表示极细的粗细;最大粗细为 255。如果传递的值大于 255,则默认值为 255。
  15214. * @param color 线条的十六进制颜色值(例如,红色为 0xFF0000,蓝色为 0x0000FF 等)。如果未指明值,则默认值为 0x000000(黑色)。可选。
  15215. * @param alpha 表示线条颜色的 Alpha 值的数字;有效值为 0 到 1。如果未指明值,则默认值为 1(纯色)。如果值小于 0,则默认值为 0。如果值大于 1,则默认值为 1。
  15216. * @param caps 用于指定线条末端处端点类型的 CapsStyle 类的值。默认值:CapsStyle.ROUND
  15217. * @param joints 指定用于拐角的连接外观的类型。默认值:JointStyle.ROUND
  15218. * @param miterLimit 用于表示剪切斜接的极限值的数字。
  15219. */
  15220. GraphicsNode.prototype.lineStyle = function (thickness, color, alpha, caps, joints, miterLimit) {
  15221. if (alpha === void 0) { alpha = 1; }
  15222. if (miterLimit === void 0) { miterLimit = 3; }
  15223. if (CAPS_STYLES.indexOf(caps) == -1) {
  15224. caps = "round";
  15225. }
  15226. if (JOINT_STYLES.indexOf(joints) == -1) {
  15227. joints = "round";
  15228. }
  15229. var path = new sys.StrokePath();
  15230. path.lineWidth = thickness;
  15231. path.lineColor = color;
  15232. path.lineAlpha = alpha;
  15233. path.caps = caps || egret.CapsStyle.ROUND;
  15234. path.joints = joints;
  15235. path.miterLimit = miterLimit;
  15236. this.drawData.push(path);
  15237. return path;
  15238. };
  15239. /**
  15240. * 清空所有缓存的绘制数据
  15241. */
  15242. GraphicsNode.prototype.clear = function () {
  15243. this.drawData.length = 0;
  15244. this.dirtyRender = true;
  15245. };
  15246. /**
  15247. * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。
  15248. */
  15249. GraphicsNode.prototype.cleanBeforeRender = function () {
  15250. };
  15251. /**
  15252. * 清除非绘制的缓存数据
  15253. */
  15254. GraphicsNode.prototype.clean = function () {
  15255. if (this.$texture) {
  15256. egret.WebGLUtils.deleteWebGLTexture(this.$texture);
  15257. this.$texture = null;
  15258. this.dirtyRender = true;
  15259. }
  15260. };
  15261. return GraphicsNode;
  15262. }(sys.RenderNode));
  15263. sys.GraphicsNode = GraphicsNode;
  15264. __reflect(GraphicsNode.prototype, "egret.sys.GraphicsNode");
  15265. })(sys = egret.sys || (egret.sys = {}));
  15266. })(egret || (egret = {}));
  15267. //////////////////////////////////////////////////////////////////////////////////////
  15268. //
  15269. // Copyright (c) 2014-present, Egret Technology.
  15270. // All rights reserved.
  15271. // Redistribution and use in source and binary forms, with or without
  15272. // modification, are permitted provided that the following conditions are met:
  15273. //
  15274. // * Redistributions of source code must retain the above copyright
  15275. // notice, this list of conditions and the following disclaimer.
  15276. // * Redistributions in binary form must reproduce the above copyright
  15277. // notice, this list of conditions and the following disclaimer in the
  15278. // documentation and/or other materials provided with the distribution.
  15279. // * Neither the name of the Egret nor the
  15280. // names of its contributors may be used to endorse or promote products
  15281. // derived from this software without specific prior written permission.
  15282. //
  15283. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  15284. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  15285. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15286. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  15287. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  15288. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  15289. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  15290. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  15291. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  15292. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15293. //
  15294. //////////////////////////////////////////////////////////////////////////////////////
  15295. var egret;
  15296. (function (egret) {
  15297. var sys;
  15298. (function (sys) {
  15299. /**
  15300. * @private
  15301. * 组渲染节点,用于组合多个渲染节点
  15302. */
  15303. var GroupNode = (function (_super) {
  15304. __extends(GroupNode, _super);
  15305. function GroupNode() {
  15306. var _this = _super.call(this) || this;
  15307. _this.type = 4 /* GroupNode */;
  15308. return _this;
  15309. }
  15310. GroupNode.prototype.addNode = function (node) {
  15311. this.drawData.push(node);
  15312. };
  15313. /**
  15314. * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。
  15315. * 这里只是想清空绘制命令,因此不调用super
  15316. */
  15317. GroupNode.prototype.cleanBeforeRender = function () {
  15318. var data = this.drawData;
  15319. for (var i = data.length - 1; i >= 0; i--) {
  15320. data[i].cleanBeforeRender();
  15321. }
  15322. };
  15323. GroupNode.prototype.$getRenderCount = function () {
  15324. var result = 0;
  15325. var data = this.drawData;
  15326. for (var i = data.length - 1; i >= 0; i--) {
  15327. result += data[i].$getRenderCount();
  15328. }
  15329. return result;
  15330. };
  15331. return GroupNode;
  15332. }(sys.RenderNode));
  15333. sys.GroupNode = GroupNode;
  15334. __reflect(GroupNode.prototype, "egret.sys.GroupNode");
  15335. })(sys = egret.sys || (egret.sys = {}));
  15336. })(egret || (egret = {}));
  15337. //////////////////////////////////////////////////////////////////////////////////////
  15338. //
  15339. // Copyright (c) 2014-present, Egret Technology.
  15340. // All rights reserved.
  15341. // Redistribution and use in source and binary forms, with or without
  15342. // modification, are permitted provided that the following conditions are met:
  15343. //
  15344. // * Redistributions of source code must retain the above copyright
  15345. // notice, this list of conditions and the following disclaimer.
  15346. // * Redistributions in binary form must reproduce the above copyright
  15347. // notice, this list of conditions and the following disclaimer in the
  15348. // documentation and/or other materials provided with the distribution.
  15349. // * Neither the name of the Egret nor the
  15350. // names of its contributors may be used to endorse or promote products
  15351. // derived from this software without specific prior written permission.
  15352. //
  15353. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  15354. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  15355. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15356. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  15357. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  15358. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  15359. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  15360. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  15361. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  15362. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15363. //
  15364. //////////////////////////////////////////////////////////////////////////////////////
  15365. var egret;
  15366. (function (egret) {
  15367. var sys;
  15368. (function (sys) {
  15369. /**
  15370. * @private
  15371. * Mesh 渲染节点
  15372. */
  15373. var MeshNode = (function (_super) {
  15374. __extends(MeshNode, _super);
  15375. function MeshNode() {
  15376. var _this = _super.call(this) || this;
  15377. /**
  15378. * 要绘制的位图
  15379. */
  15380. _this.image = null;
  15381. /**
  15382. * 控制在缩放时是否对位图进行平滑处理。
  15383. */
  15384. _this.smoothing = true;
  15385. /**
  15386. * 顶点索引。
  15387. */
  15388. _this.bounds = new egret.Rectangle();
  15389. _this.type = 7 /* MeshNode */;
  15390. _this.vertices = [];
  15391. _this.uvs = [];
  15392. _this.indices = [];
  15393. return _this;
  15394. }
  15395. ;
  15396. /**
  15397. * 绘制一次位图
  15398. */
  15399. MeshNode.prototype.drawMesh = function (sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH) {
  15400. this.drawData.push(sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH);
  15401. this.renderCount++;
  15402. };
  15403. /**
  15404. * 在显示对象的$render()方法被调用前,自动清空自身的drawData数据。
  15405. */
  15406. MeshNode.prototype.cleanBeforeRender = function () {
  15407. _super.prototype.cleanBeforeRender.call(this);
  15408. this.image = null;
  15409. this.matrix = null;
  15410. };
  15411. return MeshNode;
  15412. }(sys.RenderNode));
  15413. sys.MeshNode = MeshNode;
  15414. __reflect(MeshNode.prototype, "egret.sys.MeshNode");
  15415. })(sys = egret.sys || (egret.sys = {}));
  15416. })(egret || (egret = {}));
  15417. //////////////////////////////////////////////////////////////////////////////////////
  15418. //
  15419. // Copyright (c) 2014-present, Egret Technology.
  15420. // All rights reserved.
  15421. // Redistribution and use in source and binary forms, with or without
  15422. // modification, are permitted provided that the following conditions are met:
  15423. //
  15424. // * Redistributions of source code must retain the above copyright
  15425. // notice, this list of conditions and the following disclaimer.
  15426. // * Redistributions in binary form must reproduce the above copyright
  15427. // notice, this list of conditions and the following disclaimer in the
  15428. // documentation and/or other materials provided with the distribution.
  15429. // * Neither the name of the Egret nor the
  15430. // names of its contributors may be used to endorse or promote products
  15431. // derived from this software without specific prior written permission.
  15432. //
  15433. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  15434. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  15435. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15436. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  15437. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  15438. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  15439. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  15440. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  15441. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  15442. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15443. //
  15444. //////////////////////////////////////////////////////////////////////////////////////
  15445. var egret;
  15446. (function (egret) {
  15447. /**
  15448. * @language en_US
  15449. * RenderTexture is a dynamic texture
  15450. * @extends egret.Texture
  15451. * @version Egret 2.4
  15452. * @platform Web,Native
  15453. * @includeExample egret/display/RenderTexture.ts
  15454. */
  15455. /**
  15456. * @language zh_CN
  15457. * RenderTexture 是动态纹理类,他实现了将显示对象及其子对象绘制成为一个纹理的功能
  15458. * @extends egret.Texture
  15459. * @version Egret 2.4
  15460. * @platform Web,Native
  15461. * @includeExample egret/display/RenderTexture.ts
  15462. */
  15463. var RenderTexture = (function (_super) {
  15464. __extends(RenderTexture, _super);
  15465. function RenderTexture() {
  15466. var _this = _super.call(this) || this;
  15467. _this.$renderBuffer = new egret.sys.RenderBuffer();
  15468. var bitmapData = new egret.BitmapData(_this.$renderBuffer.surface);
  15469. bitmapData.$deleteSource = false;
  15470. _this._setBitmapData(bitmapData);
  15471. return _this;
  15472. }
  15473. /**
  15474. * @language en_US
  15475. * The specified display object is drawn as a texture
  15476. * @param displayObject {egret.DisplayObject} the display to draw
  15477. * @param clipBounds {egret.Rectangle} clip rect
  15478. * @param scale {number} scale factor
  15479. * @version Egret 2.4
  15480. * @platform Web,Native
  15481. */
  15482. /**
  15483. * @language zh_CN
  15484. * 将指定显示对象绘制为一个纹理
  15485. * @param displayObject {egret.DisplayObject} 需要绘制的显示对象
  15486. * @param clipBounds {egret.Rectangle} 绘制矩形区域
  15487. * @param scale {number} 缩放比例
  15488. * @version Egret 2.4
  15489. * @platform Web,Native
  15490. */
  15491. RenderTexture.prototype.drawToTexture = function (displayObject, clipBounds, scale) {
  15492. if (scale === void 0) { scale = 1; }
  15493. if (clipBounds && (clipBounds.width == 0 || clipBounds.height == 0)) {
  15494. return false;
  15495. }
  15496. var bounds = clipBounds || displayObject.$getOriginalBounds();
  15497. if (bounds.width == 0 || bounds.height == 0) {
  15498. return false;
  15499. }
  15500. scale /= egret.$TextureScaleFactor;
  15501. var width = (bounds.x + bounds.width) * scale;
  15502. var height = (bounds.y + bounds.height) * scale;
  15503. if (clipBounds) {
  15504. width = bounds.width * scale;
  15505. height = bounds.height * scale;
  15506. }
  15507. var renderBuffer = this.$renderBuffer;
  15508. if (!renderBuffer) {
  15509. return false;
  15510. }
  15511. renderBuffer.resize(width, height);
  15512. this._bitmapData.width = width;
  15513. this._bitmapData.height = height;
  15514. var matrix = egret.Matrix.create();
  15515. matrix.identity();
  15516. //应用裁切
  15517. if (clipBounds) {
  15518. matrix.translate(-clipBounds.x, -clipBounds.y);
  15519. }
  15520. matrix.scale(scale, scale);
  15521. egret.sys.systemRenderer.render(displayObject, renderBuffer, matrix, null, true);
  15522. egret.Matrix.release(matrix);
  15523. //设置纹理参数
  15524. this.$initData(0, 0, width, height, 0, 0, width, height, width, height);
  15525. return true;
  15526. };
  15527. /**
  15528. * @inheritDoc
  15529. */
  15530. RenderTexture.prototype.getPixel32 = function (x, y) {
  15531. var data;
  15532. if (this.$renderBuffer) {
  15533. var scale = egret.$TextureScaleFactor;
  15534. x = Math.round(x / scale);
  15535. y = Math.round(y / scale);
  15536. data = this.$renderBuffer.getPixels(x, y, 1, 1);
  15537. }
  15538. return data;
  15539. };
  15540. /**
  15541. * @inheritDoc
  15542. */
  15543. RenderTexture.prototype.dispose = function () {
  15544. _super.prototype.dispose.call(this);
  15545. this.$renderBuffer = null;
  15546. };
  15547. return RenderTexture;
  15548. }(egret.Texture));
  15549. egret.RenderTexture = RenderTexture;
  15550. __reflect(RenderTexture.prototype, "egret.RenderTexture");
  15551. })(egret || (egret = {}));
  15552. //////////////////////////////////////////////////////////////////////////////////////
  15553. //
  15554. // Copyright (c) 2014-present, Egret Technology.
  15555. // All rights reserved.
  15556. // Redistribution and use in source and binary forms, with or without
  15557. // modification, are permitted provided that the following conditions are met:
  15558. //
  15559. // * Redistributions of source code must retain the above copyright
  15560. // notice, this list of conditions and the following disclaimer.
  15561. // * Redistributions in binary form must reproduce the above copyright
  15562. // notice, this list of conditions and the following disclaimer in the
  15563. // documentation and/or other materials provided with the distribution.
  15564. // * Neither the name of the Egret nor the
  15565. // names of its contributors may be used to endorse or promote products
  15566. // derived from this software without specific prior written permission.
  15567. //
  15568. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  15569. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  15570. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15571. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  15572. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  15573. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  15574. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  15575. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  15576. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  15577. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15578. //
  15579. //////////////////////////////////////////////////////////////////////////////////////
  15580. var egret;
  15581. (function (egret) {
  15582. var sys;
  15583. (function (sys) {
  15584. /**
  15585. * @private
  15586. * 位图渲染节点
  15587. */
  15588. var SetAlphaNode = (function (_super) {
  15589. __extends(SetAlphaNode, _super);
  15590. function SetAlphaNode() {
  15591. var _this = _super.call(this) || this;
  15592. _this.type = 6 /* SetAlphaNode */;
  15593. return _this;
  15594. }
  15595. /**
  15596. * 绘制一次位图
  15597. */
  15598. SetAlphaNode.prototype.setAlpha = function (alpha) {
  15599. if (this.drawData.length != 0) {
  15600. this.drawData.length = 0;
  15601. }
  15602. this.drawData.push(alpha);
  15603. this.renderCount++;
  15604. };
  15605. return SetAlphaNode;
  15606. }(sys.RenderNode));
  15607. sys.SetAlphaNode = SetAlphaNode;
  15608. __reflect(SetAlphaNode.prototype, "egret.sys.SetAlphaNode");
  15609. })(sys = egret.sys || (egret.sys = {}));
  15610. })(egret || (egret = {}));
  15611. //////////////////////////////////////////////////////////////////////////////////////
  15612. //
  15613. // Copyright (c) 2014-present, Egret Technology.
  15614. // All rights reserved.
  15615. // Redistribution and use in source and binary forms, with or without
  15616. // modification, are permitted provided that the following conditions are met:
  15617. //
  15618. // * Redistributions of source code must retain the above copyright
  15619. // notice, this list of conditions and the following disclaimer.
  15620. // * Redistributions in binary form must reproduce the above copyright
  15621. // notice, this list of conditions and the following disclaimer in the
  15622. // documentation and/or other materials provided with the distribution.
  15623. // * Neither the name of the Egret nor the
  15624. // names of its contributors may be used to endorse or promote products
  15625. // derived from this software without specific prior written permission.
  15626. //
  15627. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  15628. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  15629. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15630. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  15631. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  15632. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  15633. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  15634. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  15635. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  15636. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15637. //
  15638. //////////////////////////////////////////////////////////////////////////////////////
  15639. //////////////////////////////////////////////////////////////////////////////////////
  15640. //
  15641. // Copyright (c) 2014-present, Egret Technology.
  15642. // All rights reserved.
  15643. // Redistribution and use in source and binary forms, with or without
  15644. // modification, are permitted provided that the following conditions are met:
  15645. //
  15646. // * Redistributions of source code must retain the above copyright
  15647. // notice, this list of conditions and the following disclaimer.
  15648. // * Redistributions in binary form must reproduce the above copyright
  15649. // notice, this list of conditions and the following disclaimer in the
  15650. // documentation and/or other materials provided with the distribution.
  15651. // * Neither the name of the Egret nor the
  15652. // names of its contributors may be used to endorse or promote products
  15653. // derived from this software without specific prior written permission.
  15654. //
  15655. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  15656. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  15657. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15658. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  15659. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  15660. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  15661. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  15662. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  15663. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  15664. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15665. //
  15666. //////////////////////////////////////////////////////////////////////////////////////
  15667. var egret;
  15668. (function (egret) {
  15669. var sys;
  15670. (function (sys) {
  15671. /**
  15672. * @private
  15673. * 文本渲染节点
  15674. */
  15675. var TextNode = (function (_super) {
  15676. __extends(TextNode, _super);
  15677. function TextNode() {
  15678. var _this = _super.call(this) || this;
  15679. /**
  15680. * 颜色值
  15681. */
  15682. _this.textColor = 0xFFFFFF;
  15683. /**
  15684. * 描边颜色值
  15685. */
  15686. _this.strokeColor = 0x000000;
  15687. /**
  15688. * 字号
  15689. */
  15690. _this.size = 30;
  15691. /**
  15692. * 描边大小
  15693. */
  15694. _this.stroke = 0;
  15695. /**
  15696. * 是否加粗
  15697. */
  15698. _this.bold = false;
  15699. /**
  15700. * 是否倾斜
  15701. */
  15702. _this.italic = false;
  15703. /**
  15704. * 字体名称
  15705. */
  15706. _this.fontFamily = "Arial";
  15707. /**
  15708. * 脏渲染标记
  15709. */
  15710. _this.dirtyRender = true;
  15711. _this.type = 2 /* TextNode */;
  15712. return _this;
  15713. }
  15714. /**
  15715. * 绘制一行文本
  15716. */
  15717. TextNode.prototype.drawText = function (x, y, text, format) {
  15718. this.drawData.push(x, y, text, format);
  15719. this.renderCount++;
  15720. this.dirtyRender = true;
  15721. };
  15722. /**
  15723. * 在显示对象的$render()方法被调用前,自动清空自身的drawData数据。
  15724. */
  15725. TextNode.prototype.cleanBeforeRender = function () {
  15726. _super.prototype.cleanBeforeRender.call(this);
  15727. };
  15728. /**
  15729. * 清除非绘制的缓存数据
  15730. */
  15731. TextNode.prototype.clean = function () {
  15732. if (this.$texture) {
  15733. egret.WebGLUtils.deleteWebGLTexture(this.$texture);
  15734. this.$texture = null;
  15735. this.dirtyRender = true;
  15736. }
  15737. };
  15738. return TextNode;
  15739. }(sys.RenderNode));
  15740. sys.TextNode = TextNode;
  15741. __reflect(TextNode.prototype, "egret.sys.TextNode");
  15742. })(sys = egret.sys || (egret.sys = {}));
  15743. })(egret || (egret = {}));
  15744. //////////////////////////////////////////////////////////////////////////////////////
  15745. //
  15746. // Copyright (c) 2014-present, Egret Technology.
  15747. // All rights reserved.
  15748. // Redistribution and use in source and binary forms, with or without
  15749. // modification, are permitted provided that the following conditions are met:
  15750. //
  15751. // * Redistributions of source code must retain the above copyright
  15752. // notice, this list of conditions and the following disclaimer.
  15753. // * Redistributions in binary form must reproduce the above copyright
  15754. // notice, this list of conditions and the following disclaimer in the
  15755. // documentation and/or other materials provided with the distribution.
  15756. // * Neither the name of the Egret nor the
  15757. // names of its contributors may be used to endorse or promote products
  15758. // derived from this software without specific prior written permission.
  15759. //
  15760. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  15761. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  15762. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15763. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  15764. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  15765. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  15766. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  15767. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  15768. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  15769. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15770. //
  15771. //////////////////////////////////////////////////////////////////////////////////////
  15772. var egret;
  15773. (function (egret) {
  15774. var sys;
  15775. (function (sys) {
  15776. /**
  15777. * @private
  15778. * 填充路径
  15779. */
  15780. var FillPath = (function (_super) {
  15781. __extends(FillPath, _super);
  15782. function FillPath() {
  15783. var _this = _super.call(this) || this;
  15784. _this.type = 1 /* Fill */;
  15785. return _this;
  15786. }
  15787. return FillPath;
  15788. }(sys.Path2D));
  15789. sys.FillPath = FillPath;
  15790. __reflect(FillPath.prototype, "egret.sys.FillPath");
  15791. })(sys = egret.sys || (egret.sys = {}));
  15792. })(egret || (egret = {}));
  15793. //////////////////////////////////////////////////////////////////////////////////////
  15794. //
  15795. // Copyright (c) 2014-present, Egret Technology.
  15796. // All rights reserved.
  15797. // Redistribution and use in source and binary forms, with or without
  15798. // modification, are permitted provided that the following conditions are met:
  15799. //
  15800. // * Redistributions of source code must retain the above copyright
  15801. // notice, this list of conditions and the following disclaimer.
  15802. // * Redistributions in binary form must reproduce the above copyright
  15803. // notice, this list of conditions and the following disclaimer in the
  15804. // documentation and/or other materials provided with the distribution.
  15805. // * Neither the name of the Egret nor the
  15806. // names of its contributors may be used to endorse or promote products
  15807. // derived from this software without specific prior written permission.
  15808. //
  15809. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  15810. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  15811. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15812. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  15813. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  15814. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  15815. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  15816. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  15817. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  15818. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15819. //
  15820. //////////////////////////////////////////////////////////////////////////////////////
  15821. var egret;
  15822. (function (egret) {
  15823. var sys;
  15824. (function (sys) {
  15825. /**
  15826. * @private
  15827. * 渐变填充路径
  15828. */
  15829. var GradientFillPath = (function (_super) {
  15830. __extends(GradientFillPath, _super);
  15831. function GradientFillPath() {
  15832. var _this = _super.call(this) || this;
  15833. _this.type = 2 /* GradientFill */;
  15834. return _this;
  15835. }
  15836. return GradientFillPath;
  15837. }(sys.Path2D));
  15838. sys.GradientFillPath = GradientFillPath;
  15839. __reflect(GradientFillPath.prototype, "egret.sys.GradientFillPath");
  15840. })(sys = egret.sys || (egret.sys = {}));
  15841. })(egret || (egret = {}));
  15842. //////////////////////////////////////////////////////////////////////////////////////
  15843. //
  15844. // Copyright (c) 2014-present, Egret Technology.
  15845. // All rights reserved.
  15846. // Redistribution and use in source and binary forms, with or without
  15847. // modification, are permitted provided that the following conditions are met:
  15848. //
  15849. // * Redistributions of source code must retain the above copyright
  15850. // notice, this list of conditions and the following disclaimer.
  15851. // * Redistributions in binary form must reproduce the above copyright
  15852. // notice, this list of conditions and the following disclaimer in the
  15853. // documentation and/or other materials provided with the distribution.
  15854. // * Neither the name of the Egret nor the
  15855. // names of its contributors may be used to endorse or promote products
  15856. // derived from this software without specific prior written permission.
  15857. //
  15858. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  15859. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  15860. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15861. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  15862. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  15863. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  15864. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  15865. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  15866. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  15867. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15868. //
  15869. //////////////////////////////////////////////////////////////////////////////////////
  15870. var egret;
  15871. (function (egret) {
  15872. /**
  15873. * @language en_US
  15874. * This class is used to create lightweight shapes using the drawing application program interface (API). The Shape
  15875. * class includes a graphics property, which lets you access methods from the Graphics class.
  15876. * @see egret.Graphics
  15877. * @version Egret 2.4
  15878. * @platform Web,Native
  15879. * @includeExample egret/display/Shape.ts
  15880. */
  15881. /**
  15882. * @language zh_CN
  15883. * 此类用于使用绘图应用程序编程接口 (API) 创建简单形状。Shape 类含有 graphics 属性,通过该属性您可以访问各种矢量绘图方法。
  15884. * @see egret.Graphics
  15885. * @version Egret 2.4
  15886. * @platform Web,Native
  15887. * @includeExample egret/display/Shape.ts
  15888. */
  15889. var Shape = (function (_super) {
  15890. __extends(Shape, _super);
  15891. /**
  15892. * @language en_US
  15893. * Creates a new Shape object.
  15894. * @version Egret 2.4
  15895. * @platform Web,Native
  15896. */
  15897. /**
  15898. * @language zh_CN
  15899. * 创建一个 Shape 对象
  15900. * @version Egret 2.4
  15901. * @platform Web,Native
  15902. */
  15903. function Shape() {
  15904. var _this = _super.call(this) || this;
  15905. _this.$graphics = new egret.Graphics();
  15906. _this.$graphics.$setTarget(_this);
  15907. return _this;
  15908. }
  15909. Object.defineProperty(Shape.prototype, "graphics", {
  15910. /**
  15911. * @language en_US
  15912. * Specifies the Graphics object belonging to this Shape object, where vector drawing commands can occur.
  15913. * @version Egret 2.4
  15914. * @platform Web,Native
  15915. */
  15916. /**
  15917. * @language zh_CN
  15918. * 获取 Shape 中的 Graphics 对象。可通过此对象执行矢量绘图命令。
  15919. * @version Egret 2.4
  15920. * @platform Web,Native
  15921. */
  15922. get: function () {
  15923. return this.$graphics;
  15924. },
  15925. enumerable: true,
  15926. configurable: true
  15927. });
  15928. /**
  15929. * @private
  15930. */
  15931. Shape.prototype.$measureContentBounds = function (bounds) {
  15932. this.$graphics.$measureContentBounds(bounds);
  15933. };
  15934. Shape.prototype.$hitTest = function (stageX, stageY) {
  15935. var target = _super.prototype.$hitTest.call(this, stageX, stageY);
  15936. if (target == this) {
  15937. target = this.$graphics.$hitTest(stageX, stageY);
  15938. }
  15939. return target;
  15940. };
  15941. /**
  15942. * @private
  15943. */
  15944. Shape.prototype.$onRemoveFromStage = function () {
  15945. _super.prototype.$onRemoveFromStage.call(this);
  15946. if (this.$graphics) {
  15947. this.$graphics.$onRemoveFromStage();
  15948. }
  15949. };
  15950. return Shape;
  15951. }(egret.DisplayObject));
  15952. egret.Shape = Shape;
  15953. __reflect(Shape.prototype, "egret.Shape");
  15954. if (true) {
  15955. egret.$markReadOnly(Shape, "graphics");
  15956. }
  15957. })(egret || (egret = {}));
  15958. //////////////////////////////////////////////////////////////////////////////////////
  15959. //
  15960. // Copyright (c) 2014-present, Egret Technology.
  15961. // All rights reserved.
  15962. // Redistribution and use in source and binary forms, with or without
  15963. // modification, are permitted provided that the following conditions are met:
  15964. //
  15965. // * Redistributions of source code must retain the above copyright
  15966. // notice, this list of conditions and the following disclaimer.
  15967. // * Redistributions in binary form must reproduce the above copyright
  15968. // notice, this list of conditions and the following disclaimer in the
  15969. // documentation and/or other materials provided with the distribution.
  15970. // * Neither the name of the Egret nor the
  15971. // names of its contributors may be used to endorse or promote products
  15972. // derived from this software without specific prior written permission.
  15973. //
  15974. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  15975. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  15976. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15977. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  15978. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  15979. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  15980. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  15981. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  15982. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  15983. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15984. //
  15985. //////////////////////////////////////////////////////////////////////////////////////
  15986. var egret;
  15987. (function (egret) {
  15988. var sys;
  15989. (function (sys) {
  15990. /**
  15991. * @private
  15992. * 线条路径。
  15993. * 注意:当线条宽度(lineWidth)为1或3像素时,需要特殊处理,往右下角偏移0.5像素,以显示清晰锐利的线条。
  15994. */
  15995. var StrokePath = (function (_super) {
  15996. __extends(StrokePath, _super);
  15997. function StrokePath() {
  15998. var _this = _super.call(this) || this;
  15999. _this.type = 3 /* Stroke */;
  16000. return _this;
  16001. }
  16002. return StrokePath;
  16003. }(sys.Path2D));
  16004. sys.StrokePath = StrokePath;
  16005. __reflect(StrokePath.prototype, "egret.sys.StrokePath");
  16006. })(sys = egret.sys || (egret.sys = {}));
  16007. })(egret || (egret = {}));
  16008. //////////////////////////////////////////////////////////////////////////////////////
  16009. //
  16010. // Copyright (c) 2014-present, Egret Technology.
  16011. // All rights reserved.
  16012. // Redistribution and use in source and binary forms, with or without
  16013. // modification, are permitted provided that the following conditions are met:
  16014. //
  16015. // * Redistributions of source code must retain the above copyright
  16016. // notice, this list of conditions and the following disclaimer.
  16017. // * Redistributions in binary form must reproduce the above copyright
  16018. // notice, this list of conditions and the following disclaimer in the
  16019. // documentation and/or other materials provided with the distribution.
  16020. // * Neither the name of the Egret nor the
  16021. // names of its contributors may be used to endorse or promote products
  16022. // derived from this software without specific prior written permission.
  16023. //
  16024. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  16025. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  16026. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  16027. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  16028. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  16029. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  16030. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  16031. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  16032. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  16033. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16034. //
  16035. //////////////////////////////////////////////////////////////////////////////////////
  16036. var egret;
  16037. (function (egret) {
  16038. var blendModes = ["source-over", "lighter", "destination-out"];
  16039. var defaultCompositeOp = "source-over";
  16040. var BLACK_COLOR = "#000000";
  16041. var CAPS_STYLES = { none: 'butt', square: 'square', round: 'round' };
  16042. var renderBufferPool = []; //渲染缓冲区对象池
  16043. /**
  16044. * @private
  16045. * Canvas渲染器
  16046. */
  16047. var CanvasRenderer = (function () {
  16048. function CanvasRenderer() {
  16049. this.nestLevel = 0; //渲染的嵌套层次,0表示在调用堆栈的最外层。
  16050. this.renderingMask = false;
  16051. }
  16052. /**
  16053. * 渲染一个显示对象
  16054. * @param displayObject 要渲染的显示对象
  16055. * @param buffer 渲染缓冲
  16056. * @param matrix 要对显示对象整体叠加的变换矩阵
  16057. * @param dirtyList 脏矩形列表
  16058. * @param forRenderTexture 绘制目标是RenderTexture的标志
  16059. * @returns drawCall触发绘制的次数
  16060. */
  16061. CanvasRenderer.prototype.render = function (displayObject, buffer, matrix, dirtyList, forRenderTexture) {
  16062. this.nestLevel++;
  16063. var context = buffer.context;
  16064. var root = forRenderTexture ? displayObject : null;
  16065. //绘制显示对象
  16066. var drawCall = this.drawDisplayObject(displayObject, context, dirtyList, matrix, null, null, root);
  16067. this.nestLevel--;
  16068. if (this.nestLevel === 0) {
  16069. //最大缓存6个渲染缓冲
  16070. if (renderBufferPool.length > 6) {
  16071. renderBufferPool.length = 6;
  16072. }
  16073. var length_8 = renderBufferPool.length;
  16074. for (var i = 0; i < length_8; i++) {
  16075. renderBufferPool[i].resize(0, 0);
  16076. }
  16077. }
  16078. return drawCall;
  16079. };
  16080. /**
  16081. * @private
  16082. * 绘制一个显示对象
  16083. */
  16084. CanvasRenderer.prototype.drawDisplayObject = function (displayObject, context, dirtyList, matrix, displayList, clipRegion, root) {
  16085. var drawCalls = 0;
  16086. var node;
  16087. if (displayList && !root) {
  16088. if (displayList.isDirty) {
  16089. drawCalls += displayList.drawToSurface();
  16090. }
  16091. node = displayList.$renderNode;
  16092. }
  16093. else {
  16094. node = displayObject.$getRenderNode();
  16095. }
  16096. if (node) {
  16097. if (dirtyList) {
  16098. var renderRegion = node.renderRegion;
  16099. if (clipRegion && !clipRegion.intersects(renderRegion)) {
  16100. node.needRedraw = false;
  16101. }
  16102. else if (!node.needRedraw) {
  16103. var l = dirtyList.length;
  16104. for (var j = 0; j < l; j++) {
  16105. if (renderRegion.intersects(dirtyList[j])) {
  16106. node.needRedraw = true;
  16107. break;
  16108. }
  16109. }
  16110. }
  16111. }
  16112. else {
  16113. node.needRedraw = true;
  16114. }
  16115. if (node.needRedraw) {
  16116. var renderAlpha = void 0;
  16117. var m = void 0;
  16118. if (root) {
  16119. renderAlpha = displayObject.$getConcatenatedAlphaAt(root, displayObject.$getConcatenatedAlpha());
  16120. m = egret.Matrix.create().copyFrom(displayObject.$getConcatenatedMatrix());
  16121. displayObject.$getConcatenatedMatrixAt(root, m);
  16122. matrix.$preMultiplyInto(m, m);
  16123. context.setTransform(m.a, m.b, m.c, m.d, m.tx, m.ty);
  16124. egret.Matrix.release(m);
  16125. }
  16126. else {
  16127. renderAlpha = node.renderAlpha;
  16128. m = node.renderMatrix;
  16129. context.setTransform(m.a, m.b, m.c, m.d, m.tx + matrix.tx, m.ty + matrix.ty);
  16130. }
  16131. context.globalAlpha = renderAlpha;
  16132. drawCalls += this.renderNode(node, context);
  16133. node.needRedraw = false;
  16134. }
  16135. }
  16136. if (displayList && !root) {
  16137. return drawCalls;
  16138. }
  16139. var children = displayObject.$children;
  16140. if (children) {
  16141. var length_9 = children.length;
  16142. for (var i = 0; i < length_9; i++) {
  16143. var child = children[i];
  16144. if (!child.$visible || child.$alpha <= 0 || child.$maskedObject) {
  16145. continue;
  16146. }
  16147. var filters = child.$getFilters();
  16148. if (filters && filters.length > 0) {
  16149. drawCalls += this.drawWithFilter(child, context, dirtyList, matrix, clipRegion, root);
  16150. }
  16151. else if ((child.$blendMode !== 0 ||
  16152. (child.$mask && (child.$mask.$parentDisplayList || root)))) {
  16153. drawCalls += this.drawWithClip(child, context, dirtyList, matrix, clipRegion, root);
  16154. }
  16155. else if (child.$scrollRect || child.$maskRect) {
  16156. drawCalls += this.drawWithScrollRect(child, context, dirtyList, matrix, clipRegion, root);
  16157. }
  16158. else {
  16159. if (child["isFPS"]) {
  16160. this.drawDisplayObject(child, context, dirtyList, matrix, child.$displayList, clipRegion, root);
  16161. }
  16162. else {
  16163. drawCalls += this.drawDisplayObject(child, context, dirtyList, matrix, child.$displayList, clipRegion, root);
  16164. }
  16165. }
  16166. }
  16167. }
  16168. return drawCalls;
  16169. };
  16170. /**
  16171. * @private
  16172. */
  16173. CanvasRenderer.prototype.drawWithFilter = function (displayObject, context, dirtyList, matrix, clipRegion, root) {
  16174. if (egret.Capabilities.runtimeType == egret.RuntimeType.NATIVE) {
  16175. var drawCalls_1 = 0;
  16176. var filters_1 = displayObject.$getFilters();
  16177. var hasBlendMode_1 = (displayObject.$blendMode !== 0);
  16178. var compositeOp_1;
  16179. if (hasBlendMode_1) {
  16180. compositeOp_1 = blendModes[displayObject.$blendMode];
  16181. if (!compositeOp_1) {
  16182. compositeOp_1 = defaultCompositeOp;
  16183. }
  16184. }
  16185. if (filters_1.length == 1 && filters_1[0].type == "colorTransform" && !displayObject.$children) {
  16186. if (hasBlendMode_1) {
  16187. context.globalCompositeOperation = compositeOp_1;
  16188. }
  16189. context.setGlobalShader(filters_1[0]);
  16190. if (displayObject.$mask && (displayObject.$mask.$parentDisplayList || root)) {
  16191. drawCalls_1 += this.drawWithClip(displayObject, context, dirtyList, matrix, clipRegion, root);
  16192. }
  16193. else if (displayObject.$scrollRect || displayObject.$maskRect) {
  16194. drawCalls_1 += this.drawWithScrollRect(displayObject, context, dirtyList, matrix, clipRegion, root);
  16195. }
  16196. else {
  16197. drawCalls_1 += this.drawDisplayObject(displayObject, context, dirtyList, matrix, displayObject.$displayList, clipRegion, root);
  16198. }
  16199. context.setGlobalShader(null);
  16200. if (hasBlendMode_1) {
  16201. context.globalCompositeOperation = defaultCompositeOp;
  16202. }
  16203. return drawCalls_1;
  16204. }
  16205. // 获取显示对象的链接矩阵
  16206. var displayMatrix_1 = egret.Matrix.create();
  16207. displayMatrix_1.copyFrom(displayObject.$getConcatenatedMatrix());
  16208. if (root) {
  16209. displayObject.$getConcatenatedMatrixAt(root, displayMatrix_1);
  16210. }
  16211. // 获取显示对象的矩形区域
  16212. var region_1;
  16213. region_1 = egret.sys.Region.create();
  16214. var bounds_1 = displayObject.$getOriginalBounds();
  16215. region_1.updateRegion(bounds_1, displayMatrix_1);
  16216. // 为显示对象创建一个新的buffer
  16217. // todo 这里应该计算 region.x region.y
  16218. var displayBuffer_1 = this.createRenderBuffer(region_1.width, region_1.height);
  16219. displayBuffer_1.context.setTransform(1, 0, 0, 1, -region_1.minX, -region_1.minY);
  16220. var offsetM_1 = egret.Matrix.create().setTo(1, 0, 0, 1, -region_1.minX, -region_1.minY);
  16221. if (displayObject.$mask && (displayObject.$mask.$parentDisplayList || root)) {
  16222. drawCalls_1 += this.drawWithClip(displayObject, displayBuffer_1.context, dirtyList, offsetM_1, region_1, root);
  16223. }
  16224. else if (displayObject.$scrollRect || displayObject.$maskRect) {
  16225. drawCalls_1 += this.drawWithScrollRect(displayObject, displayBuffer_1.context, dirtyList, offsetM_1, region_1, root);
  16226. }
  16227. else {
  16228. drawCalls_1 += this.drawDisplayObject(displayObject, displayBuffer_1.context, dirtyList, offsetM_1, displayObject.$displayList, region_1, root);
  16229. }
  16230. egret.Matrix.release(offsetM_1);
  16231. //绘制结果到屏幕
  16232. if (drawCalls_1 > 0) {
  16233. if (hasBlendMode_1) {
  16234. context.globalCompositeOperation = compositeOp_1;
  16235. }
  16236. drawCalls_1++;
  16237. context.globalAlpha = 1;
  16238. context.setTransform(1, 0, 0, 1, region_1.minX + matrix.tx, region_1.minY + matrix.ty);
  16239. // 绘制结果的时候,应用滤镜
  16240. context.setGlobalShader(filters_1[0]);
  16241. context.drawImage(displayBuffer_1.surface, 0, 0, displayBuffer_1.width, displayBuffer_1.height, 0, 0, displayBuffer_1.width, displayBuffer_1.height);
  16242. context.setGlobalShader(null);
  16243. if (hasBlendMode_1) {
  16244. context.globalCompositeOperation = defaultCompositeOp;
  16245. }
  16246. }
  16247. renderBufferPool.push(displayBuffer_1);
  16248. egret.sys.Region.release(region_1);
  16249. egret.Matrix.release(displayMatrix_1);
  16250. return drawCalls_1;
  16251. }
  16252. var drawCalls = 0;
  16253. var filters = displayObject.$getFilters();
  16254. var filtersLen = filters.length;
  16255. var hasBlendMode = (displayObject.$blendMode !== 0);
  16256. var compositeOp;
  16257. if (hasBlendMode) {
  16258. compositeOp = blendModes[displayObject.$blendMode];
  16259. if (!compositeOp) {
  16260. compositeOp = defaultCompositeOp;
  16261. }
  16262. }
  16263. // 获取显示对象的链接矩阵
  16264. var displayMatrix = egret.Matrix.create();
  16265. displayMatrix.copyFrom(displayObject.$getConcatenatedMatrix());
  16266. if (root) {
  16267. displayObject.$getConcatenatedMatrixAt(root, displayMatrix);
  16268. }
  16269. // 获取显示对象的矩形区域
  16270. var region;
  16271. region = egret.sys.Region.create();
  16272. var bounds = displayObject.$getOriginalBounds();
  16273. region.updateRegion(bounds, displayMatrix);
  16274. // 为显示对象创建一个新的buffer
  16275. // todo 这里应该计算 region.x region.y
  16276. var displayBuffer = this.createRenderBuffer(region.width, region.height);
  16277. var displayContext = displayBuffer.context;
  16278. displayContext.setTransform(1, 0, 0, 1, -region.minX, -region.minY);
  16279. var offsetM = egret.Matrix.create().setTo(1, 0, 0, 1, -region.minX, -region.minY);
  16280. //todo 可以优化减少draw次数
  16281. if (displayObject.$mask && (displayObject.$mask.$parentDisplayList || root)) {
  16282. drawCalls += this.drawWithClip(displayObject, displayContext, dirtyList, offsetM, region, root);
  16283. }
  16284. else if (displayObject.$scrollRect || displayObject.$maskRect) {
  16285. drawCalls += this.drawWithScrollRect(displayObject, displayContext, dirtyList, offsetM, region, root);
  16286. }
  16287. else {
  16288. drawCalls += this.drawDisplayObject(displayObject, displayContext, dirtyList, offsetM, displayObject.$displayList, region, root);
  16289. }
  16290. egret.Matrix.release(offsetM);
  16291. //绘制结果到屏幕
  16292. if (drawCalls > 0) {
  16293. if (hasBlendMode) {
  16294. context.globalCompositeOperation = compositeOp;
  16295. }
  16296. drawCalls++;
  16297. context.globalAlpha = 1;
  16298. context.setTransform(1, 0, 0, 1, region.minX + matrix.tx, region.minY + matrix.ty);
  16299. // 应用滤镜
  16300. var imageData = displayContext.getImageData(0, 0, displayBuffer.surface.width, displayBuffer.surface.height);
  16301. for (var i = 0; i < filtersLen; i++) {
  16302. var filter = filters[i];
  16303. if (filter.type == "colorTransform") {
  16304. colorFilter(imageData.data, displayBuffer.surface.width, displayBuffer.surface.height, filter.$matrix);
  16305. }
  16306. else if (filter.type == "blur") {
  16307. blurFilter(imageData.data, displayBuffer.surface.width, displayBuffer.surface.height, filter.$blurX, filter.$blurY);
  16308. }
  16309. else if (filter.type == "glow") {
  16310. var r = filter.$red;
  16311. var g = filter.$green;
  16312. var b = filter.$blue;
  16313. var a = filter.$alpha;
  16314. if (filter.$inner || filter.$knockout || filter.$hideObject) {
  16315. dropShadowFilter2(imageData.data, displayBuffer.surface.width, displayBuffer.surface.height, [r / 255, g / 255, b / 255, a], filter.$blurX, filter.$blurY, filter.$angle ? (filter.$angle / 180 * Math.PI) : 0, filter.$distance || 0, filter.$strength, filter.$inner ? 1 : 0, filter.$knockout ? 0 : 1, filter.$hideObject ? 1 : 0);
  16316. }
  16317. else {
  16318. // 如果没有高级效果,使用性能比较高的方式
  16319. dropShadowFilter(imageData.data, displayBuffer.surface.width, displayBuffer.surface.height, [r / 255, g / 255, b / 255, a / 255], filter.$blurX, filter.$blurY, filter.$angle ? (filter.$angle / 180 * Math.PI) : 0, filter.$distance || 0, filter.$strength);
  16320. }
  16321. }
  16322. }
  16323. displayContext.putImageData(imageData, 0, 0);
  16324. // 绘制结果的时候,应用滤镜
  16325. context.drawImage(displayBuffer.surface, 0, 0);
  16326. if (hasBlendMode) {
  16327. context.globalCompositeOperation = defaultCompositeOp;
  16328. }
  16329. }
  16330. renderBufferPool.push(displayBuffer);
  16331. egret.sys.Region.release(region);
  16332. egret.Matrix.release(displayMatrix);
  16333. return drawCalls;
  16334. };
  16335. /**
  16336. * @private
  16337. */
  16338. CanvasRenderer.prototype.drawWithClip = function (displayObject, context, dirtyList, matrix, clipRegion, root) {
  16339. var drawCalls = 0;
  16340. var hasBlendMode = (displayObject.$blendMode !== 0);
  16341. var compositeOp;
  16342. if (hasBlendMode) {
  16343. compositeOp = blendModes[displayObject.$blendMode];
  16344. if (!compositeOp) {
  16345. compositeOp = defaultCompositeOp;
  16346. }
  16347. }
  16348. var scrollRect = displayObject.$scrollRect ? displayObject.$scrollRect : displayObject.$maskRect;
  16349. var mask = displayObject.$mask;
  16350. var maskRenderNode;
  16351. if (mask) {
  16352. maskRenderNode = mask.$getRenderNode();
  16353. if (maskRenderNode) {
  16354. var maskRenderMatrix = maskRenderNode.renderMatrix;
  16355. //遮罩scaleX或scaleY为0,放弃绘制
  16356. if ((maskRenderMatrix.a == 0 && maskRenderMatrix.b == 0) || (maskRenderMatrix.c == 0 && maskRenderMatrix.d == 0)) {
  16357. return drawCalls;
  16358. }
  16359. }
  16360. }
  16361. //if (mask && !mask.$parentDisplayList) {
  16362. // mask = null; //如果遮罩不在显示列表中,放弃绘制遮罩。
  16363. //}
  16364. //计算scrollRect和mask的clip区域是否需要绘制,不需要就直接返回,跳过所有子项的遍历。
  16365. var maskRegion;
  16366. var displayMatrix = egret.Matrix.create();
  16367. displayMatrix.copyFrom(displayObject.$getConcatenatedMatrix());
  16368. if (displayObject.$parentDisplayList) {
  16369. var displayRoot = displayObject.$parentDisplayList.root;
  16370. if (displayRoot !== displayObject.$stage) {
  16371. displayObject.$getConcatenatedMatrixAt(displayRoot, displayMatrix);
  16372. }
  16373. }
  16374. var bounds;
  16375. if (mask) {
  16376. bounds = mask.$getOriginalBounds();
  16377. maskRegion = egret.sys.Region.create();
  16378. var m = egret.Matrix.create();
  16379. m.copyFrom(mask.$getConcatenatedMatrix());
  16380. maskRegion.updateRegion(bounds, m);
  16381. egret.Matrix.release(m);
  16382. }
  16383. var region;
  16384. if (scrollRect) {
  16385. region = egret.sys.Region.create();
  16386. region.updateRegion(scrollRect, displayMatrix);
  16387. }
  16388. if (region && maskRegion) {
  16389. region.intersect(maskRegion);
  16390. egret.sys.Region.release(maskRegion);
  16391. }
  16392. else if (!region && maskRegion) {
  16393. region = maskRegion;
  16394. }
  16395. if (region) {
  16396. if (region.isEmpty() || (clipRegion && !clipRegion.intersects(region))) {
  16397. egret.sys.Region.release(region);
  16398. egret.Matrix.release(displayMatrix);
  16399. return drawCalls;
  16400. }
  16401. }
  16402. else {
  16403. region = egret.sys.Region.create();
  16404. bounds = displayObject.$getOriginalBounds();
  16405. region.updateRegion(bounds, displayMatrix);
  16406. }
  16407. var found = false;
  16408. if (!dirtyList) {
  16409. found = true;
  16410. }
  16411. else {
  16412. var l = dirtyList.length;
  16413. for (var j = 0; j < l; j++) {
  16414. if (region.intersects(dirtyList[j])) {
  16415. found = true;
  16416. break;
  16417. }
  16418. }
  16419. }
  16420. if (!found) {
  16421. egret.sys.Region.release(region);
  16422. egret.Matrix.release(displayMatrix);
  16423. return drawCalls;
  16424. }
  16425. //没有遮罩,同时显示对象没有子项
  16426. if (!mask && (!displayObject.$children || displayObject.$children.length == 0)) {
  16427. if (scrollRect) {
  16428. var m = displayMatrix;
  16429. context.save();
  16430. context.setTransform(m.a, m.b, m.c, m.d, m.tx - region.minX, m.ty - region.minY);
  16431. context.beginPath();
  16432. context.rect(scrollRect.x, scrollRect.y, scrollRect.width, scrollRect.height);
  16433. context.clip();
  16434. }
  16435. if (hasBlendMode) {
  16436. context.globalCompositeOperation = compositeOp;
  16437. }
  16438. drawCalls += this.drawDisplayObject(displayObject, context, dirtyList, matrix, displayObject.$displayList, clipRegion, root);
  16439. if (hasBlendMode) {
  16440. context.globalCompositeOperation = defaultCompositeOp;
  16441. }
  16442. if (scrollRect) {
  16443. context.restore();
  16444. }
  16445. return drawCalls;
  16446. }
  16447. //遮罩是单纯的填充图形,且alpha为1,性能优化
  16448. //todo 平台差异
  16449. if (mask && egret.Capabilities.$runtimeType == egret.RuntimeType.WEB && (!mask.$children || mask.$children.length == 0) &&
  16450. maskRenderNode && maskRenderNode.type == 3 /* GraphicsNode */ &&
  16451. maskRenderNode.drawData.length == 1 &&
  16452. maskRenderNode.drawData[0].type == 1 /* Fill */ &&
  16453. maskRenderNode.drawData[0].fillAlpha == 1) {
  16454. this.renderingMask = true;
  16455. context.save();
  16456. var calls = this.drawDisplayObject(mask, context, dirtyList, matrix, mask.$displayList, clipRegion, root);
  16457. this.renderingMask = false;
  16458. if (scrollRect) {
  16459. var m = displayMatrix;
  16460. context.setTransform(m.a, m.b, m.c, m.d, m.tx - region.minX, m.ty - region.minY);
  16461. context.beginPath();
  16462. context.rect(scrollRect.x, scrollRect.y, scrollRect.width, scrollRect.height);
  16463. context.clip();
  16464. }
  16465. calls += this.drawDisplayObject(displayObject, context, dirtyList, matrix, displayObject.$displayList, clipRegion, root);
  16466. context.restore();
  16467. return calls;
  16468. }
  16469. //todo 若显示对象是容器,同时子项有混合模式,则需要先绘制背景到displayBuffer并清除背景区域
  16470. //绘制显示对象自身,若有scrollRect,应用clip
  16471. var displayBuffer = this.createRenderBuffer(region.width, region.height);
  16472. var displayContext = displayBuffer.context;
  16473. if (!displayContext) {
  16474. drawCalls += this.drawDisplayObject(displayObject, context, dirtyList, matrix, displayObject.$displayList, clipRegion, root);
  16475. egret.sys.Region.release(region);
  16476. egret.Matrix.release(displayMatrix);
  16477. return drawCalls;
  16478. }
  16479. displayContext.setTransform(1, 0, 0, 1, -region.minX, -region.minY);
  16480. var offsetM = egret.Matrix.create().setTo(1, 0, 0, 1, -region.minX, -region.minY);
  16481. drawCalls += this.drawDisplayObject(displayObject, displayContext, dirtyList, offsetM, displayObject.$displayList, region, root);
  16482. //绘制遮罩
  16483. if (mask) {
  16484. //如果只有一次绘制或是已经被cache直接绘制到displayContext
  16485. if (egret.Capabilities.$runtimeType == egret.RuntimeType.WEB && maskRenderNode && maskRenderNode.$getRenderCount() == 1 || mask.$displayList) {
  16486. displayContext.globalCompositeOperation = "destination-in";
  16487. drawCalls += this.drawDisplayObject(mask, displayContext, dirtyList, offsetM, mask.$displayList, region, root);
  16488. }
  16489. else {
  16490. var maskBuffer = this.createRenderBuffer(region.width, region.height);
  16491. var maskContext = maskBuffer.context;
  16492. if (!maskContext) {
  16493. drawCalls += this.drawDisplayObject(displayObject, context, dirtyList, matrix, displayObject.$displayList, clipRegion, root);
  16494. renderBufferPool.push(displayBuffer);
  16495. egret.sys.Region.release(region);
  16496. egret.Matrix.release(displayMatrix);
  16497. return drawCalls;
  16498. }
  16499. maskContext.setTransform(1, 0, 0, 1, -region.minX, -region.minY);
  16500. offsetM = egret.Matrix.create().setTo(1, 0, 0, 1, -region.minX, -region.minY);
  16501. drawCalls += this.drawDisplayObject(mask, maskContext, dirtyList, offsetM, mask.$displayList, region, root);
  16502. displayContext.globalCompositeOperation = "destination-in";
  16503. displayContext.setTransform(1, 0, 0, 1, 0, 0);
  16504. displayContext.globalAlpha = 1;
  16505. displayContext.drawImage(maskBuffer.surface, 0, 0);
  16506. renderBufferPool.push(maskBuffer);
  16507. }
  16508. }
  16509. egret.Matrix.release(offsetM);
  16510. //绘制结果到屏幕
  16511. if (drawCalls > 0) {
  16512. drawCalls++;
  16513. if (hasBlendMode) {
  16514. context.globalCompositeOperation = compositeOp;
  16515. }
  16516. if (scrollRect) {
  16517. var m = displayMatrix;
  16518. context.save();
  16519. context.setTransform(m.a, m.b, m.c, m.d, m.tx - region.minX, m.ty - region.minY);
  16520. context.beginPath();
  16521. context.rect(scrollRect.x, scrollRect.y, scrollRect.width, scrollRect.height);
  16522. context.clip();
  16523. }
  16524. context.globalAlpha = 1;
  16525. context.setTransform(1, 0, 0, 1, region.minX + matrix.tx, region.minY + matrix.ty);
  16526. context.drawImage(displayBuffer.surface, 0, 0);
  16527. if (scrollRect) {
  16528. context.restore();
  16529. }
  16530. if (hasBlendMode) {
  16531. context.globalCompositeOperation = defaultCompositeOp;
  16532. }
  16533. }
  16534. renderBufferPool.push(displayBuffer);
  16535. egret.sys.Region.release(region);
  16536. egret.Matrix.release(displayMatrix);
  16537. return drawCalls;
  16538. };
  16539. /**
  16540. * @private
  16541. */
  16542. CanvasRenderer.prototype.drawWithScrollRect = function (displayObject, context, dirtyList, matrix, clipRegion, root) {
  16543. var drawCalls = 0;
  16544. var scrollRect = displayObject.$scrollRect ? displayObject.$scrollRect : displayObject.$maskRect;
  16545. if (scrollRect.isEmpty()) {
  16546. return drawCalls;
  16547. }
  16548. var m = egret.Matrix.create();
  16549. m.copyFrom(displayObject.$getConcatenatedMatrix());
  16550. if (root) {
  16551. displayObject.$getConcatenatedMatrixAt(root, m);
  16552. }
  16553. else if (displayObject.$parentDisplayList) {
  16554. var displayRoot = displayObject.$parentDisplayList.root;
  16555. if (displayRoot !== displayObject.$stage) {
  16556. displayObject.$getConcatenatedMatrixAt(displayRoot, m);
  16557. }
  16558. }
  16559. var region = egret.sys.Region.create();
  16560. region.updateRegion(scrollRect, m);
  16561. if (region.isEmpty() || (clipRegion && !clipRegion.intersects(region))) {
  16562. egret.sys.Region.release(region);
  16563. egret.Matrix.release(m);
  16564. return drawCalls;
  16565. }
  16566. var found = false;
  16567. if (!dirtyList) {
  16568. found = true;
  16569. }
  16570. else {
  16571. var l = dirtyList.length;
  16572. for (var j = 0; j < l; j++) {
  16573. if (region.intersects(dirtyList[j])) {
  16574. found = true;
  16575. break;
  16576. }
  16577. }
  16578. }
  16579. if (!found) {
  16580. egret.sys.Region.release(region);
  16581. egret.Matrix.release(m);
  16582. return drawCalls;
  16583. }
  16584. //绘制显示对象自身
  16585. context.save();
  16586. context.setTransform(m.a, m.b, m.c, m.d, m.tx + matrix.tx, m.ty + matrix.ty);
  16587. context.beginPath();
  16588. context.rect(scrollRect.x, scrollRect.y, scrollRect.width, scrollRect.height);
  16589. context.clip();
  16590. drawCalls += this.drawDisplayObject(displayObject, context, dirtyList, matrix, displayObject.$displayList, region, root);
  16591. context.restore();
  16592. egret.sys.Region.release(region);
  16593. egret.Matrix.release(m);
  16594. return drawCalls;
  16595. };
  16596. /**
  16597. * 将一个RenderNode对象绘制到渲染缓冲
  16598. * @param node 要绘制的节点
  16599. * @param buffer 渲染缓冲
  16600. * @param matrix 要叠加的矩阵
  16601. * @param forHitTest 绘制结果是用于碰撞检测。若为true,当渲染GraphicsNode时,会忽略透明度样式设置,全都绘制为不透明的。
  16602. */
  16603. CanvasRenderer.prototype.drawNodeToBuffer = function (node, buffer, matrix, forHitTest) {
  16604. var context = buffer.context;
  16605. context.setTransform(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);
  16606. this.renderNode(node, context, forHitTest);
  16607. };
  16608. /**
  16609. * @private
  16610. */
  16611. CanvasRenderer.prototype.renderNode = function (node, context, forHitTest) {
  16612. var drawCalls = 0;
  16613. switch (node.type) {
  16614. case 1 /* BitmapNode */:
  16615. drawCalls = this.renderBitmap(node, context);
  16616. break;
  16617. case 2 /* TextNode */:
  16618. drawCalls = 1;
  16619. this.renderText(node, context);
  16620. break;
  16621. case 3 /* GraphicsNode */:
  16622. drawCalls = this.renderGraphics(node, context, forHitTest);
  16623. break;
  16624. case 4 /* GroupNode */:
  16625. drawCalls = this.renderGroup(node, context);
  16626. break;
  16627. case 6 /* SetAlphaNode */:
  16628. context.globalAlpha = node.drawData[0];
  16629. break;
  16630. case 7 /* MeshNode */:
  16631. drawCalls = this.renderMesh(node, context);
  16632. break;
  16633. }
  16634. return drawCalls;
  16635. };
  16636. /**
  16637. * render mesh
  16638. */
  16639. CanvasRenderer.prototype.renderMesh = function (node, context) {
  16640. if (egret.Capabilities.runtimeType != egret.RuntimeType.NATIVE) {
  16641. return 0;
  16642. }
  16643. var image = node.image;
  16644. var data = node.drawData;
  16645. var length = data.length;
  16646. var pos = 0;
  16647. var m = node.matrix;
  16648. if (m) {
  16649. context.saveTransform();
  16650. context.transform(m.a, m.b, m.c, m.d, m.tx, m.ty);
  16651. }
  16652. while (pos < length) {
  16653. context.drawMesh(image.source, data[pos++], data[pos++], data[pos++], data[pos++], data[pos++], data[pos++], data[pos++], data[pos++], node.imageWidth, node.imageHeight, node.uvs, node.vertices, node.indices, node.bounds);
  16654. }
  16655. if (m) {
  16656. context.restoreTransform();
  16657. }
  16658. // TODO 应该计算合理的drawCall?
  16659. return 1;
  16660. };
  16661. /**
  16662. * @private
  16663. */
  16664. CanvasRenderer.prototype.renderBitmap = function (node, context) {
  16665. var image = node.image;
  16666. if (!image || !image.source) {
  16667. return 0;
  16668. }
  16669. if (context.$imageSmoothingEnabled != node.smoothing) {
  16670. context.imageSmoothingEnabled = node.smoothing;
  16671. context.$imageSmoothingEnabled = node.smoothing;
  16672. }
  16673. var data = node.drawData;
  16674. var length = data.length;
  16675. var pos = 0;
  16676. var m = node.matrix;
  16677. var blendMode = node.blendMode;
  16678. var alpha = node.alpha;
  16679. var saved = false;
  16680. if (m) {
  16681. if (context.saveTransform) {
  16682. context.saveTransform();
  16683. }
  16684. else {
  16685. context.save();
  16686. }
  16687. saved = true;
  16688. context.transform(m.a, m.b, m.c, m.d, m.tx, m.ty);
  16689. }
  16690. //这里不考虑嵌套
  16691. if (blendMode) {
  16692. context.globalCompositeOperation = blendModes[blendMode];
  16693. }
  16694. var originAlpha;
  16695. if (alpha == alpha) {
  16696. originAlpha = context.globalAlpha;
  16697. context.globalAlpha *= alpha;
  16698. }
  16699. var drawCalls = 0;
  16700. var filter = node.filter;
  16701. //todo 暂时只考虑绘制一次的情况
  16702. if (filter && length == 8) {
  16703. if (egret.Capabilities.runtimeType == egret.RuntimeType.NATIVE) {
  16704. egret_native.Graphics.setGlobalShader(filter);
  16705. while (pos < length) {
  16706. drawCalls++;
  16707. context.drawImage(image.source, data[pos++], data[pos++], data[pos++], data[pos++], data[pos++], data[pos++], data[pos++], data[pos++]);
  16708. }
  16709. egret_native.Graphics.setGlobalShader(null);
  16710. }
  16711. else {
  16712. var displayBuffer = this.createRenderBuffer(data[6], data[7]);
  16713. var displayContext = displayBuffer.context;
  16714. drawCalls++;
  16715. displayContext.drawImage(image.source, data[0], data[1], data[2], data[3], 0, 0, data[6], data[7]);
  16716. //绘制结果到屏幕
  16717. drawCalls++;
  16718. // 应用滤镜
  16719. var imageData = displayContext.getImageData(0, 0, displayBuffer.surface.width, displayBuffer.surface.height);
  16720. colorFilter(imageData.data, displayBuffer.surface.width, displayBuffer.surface.height, filter.$matrix);
  16721. displayContext.putImageData(imageData, 0, 0);
  16722. // 绘制结果的时候,应用滤镜
  16723. context.drawImage(displayBuffer.surface, 0, 0, data[6], data[7], data[4], data[5], data[6], data[7]);
  16724. renderBufferPool.push(displayBuffer);
  16725. }
  16726. }
  16727. else {
  16728. while (pos < length) {
  16729. drawCalls++;
  16730. context.drawImage(image.source, data[pos++], data[pos++], data[pos++], data[pos++], data[pos++], data[pos++], data[pos++], data[pos++]);
  16731. }
  16732. }
  16733. if (saved) {
  16734. if (context.restoreTransform) {
  16735. context.restoreTransform();
  16736. if (blendMode) {
  16737. context.globalCompositeOperation = defaultCompositeOp;
  16738. }
  16739. if (alpha == alpha) {
  16740. context.globalAlpha = originAlpha;
  16741. }
  16742. }
  16743. else {
  16744. context.restore();
  16745. }
  16746. }
  16747. else {
  16748. if (blendMode) {
  16749. context.globalCompositeOperation = defaultCompositeOp;
  16750. }
  16751. if (alpha == alpha) {
  16752. context.globalAlpha = originAlpha;
  16753. }
  16754. }
  16755. return drawCalls;
  16756. };
  16757. /**
  16758. * @private
  16759. */
  16760. CanvasRenderer.prototype.renderText = function (node, context) {
  16761. context.textAlign = "left";
  16762. context.textBaseline = "middle";
  16763. context.lineJoin = "round"; //确保描边样式是圆角
  16764. var drawData = node.drawData;
  16765. var length = drawData.length;
  16766. var pos = 0;
  16767. while (pos < length) {
  16768. var x = drawData[pos++];
  16769. var y = drawData[pos++];
  16770. var text = drawData[pos++];
  16771. var format = drawData[pos++];
  16772. context.font = getFontString(node, format);
  16773. var textColor = format.textColor == null ? node.textColor : format.textColor;
  16774. var strokeColor = format.strokeColor == null ? node.strokeColor : format.strokeColor;
  16775. var stroke = format.stroke == null ? node.stroke : format.stroke;
  16776. context.fillStyle = egret.toColorString(textColor);
  16777. context.strokeStyle = egret.toColorString(strokeColor);
  16778. if (stroke) {
  16779. context.lineWidth = stroke * 2;
  16780. context.strokeText(text, x, y);
  16781. }
  16782. context.fillText(text, x, y);
  16783. }
  16784. };
  16785. /**
  16786. * @private
  16787. */
  16788. CanvasRenderer.prototype.renderGraphics = function (node, context, forHitTest) {
  16789. var drawData = node.drawData;
  16790. var length = drawData.length;
  16791. forHitTest = !!forHitTest;
  16792. for (var i = 0; i < length; i++) {
  16793. var path = drawData[i];
  16794. switch (path.type) {
  16795. case 1 /* Fill */:
  16796. var fillPath = path;
  16797. context.fillStyle = forHitTest ? BLACK_COLOR : getRGBAString(fillPath.fillColor, fillPath.fillAlpha);
  16798. this.renderPath(path, context);
  16799. if (this.renderingMask) {
  16800. context.clip();
  16801. }
  16802. else {
  16803. context.fill();
  16804. }
  16805. break;
  16806. case 2 /* GradientFill */:
  16807. var g = path;
  16808. context.fillStyle = forHitTest ? BLACK_COLOR : getGradient(context, g.gradientType, g.colors, g.alphas, g.ratios, g.matrix);
  16809. context.save();
  16810. var m = g.matrix;
  16811. this.renderPath(path, context);
  16812. context.transform(m.a, m.b, m.c, m.d, m.tx, m.ty);
  16813. context.fill();
  16814. context.restore();
  16815. break;
  16816. case 3 /* Stroke */:
  16817. var strokeFill = path;
  16818. var lineWidth = strokeFill.lineWidth;
  16819. context.lineWidth = lineWidth;
  16820. context.strokeStyle = forHitTest ? BLACK_COLOR : getRGBAString(strokeFill.lineColor, strokeFill.lineAlpha);
  16821. context.lineCap = CAPS_STYLES[strokeFill.caps];
  16822. context.lineJoin = strokeFill.joints;
  16823. context.miterLimit = strokeFill.miterLimit;
  16824. //对1像素和3像素特殊处理,向右下角偏移0.5像素,以显示清晰锐利的线条。
  16825. var isSpecialCaseWidth = lineWidth === 1 || lineWidth === 3;
  16826. if (isSpecialCaseWidth) {
  16827. context.translate(0.5, 0.5);
  16828. }
  16829. this.renderPath(path, context);
  16830. context.stroke();
  16831. if (isSpecialCaseWidth) {
  16832. context.translate(-0.5, -0.5);
  16833. }
  16834. break;
  16835. }
  16836. }
  16837. return length == 0 ? 0 : 1;
  16838. };
  16839. CanvasRenderer.prototype.renderPath = function (path, context) {
  16840. context.beginPath();
  16841. var data = path.$data;
  16842. var commands = path.$commands;
  16843. var commandCount = commands.length;
  16844. var pos = 0;
  16845. for (var commandIndex = 0; commandIndex < commandCount; commandIndex++) {
  16846. var command = commands[commandIndex];
  16847. switch (command) {
  16848. case 4 /* CubicCurveTo */:
  16849. context.bezierCurveTo(data[pos++], data[pos++], data[pos++], data[pos++], data[pos++], data[pos++]);
  16850. break;
  16851. case 3 /* CurveTo */:
  16852. context.quadraticCurveTo(data[pos++], data[pos++], data[pos++], data[pos++]);
  16853. break;
  16854. case 2 /* LineTo */:
  16855. context.lineTo(data[pos++], data[pos++]);
  16856. break;
  16857. case 1 /* MoveTo */:
  16858. context.moveTo(data[pos++], data[pos++]);
  16859. break;
  16860. }
  16861. }
  16862. };
  16863. CanvasRenderer.prototype.renderGroup = function (groupNode, context) {
  16864. var drawCalls = 0;
  16865. var children = groupNode.drawData;
  16866. var length = children.length;
  16867. for (var i = 0; i < length; i++) {
  16868. var node = children[i];
  16869. drawCalls += this.renderNode(node, context);
  16870. }
  16871. return drawCalls;
  16872. };
  16873. /**
  16874. * @private
  16875. */
  16876. CanvasRenderer.prototype.createRenderBuffer = function (width, height) {
  16877. var buffer = renderBufferPool.pop();
  16878. if (buffer) {
  16879. buffer.resize(width, height, true);
  16880. }
  16881. else {
  16882. buffer = new egret.sys.CanvasRenderBuffer(width, height);
  16883. }
  16884. return buffer;
  16885. };
  16886. return CanvasRenderer;
  16887. }());
  16888. egret.CanvasRenderer = CanvasRenderer;
  16889. __reflect(CanvasRenderer.prototype, "egret.CanvasRenderer", ["egret.sys.SystemRenderer"]);
  16890. /**
  16891. * @private
  16892. * 获取字体字符串
  16893. */
  16894. function getFontString(node, format) {
  16895. var italic = format.italic == null ? node.italic : format.italic;
  16896. var bold = format.bold == null ? node.bold : format.bold;
  16897. var size = format.size == null ? node.size : format.size;
  16898. var fontFamily = format.fontFamily || node.fontFamily;
  16899. var font = italic ? "italic " : "normal ";
  16900. font += bold ? "bold " : "normal ";
  16901. font += size + "px " + fontFamily;
  16902. return font;
  16903. }
  16904. /**
  16905. * @private
  16906. * 获取RGBA字符串
  16907. */
  16908. function getRGBAString(color, alpha) {
  16909. var red = color >> 16;
  16910. var green = (color >> 8) & 0xFF;
  16911. var blue = color & 0xFF;
  16912. return "rgba(" + red + "," + green + "," + blue + "," + alpha + ")";
  16913. }
  16914. /**
  16915. * @private
  16916. * 获取渐变填充样式对象
  16917. */
  16918. function getGradient(context, type, colors, alphas, ratios, matrix) {
  16919. var gradient;
  16920. if (type == egret.GradientType.LINEAR) {
  16921. gradient = context.createLinearGradient(-1, 0, 1, 0);
  16922. }
  16923. else {
  16924. gradient = context.createRadialGradient(0, 0, 0, 0, 0, 1);
  16925. }
  16926. //todo colors alphas ratios数量不一致情况处理
  16927. var l = colors.length;
  16928. for (var i = 0; i < l; i++) {
  16929. gradient.addColorStop(ratios[i] / 255, getRGBAString(colors[i], alphas[i]));
  16930. }
  16931. return gradient;
  16932. }
  16933. // 判断浏览器是否支持 Uint8ClampedArray
  16934. var use8Clamp = false;
  16935. try {
  16936. use8Clamp = (typeof Uint8ClampedArray !== undefined);
  16937. }
  16938. catch (e) { }
  16939. function setArray(a, b, index) {
  16940. if (index === void 0) { index = 0; }
  16941. for (var i = 0, l = b.length; i < l; i++) {
  16942. a[i + index] = b[i];
  16943. }
  16944. }
  16945. /**
  16946. * @private
  16947. */
  16948. function colorFilter(buffer, w, h, matrix) {
  16949. var r0 = matrix[0], r1 = matrix[1], r2 = matrix[2], r3 = matrix[3], r4 = matrix[4];
  16950. var g0 = matrix[5], g1 = matrix[6], g2 = matrix[7], g3 = matrix[8], g4 = matrix[9];
  16951. var b0 = matrix[10], b1 = matrix[11], b2 = matrix[12], b3 = matrix[13], b4 = matrix[14];
  16952. var a0 = matrix[15], a1 = matrix[16], a2 = matrix[17], a3 = matrix[18], a4 = matrix[19];
  16953. for (var p = 0, e = w * h * 4; p < e; p += 4) {
  16954. var r = buffer[p + 0];
  16955. var g = buffer[p + 1];
  16956. var b = buffer[p + 2];
  16957. var a = buffer[p + 3];
  16958. buffer[p + 0] = r0 * r + r1 * g + r2 * b + r3 * a + r4;
  16959. buffer[p + 1] = g0 * r + g1 * g + g2 * b + g3 * a + g4;
  16960. buffer[p + 2] = b0 * r + b1 * g + b2 * b + b3 * a + b4;
  16961. buffer[p + 3] = a0 * r + a1 * g + a2 * b + a3 * a + a4;
  16962. }
  16963. }
  16964. /**
  16965. * @private
  16966. */
  16967. function blurFilter(buffer, w, h, blurX, blurY) {
  16968. blurFilterH(buffer, w, h, blurX);
  16969. blurFilterV(buffer, w, h, blurY);
  16970. }
  16971. /**
  16972. * @private
  16973. */
  16974. function blurFilterH(buffer, w, h, blurX) {
  16975. var lineBuffer;
  16976. if (use8Clamp) {
  16977. lineBuffer = new Uint8ClampedArray(w * 4);
  16978. }
  16979. else {
  16980. lineBuffer = new Array(w * 4);
  16981. }
  16982. var lineSize = w * 4;
  16983. var windowLength = (blurX * 2) + 1;
  16984. var windowSize = windowLength * 4;
  16985. for (var y = 0; y < h; y++) {
  16986. var pLineStart = y * lineSize;
  16987. var rs = 0, gs = 0, bs = 0, _as = 0, alpha = 0, alpha2 = 0;
  16988. // Fill window
  16989. for (var ptr = -blurX * 4, end = blurX * 4 + 4; ptr < end; ptr += 4) {
  16990. var key = pLineStart + ptr;
  16991. if (key < pLineStart || key >= pLineStart + lineSize) {
  16992. continue;
  16993. }
  16994. alpha = buffer[key + 3];
  16995. rs += buffer[key + 0] * alpha;
  16996. gs += buffer[key + 1] * alpha;
  16997. bs += buffer[key + 2] * alpha;
  16998. _as += alpha;
  16999. }
  17000. // Slide window
  17001. for (var ptr = pLineStart, end = pLineStart + lineSize, linePtr = 0, lastPtr = ptr - blurX * 4, nextPtr = ptr + (blurX + 1) * 4; ptr < end; ptr += 4, linePtr += 4, nextPtr += 4, lastPtr += 4) {
  17002. if (_as === 0) {
  17003. lineBuffer[linePtr + 0] = 0;
  17004. lineBuffer[linePtr + 1] = 0;
  17005. lineBuffer[linePtr + 2] = 0;
  17006. lineBuffer[linePtr + 3] = 0;
  17007. }
  17008. else {
  17009. lineBuffer[linePtr + 0] = rs / _as;
  17010. lineBuffer[linePtr + 1] = gs / _as;
  17011. lineBuffer[linePtr + 2] = bs / _as;
  17012. lineBuffer[linePtr + 3] = _as / windowLength;
  17013. }
  17014. alpha = buffer[nextPtr + 3];
  17015. alpha2 = buffer[lastPtr + 3];
  17016. if (alpha || alpha == 0) {
  17017. if (alpha2 || alpha2 == 0) {
  17018. rs += buffer[nextPtr + 0] * alpha - buffer[lastPtr + 0] * alpha2;
  17019. gs += buffer[nextPtr + 1] * alpha - buffer[lastPtr + 1] * alpha2;
  17020. bs += buffer[nextPtr + 2] * alpha - buffer[lastPtr + 2] * alpha2;
  17021. _as += alpha - alpha2;
  17022. }
  17023. else {
  17024. rs += buffer[nextPtr + 0] * alpha;
  17025. gs += buffer[nextPtr + 1] * alpha;
  17026. bs += buffer[nextPtr + 2] * alpha;
  17027. _as += alpha;
  17028. }
  17029. }
  17030. else {
  17031. if (alpha2 || alpha2 == 0) {
  17032. rs += -buffer[lastPtr + 0] * alpha2;
  17033. gs += -buffer[lastPtr + 1] * alpha2;
  17034. bs += -buffer[lastPtr + 2] * alpha2;
  17035. _as += -alpha2;
  17036. }
  17037. else {
  17038. }
  17039. }
  17040. }
  17041. // Copy line
  17042. if (use8Clamp) {
  17043. buffer.set(lineBuffer, pLineStart);
  17044. }
  17045. else {
  17046. setArray(buffer, lineBuffer, pLineStart);
  17047. }
  17048. }
  17049. }
  17050. /**
  17051. * @private
  17052. */
  17053. function blurFilterV(buffer, w, h, blurY) {
  17054. var columnBuffer;
  17055. if (use8Clamp) {
  17056. columnBuffer = new Uint8ClampedArray(h * 4);
  17057. }
  17058. else {
  17059. columnBuffer = new Array(h * 4);
  17060. }
  17061. var stride = w * 4;
  17062. var windowLength = (blurY * 2) + 1;
  17063. for (var x = 0; x < w; x++) {
  17064. var pColumnStart = x * 4;
  17065. var rs = 0, gs = 0, bs = 0, _as = 0, alpha = 0, alpha2 = 0;
  17066. // Fill window
  17067. for (var ptr = -blurY * stride, end = blurY * stride + stride; ptr < end; ptr += stride) {
  17068. var key = pColumnStart + ptr;
  17069. if (key < pColumnStart || key >= pColumnStart + h * stride) {
  17070. continue;
  17071. }
  17072. alpha = buffer[key + 3];
  17073. rs += buffer[key + 0] * alpha;
  17074. gs += buffer[key + 1] * alpha;
  17075. bs += buffer[key + 2] * alpha;
  17076. _as += alpha;
  17077. }
  17078. // Slide window
  17079. for (var ptr = pColumnStart, end = pColumnStart + h * stride, columnPtr = 0, lastPtr = pColumnStart - blurY * stride, nextPtr = pColumnStart + ((blurY + 1) * stride); ptr < end; ptr += stride, columnPtr += 4, nextPtr += stride, lastPtr += stride) {
  17080. if (_as === 0) {
  17081. columnBuffer[columnPtr + 0] = 0;
  17082. columnBuffer[columnPtr + 1] = 0;
  17083. columnBuffer[columnPtr + 2] = 0;
  17084. columnBuffer[columnPtr + 3] = 0;
  17085. }
  17086. else {
  17087. columnBuffer[columnPtr + 0] = rs / _as;
  17088. columnBuffer[columnPtr + 1] = gs / _as;
  17089. columnBuffer[columnPtr + 2] = bs / _as;
  17090. columnBuffer[columnPtr + 3] = _as / windowLength;
  17091. }
  17092. alpha = buffer[nextPtr + 3];
  17093. alpha2 = buffer[lastPtr + 3];
  17094. if (alpha || alpha == 0) {
  17095. if (alpha2 || alpha2 == 0) {
  17096. rs += buffer[nextPtr + 0] * alpha - buffer[lastPtr + 0] * alpha2;
  17097. gs += buffer[nextPtr + 1] * alpha - buffer[lastPtr + 1] * alpha2;
  17098. bs += buffer[nextPtr + 2] * alpha - buffer[lastPtr + 2] * alpha2;
  17099. _as += alpha - alpha2;
  17100. }
  17101. else {
  17102. rs += buffer[nextPtr + 0] * alpha;
  17103. gs += buffer[nextPtr + 1] * alpha;
  17104. bs += buffer[nextPtr + 2] * alpha;
  17105. _as += alpha;
  17106. }
  17107. }
  17108. else {
  17109. if (alpha2 || alpha2 == 0) {
  17110. rs += -buffer[lastPtr + 0] * alpha2;
  17111. gs += -buffer[lastPtr + 1] * alpha2;
  17112. bs += -buffer[lastPtr + 2] * alpha2;
  17113. _as += -alpha2;
  17114. }
  17115. else {
  17116. }
  17117. }
  17118. }
  17119. // Copy column
  17120. for (var i = x * 4, end = i + h * stride, j = 0; i < end; i += stride, j += 4) {
  17121. buffer[i + 0] = columnBuffer[j + 0];
  17122. buffer[i + 1] = columnBuffer[j + 1];
  17123. buffer[i + 2] = columnBuffer[j + 2];
  17124. buffer[i + 3] = columnBuffer[j + 3];
  17125. }
  17126. }
  17127. }
  17128. // function glowFilter(buffer, w, h, color, blurX, blurY, strength) {
  17129. // dropShadowFilter(buffer, w, h, color, blurX, blurY, 0, 0, strength)
  17130. // }
  17131. function dropShadowFilter(buffer, w, h, color, blurX, blurY, angle, distance, strength) {
  17132. var tmp = alphaFilter(buffer, color);
  17133. panFilter(tmp, w, h, angle, distance);
  17134. blurFilter(tmp, w, h, blurX, blurY);
  17135. scaleAlphaChannel(tmp, strength);
  17136. compositeSourceOver(tmp, buffer);
  17137. buffer.set(tmp);
  17138. if (use8Clamp) {
  17139. buffer.set(tmp);
  17140. }
  17141. else {
  17142. setArray(buffer, tmp);
  17143. }
  17144. }
  17145. function alphaFilter(buffer, color) {
  17146. if (!color) {
  17147. color = [0, 0, 0, 0];
  17148. }
  17149. var plane;
  17150. if (use8Clamp) {
  17151. plane = new Uint8ClampedArray(buffer);
  17152. }
  17153. else {
  17154. plane = new Array(buffer.length);
  17155. setArray(plane, buffer);
  17156. }
  17157. for (var ptr = 0, end = plane.length; ptr < end; ptr += 4) {
  17158. var alpha = plane[ptr + 3];
  17159. plane[ptr + 0] = color[0] * alpha;
  17160. plane[ptr + 1] = color[1] * alpha;
  17161. plane[ptr + 2] = color[2] * alpha;
  17162. }
  17163. return plane;
  17164. }
  17165. function panFilter(buffer, w, h, angle, distance) {
  17166. var dy = (Math.sin(angle) * distance) | 0;
  17167. var dx = (Math.cos(angle) * distance) | 0;
  17168. var oldBuffer, newBuffer;
  17169. if (use8Clamp) {
  17170. oldBuffer = new Int32Array(buffer.buffer);
  17171. newBuffer = new Int32Array(oldBuffer.length);
  17172. for (var oy = 0; oy < h; oy++) {
  17173. var ny = oy + dy;
  17174. if (ny < 0 || ny > h) {
  17175. continue;
  17176. }
  17177. for (var ox = 0; ox < w; ox++) {
  17178. var nx = ox + dx;
  17179. if (nx < 0 || nx > w) {
  17180. continue;
  17181. }
  17182. newBuffer[ny * w + nx] = oldBuffer[oy * w + ox];
  17183. }
  17184. }
  17185. oldBuffer.set(newBuffer);
  17186. }
  17187. else {
  17188. oldBuffer = buffer;
  17189. newBuffer = new Array(oldBuffer.length);
  17190. for (var oy = 0; oy < h; oy++) {
  17191. var ny = oy + dy;
  17192. if (ny < 0 || ny > h) {
  17193. continue;
  17194. }
  17195. for (var ox = 0; ox < w; ox++) {
  17196. var nx = ox + dx;
  17197. if (nx < 0 || nx > w) {
  17198. continue;
  17199. }
  17200. newBuffer[(ny * w + nx) * 4 + 0] = oldBuffer[(oy * w + ox) * 4 + 0];
  17201. newBuffer[(ny * w + nx) * 4 + 1] = oldBuffer[(oy * w + ox) * 4 + 1];
  17202. newBuffer[(ny * w + nx) * 4 + 2] = oldBuffer[(oy * w + ox) * 4 + 2];
  17203. newBuffer[(ny * w + nx) * 4 + 3] = oldBuffer[(oy * w + ox) * 4 + 3];
  17204. }
  17205. }
  17206. setArray(oldBuffer, newBuffer);
  17207. }
  17208. }
  17209. function scaleAlphaChannel(buffer, value) {
  17210. for (var ptr = 0, end = buffer.length; ptr < end; ptr += 4) {
  17211. buffer[ptr + 3] *= value;
  17212. }
  17213. }
  17214. function compositeSourceOver(dst, src) {
  17215. for (var ptr = 0, end = dst.length; ptr < end; ptr += 4) {
  17216. var Dr = dst[ptr + 0];
  17217. var Dg = dst[ptr + 1];
  17218. var Db = dst[ptr + 2];
  17219. var Da = dst[ptr + 3] / 255;
  17220. var Sr = src[ptr + 0];
  17221. var Sg = src[ptr + 1];
  17222. var Sb = src[ptr + 2];
  17223. var Sa = src[ptr + 3] / 255;
  17224. dst[ptr + 0] = Sr + Dr * (1 - Sa);
  17225. dst[ptr + 1] = Sg + Dg * (1 - Sa);
  17226. dst[ptr + 2] = Sb + Db * (1 - Sa);
  17227. dst[ptr + 3] = (Sa + Da * (1 - Sa)) * 255;
  17228. }
  17229. }
  17230. function getPixelKey(w, x, y) {
  17231. return y * w * 4 + x * 4;
  17232. }
  17233. function mix(v1, v2, rate) {
  17234. return v1 * (1 - rate) + v2 * rate;
  17235. }
  17236. // dropShadowFilter2
  17237. // 模拟shader中的算法,可以实现内发光,挖空等高级效果
  17238. function dropShadowFilter2(buffer, w, h, color, blurX, blurY, angle, distance, strength, inner, knockout, hideObject) {
  17239. var plane;
  17240. if (use8Clamp) {
  17241. plane = new Uint8ClampedArray(buffer.length);
  17242. }
  17243. else {
  17244. plane = new Array(buffer.length);
  17245. }
  17246. var alpha = color[3];
  17247. var curDistanceX = 0;
  17248. var curDistanceY = 0;
  17249. var offsetX = distance * Math.cos(angle);
  17250. var offsetY = distance * Math.sin(angle);
  17251. var linearSamplingTimes = 7.0;
  17252. var circleSamplingTimes = 12.0;
  17253. var PI = 3.14159265358979323846264;
  17254. var cosAngle;
  17255. var sinAngle;
  17256. var stepX = blurX / linearSamplingTimes;
  17257. var stepY = blurY / linearSamplingTimes;
  17258. // 遍历像素
  17259. for (var u = 0; u < w; u++) {
  17260. for (var v = 0; v < h; v++) {
  17261. // 此处为了避免毛刺可以添加一个随机值
  17262. var offset = 0;
  17263. // 处理单个像素
  17264. var key = v * w * 4 + u * 4;
  17265. var totalAlpha = 0;
  17266. var maxTotalAlpha = 0;
  17267. // 采样出来的色值
  17268. var _r = buffer[key + 0] / 255;
  17269. var _g = buffer[key + 1] / 255;
  17270. var _b = buffer[key + 2] / 255;
  17271. var _a = buffer[key + 3] / 255;
  17272. for (var a = 0; a <= PI * 2; a += PI * 2 / circleSamplingTimes) {
  17273. cosAngle = Math.cos(a + offset);
  17274. sinAngle = Math.sin(a + offset);
  17275. for (var i = 0; i < linearSamplingTimes; i++) {
  17276. curDistanceX = i * stepX * cosAngle;
  17277. curDistanceY = i * stepY * sinAngle;
  17278. var _u = Math.round(u + curDistanceX - offsetX);
  17279. var _v = Math.round(v + curDistanceY - offsetY);
  17280. var __a = 0;
  17281. if (_u >= w || _u < 0 || _v < 0 || _v >= h) {
  17282. __a = 0;
  17283. }
  17284. else {
  17285. var _key = _v * w * 4 + _u * 4;
  17286. __a = buffer[_key + 3] / 255;
  17287. }
  17288. totalAlpha += (linearSamplingTimes - i) * __a;
  17289. maxTotalAlpha += (linearSamplingTimes - i);
  17290. }
  17291. }
  17292. _a = Math.max(_a, 0.0001);
  17293. // 'ownColor.rgb = ownColor.rgb / ownColor.a;',
  17294. var outerGlowAlpha = (totalAlpha / maxTotalAlpha) * strength * alpha * (1. - inner) * Math.max(Math.min(hideObject, knockout), 1. - _a);
  17295. var innerGlowAlpha = ((maxTotalAlpha - totalAlpha) / maxTotalAlpha) * strength * alpha * inner * _a;
  17296. _a = Math.max(_a * knockout * (1 - hideObject), 0.0001);
  17297. var rate1 = innerGlowAlpha / (innerGlowAlpha + _a);
  17298. var r1 = mix(_r, color[0], rate1);
  17299. var g1 = mix(_g, color[1], rate1);
  17300. var b1 = mix(_b, color[2], rate1);
  17301. var rate2 = outerGlowAlpha / (innerGlowAlpha + _a + outerGlowAlpha);
  17302. var r2 = mix(r1, color[0], rate2);
  17303. var g2 = mix(g1, color[1], rate2);
  17304. var b2 = mix(b1, color[2], rate2);
  17305. var resultAlpha = Math.min(_a + outerGlowAlpha + innerGlowAlpha, 1);
  17306. // 赋值颜色
  17307. plane[key + 0] = r2 * 255;
  17308. plane[key + 1] = g2 * 255;
  17309. plane[key + 2] = b2 * 255;
  17310. plane[key + 3] = resultAlpha * 255;
  17311. }
  17312. }
  17313. if (use8Clamp) {
  17314. buffer.set(plane);
  17315. }
  17316. else {
  17317. setArray(buffer, plane);
  17318. }
  17319. }
  17320. })(egret || (egret = {}));
  17321. var egret;
  17322. (function (egret) {
  17323. /**
  17324. * @copy egret.Orientation
  17325. */
  17326. egret.DeviceOrientation = null;
  17327. })(egret || (egret = {}));
  17328. var egret;
  17329. (function (egret) {
  17330. })(egret || (egret = {}));
  17331. var egret;
  17332. (function (egret) {
  17333. })(egret || (egret = {}));
  17334. //////////////////////////////////////////////////////////////////////////////////////
  17335. //
  17336. // Copyright (c) 2014-present, Egret Technology.
  17337. // All rights reserved.
  17338. // Redistribution and use in source and binary forms, with or without
  17339. // modification, are permitted provided that the following conditions are met:
  17340. //
  17341. // * Redistributions of source code must retain the above copyright
  17342. // notice, this list of conditions and the following disclaimer.
  17343. // * Redistributions in binary form must reproduce the above copyright
  17344. // notice, this list of conditions and the following disclaimer in the
  17345. // documentation and/or other materials provided with the distribution.
  17346. // * Neither the name of the Egret nor the
  17347. // names of its contributors may be used to endorse or promote products
  17348. // derived from this software without specific prior written permission.
  17349. //
  17350. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  17351. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  17352. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  17353. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  17354. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  17355. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  17356. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  17357. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  17358. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  17359. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17360. //
  17361. //////////////////////////////////////////////////////////////////////////////////////
  17362. var egret;
  17363. (function (egret) {
  17364. /**
  17365. * @language en_US
  17366. * Type of operation.
  17367. * @version Egret 2.4
  17368. * @platform Web,Native
  17369. */
  17370. /**
  17371. * @language zh_CN
  17372. * 运行类型的类型。
  17373. * @version Egret 2.4
  17374. * @platform Web,Native
  17375. */
  17376. var RuntimeType = (function () {
  17377. function RuntimeType() {
  17378. }
  17379. return RuntimeType;
  17380. }());
  17381. /**
  17382. * @language en_US
  17383. * Running on Web
  17384. * @version Egret 2.4
  17385. * @platform Web,Native
  17386. */
  17387. /**
  17388. * @language zh_CN
  17389. * 运行在Web上
  17390. * @version Egret 2.4
  17391. * @platform Web,Native
  17392. */
  17393. RuntimeType.WEB = "web";
  17394. /**
  17395. * @language en_US
  17396. * Running on NATIVE
  17397. * @version Egret 2.4
  17398. * @platform Web,Native
  17399. */
  17400. /**
  17401. * @language zh_CN
  17402. * 运行在NATIVE上
  17403. * @version Egret 2.4
  17404. * @platform Web,Native
  17405. */
  17406. RuntimeType.NATIVE = "native";
  17407. egret.RuntimeType = RuntimeType;
  17408. __reflect(RuntimeType.prototype, "egret.RuntimeType");
  17409. /**
  17410. * @language en_US
  17411. * The Capabilities class provides properties that describe the system and runtime that are hosting the application.
  17412. * @version Egret 2.4
  17413. * @platform Web,Native
  17414. * @includeExample egret/system/Capabilities.ts
  17415. */
  17416. /**
  17417. * @language zh_CN
  17418. * Capabilities 类提供一些属性,这些属性描述了承载应用程序的系统和运行时。
  17419. * @version Egret 2.4
  17420. * @platform Web,Native
  17421. * @includeExample egret/system/Capabilities.ts
  17422. */
  17423. var Capabilities = (function () {
  17424. function Capabilities() {
  17425. }
  17426. Object.defineProperty(Capabilities, "language", {
  17427. /**
  17428. * @language en_US
  17429. * Specifies the language code of the system on which the content is running. The language is specified as a lowercase
  17430. * two-letter language code from ISO 639-1. For Chinese, an additional uppercase two-letter country code from ISO 3166
  17431. * distinguishes between Simplified and Traditional Chinese.<br/>
  17432. * The following table lists the possible values,but not limited to them:
  17433. * <ul>
  17434. * <li>Simplified Chinese zh-CN</li>
  17435. * <li>Traditional Chinese zh-TW</li>
  17436. * <li>English en</li>
  17437. * <li>Japanese ja</li>
  17438. * <li>Korean ko</li>
  17439. * </ul>
  17440. * @version Egret 2.4
  17441. * @platform Web,Native
  17442. */
  17443. /**
  17444. * @language zh_CN
  17445. * 表示运行内容的系统的语言代码。语言指定为 ISO 639-1 中的小写双字母语言代码。
  17446. * 对于中文,另外使用 ISO 3166 中的大写双字母国家/地区代码,以区分简体中文和繁体中文。<br/>
  17447. * 以下是可能但不限于的语言和值:
  17448. * <ul>
  17449. * <li>简体中文 zh-CN</li>
  17450. * <li>繁体中文 zh-TW</li>
  17451. * <li>英语 en</li>
  17452. * <li>日语 ja</li>
  17453. * <li>韩语 ko</li>
  17454. * </ul>
  17455. * @version Egret 2.4
  17456. * @platform Web,Native
  17457. */
  17458. get: function () {
  17459. return Capabilities.$language;
  17460. },
  17461. enumerable: true,
  17462. configurable: true
  17463. });
  17464. Object.defineProperty(Capabilities, "isMobile", {
  17465. /**
  17466. * @language en_US
  17467. * Specifies whether the system is running in a mobile device.(such as a mobile phone or tablet)
  17468. * @version Egret 2.4
  17469. * @platform Web,Native
  17470. */
  17471. /**
  17472. * @language zh_CN
  17473. * 表示程序内容是否运行在移动设备中(例如移动电话或平板电脑)。
  17474. * @version Egret 2.4
  17475. * @platform Web,Native
  17476. */
  17477. get: function () {
  17478. return Capabilities.$isMobile;
  17479. },
  17480. enumerable: true,
  17481. configurable: true
  17482. });
  17483. Object.defineProperty(Capabilities, "os", {
  17484. /**
  17485. * @language en_US
  17486. * Specifies the current operating system. The os property can return the following strings:
  17487. * <ul>
  17488. * <li>iPhone "iOS"</li>
  17489. * <li>Android Phone "Android"</li>
  17490. * <li>Windows Phone "Windows Phone"</li>
  17491. * <li>Windows Desktop "Windows PC"</li>
  17492. * <li>Mac Desktop "Mac OS"</li>
  17493. * <li>Unknown OS "Unknown"</li>
  17494. * </ul>
  17495. * @version Egret 2.4
  17496. * @platform Web,Native
  17497. */
  17498. /**
  17499. * @language zh_CN
  17500. * 指示当前的操作系统。os 属性返回下列字符串:
  17501. * <ul>
  17502. * <li>苹果手机操作系统 "iOS"</li>
  17503. * <li>安卓手机操作系统 "Android"</li>
  17504. * <li>微软手机操作系统 "Windows Phone"</li>
  17505. * <li>微软桌面操作系统 "Windows PC"</li>
  17506. * <li>苹果桌面操作系统 "Mac OS"</li>
  17507. * <li>未知操作系统 "Unknown"</li>
  17508. * </ul>
  17509. * @version Egret 2.4
  17510. * @platform Web,Native
  17511. */
  17512. get: function () {
  17513. return Capabilities.$os;
  17514. },
  17515. enumerable: true,
  17516. configurable: true
  17517. });
  17518. Object.defineProperty(Capabilities, "runtimeType", {
  17519. /**
  17520. * @language en_US
  17521. * It indicates the current type of operation. runtimeType property returns the following string:
  17522. * <ul>
  17523. * <li>Run on Web egret.RuntimeType.WEB</li>
  17524. * <li>Run on Native egret.RuntimeType.NATIVE</li>
  17525. * </ul>
  17526. * @version Egret 2.4
  17527. * @platform Web,Native
  17528. */
  17529. /**
  17530. * @language zh_CN
  17531. * 指示当前的运行类型。runtimeType 属性返回下列字符串:
  17532. * <ul>
  17533. * <li>运行在Web上 egret.RuntimeType.WEB</li>
  17534. * <li>运行在Native上 egret.RuntimeType.NATIVE</li>
  17535. * </ul>
  17536. * @version Egret 2.4
  17537. * @platform Web,Native
  17538. */
  17539. get: function () {
  17540. return Capabilities.$runtimeType;
  17541. },
  17542. enumerable: true,
  17543. configurable: true
  17544. });
  17545. Object.defineProperty(Capabilities, "supportVersion", {
  17546. /***
  17547. * @language en_US
  17548. * version of the native support.
  17549. * @type {string}
  17550. * @version Egret 2.5
  17551. * @platform Web,Native
  17552. */
  17553. /***
  17554. * @language zh_CN
  17555. * native support 的版本号。
  17556. * @type {string}
  17557. * @version Egret 2.5
  17558. * @platform Web,Native
  17559. */
  17560. get: function () {
  17561. return Capabilities.$supportVersion;
  17562. },
  17563. enumerable: true,
  17564. configurable: true
  17565. });
  17566. Object.defineProperty(Capabilities, "engineVersion", {
  17567. /***
  17568. * @language en_US
  17569. * version of Egret.
  17570. * @type {string}
  17571. * @version Egret 3.2.0
  17572. * @platform Web,Native
  17573. */
  17574. /***
  17575. * @language zh_CN
  17576. * Egret 的版本号。
  17577. * @type {string}
  17578. * @version Egret 3.2.0
  17579. * @platform Web,Native
  17580. */
  17581. get: function () {
  17582. return "3.2.6";
  17583. },
  17584. enumerable: true,
  17585. configurable: true
  17586. });
  17587. /**
  17588. * 设置系统信息
  17589. */
  17590. Capabilities.$setNativeCapabilities = function (value) {
  17591. var arr = value.split("-");
  17592. if (arr.length <= 4) {
  17593. //todo 未来去掉数量判断,2.5.4版本之前的参数大于4个
  17594. var osType = arr[0];
  17595. switch (osType) {
  17596. case "android":
  17597. osType = "Android";
  17598. break;
  17599. case "ios":
  17600. osType = 'iOS';
  17601. break;
  17602. }
  17603. Capabilities.$os = osType;
  17604. var version = arr[2].substring(1, arr[2].length);
  17605. Capabilities.$supportVersion = version;
  17606. }
  17607. };
  17608. Object.defineProperty(Capabilities, "renderMode", {
  17609. /***
  17610. * @language en_US
  17611. * current render mode.
  17612. * @type {string}
  17613. * @version Egret 3.0.7
  17614. * @platform Web,Native
  17615. */
  17616. /***
  17617. * @language zh_CN
  17618. * 当前渲染模式。
  17619. * @type {string}
  17620. * @version Egret 3.0.7
  17621. * @platform Web,Native
  17622. */
  17623. get: function () {
  17624. return Capabilities.$renderMode;
  17625. },
  17626. enumerable: true,
  17627. configurable: true
  17628. });
  17629. Object.defineProperty(Capabilities, "boundingClientWidth", {
  17630. /***
  17631. * @language en_US
  17632. * Clients border width.
  17633. * The value before the document class initialization is always 0.
  17634. * This value will change after the distribution Event.RESIZE and StageOrientationEvent.ORIENTATION_CHANGE.
  17635. * @version Egret 3.1.3
  17636. * @platform Web,Native
  17637. */
  17638. /***
  17639. * @language zh_CN
  17640. * 客户端边界宽度。
  17641. * 该值在文档类初始化之前始终是0。
  17642. * 该值在派发 Event.RESIZE 以及 StageOrientationEvent.ORIENTATION_CHANGE 之后会发生改变。
  17643. * @version Egret 3.1.3
  17644. * @platform Web,Native
  17645. */
  17646. get: function () {
  17647. return Capabilities.$boundingClientWidth;
  17648. },
  17649. enumerable: true,
  17650. configurable: true
  17651. });
  17652. Object.defineProperty(Capabilities, "boundingClientHeight", {
  17653. /***
  17654. * @language en_US
  17655. * Clients border height.
  17656. * The value before the document class initialization is always 0.
  17657. * This value will change after the distribution Event.RESIZE and StageOrientationEvent.ORIENTATION_CHANGE.
  17658. * @version Egret 3.1.3
  17659. * @platform Web,Native
  17660. */
  17661. /***
  17662. * @language zh_CN
  17663. * 客户端边界高度。
  17664. * 该值在文档类初始化之前始终是0。
  17665. * 该值在派发 Event.RESIZE 以及 StageOrientationEvent.ORIENTATION_CHANGE 之后会发生改变。
  17666. * @version Egret 3.1.3
  17667. * @platform Web,Native
  17668. */
  17669. get: function () {
  17670. return Capabilities.$boundingClientHeight;
  17671. },
  17672. enumerable: true,
  17673. configurable: true
  17674. });
  17675. return Capabilities;
  17676. }());
  17677. /**
  17678. * @private
  17679. */
  17680. Capabilities.$language = "zh-CN";
  17681. /**
  17682. * @private
  17683. */
  17684. Capabilities.$os = "Unknown";
  17685. /**
  17686. * @private
  17687. */
  17688. Capabilities.$runtimeType = "Unknown";
  17689. Capabilities.$supportVersion = "Unknown";
  17690. Capabilities.$renderMode = "Unknown";
  17691. Capabilities.$boundingClientWidth = 0;
  17692. Capabilities.$boundingClientHeight = 0;
  17693. egret.Capabilities = Capabilities;
  17694. __reflect(Capabilities.prototype, "egret.Capabilities");
  17695. if (true) {
  17696. egret.$markReadOnly(Capabilities, "language", false);
  17697. egret.$markReadOnly(Capabilities, "isMobile", false);
  17698. egret.$markReadOnly(Capabilities, "os", false);
  17699. egret.$markReadOnly(Capabilities, "runtimeType", false);
  17700. egret.$markReadOnly(Capabilities, "supportVersion", false);
  17701. egret.$markReadOnly(Capabilities, "renderMode", false);
  17702. egret.$markReadOnly(Capabilities, "boundingClientWidth", false);
  17703. egret.$markReadOnly(Capabilities, "boundingClientHeight", false);
  17704. }
  17705. })(egret || (egret = {}));
  17706. /**
  17707. * @private
  17708. */
  17709. var testDeviceType = function () {
  17710. if (!this["navigator"]) {
  17711. return true;
  17712. }
  17713. var ua = navigator.userAgent.toLowerCase();
  17714. return (ua.indexOf('mobile') != -1 || ua.indexOf('android') != -1);
  17715. };
  17716. /**
  17717. * @private
  17718. */
  17719. var testRuntimeType = function () {
  17720. if (this["navigator"]) {
  17721. return true;
  17722. }
  17723. return false;
  17724. };
  17725. egret.Capabilities.$isMobile = testDeviceType();
  17726. egret.Capabilities.$runtimeType = testRuntimeType() ? egret.RuntimeType.WEB : egret.RuntimeType.NATIVE;
  17727. //////////////////////////////////////////////////////////////////////////////////////
  17728. //
  17729. // Copyright (c) 2014-present, Egret Technology.
  17730. // All rights reserved.
  17731. // Redistribution and use in source and binary forms, with or without
  17732. // modification, are permitted provided that the following conditions are met:
  17733. //
  17734. // * Redistributions of source code must retain the above copyright
  17735. // notice, this list of conditions and the following disclaimer.
  17736. // * Redistributions in binary form must reproduce the above copyright
  17737. // notice, this list of conditions and the following disclaimer in the
  17738. // documentation and/or other materials provided with the distribution.
  17739. // * Neither the name of the Egret nor the
  17740. // names of its contributors may be used to endorse or promote products
  17741. // derived from this software without specific prior written permission.
  17742. //
  17743. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  17744. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  17745. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  17746. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  17747. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  17748. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  17749. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  17750. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  17751. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  17752. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17753. //
  17754. //////////////////////////////////////////////////////////////////////////////////////
  17755. var egret;
  17756. (function (egret) {
  17757. /**
  17758. * @language en_US
  17759. * The BitmapFillMode class defines the image fill mode of Bitmap.
  17760. * The BitmapFillMode class defines a pattern enumeration for adjusting size. These patterns determine how Bitmap fill the size designated by the layout system.
  17761. * @see http://edn.egret.com/cn/docs/page/134 Texture filling way
  17762. * @version Egret 2.4
  17763. * @platform Web,Native
  17764. * @includeExample egret/display/BitmapFillMode.ts
  17765. */
  17766. /**
  17767. * @language zh_CN
  17768. * BitmapFillMode 类定义Bitmap的图像填充方式。
  17769. * BitmapFillMode 类定义了调整大小模式的一个枚举,这些模式确定 Bitmap 如何填充由布局系统指定的尺寸。
  17770. * @see http://edn.egret.com/cn/docs/page/134 纹理的填充方式
  17771. * @version Egret 2.4
  17772. * @platform Web,Native
  17773. * @includeExample egret/display/BitmapFillMode.ts
  17774. */
  17775. egret.BitmapFillMode = {
  17776. /**
  17777. * @language en_US
  17778. * Repeat the bitmap to fill area.
  17779. * @version Egret 2.4
  17780. * @platform Web
  17781. */
  17782. /**
  17783. * @language zh_CN
  17784. * 重复位图以填充区域。
  17785. * @version Egret 2.4
  17786. * @platform Web
  17787. */
  17788. REPEAT: "repeat",
  17789. /**
  17790. * @language en_US
  17791. * Scale bitmap fill to fill area.
  17792. * @version Egret 2.4
  17793. * @platform Web,Native
  17794. */
  17795. /**
  17796. * @language zh_CN
  17797. * 位图填充拉伸以填充区域。
  17798. * @version Egret 2.4
  17799. * @platform Web,Native
  17800. */
  17801. SCALE: "scale",
  17802. /**
  17803. * @language en_US
  17804. * The bitmap ends at the edge of the region.
  17805. * @version Egret 2.4
  17806. * @platform Web,Native
  17807. */
  17808. /**
  17809. * @language zh_CN
  17810. * 在区域的边缘处截断不显示位图。
  17811. * @version Egret 2.4
  17812. * @platform Web,Native
  17813. */
  17814. CLIP: "clip"
  17815. };
  17816. })(egret || (egret = {}));
  17817. var egret;
  17818. (function (egret) {
  17819. /**
  17820. * @private
  17821. */
  17822. var implMap = {};
  17823. /**
  17824. * @language en_US
  17825. * Adds an interface-name-to-implementation-class mapping to the registry.
  17826. * @param interfaceName the interface name to register. For example:"eui.IAssetAdapter","eui.Theme"
  17827. * @param instance the instance to register.
  17828. * @version Egret 3.2.1
  17829. * @platform Web,Native
  17830. */
  17831. /**
  17832. * @language zh_CN
  17833. * 注册一个接口实现。
  17834. * @param interfaceName 注入的接口名称。例如:"eui.IAssetAdapter","eui.Theme"
  17835. * @param instance 实现此接口的实例。
  17836. * @version Egret 3.2.1
  17837. * @platform Web,Native
  17838. */
  17839. function registerImplementation(interfaceName, instance) {
  17840. implMap[interfaceName] = instance;
  17841. }
  17842. egret.registerImplementation = registerImplementation;
  17843. /**
  17844. * @language en_US
  17845. * Returns the singleton instance of the implementation class that was registered for the specified interface.
  17846. * This method is usually called by egret framework.
  17847. * @param interfaceName The interface name to identify. For example:"eui.IAssetAdapter","eui.Theme"
  17848. * @returns the singleton instance of the implementation class
  17849. * @version Egret 3.2.1
  17850. * @platform Web,Native
  17851. */
  17852. /**
  17853. * @language zh_CN
  17854. * 获取一个接口实现。此方法通常由框架内部调用。获取项目注入的自定义实现实例。
  17855. * @param interfaceName 要获取的接口名称。例如:"eui.IAssetAdapter","eui.Theme"
  17856. * @returns 返回实现此接口的实例。
  17857. * @version Egret 3.2.1
  17858. * @platform Web,Native
  17859. */
  17860. function getImplementation(interfaceName) {
  17861. return implMap[interfaceName];
  17862. }
  17863. egret.getImplementation = getImplementation;
  17864. })(egret || (egret = {}));
  17865. //////////////////////////////////////////////////////////////////////////////////////
  17866. //
  17867. // Copyright (c) 2014-present, Egret Technology.
  17868. // All rights reserved.
  17869. // Redistribution and use in source and binary forms, with or without
  17870. // modification, are permitted provided that the following conditions are met:
  17871. //
  17872. // * Redistributions of source code must retain the above copyright
  17873. // notice, this list of conditions and the following disclaimer.
  17874. // * Redistributions in binary form must reproduce the above copyright
  17875. // notice, this list of conditions and the following disclaimer in the
  17876. // documentation and/or other materials provided with the distribution.
  17877. // * Neither the name of the Egret nor the
  17878. // names of its contributors may be used to endorse or promote products
  17879. // derived from this software without specific prior written permission.
  17880. //
  17881. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  17882. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  17883. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  17884. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  17885. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  17886. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  17887. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  17888. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  17889. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  17890. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17891. //
  17892. //////////////////////////////////////////////////////////////////////////////////////
  17893. var egret;
  17894. (function (egret) {
  17895. /**
  17896. * @language en_US
  17897. * Bitmap font, texture set of a font. It is generally used as the value of the BitmapText.font attribute.
  17898. * @see http://bbs.egret-labs.org/thread-918-1-1.html TextureMerger
  17899. * @see http://bbs.egret-labs.org/forum.php?mod=viewthread&tid=251 Text(Containing the specific usage of the bitmap font )
  17900. * @version Egret 2.4
  17901. * @platform Web,Native
  17902. * @includeExample egret/text/BitmapFont.ts
  17903. */
  17904. /**
  17905. * @language zh_CN
  17906. * 位图字体,是一个字体的纹理集,通常作为BitmapText.font属性的值。
  17907. * @see http://bbs.egret-labs.org/thread-918-1-1.html TextureMerger
  17908. * @see http://bbs.egret-labs.org/forum.php?mod=viewthread&tid=251 文本(含位图字体具体用法)
  17909. * @version Egret 2.4
  17910. * @platform Web,Native
  17911. * @includeExample egret/text/BitmapFont.ts
  17912. */
  17913. var BitmapFont = (function (_super) {
  17914. __extends(BitmapFont, _super);
  17915. /**
  17916. * @language en_US
  17917. * Create an egret.BitmapFont object
  17918. * @param texture {egret.Texture} Texture set that use TextureMerger create
  17919. * @param config {any} Configure data that use TextureMerger create
  17920. * @version Egret 2.4
  17921. * @platform Web,Native
  17922. */
  17923. /**
  17924. * @language zh_CN
  17925. * 创建一个 egret.BitmapFont 对象
  17926. * @param texture {egret.Texture} 使用TextureMerger生成的纹理集
  17927. * @param config {any} 使用TextureMerger生成的配置数据
  17928. * @version Egret 2.4
  17929. * @platform Web,Native
  17930. */
  17931. function BitmapFont(texture, config) {
  17932. var _this = _super.call(this, texture) || this;
  17933. /**
  17934. * @private
  17935. */
  17936. _this.firstCharHeight = 0;
  17937. if (typeof (config) == "string") {
  17938. _this.charList = _this.parseConfig(config);
  17939. }
  17940. else if (config && config.hasOwnProperty("frames")) {
  17941. _this.charList = config.frames;
  17942. }
  17943. else {
  17944. _this.charList = {};
  17945. }
  17946. return _this;
  17947. }
  17948. /**
  17949. * @language en_US
  17950. * Obtain corresponding texture through the name attribute
  17951. * @param name {string} name Attribute
  17952. * @returns {egret.Texture}
  17953. * @version Egret 2.4
  17954. * @platform Web,Native
  17955. */
  17956. /**
  17957. * @language zh_CN
  17958. * 通过 name 属性获取对应纹理
  17959. * @param name {string} name属性
  17960. * @returns {egret.Texture}
  17961. * @version Egret 2.4
  17962. * @platform Web,Native
  17963. */
  17964. BitmapFont.prototype.getTexture = function (name) {
  17965. var texture = this._textureMap[name];
  17966. if (!texture) {
  17967. var c = this.charList[name];
  17968. if (!c) {
  17969. return null;
  17970. }
  17971. texture = this.createTexture(name, c.x, c.y, c.w, c.h, c.offX, c.offY, c.sourceW, c.sourceH);
  17972. this._textureMap[name] = texture;
  17973. }
  17974. return texture;
  17975. };
  17976. /**
  17977. * @private
  17978. */
  17979. BitmapFont.prototype.getConfig = function (name, key) {
  17980. if (!this.charList[name]) {
  17981. return 0;
  17982. }
  17983. return this.charList[name][key];
  17984. };
  17985. /**
  17986. * @private
  17987. *
  17988. * @returns
  17989. */
  17990. BitmapFont.prototype._getFirstCharHeight = function () {
  17991. if (this.firstCharHeight == 0) {
  17992. for (var str in this.charList) {
  17993. var c = this.charList[str];
  17994. if (c) {
  17995. var sourceH = c.sourceH;
  17996. if (sourceH === undefined) {
  17997. var h = c.h;
  17998. if (h === undefined) {
  17999. h = 0;
  18000. }
  18001. var offY = c.offY;
  18002. if (offY === undefined) {
  18003. offY = 0;
  18004. }
  18005. sourceH = h + offY;
  18006. }
  18007. if (sourceH <= 0) {
  18008. continue;
  18009. }
  18010. this.firstCharHeight = sourceH;
  18011. break;
  18012. }
  18013. }
  18014. }
  18015. return this.firstCharHeight;
  18016. };
  18017. /**
  18018. * @private
  18019. *
  18020. * @param fntText
  18021. * @returns
  18022. */
  18023. BitmapFont.prototype.parseConfig = function (fntText) {
  18024. fntText = fntText.split("\r\n").join("\n");
  18025. var lines = fntText.split("\n");
  18026. var charsCount = this.getConfigByKey(lines[3], "count");
  18027. var chars = {};
  18028. for (var i = 4; i < 4 + charsCount; i++) {
  18029. var charText = lines[i];
  18030. var letter = String.fromCharCode(this.getConfigByKey(charText, "id"));
  18031. var c = {};
  18032. chars[letter] = c;
  18033. c["x"] = this.getConfigByKey(charText, "x");
  18034. c["y"] = this.getConfigByKey(charText, "y");
  18035. c["w"] = this.getConfigByKey(charText, "width");
  18036. c["h"] = this.getConfigByKey(charText, "height");
  18037. c["offX"] = this.getConfigByKey(charText, "xoffset");
  18038. c["offY"] = this.getConfigByKey(charText, "yoffset");
  18039. c["xadvance"] = this.getConfigByKey(charText, "xadvance");
  18040. }
  18041. return chars;
  18042. };
  18043. /**
  18044. * @private
  18045. *
  18046. * @param configText
  18047. * @param key
  18048. * @returns
  18049. */
  18050. BitmapFont.prototype.getConfigByKey = function (configText, key) {
  18051. var itemConfigTextList = configText.split(" ");
  18052. for (var i = 0, length_10 = itemConfigTextList.length; i < length_10; i++) {
  18053. var itemConfigText = itemConfigTextList[i];
  18054. if (key == itemConfigText.substring(0, key.length)) {
  18055. var value = itemConfigText.substring(key.length + 1);
  18056. return parseInt(value);
  18057. }
  18058. }
  18059. return 0;
  18060. };
  18061. return BitmapFont;
  18062. }(egret.SpriteSheet));
  18063. egret.BitmapFont = BitmapFont;
  18064. __reflect(BitmapFont.prototype, "egret.BitmapFont");
  18065. })(egret || (egret = {}));
  18066. var egret;
  18067. (function (egret) {
  18068. /**
  18069. * @language en_US
  18070. * Bitmap font adopts the Bitmap+SpriteSheet mode to render text.
  18071. * @version Egret 2.4
  18072. * @platform Web,Native
  18073. * @includeExample egret/text/BitmapText.ts
  18074. */
  18075. /**
  18076. * @language zh_CN
  18077. * 位图字体采用了Bitmap+SpriteSheet的方式来渲染文字。
  18078. * @version Egret 2.4
  18079. * @platform Web,Native
  18080. * @includeExample egret/text/BitmapText.ts
  18081. */
  18082. var BitmapText = (function (_super) {
  18083. __extends(BitmapText, _super);
  18084. /**
  18085. * @language en_US
  18086. * Create an egret.BitmapText object
  18087. * @version Egret 2.4
  18088. * @platform Web,Native
  18089. */
  18090. /**
  18091. * @language zh_CN
  18092. * 创建一个 egret.BitmapText 对象
  18093. * @version Egret 2.4
  18094. * @platform Web,Native
  18095. */
  18096. function BitmapText() {
  18097. var _this = _super.call(this) || this;
  18098. /**
  18099. * @private
  18100. */
  18101. _this.$textOffsetX = 0;
  18102. /**
  18103. * @private
  18104. */
  18105. _this.$textOffsetY = 0;
  18106. /**
  18107. * @private
  18108. */
  18109. _this.$textStartX = 0;
  18110. /**
  18111. * @private
  18112. */
  18113. _this.$textStartY = 0;
  18114. /**
  18115. * @private
  18116. */
  18117. _this.$lineHeights = [];
  18118. _this.$renderNode = new egret.sys.BitmapNode();
  18119. //this.cacheAsBitmap = true;
  18120. _this.$BitmapText = {
  18121. 0: NaN,
  18122. 1: NaN,
  18123. 2: "",
  18124. 3: 0,
  18125. 4: 0,
  18126. 5: null,
  18127. 6: false,
  18128. 7: false,
  18129. 8: false,
  18130. 9: false,
  18131. 10: "left",
  18132. 11: "top",
  18133. 12: egret.Bitmap.defaultSmoothing //smoothing
  18134. };
  18135. return _this;
  18136. }
  18137. Object.defineProperty(BitmapText.prototype, "smoothing", {
  18138. /**
  18139. * @language en_US
  18140. * Whether or not is smoothed when scaled.
  18141. * @default true。
  18142. * @version Egret 3.0
  18143. * @platform Web
  18144. */
  18145. /**
  18146. * @language zh_CN
  18147. * 控制在缩放时是否进行平滑处理。
  18148. * @default true。
  18149. * @version Egret 3.0
  18150. * @platform Web
  18151. */
  18152. get: function () {
  18153. var values = this.$BitmapText;
  18154. return values[12 /* smoothing */];
  18155. },
  18156. set: function (value) {
  18157. value = !!value;
  18158. var values = this.$BitmapText;
  18159. if (value == values[12 /* smoothing */]) {
  18160. return;
  18161. }
  18162. values[12 /* smoothing */] = value;
  18163. this.$invalidate();
  18164. },
  18165. enumerable: true,
  18166. configurable: true
  18167. });
  18168. Object.defineProperty(BitmapText.prototype, "text", {
  18169. /**
  18170. * @language en_US
  18171. * A string to display in the text field.
  18172. * @version Egret 2.4
  18173. * @platform Web,Native
  18174. */
  18175. /**
  18176. * @language zh_CN
  18177. * 要显示的文本内容
  18178. * @version Egret 2.4
  18179. * @platform Web,Native
  18180. */
  18181. get: function () {
  18182. return this.$BitmapText[2 /* text */];
  18183. },
  18184. set: function (value) {
  18185. this.$setText(value);
  18186. },
  18187. enumerable: true,
  18188. configurable: true
  18189. });
  18190. /**
  18191. * @private
  18192. */
  18193. BitmapText.prototype.$setText = function (value) {
  18194. if (value == null) {
  18195. value = "";
  18196. }
  18197. value = String(value);
  18198. var values = this.$BitmapText;
  18199. if (value == values[2 /* text */])
  18200. return false;
  18201. values[2 /* text */] = value;
  18202. this.$invalidateContentBounds();
  18203. return true;
  18204. };
  18205. /**
  18206. * @private
  18207. */
  18208. BitmapText.prototype.$getWidth = function () {
  18209. var w = this.$BitmapText[0 /* textFieldWidth */];
  18210. return isNaN(w) ? this.$getContentBounds().width : w;
  18211. };
  18212. /**
  18213. * @private
  18214. */
  18215. BitmapText.prototype.$setWidth = function (value) {
  18216. //value = +value || 0;
  18217. var values = this.$BitmapText;
  18218. if (value < 0 || value == values[0 /* textFieldWidth */]) {
  18219. return false;
  18220. }
  18221. values[0 /* textFieldWidth */] = value;
  18222. this.$invalidateContentBounds();
  18223. return true;
  18224. };
  18225. /**
  18226. * @private
  18227. */
  18228. BitmapText.prototype.$invalidateContentBounds = function () {
  18229. _super.prototype.$invalidateContentBounds.call(this);
  18230. this.$BitmapText[7 /* textLinesChanged */] = true;
  18231. };
  18232. /**
  18233. * @private
  18234. */
  18235. BitmapText.prototype.$getHeight = function () {
  18236. var h = this.$BitmapText[1 /* textFieldHeight */];
  18237. return isNaN(h) ? this.$getContentBounds().height : h;
  18238. };
  18239. /**
  18240. * @private
  18241. */
  18242. BitmapText.prototype.$setHeight = function (value) {
  18243. //value = +value || 0;
  18244. var values = this.$BitmapText;
  18245. if (value < 0 || value == values[1 /* textFieldHeight */]) {
  18246. return false;
  18247. }
  18248. values[1 /* textFieldHeight */] = value;
  18249. this.$invalidateContentBounds();
  18250. return true;
  18251. };
  18252. Object.defineProperty(BitmapText.prototype, "font", {
  18253. /**
  18254. * @language en_US
  18255. * The name of the font to use, or a comma-separated list of font names, the type of value must be BitmapFont.
  18256. * @default null
  18257. * @version Egret 2.4
  18258. * @platform Web,Native
  18259. */
  18260. /**
  18261. * @language zh_CN
  18262. * 要使用的字体的名称或用逗号分隔的字体名称列表,类型必须是 BitmapFont。
  18263. * @default null
  18264. * @version Egret 2.4
  18265. * @platform Web,Native
  18266. */
  18267. get: function () {
  18268. return this.$BitmapText[5 /* font */];
  18269. },
  18270. set: function (value) {
  18271. this.$setFont(value);
  18272. },
  18273. enumerable: true,
  18274. configurable: true
  18275. });
  18276. BitmapText.prototype.$setFont = function (value) {
  18277. var values = this.$BitmapText;
  18278. if (values[5 /* font */] == value) {
  18279. return false;
  18280. }
  18281. values[5 /* font */] = value;
  18282. this.$BitmapText[6 /* fontStringChanged */] = true;
  18283. this.$invalidateContentBounds();
  18284. return true;
  18285. };
  18286. Object.defineProperty(BitmapText.prototype, "lineSpacing", {
  18287. /**
  18288. /**
  18289. * @language en_US
  18290. * An integer representing the amount of vertical space between lines.
  18291. * @default 0
  18292. * @version Egret 2.4
  18293. * @platform Web,Native
  18294. */
  18295. /**
  18296. * @language zh_CN
  18297. * 一个整数,表示行与行之间的垂直间距量
  18298. * @default 0
  18299. * @version Egret 2.4
  18300. * @platform Web,Native
  18301. */
  18302. get: function () {
  18303. return this.$BitmapText[3 /* lineSpacing */];
  18304. },
  18305. set: function (value) {
  18306. this.$setLineSpacing(value);
  18307. },
  18308. enumerable: true,
  18309. configurable: true
  18310. });
  18311. BitmapText.prototype.$setLineSpacing = function (value) {
  18312. value = +value || 0;
  18313. var values = this.$BitmapText;
  18314. if (values[3 /* lineSpacing */] == value)
  18315. return false;
  18316. values[3 /* lineSpacing */] = value;
  18317. this.$invalidateContentBounds();
  18318. return true;
  18319. };
  18320. Object.defineProperty(BitmapText.prototype, "letterSpacing", {
  18321. /**
  18322. * @language en_US
  18323. * An integer representing the amount of distance between characters.
  18324. * @default 0
  18325. * @version Egret 2.4
  18326. * @platform Web,Native
  18327. */
  18328. /**
  18329. * @language zh_CN
  18330. * 一个整数,表示字符之间的距离。
  18331. * @default 0
  18332. * @version Egret 2.4
  18333. * @platform Web,Native
  18334. */
  18335. get: function () {
  18336. return this.$BitmapText[4 /* letterSpacing */];
  18337. },
  18338. set: function (value) {
  18339. this.$setLetterSpacing(value);
  18340. },
  18341. enumerable: true,
  18342. configurable: true
  18343. });
  18344. BitmapText.prototype.$setLetterSpacing = function (value) {
  18345. value = +value || 0;
  18346. var values = this.$BitmapText;
  18347. if (values[4 /* letterSpacing */] == value)
  18348. return false;
  18349. values[4 /* letterSpacing */] = value;
  18350. this.$invalidateContentBounds();
  18351. return true;
  18352. };
  18353. Object.defineProperty(BitmapText.prototype, "textAlign", {
  18354. /**
  18355. * @language en_US
  18356. * Horizontal alignment of text.
  18357. * @default:egret.HorizontalAlign.LEFT
  18358. * @version Egret 2.5.6
  18359. * @platform Web,Native
  18360. */
  18361. /**
  18362. * @language zh_CN
  18363. * 文本的水平对齐方式。
  18364. * @default:egret.HorizontalAlign.LEFT
  18365. * @version Egret 2.5.6
  18366. * @platform Web,Native
  18367. */
  18368. get: function () {
  18369. return this.$BitmapText[10 /* textAlign */];
  18370. },
  18371. set: function (value) {
  18372. this.$setTextAlign(value);
  18373. },
  18374. enumerable: true,
  18375. configurable: true
  18376. });
  18377. BitmapText.prototype.$setTextAlign = function (value) {
  18378. var values = this.$BitmapText;
  18379. if (values[10 /* textAlign */] == value)
  18380. return false;
  18381. values[10 /* textAlign */] = value;
  18382. this.$invalidateContentBounds();
  18383. return true;
  18384. };
  18385. Object.defineProperty(BitmapText.prototype, "verticalAlign", {
  18386. /**
  18387. * @language en_US
  18388. * Vertical alignment of text.
  18389. * @default:egret.VerticalAlign.TOP
  18390. * @version Egret 2.5.6
  18391. * @platform Web,Native
  18392. */
  18393. /**
  18394. * @language zh_CN
  18395. * 文字的垂直对齐方式。
  18396. * @default:egret.VerticalAlign.TOP
  18397. * @version Egret 2.5.6
  18398. * @platform Web,Native
  18399. */
  18400. get: function () {
  18401. return this.$BitmapText[11 /* verticalAlign */];
  18402. },
  18403. set: function (value) {
  18404. this.$setVerticalAlign(value);
  18405. },
  18406. enumerable: true,
  18407. configurable: true
  18408. });
  18409. BitmapText.prototype.$setVerticalAlign = function (value) {
  18410. var values = this.$BitmapText;
  18411. if (values[11 /* verticalAlign */] == value)
  18412. return false;
  18413. values[11 /* verticalAlign */] = value;
  18414. this.$invalidateContentBounds();
  18415. return true;
  18416. };
  18417. /**
  18418. * @private
  18419. */
  18420. BitmapText.prototype.$render = function () {
  18421. var values = this.$BitmapText;
  18422. var textLines = this.$getTextLines();
  18423. var length = textLines.length;
  18424. if (length == 0) {
  18425. return;
  18426. }
  18427. var textLinesWidth = this.$textLinesWidth;
  18428. var bitmapFont = values[5 /* font */];
  18429. var node = this.$renderNode;
  18430. if (bitmapFont.$texture) {
  18431. node.image = bitmapFont.$texture._bitmapData;
  18432. }
  18433. node.smoothing = values[12 /* smoothing */];
  18434. var emptyHeight = bitmapFont._getFirstCharHeight();
  18435. var emptyWidth = Math.ceil(emptyHeight * BitmapText.EMPTY_FACTOR);
  18436. var hasSetHeight = !isNaN(values[1 /* textFieldHeight */]);
  18437. var textWidth = values[8 /* textWidth */];
  18438. var textFieldWidth = values[0 /* textFieldWidth */];
  18439. var textFieldHeight = values[1 /* textFieldHeight */];
  18440. var align = values[10 /* textAlign */];
  18441. var yPos = this.$textOffsetY + this.$textStartY;
  18442. var lineHeights = this.$lineHeights;
  18443. for (var i = 0; i < length; i++) {
  18444. var lineHeight = lineHeights[i];
  18445. if (hasSetHeight && i > 0 && yPos + lineHeight > textFieldHeight) {
  18446. break;
  18447. }
  18448. var line = textLines[i];
  18449. var len = line.length;
  18450. var xPos = this.$textOffsetX;
  18451. if (align != egret.HorizontalAlign.LEFT) {
  18452. var countWidth = textFieldWidth > textWidth ? textFieldWidth : textWidth;
  18453. if (align == egret.HorizontalAlign.RIGHT) {
  18454. xPos += countWidth - textLinesWidth[i];
  18455. }
  18456. else if (align == egret.HorizontalAlign.CENTER) {
  18457. xPos += Math.floor((countWidth - textLinesWidth[i]) / 2);
  18458. }
  18459. }
  18460. for (var j = 0; j < len; j++) {
  18461. var character = line.charAt(j);
  18462. var texture = bitmapFont.getTexture(character);
  18463. if (!texture) {
  18464. if (character == " ") {
  18465. xPos += emptyWidth;
  18466. }
  18467. else {
  18468. egret.$warn(1046, character);
  18469. }
  18470. continue;
  18471. }
  18472. var bitmapWidth = texture._bitmapWidth;
  18473. var bitmapHeight = texture._bitmapHeight;
  18474. node.imageWidth = texture._sourceWidth;
  18475. node.imageHeight = texture._sourceHeight;
  18476. node.drawImage(texture._bitmapX, texture._bitmapY, bitmapWidth, bitmapHeight, xPos + texture._offsetX, yPos + texture._offsetY, texture.$getScaleBitmapWidth(), texture.$getScaleBitmapHeight());
  18477. xPos += (bitmapFont.getConfig(character, "xadvance") || texture.$getTextureWidth()) + values[4 /* letterSpacing */];
  18478. }
  18479. yPos += lineHeight + values[3 /* lineSpacing */];
  18480. }
  18481. };
  18482. /**
  18483. * @private
  18484. */
  18485. BitmapText.prototype.$measureContentBounds = function (bounds) {
  18486. var lines = this.$getTextLines();
  18487. if (lines.length == 0) {
  18488. bounds.setEmpty();
  18489. }
  18490. else {
  18491. bounds.setTo(this.$textOffsetX + this.$textStartX, this.$textOffsetY + this.$textStartY, this.$BitmapText[8 /* textWidth */] - this.$textOffsetX, this.$BitmapText[9 /* textHeight */] - this.$textOffsetY);
  18492. }
  18493. };
  18494. Object.defineProperty(BitmapText.prototype, "textWidth", {
  18495. /**
  18496. * @language en_US
  18497. * Get the BitmapText measured width
  18498. * @version Egret 2.4
  18499. * @platform Web,Native
  18500. */
  18501. /**
  18502. * @language zh_CN
  18503. * 获取位图文本测量宽度
  18504. * @version Egret 2.4
  18505. * @platform Web,Native
  18506. */
  18507. get: function () {
  18508. this.$getTextLines();
  18509. return this.$BitmapText[8 /* textWidth */];
  18510. },
  18511. enumerable: true,
  18512. configurable: true
  18513. });
  18514. Object.defineProperty(BitmapText.prototype, "textHeight", {
  18515. /**
  18516. * @language en_US
  18517. * Get Text BitmapText height
  18518. * @version Egret 2.4
  18519. * @platform Web,Native
  18520. */
  18521. /**
  18522. * @language zh_CN
  18523. * 获取位图文本测量高度
  18524. * @version Egret 2.4
  18525. * @platform Web,Native
  18526. */
  18527. get: function () {
  18528. this.$getTextLines();
  18529. return this.$BitmapText[9 /* textHeight */];
  18530. },
  18531. enumerable: true,
  18532. configurable: true
  18533. });
  18534. /**
  18535. * @private
  18536. *
  18537. * @returns
  18538. */
  18539. BitmapText.prototype.$getTextLines = function () {
  18540. var values = this.$BitmapText;
  18541. if (!values[7 /* textLinesChanged */]) {
  18542. return this.textLines;
  18543. }
  18544. var textLines = [];
  18545. this.textLines = textLines;
  18546. var textLinesWidth = [];
  18547. this.$textLinesWidth = textLinesWidth;
  18548. values[7 /* textLinesChanged */] = false;
  18549. var lineHeights = [];
  18550. this.$lineHeights = lineHeights;
  18551. if (!values[2 /* text */] || !values[5 /* font */]) {
  18552. return textLines;
  18553. }
  18554. var lineSpacing = values[3 /* lineSpacing */];
  18555. var letterSpacing = values[4 /* letterSpacing */];
  18556. var textWidth = 0;
  18557. var textHeight = 0;
  18558. var textOffsetX = 0;
  18559. var textOffsetY = 0;
  18560. var hasWidthSet = !isNaN(values[0 /* textFieldWidth */]);
  18561. var textFieldWidth = values[0 /* textFieldWidth */];
  18562. var textFieldHeight = values[1 /* textFieldHeight */];
  18563. var bitmapFont = values[5 /* font */];
  18564. var emptyHeight = bitmapFont._getFirstCharHeight();
  18565. var emptyWidth = Math.ceil(emptyHeight * BitmapText.EMPTY_FACTOR);
  18566. var text = values[2 /* text */];
  18567. var textArr = text.split(/(?:\r\n|\r|\n)/);
  18568. var length = textArr.length;
  18569. var isFirstLine = true;
  18570. var isFirstChar;
  18571. var isLastChar;
  18572. var lineHeight;
  18573. var xPos;
  18574. for (var i = 0; i < length; i++) {
  18575. var line = textArr[i];
  18576. var len = line.length;
  18577. lineHeight = 0;
  18578. xPos = 0;
  18579. isFirstChar = true;
  18580. isLastChar = false;
  18581. for (var j = 0; j < len; j++) {
  18582. if (!isFirstChar) {
  18583. xPos += letterSpacing;
  18584. }
  18585. var character = line.charAt(j);
  18586. var texureWidth = void 0;
  18587. var textureHeight = void 0;
  18588. var offsetX = 0;
  18589. var offsetY = 0;
  18590. var texture = bitmapFont.getTexture(character);
  18591. if (!texture) {
  18592. if (character == " ") {
  18593. texureWidth = emptyWidth;
  18594. textureHeight = emptyHeight;
  18595. }
  18596. else {
  18597. egret.$warn(1046, character);
  18598. if (isFirstChar) {
  18599. isFirstChar = false;
  18600. }
  18601. continue;
  18602. }
  18603. }
  18604. else {
  18605. texureWidth = texture.$getTextureWidth();
  18606. textureHeight = texture.$getTextureHeight();
  18607. offsetX = texture._offsetX;
  18608. offsetY = texture._offsetY;
  18609. }
  18610. if (isFirstChar) {
  18611. isFirstChar = false;
  18612. textOffsetX = Math.min(offsetX, textOffsetX);
  18613. }
  18614. if (isFirstLine) {
  18615. isFirstLine = false;
  18616. textOffsetY = Math.min(offsetY, textOffsetY);
  18617. }
  18618. if (hasWidthSet && j > 0 && xPos + texureWidth > textFieldWidth) {
  18619. if (!setLineData(line.substring(0, j)))
  18620. break;
  18621. line = line.substring(j);
  18622. len = line.length;
  18623. j = 0;
  18624. //最后一个字符要计算纹理宽度,而不是xadvance
  18625. if (j == len - 1) {
  18626. xPos = texureWidth;
  18627. }
  18628. else {
  18629. xPos = bitmapFont.getConfig(character, "xadvance") || texureWidth;
  18630. }
  18631. lineHeight = textureHeight;
  18632. continue;
  18633. }
  18634. //最后一个字符要计算纹理宽度,而不是xadvance
  18635. if (j == len - 1) {
  18636. xPos += texureWidth;
  18637. }
  18638. else {
  18639. xPos += bitmapFont.getConfig(character, "xadvance") || texureWidth;
  18640. }
  18641. lineHeight = Math.max(textureHeight, lineHeight);
  18642. }
  18643. if (textFieldHeight && i > 0 && textHeight > textFieldHeight) {
  18644. break;
  18645. }
  18646. isLastChar = true;
  18647. if (!setLineData(line))
  18648. break;
  18649. }
  18650. function setLineData(str) {
  18651. if (textFieldHeight && textLines.length > 0 && textHeight > textFieldHeight) {
  18652. return false;
  18653. }
  18654. textHeight += lineHeight + lineSpacing;
  18655. if (!isFirstChar && !isLastChar) {
  18656. xPos -= letterSpacing;
  18657. }
  18658. textLines.push(str);
  18659. lineHeights.push(lineHeight);
  18660. textLinesWidth.push(xPos);
  18661. textWidth = Math.max(xPos, textWidth);
  18662. return true;
  18663. }
  18664. textHeight -= lineSpacing;
  18665. values[8 /* textWidth */] = textWidth;
  18666. values[9 /* textHeight */] = textHeight;
  18667. this.$textOffsetX = textOffsetX;
  18668. this.$textOffsetY = textOffsetY;
  18669. this.$textStartX = 0;
  18670. this.$textStartY = 0;
  18671. var alignType;
  18672. if (textFieldWidth > textWidth) {
  18673. alignType = values[10 /* textAlign */];
  18674. if (alignType == egret.HorizontalAlign.RIGHT) {
  18675. this.$textStartX = textFieldWidth - textWidth;
  18676. }
  18677. else if (alignType == egret.HorizontalAlign.CENTER) {
  18678. this.$textStartX = Math.floor((textFieldWidth - textWidth) / 2);
  18679. }
  18680. }
  18681. if (textFieldHeight > textHeight) {
  18682. alignType = values[11 /* verticalAlign */];
  18683. if (alignType == egret.VerticalAlign.BOTTOM) {
  18684. this.$textStartY = textFieldHeight - textHeight;
  18685. }
  18686. else if (alignType == egret.VerticalAlign.MIDDLE) {
  18687. this.$textStartY = Math.floor((textFieldHeight - textHeight) / 2);
  18688. }
  18689. }
  18690. return textLines;
  18691. };
  18692. return BitmapText;
  18693. }(egret.DisplayObject));
  18694. /**
  18695. * @language en_US
  18696. * A ratio of the width of the space character. This value is multiplied by the height of the first character is the space character width.
  18697. * @default 0.33
  18698. * @version Egret 2.4
  18699. * @platform Web,Native
  18700. */
  18701. /**
  18702. * @language zh_CN
  18703. * 一个空格字符的宽度比例。这个数值乘以第一个字符的高度即为空格字符的宽。
  18704. * @default 0.33
  18705. * @version Egret 2.4
  18706. * @platform Web,Native
  18707. */
  18708. BitmapText.EMPTY_FACTOR = 0.33;
  18709. egret.BitmapText = BitmapText;
  18710. __reflect(BitmapText.prototype, "egret.BitmapText");
  18711. })(egret || (egret = {}));
  18712. //////////////////////////////////////////////////////////////////////////////////////
  18713. //
  18714. // Copyright (c) 2014-present, Egret Technology.
  18715. // All rights reserved.
  18716. // Redistribution and use in source and binary forms, with or without
  18717. // modification, are permitted provided that the following conditions are met:
  18718. //
  18719. // * Redistributions of source code must retain the above copyright
  18720. // notice, this list of conditions and the following disclaimer.
  18721. // * Redistributions in binary form must reproduce the above copyright
  18722. // notice, this list of conditions and the following disclaimer in the
  18723. // documentation and/or other materials provided with the distribution.
  18724. // * Neither the name of the Egret nor the
  18725. // names of its contributors may be used to endorse or promote products
  18726. // derived from this software without specific prior written permission.
  18727. //
  18728. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  18729. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  18730. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  18731. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  18732. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  18733. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  18734. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  18735. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  18736. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  18737. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18738. //
  18739. //////////////////////////////////////////////////////////////////////////////////////
  18740. var egret;
  18741. (function (egret) {
  18742. /**
  18743. * @language en_US
  18744. * The HorizontalAlign class defines the possible values for the horizontal alignment.
  18745. * @see egret.TextField#textAlign
  18746. * @version Egret 2.4
  18747. * @platform Web,Native
  18748. */
  18749. /**
  18750. * @language zh_CN
  18751. * HorizontalAlign 类为水平对齐方式定义可能的值。
  18752. * @see egret.TextField#textAlign
  18753. * @version Egret 2.4
  18754. * @platform Web,Native
  18755. */
  18756. var HorizontalAlign = (function () {
  18757. function HorizontalAlign() {
  18758. }
  18759. return HorizontalAlign;
  18760. }());
  18761. /**
  18762. * @language en_US
  18763. * Horizontally align content to the left of the container.
  18764. * @version Egret 2.4
  18765. * @platform Web,Native
  18766. */
  18767. /**
  18768. * @language zh_CN
  18769. * 将内容与容器的左侧对齐。
  18770. * @version Egret 2.4
  18771. * @platform Web,Native
  18772. */
  18773. HorizontalAlign.LEFT = "left";
  18774. /**
  18775. * @language en_US
  18776. * Horizontally align content to the right of the container.
  18777. * @version Egret 2.4
  18778. * @platform Web,Native
  18779. */
  18780. /**
  18781. * @language zh_CN
  18782. * 将内容与容器的右侧对齐。
  18783. * @version Egret 2.4
  18784. * @platform Web,Native
  18785. */
  18786. HorizontalAlign.RIGHT = "right";
  18787. /**
  18788. * @language en_US
  18789. * Horizontally align content in the center of the container.
  18790. * @version Egret 2.4
  18791. * @platform Web,Native
  18792. */
  18793. /**
  18794. * @language zh_CN
  18795. * 在容器的水平中心对齐内容。
  18796. * @version Egret 2.4
  18797. * @platform Web,Native
  18798. */
  18799. HorizontalAlign.CENTER = "center";
  18800. /**
  18801. * @language en_US
  18802. * Horizontal alignment with both edges.
  18803. * Note: TextFiled does not support this alignment method.
  18804. * @constant egret.HorizontalAlign.JUSTIFY
  18805. * @version Egret 2.4
  18806. * @platform Web,Native
  18807. */
  18808. /**
  18809. * @language zh_CN
  18810. * 水平两端对齐。
  18811. * 注意:TextFiled不支持此对齐方式。
  18812. * @constant egret.HorizontalAlign.JUSTIFY
  18813. * @version Egret 2.4
  18814. * @platform Web,Native
  18815. */
  18816. HorizontalAlign.JUSTIFY = "justify";
  18817. /**
  18818. * @language en_US
  18819. * Align the content of the child items, relative to the container. This operation will adjust uniformly the size of all the child items to be the Content Width \" of the container \".
  18820. * The Content Width \" of the container \" is the size of the max. child item. If the size of all child items are less than the width of the container, they will be adjusted to the width of the container.
  18821. * Note: TextFiled does not support this alignment method.
  18822. * @constant egret.HorizontalAlign.CONTENT_JUSTIFY
  18823. * @version Egret 2.4
  18824. * @platform Web,Native
  18825. */
  18826. /**
  18827. * @language zh_CN
  18828. * 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的"内容宽度"。
  18829. * 容器的"内容宽度"是最大子项的大小,如果所有子项都小于容器的宽度,则会将所有子项的大小调整为容器的宽度。
  18830. * 注意:TextFiled不支持此对齐方式。
  18831. * @constant egret.HorizontalAlign.CONTENT_JUSTIFY
  18832. * @version Egret 2.4
  18833. * @platform Web,Native
  18834. */
  18835. HorizontalAlign.CONTENT_JUSTIFY = "contentJustify";
  18836. egret.HorizontalAlign = HorizontalAlign;
  18837. __reflect(HorizontalAlign.prototype, "egret.HorizontalAlign");
  18838. })(egret || (egret = {}));
  18839. //////////////////////////////////////////////////////////////////////////////////////
  18840. //
  18841. // Copyright (c) 2014-present, Egret Technology.
  18842. // All rights reserved.
  18843. // Redistribution and use in source and binary forms, with or without
  18844. // modification, are permitted provided that the following conditions are met:
  18845. //
  18846. // * Redistributions of source code must retain the above copyright
  18847. // notice, this list of conditions and the following disclaimer.
  18848. // * Redistributions in binary form must reproduce the above copyright
  18849. // notice, this list of conditions and the following disclaimer in the
  18850. // documentation and/or other materials provided with the distribution.
  18851. // * Neither the name of the Egret nor the
  18852. // names of its contributors may be used to endorse or promote products
  18853. // derived from this software without specific prior written permission.
  18854. //
  18855. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  18856. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  18857. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  18858. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  18859. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  18860. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  18861. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  18862. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  18863. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  18864. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18865. //
  18866. //////////////////////////////////////////////////////////////////////////////////////
  18867. var egret;
  18868. (function (egret) {
  18869. /**
  18870. * @language en_US
  18871. * Convert the text in html format to the object that can be assigned to the egret.TextField#textFlow property
  18872. * @see http://edn.egret.com/cn/docs/page/146 Text mixed in a variety of style
  18873. * @version Egret 2.4
  18874. * @platform Web,Native
  18875. * @includeExample egret/text/HtmlTextParser.ts
  18876. */
  18877. /**
  18878. * @language zh_CN
  18879. * 将html格式文本转换为可赋值给 egret.TextField#textFlow 属性的对象
  18880. * @see http://edn.egret.com/cn/docs/page/146 多种样式文本混合
  18881. * @version Egret 2.4
  18882. * @platform Web,Native
  18883. * @includeExample egret/text/HtmlTextParser.ts
  18884. */
  18885. var HtmlTextParser = (function () {
  18886. /**
  18887. * @version Egret 2.4
  18888. * @platform Web,Native
  18889. */
  18890. function HtmlTextParser() {
  18891. this.replaceArr = [];
  18892. /**
  18893. * @private
  18894. */
  18895. this.resutlArr = [];
  18896. this.initReplaceArr();
  18897. }
  18898. HtmlTextParser.prototype.initReplaceArr = function () {
  18899. this.replaceArr = [];
  18900. this.replaceArr.push([/&lt;/g, "<"]);
  18901. this.replaceArr.push([/&gt;/g, ">"]);
  18902. this.replaceArr.push([/&amp;/g, "&"]);
  18903. this.replaceArr.push([/&quot;/g, "\""]);
  18904. this.replaceArr.push([/&apos;/g, "\'"]);
  18905. };
  18906. /**
  18907. * @private
  18908. *
  18909. * @param value
  18910. * @returns
  18911. */
  18912. HtmlTextParser.prototype.replaceSpecial = function (value) {
  18913. for (var i = 0; i < this.replaceArr.length; i++) {
  18914. var k = this.replaceArr[i][0];
  18915. var v = this.replaceArr[i][1];
  18916. value = value.replace(k, v);
  18917. }
  18918. return value;
  18919. };
  18920. /**
  18921. * @language en_US
  18922. * Convert the text in html format to the object that can be assigned to the egret.TextField#textFlow property
  18923. * @param htmltext {string} Text in html
  18924. * @returns {Array<egret.ITextElement>} 可赋值给 egret.TextField#textFlow Object that can be assigned to the egret.TextField#textFlow property
  18925. * @version Egret 2.4
  18926. * @platform Web,Native
  18927. */
  18928. /**
  18929. * @language zh_CN
  18930. * 将html格式文本转换为可赋值给 egret.TextField#textFlow 属性的对象
  18931. * @param htmltext {string} html文本
  18932. * @returns {Array<egret.ITextElement>} 可赋值给 egret.TextField#textFlow 属性的对象
  18933. * @version Egret 2.4
  18934. * @platform Web,Native
  18935. */
  18936. HtmlTextParser.prototype.parser = function (htmltext) {
  18937. this.stackArray = [];
  18938. this.resutlArr = [];
  18939. var firstIdx = 0; //文本段开始位置
  18940. var length = htmltext.length;
  18941. while (firstIdx < length) {
  18942. var starIdx = htmltext.indexOf("<", firstIdx);
  18943. if (starIdx < 0) {
  18944. this.addToResultArr(htmltext.substring(firstIdx));
  18945. firstIdx = length;
  18946. }
  18947. else {
  18948. this.addToResultArr(htmltext.substring(firstIdx, starIdx));
  18949. var fontEnd = htmltext.indexOf(">", starIdx);
  18950. if (fontEnd == -1) {
  18951. egret.$error(1038);
  18952. fontEnd = starIdx;
  18953. }
  18954. else if (htmltext.charAt(starIdx + 1) == "\/") {
  18955. this.stackArray.pop();
  18956. }
  18957. else {
  18958. this.addToArray(htmltext.substring(starIdx + 1, fontEnd));
  18959. }
  18960. firstIdx = fontEnd + 1;
  18961. }
  18962. }
  18963. return this.resutlArr;
  18964. };
  18965. /**
  18966. * @private
  18967. *
  18968. * @param value
  18969. */
  18970. HtmlTextParser.prototype.addToResultArr = function (value) {
  18971. if (value == "") {
  18972. return;
  18973. }
  18974. value = this.replaceSpecial(value);
  18975. if (this.stackArray.length > 0) {
  18976. this.resutlArr.push({ text: value, style: this.stackArray[this.stackArray.length - 1] });
  18977. }
  18978. else {
  18979. this.resutlArr.push({ text: value });
  18980. }
  18981. };
  18982. //将字符数据转成Json数据
  18983. HtmlTextParser.prototype.changeStringToObject = function (str) {
  18984. str = str.trim();
  18985. var info = {};
  18986. var header = [];
  18987. if (str.charAt(0) == "i" || str.charAt(0) == "b" || str.charAt(0) == "u") {
  18988. this.addProperty(info, str, "true");
  18989. }
  18990. else if (header = str.match(/^(font|a)\s/)) {
  18991. str = str.substring(header[0].length).trim();
  18992. var next = 0;
  18993. var titles = void 0;
  18994. while (titles = str.match(this.getHeadReg())) {
  18995. var title = titles[0];
  18996. var value = "";
  18997. str = str.substring(title.length).trim();
  18998. if (str.charAt(0) == "\"") {
  18999. next = str.indexOf("\"", 1);
  19000. value = str.substring(1, next);
  19001. next += 1;
  19002. }
  19003. else if (str.charAt(0) == "\'") {
  19004. next = str.indexOf("\'", 1);
  19005. value = str.substring(1, next);
  19006. next += 1;
  19007. }
  19008. else {
  19009. value = str.match(/(\S)+/)[0];
  19010. next = value.length;
  19011. }
  19012. this.addProperty(info, title.substring(0, title.length - 1).trim(), value.trim());
  19013. str = str.substring(next).trim();
  19014. }
  19015. }
  19016. return info;
  19017. };
  19018. /**
  19019. * @private
  19020. *
  19021. * @returns
  19022. */
  19023. HtmlTextParser.prototype.getHeadReg = function () {
  19024. return /^(color|textcolor|strokecolor|stroke|b|bold|i|italic|u|size|fontfamily|href|target)(\s)*=/;
  19025. };
  19026. /**
  19027. * @private
  19028. *
  19029. * @param info
  19030. * @param head
  19031. * @param value
  19032. */
  19033. HtmlTextParser.prototype.addProperty = function (info, head, value) {
  19034. switch (head.toLowerCase()) {
  19035. case "color":
  19036. case "textcolor":
  19037. value = value.replace(/#/, "0x");
  19038. info.textColor = parseInt(value);
  19039. break;
  19040. case "strokecolor":
  19041. value = value.replace(/#/, "0x");
  19042. info.strokeColor = parseInt(value);
  19043. break;
  19044. case "stroke":
  19045. info.stroke = parseInt(value);
  19046. break;
  19047. case "b":
  19048. case "bold":
  19049. info.bold = value == "true";
  19050. break;
  19051. case "u":
  19052. info.underline = value == "true";
  19053. break;
  19054. case "i":
  19055. case "italic":
  19056. info.italic = value == "true";
  19057. break;
  19058. case "size":
  19059. info.size = parseInt(value);
  19060. break;
  19061. case "fontfamily":
  19062. info.fontFamily = value;
  19063. break;
  19064. case "href":
  19065. info.href = this.replaceSpecial(value);
  19066. break;
  19067. case "target":
  19068. info.target = this.replaceSpecial(value);
  19069. break;
  19070. }
  19071. };
  19072. /**
  19073. * @private
  19074. *
  19075. * @param infoStr
  19076. */
  19077. HtmlTextParser.prototype.addToArray = function (infoStr) {
  19078. var info = this.changeStringToObject(infoStr);
  19079. if (this.stackArray.length == 0) {
  19080. this.stackArray.push(info);
  19081. }
  19082. else {
  19083. var lastInfo = this.stackArray[this.stackArray.length - 1];
  19084. for (var key in lastInfo) {
  19085. if (info[key] == null) {
  19086. info[key] = lastInfo[key];
  19087. }
  19088. }
  19089. this.stackArray.push(info);
  19090. }
  19091. };
  19092. return HtmlTextParser;
  19093. }());
  19094. egret.HtmlTextParser = HtmlTextParser;
  19095. __reflect(HtmlTextParser.prototype, "egret.HtmlTextParser");
  19096. })(egret || (egret = {}));
  19097. //////////////////////////////////////////////////////////////////////////////////////
  19098. //
  19099. // Copyright (c) 2014-present, Egret Technology.
  19100. // All rights reserved.
  19101. // Redistribution and use in source and binary forms, with or without
  19102. // modification, are permitted provided that the following conditions are met:
  19103. //
  19104. // * Redistributions of source code must retain the above copyright
  19105. // notice, this list of conditions and the following disclaimer.
  19106. // * Redistributions in binary form must reproduce the above copyright
  19107. // notice, this list of conditions and the following disclaimer in the
  19108. // documentation and/or other materials provided with the distribution.
  19109. // * Neither the name of the Egret nor the
  19110. // names of its contributors may be used to endorse or promote products
  19111. // derived from this software without specific prior written permission.
  19112. //
  19113. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  19114. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19115. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  19116. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  19117. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  19118. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  19119. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  19120. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  19121. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  19122. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19123. //
  19124. //////////////////////////////////////////////////////////////////////////////////////
  19125. //////////////////////////////////////////////////////////////////////////////////////
  19126. //
  19127. // Copyright (c) 2014-present, Egret Technology.
  19128. // All rights reserved.
  19129. // Redistribution and use in source and binary forms, with or without
  19130. // modification, are permitted provided that the following conditions are met:
  19131. //
  19132. // * Redistributions of source code must retain the above copyright
  19133. // notice, this list of conditions and the following disclaimer.
  19134. // * Redistributions in binary form must reproduce the above copyright
  19135. // notice, this list of conditions and the following disclaimer in the
  19136. // documentation and/or other materials provided with the distribution.
  19137. // * Neither the name of the Egret nor the
  19138. // names of its contributors may be used to endorse or promote products
  19139. // derived from this software without specific prior written permission.
  19140. //
  19141. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  19142. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19143. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  19144. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  19145. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  19146. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  19147. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  19148. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  19149. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  19150. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19151. //
  19152. //////////////////////////////////////////////////////////////////////////////////////
  19153. var egret;
  19154. (function (egret) {
  19155. /**
  19156. * @private
  19157. * @version Egret 2.4
  19158. * @platform Web,Native
  19159. */
  19160. var InputController = (function (_super) {
  19161. __extends(InputController, _super);
  19162. /**
  19163. * @version Egret 2.4
  19164. * @platform Web,Native
  19165. */
  19166. function InputController() {
  19167. var _this = _super.call(this) || this;
  19168. /**
  19169. * @private
  19170. */
  19171. _this.stageTextAdded = false;
  19172. /**
  19173. * @private
  19174. */
  19175. _this._text = null;
  19176. /**
  19177. * @private
  19178. */
  19179. _this._isFocus = false;
  19180. return _this;
  19181. }
  19182. /**
  19183. *
  19184. * @param text
  19185. * @version Egret 2.4
  19186. * @platform Web,Native
  19187. */
  19188. InputController.prototype.init = function (text) {
  19189. this._text = text;
  19190. this.stageText = new egret.StageText();
  19191. this.stageText.$setTextField(this._text);
  19192. };
  19193. /**
  19194. * @private
  19195. *
  19196. */
  19197. InputController.prototype._addStageText = function () {
  19198. if (this.stageTextAdded) {
  19199. return;
  19200. }
  19201. if (!this._text.$inputEnabled) {
  19202. this._text.$touchEnabled = true;
  19203. }
  19204. this.tempStage = this._text.stage;
  19205. this.stageText.$addToStage();
  19206. this.stageText.addEventListener("updateText", this.updateTextHandler, this);
  19207. this._text.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onMouseDownHandler, this);
  19208. this.stageText.addEventListener("blur", this.blurHandler, this);
  19209. this.stageText.addEventListener("focus", this.focusHandler, this);
  19210. this.stageTextAdded = true;
  19211. };
  19212. /**
  19213. * @private
  19214. *
  19215. */
  19216. InputController.prototype._removeStageText = function () {
  19217. if (!this.stageTextAdded) {
  19218. return;
  19219. }
  19220. if (!this._text.$inputEnabled) {
  19221. this._text.$touchEnabled = false;
  19222. }
  19223. this.stageText.$removeFromStage();
  19224. this.stageText.removeEventListener("updateText", this.updateTextHandler, this);
  19225. this._text.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onMouseDownHandler, this);
  19226. this.tempStage.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onStageDownHandler, this);
  19227. this.stageText.removeEventListener("blur", this.blurHandler, this);
  19228. this.stageText.removeEventListener("focus", this.focusHandler, this);
  19229. this.stageTextAdded = false;
  19230. };
  19231. /**
  19232. * @private
  19233. *
  19234. * @returns
  19235. */
  19236. InputController.prototype._getText = function () {
  19237. return this.stageText.$getText();
  19238. };
  19239. /**
  19240. * @private
  19241. *
  19242. * @param value
  19243. */
  19244. InputController.prototype._setText = function (value) {
  19245. this.stageText.$setText(value);
  19246. };
  19247. /**
  19248. * @private
  19249. */
  19250. InputController.prototype._setColor = function (value) {
  19251. this.stageText.$setColor(value);
  19252. };
  19253. /**
  19254. * @private
  19255. *
  19256. * @param event
  19257. */
  19258. InputController.prototype.focusHandler = function (event) {
  19259. //不再显示竖线,并且输入框显示最开始
  19260. if (!this._isFocus) {
  19261. this._isFocus = true;
  19262. if (!event["showing"]) {
  19263. this._text.$isTyping = true;
  19264. }
  19265. this._text.$invalidateContentBounds();
  19266. this._text.dispatchEvent(new egret.FocusEvent(egret.FocusEvent.FOCUS_IN, true));
  19267. }
  19268. };
  19269. /**
  19270. * @private
  19271. *
  19272. * @param event
  19273. */
  19274. InputController.prototype.blurHandler = function (event) {
  19275. if (this._isFocus) {
  19276. //不再显示竖线,并且输入框显示最开始
  19277. this._isFocus = false;
  19278. this.tempStage.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onStageDownHandler, this);
  19279. this._text.$isTyping = false;
  19280. this._text.$invalidateContentBounds();
  19281. //失去焦点后调用
  19282. this.stageText.$onBlur();
  19283. this._text.dispatchEvent(new egret.FocusEvent(egret.FocusEvent.FOCUS_OUT, true));
  19284. }
  19285. };
  19286. //点中文本
  19287. InputController.prototype.onMouseDownHandler = function (event) {
  19288. this.$onFocus();
  19289. };
  19290. InputController.prototype.$onFocus = function () {
  19291. var self = this;
  19292. if (!this._text.visible) {
  19293. return;
  19294. }
  19295. if (this._isFocus) {
  19296. return;
  19297. }
  19298. this.tempStage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onStageDownHandler, this);
  19299. //强制更新输入框位置
  19300. this.stageText.$show();
  19301. };
  19302. //未点中文本
  19303. InputController.prototype.onStageDownHandler = function (event) {
  19304. if (event.$target != this._text) {
  19305. this.stageText.$hide();
  19306. }
  19307. };
  19308. /**
  19309. * @private
  19310. *
  19311. * @param event
  19312. */
  19313. InputController.prototype.updateTextHandler = function (event) {
  19314. var values = this._text.$TextField;
  19315. var textValue = this.stageText.$getText();
  19316. var isChanged = false;
  19317. var reg;
  19318. var result;
  19319. if (values[35 /* restrictAnd */] != null) {
  19320. reg = new RegExp("[" + values[35 /* restrictAnd */] + "]", "g");
  19321. result = textValue.match(reg);
  19322. if (result) {
  19323. textValue = result.join("");
  19324. }
  19325. else {
  19326. textValue = "";
  19327. }
  19328. isChanged = true;
  19329. }
  19330. if (values[36 /* restrictNot */] != null) {
  19331. reg = new RegExp("[^" + values[36 /* restrictNot */] + "]", "g");
  19332. result = textValue.match(reg);
  19333. if (result) {
  19334. textValue = result.join("");
  19335. }
  19336. else {
  19337. textValue = "";
  19338. }
  19339. isChanged = true;
  19340. }
  19341. if (isChanged && this.stageText.$getText() != textValue) {
  19342. this.stageText.$setText(textValue);
  19343. }
  19344. this.resetText();
  19345. //抛出change事件
  19346. this._text.dispatchEvent(new egret.Event(egret.Event.CHANGE, true));
  19347. };
  19348. /**
  19349. * @private
  19350. *
  19351. */
  19352. InputController.prototype.resetText = function () {
  19353. this._text.$setBaseText(this.stageText.$getText());
  19354. };
  19355. /**
  19356. * @private
  19357. *
  19358. */
  19359. InputController.prototype._hideInput = function () {
  19360. this.stageText.$removeFromStage();
  19361. };
  19362. /**
  19363. * @private
  19364. *
  19365. */
  19366. InputController.prototype.updateInput = function () {
  19367. if (!this._text.$visible && this.stageText) {
  19368. this._hideInput();
  19369. }
  19370. };
  19371. /**
  19372. * @private
  19373. *
  19374. */
  19375. InputController.prototype._updateProperties = function () {
  19376. if (this._isFocus) {
  19377. //整体修改
  19378. this.stageText.$resetStageText();
  19379. this.updateInput();
  19380. return;
  19381. }
  19382. var stage = this._text.$stage;
  19383. if (stage == null) {
  19384. }
  19385. else {
  19386. var item = this._text;
  19387. var visible = item.$visible;
  19388. while (true) {
  19389. if (!visible) {
  19390. break;
  19391. }
  19392. item = item.parent;
  19393. if (item == stage) {
  19394. break;
  19395. }
  19396. visible = item.$visible;
  19397. }
  19398. }
  19399. this.stageText.$setText(this._text.$TextField[13 /* text */]);
  19400. //整体修改
  19401. this.stageText.$resetStageText();
  19402. this.updateInput();
  19403. };
  19404. return InputController;
  19405. }(egret.HashObject));
  19406. egret.InputController = InputController;
  19407. __reflect(InputController.prototype, "egret.InputController");
  19408. })(egret || (egret = {}));
  19409. //////////////////////////////////////////////////////////////////////////////////////
  19410. //
  19411. // Copyright (c) 2014-present, Egret Technology.
  19412. // All rights reserved.
  19413. // Redistribution and use in source and binary forms, with or without
  19414. // modification, are permitted provided that the following conditions are met:
  19415. //
  19416. // * Redistributions of source code must retain the above copyright
  19417. // notice, this list of conditions and the following disclaimer.
  19418. // * Redistributions in binary form must reproduce the above copyright
  19419. // notice, this list of conditions and the following disclaimer in the
  19420. // documentation and/or other materials provided with the distribution.
  19421. // * Neither the name of the Egret nor the
  19422. // names of its contributors may be used to endorse or promote products
  19423. // derived from this software without specific prior written permission.
  19424. //
  19425. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  19426. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19427. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  19428. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  19429. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  19430. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  19431. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  19432. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  19433. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  19434. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19435. //
  19436. //////////////////////////////////////////////////////////////////////////////////////
  19437. var egret;
  19438. (function (egret) {
  19439. })(egret || (egret = {}));
  19440. //////////////////////////////////////////////////////////////////////////////////////
  19441. //
  19442. // Copyright (c) 2014-present, Egret Technology.
  19443. // All rights reserved.
  19444. // Redistribution and use in source and binary forms, with or without
  19445. // modification, are permitted provided that the following conditions are met:
  19446. //
  19447. // * Redistributions of source code must retain the above copyright
  19448. // notice, this list of conditions and the following disclaimer.
  19449. // * Redistributions in binary form must reproduce the above copyright
  19450. // notice, this list of conditions and the following disclaimer in the
  19451. // documentation and/or other materials provided with the distribution.
  19452. // * Neither the name of the Egret nor the
  19453. // names of its contributors may be used to endorse or promote products
  19454. // derived from this software without specific prior written permission.
  19455. //
  19456. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  19457. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19458. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  19459. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  19460. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  19461. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  19462. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  19463. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  19464. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  19465. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19466. //
  19467. //////////////////////////////////////////////////////////////////////////////////////
  19468. var egret;
  19469. (function (egret) {
  19470. var SplitRegex = new RegExp("(?=[\\u00BF-\\u1FFF\\u2C00-\\uD7FF]|\\b|\\s)(?![。,!、》…))}”】\\.\\,\\!\\?\\]\\:])");
  19471. /**
  19472. * @private
  19473. * 根据样式测量文本宽度
  19474. */
  19475. function measureTextWidth(text, values, style) {
  19476. style = style || {};
  19477. var italic = style.italic == null ? values[16 /* italic */] : style.italic;
  19478. var bold = style.bold == null ? values[15 /* bold */] : style.bold;
  19479. var size = style.size == null ? values[0 /* fontSize */] : style.size;
  19480. var fontFamily = style.fontFamily || values[8 /* fontFamily */] || TextField.default_fontFamily;
  19481. return egret.sys.measureText(text, fontFamily, size, bold, italic);
  19482. }
  19483. /**
  19484. * @language en_US
  19485. * TextField is the text rendering class of egret. It conducts rendering by using the browser / device API. Due to different ways of font rendering in different browsers / devices, there may be differences in the rendering
  19486. * If developers expect no differences among all platforms, please use BitmapText
  19487. * @see http://edn.egret.com/cn/docs/page/141 Create Text
  19488. *
  19489. * @event egret.Event.CHANGE Dispatched when entering text user input。
  19490. * @event egret.FocusEvent.FOCUS_IN Dispatched after the focus to enter text.
  19491. * @event egret.FocusEvent.FOCUS_OUT Enter the text loses focus after dispatch.
  19492. * @version Egret 2.4
  19493. * @platform Web,Native
  19494. * @includeExample egret/text/TextField.ts
  19495. */
  19496. /**
  19497. * @language zh_CN
  19498. * TextField是egret的文本渲染类,采用浏览器/设备的API进行渲染,在不同的浏览器/设备中由于字体渲染方式不一,可能会有渲染差异
  19499. * 如果开发者希望所有平台完全无差异,请使用BitmapText
  19500. * @see http://edn.egret.com/cn/docs/page/141 创建文本
  19501. *
  19502. * @event egret.Event.CHANGE 输入文本有用户输入时调度。
  19503. * @event egret.FocusEvent.FOCUS_IN 聚焦输入文本后调度。
  19504. * @event egret.FocusEvent.FOCUS_OUT 输入文本失去焦点后调度。
  19505. * @version Egret 2.4
  19506. * @platform Web,Native
  19507. * @includeExample egret/text/TextField.ts
  19508. */
  19509. var TextField = (function (_super) {
  19510. __extends(TextField, _super);
  19511. /**
  19512. * @version Egret 2.4
  19513. * @platform Web,Native
  19514. */
  19515. function TextField() {
  19516. var _this = _super.call(this) || this;
  19517. _this.$inputEnabled = false;
  19518. /**
  19519. * @private
  19520. */
  19521. _this.inputUtils = null;
  19522. /**
  19523. * @private
  19524. */
  19525. _this.graphicsNode = null;
  19526. /**
  19527. * @private
  19528. */
  19529. _this.isFlow = false;
  19530. /**
  19531. * @private
  19532. */
  19533. _this.textArr = [];
  19534. /**
  19535. * @private
  19536. */
  19537. _this.linesArr = [];
  19538. /**
  19539. * @private
  19540. */
  19541. _this.$isTyping = false;
  19542. var textNode = new egret.sys.TextNode();
  19543. textNode.fontFamily = TextField.default_fontFamily;
  19544. _this.textNode = textNode;
  19545. _this.$renderNode = textNode;
  19546. _this.$TextField = {
  19547. 0: TextField.default_size,
  19548. 1: 0,
  19549. 2: TextField.default_textColor,
  19550. 3: NaN,
  19551. 4: NaN,
  19552. 5: 0,
  19553. 6: 0,
  19554. 7: 0,
  19555. 8: TextField.default_fontFamily,
  19556. 9: "left",
  19557. 10: "top",
  19558. 11: "#ffffff",
  19559. 12: "",
  19560. 13: "",
  19561. 14: [],
  19562. 15: false,
  19563. 16: false,
  19564. 17: true,
  19565. 18: false,
  19566. 19: false,
  19567. 20: false,
  19568. 21: 0,
  19569. 22: 0,
  19570. 23: 0,
  19571. 24: egret.TextFieldType.DYNAMIC,
  19572. 25: 0x000000,
  19573. 26: "#000000",
  19574. 27: 0,
  19575. 28: -1,
  19576. 29: 0,
  19577. 30: false,
  19578. 31: false,
  19579. 32: 0x000000,
  19580. 33: false,
  19581. 34: 0xffffff,
  19582. 35: null,
  19583. 36: null,
  19584. 37: egret.TextFieldInputType.TEXT //inputType
  19585. };
  19586. return _this;
  19587. }
  19588. /**
  19589. * @private
  19590. */
  19591. TextField.prototype.isInput = function () {
  19592. return this.$TextField[24 /* type */] == egret.TextFieldType.INPUT;
  19593. };
  19594. TextField.prototype.$setTouchEnabled = function (value) {
  19595. var result = _super.prototype.$setTouchEnabled.call(this, value);
  19596. if (this.isInput()) {
  19597. this.$inputEnabled = true;
  19598. }
  19599. return result;
  19600. };
  19601. Object.defineProperty(TextField.prototype, "fontFamily", {
  19602. /**
  19603. * @language en_US
  19604. * The name of the font to use, or a comma-separated list of font names.
  19605. * @default "Arial"
  19606. * @version Egret 2.4
  19607. * @platform Web,Native
  19608. */
  19609. /**
  19610. * @language zh_CN
  19611. * 要使用的字体的名称或用逗号分隔的字体名称列表。
  19612. * @default "Arial"
  19613. * @version Egret 2.4
  19614. * @platform Web,Native
  19615. */
  19616. get: function () {
  19617. return this.$TextField[8 /* fontFamily */];
  19618. },
  19619. set: function (value) {
  19620. this.$setFontFamily(value);
  19621. },
  19622. enumerable: true,
  19623. configurable: true
  19624. });
  19625. TextField.prototype.$setFontFamily = function (value) {
  19626. var values = this.$TextField;
  19627. if (values[8 /* fontFamily */] == value) {
  19628. return false;
  19629. }
  19630. values[8 /* fontFamily */] = value;
  19631. this.invalidateFontString();
  19632. return true;
  19633. };
  19634. Object.defineProperty(TextField.prototype, "size", {
  19635. /**
  19636. * @language en_US
  19637. * The size in pixels of text
  19638. * @default 30
  19639. * @version Egret 2.4
  19640. * @platform Web,Native
  19641. */
  19642. /**
  19643. * @language zh_CN
  19644. * 文本的字号大小。
  19645. * @default 30
  19646. * @version Egret 2.4
  19647. * @platform Web,Native
  19648. */
  19649. get: function () {
  19650. return this.$TextField[0 /* fontSize */];
  19651. },
  19652. set: function (value) {
  19653. this.$setSize(value);
  19654. },
  19655. enumerable: true,
  19656. configurable: true
  19657. });
  19658. TextField.prototype.$setSize = function (value) {
  19659. value = +value || 0;
  19660. var values = this.$TextField;
  19661. if (values[0 /* fontSize */] == value) {
  19662. return false;
  19663. }
  19664. values[0 /* fontSize */] = value;
  19665. this.invalidateFontString();
  19666. return true;
  19667. };
  19668. Object.defineProperty(TextField.prototype, "bold", {
  19669. /**
  19670. * @language en_US
  19671. * Specifies whether the text is boldface.
  19672. * @default false
  19673. * @version Egret 2.4
  19674. * @platform Web,Native
  19675. */
  19676. /**
  19677. * @language zh_CN
  19678. * 是否显示为粗体。
  19679. * @default false
  19680. * @version Egret 2.4
  19681. * @platform Web,Native
  19682. */
  19683. get: function () {
  19684. return this.$TextField[15 /* bold */];
  19685. },
  19686. set: function (value) {
  19687. this.$setBold(value);
  19688. },
  19689. enumerable: true,
  19690. configurable: true
  19691. });
  19692. TextField.prototype.$setBold = function (value) {
  19693. value = !!value;
  19694. var values = this.$TextField;
  19695. if (value == values[15 /* bold */]) {
  19696. return false;
  19697. }
  19698. values[15 /* bold */] = value;
  19699. this.invalidateFontString();
  19700. return true;
  19701. };
  19702. Object.defineProperty(TextField.prototype, "italic", {
  19703. /**
  19704. * @language en_US
  19705. * Determines whether the text is italic font.
  19706. * @default false
  19707. * @version Egret 2.4
  19708. * @platform Web,Native
  19709. */
  19710. /**
  19711. * @language zh_CN
  19712. * 是否显示为斜体。
  19713. * @default false
  19714. * @version Egret 2.4
  19715. * @platform Web,Native
  19716. */
  19717. get: function () {
  19718. return this.$TextField[16 /* italic */];
  19719. },
  19720. set: function (value) {
  19721. this.$setItalic(value);
  19722. },
  19723. enumerable: true,
  19724. configurable: true
  19725. });
  19726. TextField.prototype.$setItalic = function (value) {
  19727. value = !!value;
  19728. var values = this.$TextField;
  19729. if (value == values[16 /* italic */]) {
  19730. return false;
  19731. }
  19732. values[16 /* italic */] = value;
  19733. this.invalidateFontString();
  19734. return true;
  19735. };
  19736. /**
  19737. * @private
  19738. *
  19739. */
  19740. TextField.prototype.invalidateFontString = function () {
  19741. this.$TextField[17 /* fontStringChanged */] = true;
  19742. this.$invalidateTextField();
  19743. };
  19744. Object.defineProperty(TextField.prototype, "textAlign", {
  19745. /**
  19746. * @language en_US
  19747. * Horizontal alignment of text.
  19748. * @default:egret.HorizontalAlign.LEFT
  19749. * @version Egret 2.4
  19750. * @platform Web,Native
  19751. */
  19752. /**
  19753. * @language zh_CN
  19754. * 文本的水平对齐方式。
  19755. * @default:egret.HorizontalAlign.LEFT
  19756. * @version Egret 2.4
  19757. * @platform Web,Native
  19758. */
  19759. get: function () {
  19760. return this.$TextField[9 /* textAlign */];
  19761. },
  19762. set: function (value) {
  19763. this.$setTextAlign(value);
  19764. },
  19765. enumerable: true,
  19766. configurable: true
  19767. });
  19768. TextField.prototype.$setTextAlign = function (value) {
  19769. var values = this.$TextField;
  19770. if (values[9 /* textAlign */] == value) {
  19771. return false;
  19772. }
  19773. values[9 /* textAlign */] = value;
  19774. this.$invalidateTextField();
  19775. return true;
  19776. };
  19777. Object.defineProperty(TextField.prototype, "verticalAlign", {
  19778. /**
  19779. * @language en_US
  19780. * Vertical alignment of text.
  19781. * @default:egret.VerticalAlign.TOP
  19782. * @version Egret 2.4
  19783. * @platform Web,Native
  19784. */
  19785. /**
  19786. * @language zh_CN
  19787. * 文字的垂直对齐方式。
  19788. * @default:egret.VerticalAlign.TOP
  19789. * @version Egret 2.4
  19790. * @platform Web,Native
  19791. */
  19792. get: function () {
  19793. return this.$TextField[10 /* verticalAlign */];
  19794. },
  19795. set: function (value) {
  19796. this.$setVerticalAlign(value);
  19797. },
  19798. enumerable: true,
  19799. configurable: true
  19800. });
  19801. TextField.prototype.$setVerticalAlign = function (value) {
  19802. var values = this.$TextField;
  19803. if (values[10 /* verticalAlign */] == value) {
  19804. return false;
  19805. }
  19806. values[10 /* verticalAlign */] = value;
  19807. this.$invalidateTextField();
  19808. return true;
  19809. };
  19810. Object.defineProperty(TextField.prototype, "lineSpacing", {
  19811. /**
  19812. * @language en_US
  19813. * An integer representing the amount of vertical space between lines.
  19814. * @default 0
  19815. * @version Egret 2.4
  19816. * @platform Web,Native
  19817. */
  19818. /**
  19819. * @language zh_CN
  19820. * 一个整数,表示行与行之间的垂直间距量
  19821. * @default 0
  19822. * @version Egret 2.4
  19823. * @platform Web,Native
  19824. */
  19825. get: function () {
  19826. return this.$TextField[1 /* lineSpacing */];
  19827. },
  19828. set: function (value) {
  19829. this.$setLineSpacing(value);
  19830. },
  19831. enumerable: true,
  19832. configurable: true
  19833. });
  19834. TextField.prototype.$setLineSpacing = function (value) {
  19835. value = +value || 0;
  19836. var values = this.$TextField;
  19837. if (values[1 /* lineSpacing */] == value)
  19838. return false;
  19839. values[1 /* lineSpacing */] = value;
  19840. this.$invalidateTextField();
  19841. return true;
  19842. };
  19843. Object.defineProperty(TextField.prototype, "textColor", {
  19844. /**
  19845. * @language en_US
  19846. * Color of the text.
  19847. * @default 0x000000
  19848. * @version Egret 2.4
  19849. * @platform Web,Native
  19850. */
  19851. /**
  19852. * @language zh_CN
  19853. * 文本颜色
  19854. * @default 0x000000
  19855. * @version Egret 2.4
  19856. * @platform Web,Native
  19857. */
  19858. get: function () {
  19859. return this.$TextField[2 /* textColor */];
  19860. },
  19861. set: function (value) {
  19862. this.$setTextColor(value);
  19863. },
  19864. enumerable: true,
  19865. configurable: true
  19866. });
  19867. TextField.prototype.$setTextColor = function (value) {
  19868. value = +value | 0;
  19869. var values = this.$TextField;
  19870. if (values[2 /* textColor */] == value) {
  19871. return false;
  19872. }
  19873. values[2 /* textColor */] = value;
  19874. if (this.inputUtils) {
  19875. this.inputUtils._setColor(this.$TextField[2 /* textColor */]);
  19876. }
  19877. this.$invalidate();
  19878. return true;
  19879. };
  19880. Object.defineProperty(TextField.prototype, "wordWrap", {
  19881. /**
  19882. * @language en_US
  19883. * A Boolean value that indicates whether the text field word wrap. If the value is true, then the text field by word wrap;
  19884. * if the value is false, the text field by newline characters.
  19885. * @default false
  19886. * @version Egret 2.4
  19887. * @platform Web,Native
  19888. */
  19889. /**
  19890. * @language zh_CN
  19891. * 一个布尔值,表示文本字段是否按单词换行。如果值为 true,则该文本字段按单词换行;
  19892. * 如果值为 false,则该文本字段按字符换行。
  19893. * @default false
  19894. * @version Egret 2.4
  19895. * @platform Web,Native
  19896. */
  19897. get: function () {
  19898. return this.$TextField[19 /* wordWrap */];
  19899. },
  19900. set: function (value) {
  19901. this.$setWordWrap(value);
  19902. },
  19903. enumerable: true,
  19904. configurable: true
  19905. });
  19906. TextField.prototype.$setWordWrap = function (value) {
  19907. value = !!value;
  19908. var values = this.$TextField;
  19909. if (value == values[19 /* wordWrap */]) {
  19910. return;
  19911. }
  19912. if (values[20 /* displayAsPassword */]) {
  19913. return;
  19914. }
  19915. values[19 /* wordWrap */] = value;
  19916. this.$invalidateTextField();
  19917. };
  19918. Object.defineProperty(TextField.prototype, "type", {
  19919. /**
  19920. * @version Egret 2.4
  19921. * @platform Web,Native
  19922. */
  19923. get: function () {
  19924. return this.$TextField[24 /* type */];
  19925. },
  19926. /**
  19927. * @language en_US
  19928. * Type of the text field.
  19929. * Any one of the following TextFieldType constants: TextFieldType.DYNAMIC (specifies the dynamic text field that users can not edit), or TextFieldType.INPUT (specifies the dynamic text field that users can edit).
  19930. * @default egret.TextFieldType.DYNAMIC
  19931. */
  19932. /**
  19933. * @language zh_CN
  19934. * 文本字段的类型。
  19935. * 以下 TextFieldType 常量中的任一个:TextFieldType.DYNAMIC(指定用户无法编辑的动态文本字段),或 TextFieldType.INPUT(指定用户可以编辑的输入文本字段)。
  19936. * @default egret.TextFieldType.DYNAMIC
  19937. */
  19938. set: function (value) {
  19939. this.$setType(value);
  19940. },
  19941. enumerable: true,
  19942. configurable: true
  19943. });
  19944. /**
  19945. * @private
  19946. *
  19947. * @param value
  19948. */
  19949. TextField.prototype.$setType = function (value) {
  19950. var values = this.$TextField;
  19951. if (values[24 /* type */] != value) {
  19952. values[24 /* type */] = value;
  19953. if (value == egret.TextFieldType.INPUT) {
  19954. if (isNaN(values[3 /* textFieldWidth */])) {
  19955. this.$setWidth(100);
  19956. }
  19957. if (isNaN(values[4 /* textFieldHeight */])) {
  19958. this.$setHeight(30);
  19959. }
  19960. this.$setTouchEnabled(true);
  19961. //创建stageText
  19962. if (this.inputUtils == null) {
  19963. this.inputUtils = new egret.InputController();
  19964. }
  19965. this.inputUtils.init(this);
  19966. this.$invalidateTextField();
  19967. if (this.$stage) {
  19968. this.inputUtils._addStageText();
  19969. }
  19970. }
  19971. else {
  19972. if (this.inputUtils) {
  19973. this.inputUtils._removeStageText();
  19974. this.inputUtils = null;
  19975. }
  19976. this.$setTouchEnabled(false);
  19977. }
  19978. return true;
  19979. }
  19980. return false;
  19981. };
  19982. Object.defineProperty(TextField.prototype, "inputType", {
  19983. /**
  19984. * @version Egret 3.1.2
  19985. * @platform Web,Native
  19986. */
  19987. get: function () {
  19988. return this.$TextField[37 /* inputType */];
  19989. },
  19990. /**
  19991. * @language en_US
  19992. * Pop-up keyboard type.
  19993. * Any of a TextFieldInputType constants.
  19994. */
  19995. /**
  19996. * @language zh_CN
  19997. * 弹出键盘的类型。
  19998. * TextFieldInputType 常量中的任一个。
  19999. */
  20000. set: function (value) {
  20001. this.$TextField[37 /* inputType */] = value;
  20002. },
  20003. enumerable: true,
  20004. configurable: true
  20005. });
  20006. Object.defineProperty(TextField.prototype, "text", {
  20007. /**
  20008. * @version Egret 2.4
  20009. * @platform Web,Native
  20010. */
  20011. get: function () {
  20012. return this.$getText();
  20013. },
  20014. /**
  20015. * @language en_US
  20016. * Serve as a string of the current text field in the text
  20017. */
  20018. /**
  20019. * @language zh_CN
  20020. * 作为文本字段中当前文本的字符串
  20021. */
  20022. set: function (value) {
  20023. this.$setText(value);
  20024. },
  20025. enumerable: true,
  20026. configurable: true
  20027. });
  20028. /**
  20029. * @private
  20030. *
  20031. * @returns
  20032. */
  20033. TextField.prototype.$getText = function () {
  20034. if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) {
  20035. return this.inputUtils._getText();
  20036. }
  20037. return this.$TextField[13 /* text */];
  20038. };
  20039. /**
  20040. * @private
  20041. *
  20042. * @param value
  20043. */
  20044. TextField.prototype.$setBaseText = function (value) {
  20045. if (value == null) {
  20046. value = "";
  20047. }
  20048. value = value.toString();
  20049. this.isFlow = false;
  20050. var values = this.$TextField;
  20051. if (values[13 /* text */] != value) {
  20052. this.$invalidateTextField();
  20053. values[13 /* text */] = value;
  20054. var text = "";
  20055. if (values[20 /* displayAsPassword */]) {
  20056. text = this.changeToPassText(value);
  20057. }
  20058. else {
  20059. text = value;
  20060. }
  20061. this.setMiddleStyle([{ text: text }]);
  20062. return true;
  20063. }
  20064. return false;
  20065. };
  20066. /**
  20067. * @private
  20068. *
  20069. * @param value
  20070. */
  20071. TextField.prototype.$setText = function (value) {
  20072. if (value == null) {
  20073. value = "";
  20074. }
  20075. var result = this.$setBaseText(value);
  20076. if (this.inputUtils) {
  20077. this.inputUtils._setText(this.$TextField[13 /* text */]);
  20078. }
  20079. return result;
  20080. };
  20081. Object.defineProperty(TextField.prototype, "displayAsPassword", {
  20082. /**
  20083. * @language en_US
  20084. * Specify whether the text field is a password text field.
  20085. * If the value of this property is true, the text field is treated as a password text field and hides the input characters using asterisks instead of the actual characters. If false, the text field is not treated as a password text field.
  20086. * @default false
  20087. */
  20088. /**
  20089. * @language zh_CN
  20090. * 指定文本字段是否是密码文本字段。
  20091. * 如果此属性的值为 true,则文本字段被视为密码文本字段,并使用星号而不是实际字符来隐藏输入的字符。如果为 false,则不会将文本字段视为密码文本字段。
  20092. * @default false
  20093. */
  20094. get: function () {
  20095. return this.$TextField[20 /* displayAsPassword */];
  20096. },
  20097. set: function (value) {
  20098. this.$setDisplayAsPassword(value);
  20099. },
  20100. enumerable: true,
  20101. configurable: true
  20102. });
  20103. /**
  20104. * @private
  20105. *
  20106. * @param value
  20107. */
  20108. TextField.prototype.$setDisplayAsPassword = function (value) {
  20109. var values = this.$TextField;
  20110. if (values[20 /* displayAsPassword */] != value) {
  20111. values[20 /* displayAsPassword */] = value;
  20112. this.$invalidateTextField();
  20113. var text = "";
  20114. if (value) {
  20115. text = this.changeToPassText(values[13 /* text */]);
  20116. }
  20117. else {
  20118. text = values[13 /* text */];
  20119. }
  20120. this.setMiddleStyle([{ text: text }]);
  20121. return true;
  20122. }
  20123. return false;
  20124. };
  20125. Object.defineProperty(TextField.prototype, "strokeColor", {
  20126. /**
  20127. * @version Egret 2.4
  20128. * @platform Web,Native
  20129. */
  20130. get: function () {
  20131. return this.$TextField[25 /* strokeColor */];
  20132. },
  20133. /**
  20134. * @language en_US
  20135. * Represent the stroke color of the text.
  20136. * Contain three 8-bit numbers with RGB color components; for example, 0xFF0000 is red, 0x00FF00 is green.
  20137. * @default 0x000000
  20138. */
  20139. /**
  20140. * @language zh_CN
  20141. * 表示文本的描边颜色。
  20142. * 包含三个 8 位 RGB 颜色成分的数字;例如,0xFF0000 为红色,0x00FF00 为绿色。
  20143. * @default 0x000000
  20144. */
  20145. set: function (value) {
  20146. value = +value || 0;
  20147. this.$setStrokeColor(value);
  20148. },
  20149. enumerable: true,
  20150. configurable: true
  20151. });
  20152. /**
  20153. * @private
  20154. *
  20155. * @param value
  20156. */
  20157. TextField.prototype.$setStrokeColor = function (value) {
  20158. var values = this.$TextField;
  20159. if (values[25 /* strokeColor */] != value) {
  20160. this.$invalidateTextField();
  20161. values[25 /* strokeColor */] = value;
  20162. values[26 /* strokeColorString */] = egret.toColorString(value);
  20163. return true;
  20164. }
  20165. return false;
  20166. };
  20167. Object.defineProperty(TextField.prototype, "stroke", {
  20168. /**
  20169. * @version Egret 2.4
  20170. * @platform Web,Native
  20171. */
  20172. get: function () {
  20173. return this.$TextField[27 /* stroke */];
  20174. },
  20175. /**
  20176. * @language en_US
  20177. * Indicate the stroke width.
  20178. * 0 means no stroke.
  20179. * @default 0
  20180. */
  20181. /**
  20182. * @language zh_CN
  20183. * 表示描边宽度。
  20184. * 0为没有描边。
  20185. * @default 0
  20186. */
  20187. set: function (value) {
  20188. this.$setStroke(value);
  20189. },
  20190. enumerable: true,
  20191. configurable: true
  20192. });
  20193. /**
  20194. * @private
  20195. *
  20196. * @param value
  20197. */
  20198. TextField.prototype.$setStroke = function (value) {
  20199. if (this.$TextField[27 /* stroke */] != value) {
  20200. this.$invalidateTextField();
  20201. this.$TextField[27 /* stroke */] = value;
  20202. return true;
  20203. }
  20204. return false;
  20205. };
  20206. Object.defineProperty(TextField.prototype, "maxChars", {
  20207. /**
  20208. * @language en_US
  20209. * The maximum number of characters that the text field can contain, as entered by a user. \n A script can insert more text than maxChars allows; the maxChars property indicates only how much text a user can enter. If the value of this property is 0, a user can enter an unlimited amount of text.
  20210. * The default value is 0.
  20211. * @default 0
  20212. */
  20213. /**
  20214. * @language zh_CN
  20215. * 文本字段中最多可包含的字符数(即用户输入的字符数)。
  20216. * 脚本可以插入比 maxChars 允许的字符数更多的文本;maxChars 属性仅表示用户可以输入多少文本。如果此属性的值为 0,则用户可以输入无限数量的文本。
  20217. * @default 0
  20218. */
  20219. get: function () {
  20220. return this.$TextField[21 /* maxChars */];
  20221. },
  20222. set: function (value) {
  20223. this.$setMaxChars(value);
  20224. },
  20225. enumerable: true,
  20226. configurable: true
  20227. });
  20228. /**
  20229. * @private
  20230. *
  20231. * @param value
  20232. */
  20233. TextField.prototype.$setMaxChars = function (value) {
  20234. if (this.$TextField[21 /* maxChars */] != value) {
  20235. this.$TextField[21 /* maxChars */] = value;
  20236. return true;
  20237. }
  20238. return false;
  20239. };
  20240. Object.defineProperty(TextField.prototype, "scrollV", {
  20241. /**
  20242. * @version Egret 2.4
  20243. * @platform Web,Native
  20244. */
  20245. get: function () {
  20246. return Math.min(Math.max(this.$TextField[28 /* scrollV */], 1), this.maxScrollV);
  20247. },
  20248. /**
  20249. * @language en_US
  20250. * Vertical position of text in a text field. scrollV property helps users locate specific passages in a long article, and create scrolling text fields.
  20251. * Vertically scrolling units are lines, and horizontal scrolling unit is pixels.
  20252. * If the first displayed line is the first line in the text field, scrollV is set to 1 (instead of 0).
  20253. */
  20254. /**
  20255. * @language zh_CN
  20256. * 文本在文本字段中的垂直位置。scrollV 属性可帮助用户定位到长篇文章的特定段落,还可用于创建滚动文本字段。
  20257. * 垂直滚动的单位是行,而水平滚动的单位是像素。
  20258. * 如果显示的第一行是文本字段中的第一行,则 scrollV 设置为 1(而非 0)。
  20259. */
  20260. set: function (value) {
  20261. this.$TextField[28 /* scrollV */] = Math.max(value, 1);
  20262. this.$invalidateTextField();
  20263. },
  20264. enumerable: true,
  20265. configurable: true
  20266. });
  20267. Object.defineProperty(TextField.prototype, "maxScrollV", {
  20268. /**
  20269. * @language en_US
  20270. * The maximum value of scrollV
  20271. * @version Egret 2.4
  20272. * @platform Web,Native
  20273. */
  20274. /**
  20275. * @language zh_CN
  20276. * scrollV 的最大值
  20277. * @version Egret 2.4
  20278. * @platform Web,Native
  20279. */
  20280. get: function () {
  20281. this.$getLinesArr();
  20282. return Math.max(this.$TextField[29 /* numLines */] - egret.TextFieldUtils.$getScrollNum(this) + 1, 1);
  20283. },
  20284. enumerable: true,
  20285. configurable: true
  20286. });
  20287. Object.defineProperty(TextField.prototype, "selectionBeginIndex", {
  20288. /**
  20289. * @private
  20290. * @version Egret 2.4
  20291. * @platform Web,Native
  20292. */
  20293. get: function () {
  20294. return 0;
  20295. },
  20296. enumerable: true,
  20297. configurable: true
  20298. });
  20299. Object.defineProperty(TextField.prototype, "selectionEndIndex", {
  20300. /**
  20301. * @private
  20302. * @version Egret 2.4
  20303. * @platform Web,Native
  20304. */
  20305. get: function () {
  20306. return 0;
  20307. },
  20308. enumerable: true,
  20309. configurable: true
  20310. });
  20311. Object.defineProperty(TextField.prototype, "caretIndex", {
  20312. /**
  20313. * @private
  20314. * @version Egret 2.4
  20315. * @platform Web,Native
  20316. */
  20317. get: function () {
  20318. return 0;
  20319. },
  20320. enumerable: true,
  20321. configurable: true
  20322. });
  20323. /**
  20324. * @private
  20325. *
  20326. * @param beginIndex
  20327. * @param endIndex
  20328. */
  20329. TextField.prototype.$setSelection = function (beginIndex, endIndex) {
  20330. return false;
  20331. };
  20332. /**
  20333. * @private
  20334. *
  20335. * @returns
  20336. */
  20337. TextField.prototype.$getLineHeight = function () {
  20338. return this.$TextField[1 /* lineSpacing */] + this.$TextField[0 /* fontSize */];
  20339. };
  20340. Object.defineProperty(TextField.prototype, "numLines", {
  20341. /**
  20342. * @language en_US
  20343. * Number of lines of text.
  20344. * @version Egret 2.4
  20345. * @platform Web,Native
  20346. */
  20347. /**
  20348. * @language zh_CN
  20349. * 文本行数。
  20350. * @version Egret 2.4
  20351. * @platform Web,Native
  20352. */
  20353. get: function () {
  20354. this.$getLinesArr();
  20355. return this.$TextField[29 /* numLines */];
  20356. },
  20357. enumerable: true,
  20358. configurable: true
  20359. });
  20360. Object.defineProperty(TextField.prototype, "multiline", {
  20361. get: function () {
  20362. return this.$TextField[30 /* multiline */];
  20363. },
  20364. /**
  20365. * @language en_US
  20366. * Indicate whether field is a multiline text field. Note that this property is valid only when the type is TextFieldType.INPUT.
  20367. * If the value is true, the text field is multiline; if the value is false, the text field is a single-line text field. In a field of type TextFieldType.INPUT, the multiline value determines whether the Enter key creates a new line (a value of false, and the Enter key is ignored).
  20368. * @default false
  20369. */
  20370. /**
  20371. * @language zh_CN
  20372. * 表示字段是否为多行文本字段。注意,此属性仅在type为TextFieldType.INPUT时才有效。
  20373. * 如果值为 true,则文本字段为多行文本字段;如果值为 false,则文本字段为单行文本字段。在类型为 TextFieldType.INPUT 的字段中,multiline 值将确定 Enter 键是否创建新行(如果值为 false,则将忽略 Enter 键)。
  20374. * @default false
  20375. */
  20376. set: function (value) {
  20377. this.$setMultiline(value);
  20378. },
  20379. enumerable: true,
  20380. configurable: true
  20381. });
  20382. /**
  20383. * @private
  20384. *
  20385. * @param value
  20386. */
  20387. TextField.prototype.$setMultiline = function (value) {
  20388. this.$TextField[30 /* multiline */] = value;
  20389. this.$invalidateTextField();
  20390. return true;
  20391. };
  20392. Object.defineProperty(TextField.prototype, "restrict", {
  20393. get: function () {
  20394. var values = this.$TextField;
  20395. var str = null;
  20396. if (values[35 /* restrictAnd */] != null) {
  20397. str = values[35 /* restrictAnd */];
  20398. }
  20399. if (values[36 /* restrictNot */] != null) {
  20400. if (str == null) {
  20401. str = "";
  20402. }
  20403. str += "^" + values[36 /* restrictNot */];
  20404. }
  20405. return str;
  20406. },
  20407. /**
  20408. * @language en_US
  20409. * Indicates a user can enter into the text field character set. If you restrict property is null, you can enter any character. If you restrict property is an empty string, you can not enter any character. If you restrict property is a string of characters, you can enter only characters in the string in the text field. The string is scanned from left to right. You can use a hyphen (-) to specify a range. Only restricts user interaction; a script may put any text into the text field. <br/>
  20410. * If the string of characters caret (^) at the beginning, all characters are initially accepted, then the string are excluded from receiving ^ character. If the string does not begin with a caret (^) to, any characters are initially accepted and then a string of characters included in the set of accepted characters. <br/>
  20411. * The following example allows only uppercase characters, spaces, and numbers in the text field: <br/>
  20412. * My_txt.restrict = "A-Z 0-9"; <br/>
  20413. * The following example includes all characters except lowercase letters: <br/>
  20414. * My_txt.restrict = "^ a-z"; <br/>
  20415. * If you need to enter characters \ ^, use two backslash "\\ -" "\\ ^": <br/>
  20416. * Can be used anywhere in the string ^ to rule out including characters and switch between characters, but can only be used to exclude a ^. The following code includes only uppercase letters except uppercase Q: <br/>
  20417. * My_txt.restrict = "A-Z ^ Q"; <br/>
  20418. * @version Egret 2.4
  20419. * @platform Web,Native
  20420. * @default null
  20421. */
  20422. /**
  20423. * @language zh_CN
  20424. * 表示用户可输入到文本字段中的字符集。如果 restrict 属性的值为 null,则可以输入任何字符。如果 restrict 属性的值为空字符串,则不能输入任何字符。如果 restrict 属性的值为一串字符,则只能在文本字段中输入该字符串中的字符。从左向右扫描该字符串。可以使用连字符 (-) 指定一个范围。只限制用户交互;脚本可将任何文本放入文本字段中。<br/>
  20425. * 如果字符串以尖号 (^) 开头,则先接受所有字符,然后从接受字符集中排除字符串中 ^ 之后的字符。如果字符串不以尖号 (^) 开头,则最初不接受任何字符,然后将字符串中的字符包括在接受字符集中。<br/>
  20426. * 下例仅允许在文本字段中输入大写字符、空格和数字:<br/>
  20427. * my_txt.restrict = "A-Z 0-9";<br/>
  20428. * 下例包含除小写字母之外的所有字符:<br/>
  20429. * my_txt.restrict = "^a-z";<br/>
  20430. * 如果需要输入字符 \ ^,请使用2个反斜杠 "\\-" "\\^" :<br/>
  20431. * 可在字符串中的任何位置使用 ^,以在包含字符与排除字符之间进行切换,但是最多只能有一个 ^ 用来排除。下面的代码只包含除大写字母 Q 之外的大写字母:<br/>
  20432. * my_txt.restrict = "A-Z^Q";<br/>
  20433. * @version Egret 2.4
  20434. * @platform Web,Native
  20435. * @default null
  20436. */
  20437. set: function (value) {
  20438. var values = this.$TextField;
  20439. if (value == null) {
  20440. values[35 /* restrictAnd */] = null;
  20441. values[36 /* restrictNot */] = null;
  20442. }
  20443. else {
  20444. var index = -1;
  20445. while (index < value.length) {
  20446. index = value.indexOf("^", index);
  20447. if (index == 0) {
  20448. break;
  20449. }
  20450. else if (index > 0) {
  20451. if (value.charAt(index - 1) != "\\") {
  20452. break;
  20453. }
  20454. index++;
  20455. }
  20456. else {
  20457. break;
  20458. }
  20459. }
  20460. if (index == 0) {
  20461. values[35 /* restrictAnd */] = null;
  20462. values[36 /* restrictNot */] = value.substring(index + 1);
  20463. }
  20464. else if (index > 0) {
  20465. values[35 /* restrictAnd */] = value.substring(0, index);
  20466. values[36 /* restrictNot */] = value.substring(index + 1);
  20467. }
  20468. else {
  20469. values[35 /* restrictAnd */] = value;
  20470. values[36 /* restrictNot */] = null;
  20471. }
  20472. }
  20473. },
  20474. enumerable: true,
  20475. configurable: true
  20476. });
  20477. /**
  20478. * @private
  20479. *
  20480. * @param value
  20481. */
  20482. TextField.prototype.$setWidth = function (value) {
  20483. var values = this.$TextField;
  20484. if (isNaN(value)) {
  20485. if (isNaN(values[3 /* textFieldWidth */])) {
  20486. return false;
  20487. }
  20488. values[3 /* textFieldWidth */] = NaN;
  20489. }
  20490. else {
  20491. if (values[3 /* textFieldWidth */] == value) {
  20492. return false;
  20493. }
  20494. values[3 /* textFieldWidth */] = value;
  20495. }
  20496. value = +value;
  20497. if (value < 0) {
  20498. return false;
  20499. }
  20500. this.$invalidateTextField();
  20501. return true;
  20502. };
  20503. /**
  20504. * @private
  20505. *
  20506. * @param value
  20507. */
  20508. TextField.prototype.$setHeight = function (value) {
  20509. var values = this.$TextField;
  20510. if (isNaN(value)) {
  20511. if (isNaN(values[4 /* textFieldHeight */])) {
  20512. return false;
  20513. }
  20514. values[4 /* textFieldHeight */] = NaN;
  20515. }
  20516. else {
  20517. if (values[4 /* textFieldHeight */] == value) {
  20518. return false;
  20519. }
  20520. values[4 /* textFieldHeight */] = value;
  20521. }
  20522. value = +value;
  20523. if (value < 0) {
  20524. return false;
  20525. }
  20526. this.$invalidateTextField();
  20527. return true;
  20528. };
  20529. /**
  20530. * @private
  20531. * 获取显示宽度
  20532. */
  20533. TextField.prototype.$getWidth = function () {
  20534. var values = this.$TextField;
  20535. return isNaN(values[3 /* textFieldWidth */]) ? this.$getContentBounds().width : values[3 /* textFieldWidth */];
  20536. };
  20537. /**
  20538. * @private
  20539. * 获取显示宽度
  20540. */
  20541. TextField.prototype.$getHeight = function () {
  20542. var values = this.$TextField;
  20543. return isNaN(values[4 /* textFieldHeight */]) ? this.$getContentBounds().height : values[4 /* textFieldHeight */];
  20544. };
  20545. Object.defineProperty(TextField.prototype, "border", {
  20546. /**
  20547. * @version Egret 2.4
  20548. * @platform Web,Native
  20549. */
  20550. get: function () {
  20551. return this.$TextField[31 /* border */];
  20552. },
  20553. /**
  20554. * @language en_US
  20555. * Specifies whether the text field has a border.
  20556. * If true, the text field has a border. If false, the text field has no border.
  20557. * Use borderColor property to set the border color.
  20558. * @default false
  20559. */
  20560. /**
  20561. * @language zh_CN
  20562. * 指定文本字段是否具有边框。
  20563. * 如果为 true,则文本字段具有边框。如果为 false,则文本字段没有边框。
  20564. * 使用 borderColor 属性来设置边框颜色。
  20565. * @default false
  20566. */
  20567. set: function (value) {
  20568. this.$setBorder(value);
  20569. },
  20570. enumerable: true,
  20571. configurable: true
  20572. });
  20573. /**
  20574. * @private
  20575. */
  20576. TextField.prototype.$setBorder = function (value) {
  20577. this.$TextField[31 /* border */] = !!value;
  20578. this.$invalidate();
  20579. };
  20580. Object.defineProperty(TextField.prototype, "borderColor", {
  20581. /**
  20582. * @version Egret 2.4
  20583. * @platform Web,Native
  20584. */
  20585. get: function () {
  20586. return this.$TextField[32 /* borderColor */];
  20587. },
  20588. /**
  20589. * @language en_US
  20590. * The color of the text field border.
  20591. * Even currently is no border can be retrieved or set this property, but only if the text field has the border property is set to true, the color is visible.
  20592. * @default 0x000000
  20593. */
  20594. /**
  20595. * @language zh_CN
  20596. * 文本字段边框的颜色。
  20597. * 即使当前没有边框,也可检索或设置此属性,但只有当文本字段已将 border 属性设置为 true 时,才可以看到颜色。
  20598. * @default 0x000000
  20599. */
  20600. set: function (value) {
  20601. this.$setBorderColor(value);
  20602. },
  20603. enumerable: true,
  20604. configurable: true
  20605. });
  20606. /**
  20607. * @private
  20608. */
  20609. TextField.prototype.$setBorderColor = function (value) {
  20610. this.$TextField[32 /* borderColor */] = +value || 0;
  20611. this.$invalidate();
  20612. };
  20613. Object.defineProperty(TextField.prototype, "background", {
  20614. /**
  20615. * @version Egret 2.4
  20616. * @platform Web,Native
  20617. */
  20618. get: function () {
  20619. return this.$TextField[33 /* background */];
  20620. },
  20621. /**
  20622. * @language en_US
  20623. * Specifies whether the text field has a background fill.
  20624. * If true, the text field has a background fill. If false, the text field has no background fill.
  20625. * Use the backgroundColor property to set the background color of the text field.
  20626. * @default false
  20627. */
  20628. /**
  20629. * @language zh_CN
  20630. * 指定文本字段是否具有背景填充。
  20631. * 如果为 true,则文本字段具有背景填充。如果为 false,则文本字段没有背景填充。
  20632. * 使用 backgroundColor 属性来设置文本字段的背景颜色。
  20633. * @default false
  20634. */
  20635. set: function (value) {
  20636. this.$setBackground(value);
  20637. },
  20638. enumerable: true,
  20639. configurable: true
  20640. });
  20641. /**
  20642. * @private
  20643. */
  20644. TextField.prototype.$setBackground = function (value) {
  20645. this.$TextField[33 /* background */] = value;
  20646. this.$invalidate();
  20647. };
  20648. Object.defineProperty(TextField.prototype, "backgroundColor", {
  20649. /**
  20650. * @version Egret 2.4
  20651. * @platform Web,Native
  20652. */
  20653. get: function () {
  20654. return this.$TextField[34 /* backgroundColor */];
  20655. },
  20656. /**
  20657. * @language en_US
  20658. * Color of the text field background.
  20659. * Even currently is no background, can be retrieved or set this property, but only if the text field has the background property set to true, the color is visible.
  20660. * @default 0xFFFFFF
  20661. */
  20662. /**
  20663. * @language zh_CN
  20664. * 文本字段背景的颜色。
  20665. * 即使当前没有背景,也可检索或设置此属性,但只有当文本字段已将 background 属性设置为 true 时,才可以看到颜色。
  20666. * @default 0xFFFFFF
  20667. */
  20668. set: function (value) {
  20669. this.$setBackgroundColor(value);
  20670. },
  20671. enumerable: true,
  20672. configurable: true
  20673. });
  20674. /**
  20675. * @private
  20676. */
  20677. TextField.prototype.$setBackgroundColor = function (value) {
  20678. this.$TextField[34 /* backgroundColor */] = value;
  20679. this.$invalidate();
  20680. };
  20681. /**
  20682. * @private
  20683. *
  20684. */
  20685. TextField.prototype.fillBackground = function (lines) {
  20686. var graphics = this.graphicsNode;
  20687. if (graphics) {
  20688. graphics.clear();
  20689. }
  20690. var values = this.$TextField;
  20691. if (values[33 /* background */] || values[31 /* border */] || (lines && lines.length > 0)) {
  20692. if (!graphics) {
  20693. graphics = this.graphicsNode = new egret.sys.GraphicsNode();
  20694. var groupNode = new egret.sys.GroupNode();
  20695. groupNode.addNode(graphics);
  20696. groupNode.addNode(this.textNode);
  20697. this.$renderNode = groupNode;
  20698. }
  20699. var fillPath = void 0;
  20700. var strokePath = void 0;
  20701. //渲染背景
  20702. if (values[33 /* background */]) {
  20703. fillPath = graphics.beginFill(values[34 /* backgroundColor */]);
  20704. fillPath.drawRect(0, 0, this.$getWidth(), this.$getHeight());
  20705. }
  20706. //渲染边框
  20707. if (values[31 /* border */]) {
  20708. strokePath = graphics.lineStyle(1, values[32 /* borderColor */]);
  20709. //1像素和3像素线条宽度的情况,会向右下角偏移0.5像素绘制。少画一像素宽度,正好能不超出文本测量边界。
  20710. strokePath.drawRect(0, 0, this.$getWidth() - 1, this.$getHeight() - 1);
  20711. }
  20712. //渲染下划线
  20713. if (lines && lines.length > 0) {
  20714. var textColor = values[2 /* textColor */];
  20715. var lastColor = -1;
  20716. var length_11 = lines.length;
  20717. for (var i = 0; i < length_11; i += 4) {
  20718. var x = lines[i];
  20719. var y = lines[i + 1];
  20720. var w = lines[i + 2];
  20721. var color = lines[i + 3] || textColor;
  20722. if (lastColor < 0 || lastColor != color) {
  20723. lastColor = color;
  20724. strokePath = graphics.lineStyle(2, color, 1, egret.CapsStyle.NONE);
  20725. }
  20726. strokePath.moveTo(x, y);
  20727. strokePath.lineTo(x + w, y);
  20728. }
  20729. }
  20730. }
  20731. if (graphics) {
  20732. var bounds = this.$getRenderBounds();
  20733. graphics.x = bounds.x;
  20734. graphics.y = bounds.y;
  20735. graphics.width = bounds.width;
  20736. graphics.height = bounds.height;
  20737. egret.Rectangle.release(bounds);
  20738. }
  20739. };
  20740. /**
  20741. * @language en_US
  20742. * Enter the text automatically entered into the input state, the input type is text only and may only be invoked in the user interaction.
  20743. * @version Egret 3.0.8
  20744. * @platform Web,Native
  20745. */
  20746. /**
  20747. * @language zh_CN
  20748. * 输入文本自动进入到输入状态,仅在类型是输入文本并且是在用户交互下才可以调用。
  20749. * @version Egret 3.0.8
  20750. * @platform Web,Native
  20751. */
  20752. TextField.prototype.setFocus = function () {
  20753. if (this.type == egret.TextFieldType.INPUT && this.$stage) {
  20754. this.inputUtils.$onFocus();
  20755. }
  20756. };
  20757. /**
  20758. * @private
  20759. *
  20760. */
  20761. TextField.prototype.$onRemoveFromStage = function () {
  20762. _super.prototype.$onRemoveFromStage.call(this);
  20763. this.removeEvent();
  20764. if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) {
  20765. this.inputUtils._removeStageText();
  20766. }
  20767. if (this.textNode) {
  20768. this.textNode.clean();
  20769. }
  20770. };
  20771. /**
  20772. * @private
  20773. *
  20774. * @param stage
  20775. * @param nestLevel
  20776. */
  20777. TextField.prototype.$onAddToStage = function (stage, nestLevel) {
  20778. _super.prototype.$onAddToStage.call(this, stage, nestLevel);
  20779. this.addEvent();
  20780. if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) {
  20781. this.inputUtils._addStageText();
  20782. }
  20783. };
  20784. /**
  20785. * 不能重写$invalidateContentBounds,因为内部graphics调用clear时会触发$invalidateContentBounds这狗方法,从而导致死循环。
  20786. */
  20787. TextField.prototype.$invalidateTextField = function () {
  20788. this.$invalidateContentBounds();
  20789. this.$TextField[18 /* textLinesChanged */] = true;
  20790. };
  20791. TextField.prototype.$update = function (dirtyRegionPolicy, bounds) {
  20792. var tmpBounds = this.$getRenderBounds();
  20793. var result = _super.prototype.$update.call(this, dirtyRegionPolicy, tmpBounds);
  20794. egret.Rectangle.release(tmpBounds);
  20795. return result;
  20796. };
  20797. TextField.prototype.$getRenderBounds = function () {
  20798. var bounds = this.$getContentBounds();
  20799. var tmpBounds = egret.Rectangle.create();
  20800. tmpBounds.copyFrom(bounds);
  20801. if (this.$TextField[31 /* border */]) {
  20802. tmpBounds.width += 2;
  20803. tmpBounds.height += 2;
  20804. }
  20805. var _strokeDouble = this.$TextField[27 /* stroke */] * 2;
  20806. if (_strokeDouble > 0) {
  20807. tmpBounds.width += _strokeDouble * 2;
  20808. tmpBounds.height += _strokeDouble * 2;
  20809. }
  20810. tmpBounds.x -= _strokeDouble + 2; //+2和+4 是为了解决脏区域的问题
  20811. tmpBounds.y -= _strokeDouble + 2;
  20812. tmpBounds.width = Math.ceil(tmpBounds.width) + 4;
  20813. tmpBounds.height = Math.ceil(tmpBounds.height) + 4;
  20814. return tmpBounds;
  20815. };
  20816. /**
  20817. * @private
  20818. */
  20819. TextField.prototype.$measureContentBounds = function (bounds) {
  20820. this.$getLinesArr();
  20821. var w = !isNaN(this.$TextField[3 /* textFieldWidth */]) ? this.$TextField[3 /* textFieldWidth */] : this.$TextField[5 /* textWidth */];
  20822. var h = !isNaN(this.$TextField[4 /* textFieldHeight */]) ? this.$TextField[4 /* textFieldHeight */] : egret.TextFieldUtils.$getTextHeight(this);
  20823. bounds.setTo(0, 0, w, h);
  20824. };
  20825. /**
  20826. * @private
  20827. * @see egret.DisplayObject._render
  20828. * @param renderContext
  20829. */
  20830. TextField.prototype.$render = function () {
  20831. if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) {
  20832. if (this.$hasAnyFlags(2032 /* InitFlags */) || this.$hasAnyFlags(1648 /* DownOnAddedOrRemoved */)) {
  20833. this.inputUtils._updateProperties();
  20834. }
  20835. if (this.$isTyping) {
  20836. this.fillBackground();
  20837. return;
  20838. }
  20839. }
  20840. else if (this.$TextField[3 /* textFieldWidth */] == 0) {
  20841. return;
  20842. }
  20843. var underLines = this.drawText();
  20844. this.fillBackground(underLines);
  20845. //tudo 宽高很小的情况下webgl模式绘制异常
  20846. var bounds = this.$getRenderBounds();
  20847. var node = this.textNode;
  20848. node.x = bounds.x;
  20849. node.y = bounds.y;
  20850. node.width = Math.ceil(bounds.width);
  20851. node.height = Math.ceil(bounds.height);
  20852. egret.Rectangle.release(bounds);
  20853. };
  20854. Object.defineProperty(TextField.prototype, "textFlow", {
  20855. /**
  20856. * @version Egret 2.4
  20857. * @platform Web,Native
  20858. */
  20859. get: function () {
  20860. return this.textArr;
  20861. },
  20862. /**
  20863. * @language en_US
  20864. * Set rich text
  20865. */
  20866. /**
  20867. * @language zh_CN
  20868. * 设置富文本
  20869. * @see http://edn.egret.com/cn/index.php/article/index/id/146
  20870. */
  20871. set: function (textArr) {
  20872. this.isFlow = true;
  20873. var text = "";
  20874. if (textArr == null)
  20875. textArr = [];
  20876. for (var i = 0; i < textArr.length; i++) {
  20877. var element = textArr[i];
  20878. text += element.text;
  20879. }
  20880. if (this.$TextField[20 /* displayAsPassword */]) {
  20881. this.$setBaseText(text);
  20882. }
  20883. else {
  20884. this.$TextField[13 /* text */] = text;
  20885. this.setMiddleStyle(textArr);
  20886. }
  20887. },
  20888. enumerable: true,
  20889. configurable: true
  20890. });
  20891. /**
  20892. * @private
  20893. *
  20894. * @param text
  20895. * @returns
  20896. */
  20897. TextField.prototype.changeToPassText = function (text) {
  20898. if (this.$TextField[20 /* displayAsPassword */]) {
  20899. var passText = "";
  20900. for (var i = 0, num = text.length; i < num; i++) {
  20901. switch (text.charAt(i)) {
  20902. case '\n':
  20903. passText += "\n";
  20904. break;
  20905. case '\r':
  20906. break;
  20907. default:
  20908. passText += '*';
  20909. }
  20910. }
  20911. return passText;
  20912. }
  20913. return text;
  20914. };
  20915. /**
  20916. * @private
  20917. *
  20918. * @param textArr
  20919. */
  20920. TextField.prototype.setMiddleStyle = function (textArr) {
  20921. this.$TextField[18 /* textLinesChanged */] = true;
  20922. this.textArr = textArr;
  20923. this.$invalidateTextField();
  20924. };
  20925. Object.defineProperty(TextField.prototype, "textWidth", {
  20926. /**
  20927. * @language en_US
  20928. * Get the text measured width
  20929. * @version Egret 2.4
  20930. * @platform Web,Native
  20931. */
  20932. /**
  20933. * @language zh_CN
  20934. * 获取文本测量宽度
  20935. * @version Egret 2.4
  20936. * @platform Web,Native
  20937. */
  20938. get: function () {
  20939. this.$getLinesArr();
  20940. return this.$TextField[5 /* textWidth */];
  20941. },
  20942. enumerable: true,
  20943. configurable: true
  20944. });
  20945. Object.defineProperty(TextField.prototype, "textHeight", {
  20946. /**
  20947. * @language en_US
  20948. * Get Text measuring height
  20949. * @version Egret 2.4
  20950. * @platform Web,Native
  20951. */
  20952. /**
  20953. * @language zh_CN
  20954. * 获取文本测量高度
  20955. * @version Egret 2.4
  20956. * @platform Web,Native
  20957. */
  20958. get: function () {
  20959. this.$getLinesArr();
  20960. return egret.TextFieldUtils.$getTextHeight(this);
  20961. },
  20962. enumerable: true,
  20963. configurable: true
  20964. });
  20965. /**
  20966. * @private
  20967. * @param text
  20968. * @version Egret 2.4
  20969. * @platform Web,Native
  20970. */
  20971. TextField.prototype.appendText = function (text) {
  20972. this.appendElement({ text: text });
  20973. };
  20974. /**
  20975. * @private
  20976. * @param element
  20977. * @version Egret 2.4
  20978. * @platform Web,Native
  20979. */
  20980. TextField.prototype.appendElement = function (element) {
  20981. var text = this.$TextField[13 /* text */] + element.text;
  20982. if (this.$TextField[20 /* displayAsPassword */]) {
  20983. this.$setBaseText(text);
  20984. }
  20985. else {
  20986. this.$TextField[13 /* text */] = text;
  20987. this.textArr.push(element);
  20988. this.setMiddleStyle(this.textArr);
  20989. }
  20990. };
  20991. /**
  20992. * @private
  20993. *
  20994. * @returns
  20995. */
  20996. TextField.prototype.$getLinesArr = function () {
  20997. var values = this.$TextField;
  20998. if (!values[18 /* textLinesChanged */]) {
  20999. return this.linesArr;
  21000. }
  21001. values[18 /* textLinesChanged */] = false;
  21002. var text2Arr = this.textArr;
  21003. this.linesArr.length = 0;
  21004. values[6 /* textHeight */] = 0;
  21005. values[5 /* textWidth */] = 0;
  21006. var textFieldWidth = values[3 /* textFieldWidth */];
  21007. //宽度被设置为0
  21008. if (!isNaN(textFieldWidth) && textFieldWidth == 0) {
  21009. values[29 /* numLines */] = 0;
  21010. return [{ width: 0, height: 0, charNum: 0, elements: [], hasNextLine: false }];
  21011. }
  21012. var linesArr = this.linesArr;
  21013. var lineW = 0;
  21014. var lineCharNum = 0;
  21015. var lineH = 0;
  21016. var lineCount = 0;
  21017. var lineElement;
  21018. for (var i = 0, text2ArrLength = text2Arr.length; i < text2ArrLength; i++) {
  21019. var element = text2Arr[i];
  21020. //可能设置为没有文本,忽略绘制
  21021. if (!element.text) {
  21022. if (lineElement) {
  21023. lineElement.width = lineW;
  21024. lineElement.height = lineH;
  21025. lineElement.charNum = lineCharNum;
  21026. values[5 /* textWidth */] = Math.max(values[5 /* textWidth */], lineW);
  21027. values[6 /* textHeight */] += lineH;
  21028. }
  21029. continue;
  21030. }
  21031. element.style = element.style || {};
  21032. var text = element.text.toString();
  21033. var textArr = text.split(/(?:\r\n|\r|\n)/);
  21034. for (var j = 0, textArrLength = textArr.length; j < textArrLength; j++) {
  21035. if (linesArr[lineCount] == null) {
  21036. lineElement = { width: 0, height: 0, elements: [], charNum: 0, hasNextLine: false };
  21037. linesArr[lineCount] = lineElement;
  21038. lineW = 0;
  21039. lineH = 0;
  21040. lineCharNum = 0;
  21041. }
  21042. if (values[24 /* type */] == egret.TextFieldType.INPUT) {
  21043. lineH = values[0 /* fontSize */];
  21044. }
  21045. else {
  21046. lineH = Math.max(lineH, element.style.size || values[0 /* fontSize */]);
  21047. }
  21048. var isNextLine = true;
  21049. if (textArr[j] == "") {
  21050. if (j == textArrLength - 1) {
  21051. isNextLine = false;
  21052. }
  21053. }
  21054. else {
  21055. var w = measureTextWidth(textArr[j], values, element.style);
  21056. if (isNaN(textFieldWidth)) {
  21057. lineW += w;
  21058. lineCharNum += textArr[j].length;
  21059. lineElement.elements.push({
  21060. width: w,
  21061. text: textArr[j],
  21062. style: element.style
  21063. });
  21064. if (j == textArrLength - 1) {
  21065. isNextLine = false;
  21066. }
  21067. }
  21068. else {
  21069. if (lineW + w <= textFieldWidth) {
  21070. lineElement.elements.push({
  21071. width: w,
  21072. text: textArr[j],
  21073. style: element.style
  21074. });
  21075. lineW += w;
  21076. lineCharNum += textArr[j].length;
  21077. if (j == textArrLength - 1) {
  21078. isNextLine = false;
  21079. }
  21080. }
  21081. else {
  21082. var k = 0;
  21083. var ww = 0;
  21084. var word = textArr[j];
  21085. var words = void 0;
  21086. if (values[19 /* wordWrap */]) {
  21087. words = word.split(SplitRegex);
  21088. }
  21089. else {
  21090. words = word.match(/./g);
  21091. }
  21092. var wl = words.length;
  21093. var charNum = 0;
  21094. for (; k < wl; k++) {
  21095. // detect 4 bytes unicode, refer https://mths.be/punycode
  21096. var codeLen = words[k].length;
  21097. var has4BytesUnicode = false;
  21098. if (codeLen == 1 && k < wl - 1) {
  21099. var charCodeHigh = words[k].charCodeAt(0);
  21100. var charCodeLow = words[k + 1].charCodeAt(0);
  21101. if (charCodeHigh >= 0xD800 && charCodeHigh <= 0xDBFF && (charCodeLow & 0xFC00) == 0xDC00) {
  21102. var realWord = words[k] + words[k + 1];
  21103. codeLen = 2;
  21104. has4BytesUnicode = true;
  21105. w = measureTextWidth(realWord, values, element.style);
  21106. }
  21107. else {
  21108. w = measureTextWidth(words[k], values, element.style);
  21109. }
  21110. }
  21111. else {
  21112. w = measureTextWidth(words[k], values, element.style);
  21113. }
  21114. // w = measureTextWidth(words[k], values, element.style);
  21115. if (lineW != 0 && lineW + w > textFieldWidth && lineW + k != 0) {
  21116. break;
  21117. }
  21118. if (ww + w > textFieldWidth) {
  21119. var words2 = words[k].match(/./g);
  21120. for (var k2 = 0, wl2 = words2.length; k2 < wl2; k2++) {
  21121. // detect 4 bytes unicode, refer https://mths.be/punycode
  21122. var codeLen = words2[k2].length;
  21123. var has4BytesUnicode2 = false;
  21124. if (codeLen == 1 && k2 < wl2 - 1) {
  21125. var charCodeHigh = words2[k2].charCodeAt(0);
  21126. var charCodeLow = words2[k2 + 1].charCodeAt(0);
  21127. if (charCodeHigh >= 0xD800 && charCodeHigh <= 0xDBFF && (charCodeLow & 0xFC00) == 0xDC00) {
  21128. var realWord = words2[k2] + words2[k2 + 1];
  21129. codeLen = 2;
  21130. has4BytesUnicode2 = true;
  21131. w = measureTextWidth(realWord, values, element.style);
  21132. }
  21133. else {
  21134. w = measureTextWidth(words2[k2], values, element.style);
  21135. }
  21136. }
  21137. else {
  21138. w = measureTextWidth(words2[k2], values, element.style);
  21139. }
  21140. // w = measureTextWidth(words2[k2], values, element.style);
  21141. if (k2 > 0 && lineW + w > textFieldWidth) {
  21142. break;
  21143. }
  21144. // charNum += words2[k2].length;
  21145. charNum += codeLen;
  21146. ww += w;
  21147. lineW += w;
  21148. lineCharNum += charNum;
  21149. if (has4BytesUnicode2) {
  21150. k2++;
  21151. }
  21152. }
  21153. }
  21154. else {
  21155. // charNum += words[k].length;
  21156. charNum += codeLen;
  21157. ww += w;
  21158. lineW += w;
  21159. lineCharNum += charNum;
  21160. }
  21161. if (has4BytesUnicode) {
  21162. k++;
  21163. }
  21164. }
  21165. if (k > 0) {
  21166. lineElement.elements.push({
  21167. width: ww,
  21168. text: word.substring(0, charNum),
  21169. style: element.style
  21170. });
  21171. var leftWord = word.substring(charNum);
  21172. var m = void 0;
  21173. var lwleng = leftWord.length;
  21174. for (m = 0; m < lwleng; m++) {
  21175. if (leftWord.charAt(m) != " ") {
  21176. break;
  21177. }
  21178. }
  21179. textArr[j] = leftWord.substring(m);
  21180. }
  21181. if (textArr[j] != "") {
  21182. j--;
  21183. isNextLine = false;
  21184. }
  21185. }
  21186. }
  21187. }
  21188. if (isNextLine) {
  21189. lineCharNum++;
  21190. lineElement.hasNextLine = true;
  21191. }
  21192. if (j < textArr.length - 1) {
  21193. lineElement.width = lineW;
  21194. lineElement.height = lineH;
  21195. lineElement.charNum = lineCharNum;
  21196. values[5 /* textWidth */] = Math.max(values[5 /* textWidth */], lineW);
  21197. values[6 /* textHeight */] += lineH;
  21198. //if (this._type == TextFieldType.INPUT && !this._multiline) {
  21199. // this._numLines = linesArr.length;
  21200. // return linesArr;
  21201. //}
  21202. lineCount++;
  21203. }
  21204. }
  21205. if (i == text2Arr.length - 1 && lineElement) {
  21206. lineElement.width = lineW;
  21207. lineElement.height = lineH;
  21208. lineElement.charNum = lineCharNum;
  21209. values[5 /* textWidth */] = Math.max(values[5 /* textWidth */], lineW);
  21210. values[6 /* textHeight */] += lineH;
  21211. }
  21212. }
  21213. values[29 /* numLines */] = linesArr.length;
  21214. return linesArr;
  21215. };
  21216. /**
  21217. * @private
  21218. * 返回要绘制的下划线列表
  21219. */
  21220. TextField.prototype.drawText = function () {
  21221. var node = this.textNode;
  21222. var values = this.$TextField;
  21223. //更新文本样式
  21224. node.bold = values[15 /* bold */];
  21225. node.fontFamily = values[8 /* fontFamily */] || TextField.default_fontFamily;
  21226. node.italic = values[16 /* italic */];
  21227. node.size = values[0 /* fontSize */];
  21228. node.stroke = values[27 /* stroke */];
  21229. node.strokeColor = values[25 /* strokeColor */];
  21230. node.textColor = values[2 /* textColor */];
  21231. //先算出需要的数值
  21232. var lines = this.$getLinesArr();
  21233. if (values[5 /* textWidth */] == 0) {
  21234. return [];
  21235. }
  21236. var maxWidth = !isNaN(values[3 /* textFieldWidth */]) ? values[3 /* textFieldWidth */] : values[5 /* textWidth */];
  21237. var textHeight = egret.TextFieldUtils.$getTextHeight(this);
  21238. var drawY = 0;
  21239. var startLine = egret.TextFieldUtils.$getStartLine(this);
  21240. var textFieldHeight = values[4 /* textFieldHeight */];
  21241. if (!isNaN(textFieldHeight) && textFieldHeight > textHeight) {
  21242. var vAlign = egret.TextFieldUtils.$getValign(this);
  21243. drawY += vAlign * (textFieldHeight - textHeight);
  21244. }
  21245. drawY = Math.round(drawY);
  21246. var hAlign = egret.TextFieldUtils.$getHalign(this);
  21247. var drawX = 0;
  21248. var underLineData = [];
  21249. for (var i = startLine, numLinesLength = values[29 /* numLines */]; i < numLinesLength; i++) {
  21250. var line = lines[i];
  21251. var h = line.height;
  21252. drawY += h / 2;
  21253. if (i != startLine) {
  21254. if (values[24 /* type */] == egret.TextFieldType.INPUT && !values[30 /* multiline */]) {
  21255. break;
  21256. }
  21257. if (!isNaN(textFieldHeight) && drawY > textFieldHeight) {
  21258. break;
  21259. }
  21260. }
  21261. drawX = Math.round((maxWidth - line.width) * hAlign);
  21262. for (var j = 0, elementsLength = line.elements.length; j < elementsLength; j++) {
  21263. var element = line.elements[j];
  21264. var size = element.style.size || values[0 /* fontSize */];
  21265. node.drawText(drawX, drawY + (h - size) / 2, element.text, element.style);
  21266. if (element.style.underline) {
  21267. underLineData.push(drawX, drawY + (h) / 2, element.width, element.style.textColor);
  21268. }
  21269. drawX += element.width;
  21270. }
  21271. drawY += h / 2 + values[1 /* lineSpacing */];
  21272. }
  21273. return underLineData;
  21274. };
  21275. //增加点击事件
  21276. TextField.prototype.addEvent = function () {
  21277. this.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTapHandler, this);
  21278. };
  21279. //释放点击事件
  21280. TextField.prototype.removeEvent = function () {
  21281. this.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTapHandler, this);
  21282. };
  21283. //处理富文本中有href的
  21284. TextField.prototype.onTapHandler = function (e) {
  21285. if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) {
  21286. return;
  21287. }
  21288. var ele = egret.TextFieldUtils.$getTextElement(this, e.localX, e.localY);
  21289. if (ele == null) {
  21290. return;
  21291. }
  21292. var style = ele.style;
  21293. if (style && style.href) {
  21294. if (style.href.match(/^event:/)) {
  21295. var type = style.href.match(/^event:/)[0];
  21296. egret.TextEvent.dispatchTextEvent(this, egret.TextEvent.LINK, style.href.substring(type.length));
  21297. }
  21298. else {
  21299. open(style.href, style.target || "_blank");
  21300. }
  21301. }
  21302. };
  21303. return TextField;
  21304. }(egret.DisplayObject));
  21305. /**
  21306. * @language en_US
  21307. * default fontFamily
  21308. * @version Egret 2.4
  21309. * @platform Web,Native
  21310. */
  21311. /**
  21312. * @language zh_CN
  21313. * 默认文本字体
  21314. * @version Egret 2.4
  21315. * @platform Web,Native
  21316. */
  21317. TextField.default_fontFamily = "Arial";
  21318. /**
  21319. * @language en_US
  21320. * default size in pixels of text
  21321. * @version Egret 3.2.1
  21322. * @platform Web,Native
  21323. */
  21324. /**
  21325. * @language zh_CN
  21326. * 默认文本字号大小
  21327. * @version Egret 3.2.1
  21328. * @platform Web,Native
  21329. */
  21330. TextField.default_size = 30;
  21331. /**
  21332. * @language en_US
  21333. * default color of the text.
  21334. * @version Egret 3.2.1
  21335. * @platform Web,Native
  21336. */
  21337. /**
  21338. * @language zh_CN
  21339. * 默认文本颜色
  21340. * @version Egret 3.2.1
  21341. * @platform Web,Native
  21342. */
  21343. TextField.default_textColor = 0xffffff;
  21344. egret.TextField = TextField;
  21345. __reflect(TextField.prototype, "egret.TextField");
  21346. if (true) {
  21347. egret.$markReadOnly(TextField, "numLines");
  21348. egret.$markReadOnly(TextField, "textWidth");
  21349. egret.$markReadOnly(TextField, "textHeight");
  21350. }
  21351. })(egret || (egret = {}));
  21352. //////////////////////////////////////////////////////////////////////////////////////
  21353. //
  21354. // Copyright (c) 2014-present, Egret Technology.
  21355. // All rights reserved.
  21356. // Redistribution and use in source and binary forms, with or without
  21357. // modification, are permitted provided that the following conditions are met:
  21358. //
  21359. // * Redistributions of source code must retain the above copyright
  21360. // notice, this list of conditions and the following disclaimer.
  21361. // * Redistributions in binary form must reproduce the above copyright
  21362. // notice, this list of conditions and the following disclaimer in the
  21363. // documentation and/or other materials provided with the distribution.
  21364. // * Neither the name of the Egret nor the
  21365. // names of its contributors may be used to endorse or promote products
  21366. // derived from this software without specific prior written permission.
  21367. //
  21368. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  21369. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  21370. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  21371. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  21372. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  21373. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  21374. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  21375. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  21376. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  21377. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21378. //
  21379. //////////////////////////////////////////////////////////////////////////////////////
  21380. var egret;
  21381. (function (egret) {
  21382. /**
  21383. * @language en_US
  21384. * TextFieldInputType class is an enumeration of constant value used in setting the inputType property of the TextField class.
  21385. * @version Egret 3.1.2
  21386. * @platform Web,Native
  21387. */
  21388. /**
  21389. * @language zh_CN
  21390. * TextFieldInputType 类是在设置 TextField 类的 inputType 属性时使用的常数值的枚举。
  21391. * @version Egret 3.1.2
  21392. * @platform Web,Native
  21393. */
  21394. var TextFieldInputType = (function () {
  21395. function TextFieldInputType() {
  21396. }
  21397. return TextFieldInputType;
  21398. }());
  21399. /**
  21400. * @language en_US
  21401. * The default
  21402. * @version Egret 3.1.2
  21403. * @platform Web,Native
  21404. */
  21405. /**
  21406. * @language zh_CN
  21407. * 默认 input 类型
  21408. * @version Egret 3.1.2
  21409. * @platform Web,Native
  21410. */
  21411. TextFieldInputType.TEXT = "text";
  21412. /**
  21413. * @language en_US
  21414. * Telephone Number Inputs
  21415. * @version Egret 3.1.2
  21416. * @platform Web,Native
  21417. */
  21418. /**
  21419. * @language zh_CN
  21420. * 电话号码 input 类型
  21421. * @version Egret 3.1.2
  21422. * @platform Web,Native
  21423. */
  21424. TextFieldInputType.TEL = "tel";
  21425. /**
  21426. * @language en_US
  21427. * Password Inputs
  21428. * @version Egret 3.1.2
  21429. * @platform Web,Native
  21430. */
  21431. /**
  21432. * @language zh_CN
  21433. * password 类型
  21434. * @version Egret 3.1.2
  21435. * @platform Web,Native
  21436. */
  21437. TextFieldInputType.PASSWORD = "password";
  21438. egret.TextFieldInputType = TextFieldInputType;
  21439. __reflect(TextFieldInputType.prototype, "egret.TextFieldInputType");
  21440. })(egret || (egret = {}));
  21441. //////////////////////////////////////////////////////////////////////////////////////
  21442. //
  21443. // Copyright (c) 2014-present, Egret Technology.
  21444. // All rights reserved.
  21445. // Redistribution and use in source and binary forms, with or without
  21446. // modification, are permitted provided that the following conditions are met:
  21447. //
  21448. // * Redistributions of source code must retain the above copyright
  21449. // notice, this list of conditions and the following disclaimer.
  21450. // * Redistributions in binary form must reproduce the above copyright
  21451. // notice, this list of conditions and the following disclaimer in the
  21452. // documentation and/or other materials provided with the distribution.
  21453. // * Neither the name of the Egret nor the
  21454. // names of its contributors may be used to endorse or promote products
  21455. // derived from this software without specific prior written permission.
  21456. //
  21457. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  21458. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  21459. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  21460. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  21461. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  21462. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  21463. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  21464. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  21465. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  21466. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21467. //
  21468. //////////////////////////////////////////////////////////////////////////////////////
  21469. var egret;
  21470. (function (egret) {
  21471. /**
  21472. * @language en_US
  21473. * TextFieldType class is an enumeration of constant value used in setting the type property of the TextField class.
  21474. * @version Egret 2.4
  21475. * @platform Web,Native
  21476. */
  21477. /**
  21478. * @language zh_CN
  21479. * TextFieldType 类是在设置 TextField 类的 type 属性时使用的常数值的枚举。
  21480. * @version Egret 2.4
  21481. * @platform Web,Native
  21482. */
  21483. var TextFieldType = (function () {
  21484. function TextFieldType() {
  21485. }
  21486. return TextFieldType;
  21487. }());
  21488. /**
  21489. * @language en_US
  21490. * Used to specify dynamic text
  21491. * @version Egret 2.4
  21492. * @platform Web,Native
  21493. */
  21494. /**
  21495. * @language zh_CN
  21496. * 用于指定动态文本
  21497. * @version Egret 2.4
  21498. * @platform Web,Native
  21499. */
  21500. TextFieldType.DYNAMIC = "dynamic";
  21501. /**
  21502. * @language en_US
  21503. * Used to specify the input text
  21504. * @version Egret 2.4
  21505. * @platform Web,Native
  21506. */
  21507. /**
  21508. * @language zh_CN
  21509. * 用于指定输入文本
  21510. * @version Egret 2.4
  21511. * @platform Web,Native
  21512. */
  21513. TextFieldType.INPUT = "input";
  21514. egret.TextFieldType = TextFieldType;
  21515. __reflect(TextFieldType.prototype, "egret.TextFieldType");
  21516. })(egret || (egret = {}));
  21517. //////////////////////////////////////////////////////////////////////////////////////
  21518. //
  21519. // Copyright (c) 2014-present, Egret Technology.
  21520. // All rights reserved.
  21521. // Redistribution and use in source and binary forms, with or without
  21522. // modification, are permitted provided that the following conditions are met:
  21523. //
  21524. // * Redistributions of source code must retain the above copyright
  21525. // notice, this list of conditions and the following disclaimer.
  21526. // * Redistributions in binary form must reproduce the above copyright
  21527. // notice, this list of conditions and the following disclaimer in the
  21528. // documentation and/or other materials provided with the distribution.
  21529. // * Neither the name of the Egret nor the
  21530. // names of its contributors may be used to endorse or promote products
  21531. // derived from this software without specific prior written permission.
  21532. //
  21533. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  21534. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  21535. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  21536. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  21537. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  21538. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  21539. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  21540. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  21541. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  21542. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21543. //
  21544. //////////////////////////////////////////////////////////////////////////////////////
  21545. var egret;
  21546. (function (egret) {
  21547. /**
  21548. * @private
  21549. * @version Egret 2.4
  21550. * @platform Web,Native
  21551. */
  21552. var TextFieldUtils = (function () {
  21553. function TextFieldUtils() {
  21554. }
  21555. /**
  21556. * 获取第一个绘制的行数
  21557. * @param textfield 文本
  21558. * @returns {number} 行数,从0开始
  21559. * @private
  21560. */
  21561. TextFieldUtils.$getStartLine = function (textfield) {
  21562. var values = textfield.$TextField;
  21563. var textHeight = TextFieldUtils.$getTextHeight(textfield);
  21564. var startLine = 0;
  21565. var textFieldHeight = values[4 /* textFieldHeight */];
  21566. if (!isNaN(textFieldHeight)) {
  21567. if (textHeight < textFieldHeight) {
  21568. }
  21569. else if (textHeight > textFieldHeight) {
  21570. startLine = Math.max(values[28 /* scrollV */] - 1, 0);
  21571. startLine = Math.min(values[29 /* numLines */] - 1, startLine);
  21572. }
  21573. if (!values[30 /* multiline */]) {
  21574. startLine = Math.max(values[28 /* scrollV */] - 1, 0);
  21575. if (values[29 /* numLines */] > 0) {
  21576. startLine = Math.min(values[29 /* numLines */] - 1, startLine);
  21577. }
  21578. }
  21579. }
  21580. return startLine;
  21581. };
  21582. /**
  21583. * 获取水平比例
  21584. * @param textfield 文本
  21585. * @returns {number} 水平比例
  21586. * @private
  21587. */
  21588. TextFieldUtils.$getHalign = function (textfield) {
  21589. var lineArr = textfield.$getLinesArr();
  21590. var halign = 0;
  21591. if (textfield.$TextField[9 /* textAlign */] == egret.HorizontalAlign.CENTER) {
  21592. halign = 0.5;
  21593. }
  21594. else if (textfield.$TextField[9 /* textAlign */] == egret.HorizontalAlign.RIGHT) {
  21595. halign = 1;
  21596. }
  21597. if (textfield.$TextField[24 /* type */] == egret.TextFieldType.INPUT && !textfield.$TextField[30 /* multiline */] && lineArr.length > 1) {
  21598. halign = 0;
  21599. }
  21600. return halign;
  21601. };
  21602. /**
  21603. * @private
  21604. *
  21605. * @param textfield
  21606. * @returns
  21607. */
  21608. TextFieldUtils.$getTextHeight = function (textfield) {
  21609. var textHeight = (egret.TextFieldType.INPUT == textfield.$TextField[24 /* type */]
  21610. && !textfield.$TextField[30 /* multiline */]) ? textfield.$TextField[0 /* fontSize */] : (textfield.$TextField[6 /* textHeight */] + (textfield.$TextField[29 /* numLines */] - 1) * textfield.$TextField[1 /* lineSpacing */]);
  21611. return textHeight;
  21612. };
  21613. /**
  21614. * 获取垂直比例
  21615. * @param textfield 文本
  21616. * @returns {number} 垂直比例
  21617. * @private
  21618. */
  21619. TextFieldUtils.$getValign = function (textfield) {
  21620. var textHeight = TextFieldUtils.$getTextHeight(textfield);
  21621. //if (textfield.$TextField[sys.TextKeys.type] == egret.TextFieldType.INPUT) {
  21622. // if (textfield.$TextField[sys.TextKeys.multiline]) {
  21623. //return 0;
  21624. //}
  21625. //return 0.5;
  21626. //}
  21627. var textFieldHeight = textfield.$TextField[4 /* textFieldHeight */];
  21628. if (!isNaN(textFieldHeight)) {
  21629. if (textHeight < textFieldHeight) {
  21630. var valign = 0;
  21631. if (textfield.$TextField[10 /* verticalAlign */] == egret.VerticalAlign.MIDDLE)
  21632. valign = 0.5;
  21633. else if (textfield.$TextField[10 /* verticalAlign */] == egret.VerticalAlign.BOTTOM)
  21634. valign = 1;
  21635. return valign;
  21636. }
  21637. }
  21638. return 0;
  21639. };
  21640. /**
  21641. * 根据x、y获取文本项
  21642. * @param textfield 文本
  21643. * @param x x坐标值
  21644. * @param y y坐标值
  21645. * @returns 文本单项
  21646. * @private
  21647. */
  21648. TextFieldUtils.$getTextElement = function (textfield, x, y) {
  21649. var hitTextEle = TextFieldUtils.$getHit(textfield, x, y);
  21650. var lineArr = textfield.$getLinesArr();
  21651. if (hitTextEle && lineArr[hitTextEle.lineIndex] && lineArr[hitTextEle.lineIndex].elements[hitTextEle.textElementIndex]) {
  21652. return lineArr[hitTextEle.lineIndex].elements[hitTextEle.textElementIndex];
  21653. }
  21654. return null;
  21655. };
  21656. /**
  21657. * 获取文本点击块
  21658. * @param textfield 文本
  21659. * @param x x坐标值
  21660. * @param y y坐标值
  21661. * @returns 文本点击块
  21662. * @private
  21663. */
  21664. TextFieldUtils.$getHit = function (textfield, x, y) {
  21665. var lineArr = textfield.$getLinesArr();
  21666. if (textfield.$TextField[3 /* textFieldWidth */] == 0) {
  21667. return null;
  21668. }
  21669. var line = 0;
  21670. var textHeight = TextFieldUtils.$getTextHeight(textfield);
  21671. var startY = 0;
  21672. var textFieldHeight = textfield.$TextField[4 /* textFieldHeight */];
  21673. if (!isNaN(textFieldHeight) && textFieldHeight > textHeight) {
  21674. var valign = TextFieldUtils.$getValign(textfield);
  21675. startY = valign * (textFieldHeight - textHeight);
  21676. if (startY != 0) {
  21677. y -= startY;
  21678. }
  21679. }
  21680. var startLine = TextFieldUtils.$getStartLine(textfield);
  21681. var lineH = 0;
  21682. for (var i = startLine; i < lineArr.length; i++) {
  21683. var lineEle = lineArr[i];
  21684. if (lineH + lineEle.height >= y) {
  21685. if (lineH < y) {
  21686. line = i + 1;
  21687. }
  21688. break;
  21689. }
  21690. else {
  21691. lineH += lineEle.height;
  21692. }
  21693. if (lineH + textfield.$TextField[1 /* lineSpacing */] > y) {
  21694. return null;
  21695. }
  21696. lineH += textfield.$TextField[1 /* lineSpacing */];
  21697. }
  21698. if (line == 0) {
  21699. return null;
  21700. }
  21701. var lineElement = lineArr[line - 1];
  21702. var textFieldWidth = textfield.$TextField[3 /* textFieldWidth */];
  21703. if (isNaN(textFieldWidth)) {
  21704. textFieldWidth = textfield.textWidth;
  21705. }
  21706. var halign = TextFieldUtils.$getHalign(textfield);
  21707. x -= halign * (textFieldWidth - lineElement.width);
  21708. var lineW = 0;
  21709. for (var i = 0; i < lineElement.elements.length; i++) {
  21710. var iwTE = lineElement.elements[i];
  21711. if (lineW + iwTE.width <= x) {
  21712. lineW += iwTE.width;
  21713. }
  21714. else if (lineW < x) {
  21715. return { "lineIndex": line - 1, "textElementIndex": i };
  21716. }
  21717. }
  21718. return null;
  21719. };
  21720. /**
  21721. * 获取当前显示多少行
  21722. * @param textfield 文本
  21723. * @returns {number} 显示的行数
  21724. * @private
  21725. */
  21726. TextFieldUtils.$getScrollNum = function (textfield) {
  21727. var scrollNum = 1;
  21728. if (textfield.$TextField[30 /* multiline */]) {
  21729. var height = textfield.height;
  21730. var size = textfield.size;
  21731. var lineSpacing = textfield.lineSpacing;
  21732. scrollNum = Math.floor(height / (size + lineSpacing));
  21733. var leftH = height - (size + lineSpacing) * scrollNum;
  21734. if (leftH > size / 2) {
  21735. scrollNum++;
  21736. }
  21737. }
  21738. return scrollNum;
  21739. };
  21740. return TextFieldUtils;
  21741. }());
  21742. egret.TextFieldUtils = TextFieldUtils;
  21743. __reflect(TextFieldUtils.prototype, "egret.TextFieldUtils");
  21744. })(egret || (egret = {}));
  21745. //////////////////////////////////////////////////////////////////////////////////////
  21746. //
  21747. // Copyright (c) 2014-present, Egret Technology.
  21748. // All rights reserved.
  21749. // Redistribution and use in source and binary forms, with or without
  21750. // modification, are permitted provided that the following conditions are met:
  21751. //
  21752. // * Redistributions of source code must retain the above copyright
  21753. // notice, this list of conditions and the following disclaimer.
  21754. // * Redistributions in binary form must reproduce the above copyright
  21755. // notice, this list of conditions and the following disclaimer in the
  21756. // documentation and/or other materials provided with the distribution.
  21757. // * Neither the name of the Egret nor the
  21758. // names of its contributors may be used to endorse or promote products
  21759. // derived from this software without specific prior written permission.
  21760. //
  21761. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  21762. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  21763. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  21764. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  21765. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  21766. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  21767. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  21768. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  21769. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  21770. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21771. //
  21772. //////////////////////////////////////////////////////////////////////////////////////
  21773. /**
  21774. * @private
  21775. */
  21776. var egret;
  21777. (function (egret) {
  21778. var sys;
  21779. (function (sys) {
  21780. })(sys = egret.sys || (egret.sys = {}));
  21781. })(egret || (egret = {}));
  21782. //////////////////////////////////////////////////////////////////////////////////////
  21783. //
  21784. // Copyright (c) 2014-present, Egret Technology.
  21785. // All rights reserved.
  21786. // Redistribution and use in source and binary forms, with or without
  21787. // modification, are permitted provided that the following conditions are met:
  21788. //
  21789. // * Redistributions of source code must retain the above copyright
  21790. // notice, this list of conditions and the following disclaimer.
  21791. // * Redistributions in binary form must reproduce the above copyright
  21792. // notice, this list of conditions and the following disclaimer in the
  21793. // documentation and/or other materials provided with the distribution.
  21794. // * Neither the name of the Egret nor the
  21795. // names of its contributors may be used to endorse or promote products
  21796. // derived from this software without specific prior written permission.
  21797. //
  21798. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  21799. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  21800. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  21801. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  21802. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  21803. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  21804. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  21805. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  21806. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  21807. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21808. //
  21809. //////////////////////////////////////////////////////////////////////////////////////
  21810. var egret;
  21811. (function (egret) {
  21812. /**
  21813. * @language en_US
  21814. * The VerticalAlign class defines the possible values for the vertical alignment.
  21815. * @see egret.TextField#verticalAlign
  21816. * @version Egret 2.4
  21817. * @platform Web,Native
  21818. */
  21819. /**
  21820. * @language zh_CN
  21821. * VerticalAlign 类为垂直对齐方式定义可能的值。
  21822. * @see egret.TextField#verticalAlign
  21823. * @version Egret 2.4
  21824. * @platform Web,Native
  21825. */
  21826. var VerticalAlign = (function () {
  21827. function VerticalAlign() {
  21828. }
  21829. return VerticalAlign;
  21830. }());
  21831. /**
  21832. * @language en_US
  21833. * Vertically align content to the top of the container.
  21834. * @version Egret 2.4
  21835. * @platform Web,Native
  21836. */
  21837. /**
  21838. * @language zh_CN
  21839. * 将内容与容器的顶部对齐。
  21840. * @version Egret 2.4
  21841. * @platform Web,Native
  21842. */
  21843. VerticalAlign.TOP = "top";
  21844. /**
  21845. * @language en_US
  21846. * Vertically align content to the bottom of the container.
  21847. * @version Egret 2.4
  21848. * @platform Web,Native
  21849. */
  21850. /**
  21851. * @language zh_CN
  21852. * 将内容与容器的底部对齐。
  21853. * @version Egret 2.4
  21854. * @platform Web,Native
  21855. */
  21856. VerticalAlign.BOTTOM = "bottom";
  21857. /**
  21858. * @language en_US
  21859. * Vertically align content in the middle of the container.
  21860. * @version Egret 2.4
  21861. * @platform Web,Native
  21862. */
  21863. /**
  21864. * @language zh_CN
  21865. * 在容器的垂直中心对齐内容。
  21866. * @version Egret 2.4
  21867. * @platform Web,Native
  21868. */
  21869. VerticalAlign.MIDDLE = "middle";
  21870. /**
  21871. * @language en_US
  21872. * Vertical alignment with both edges
  21873. * Note: TextFiled does not support this alignment method."
  21874. * @version Egret 2.4
  21875. * @platform Web,Native
  21876. */
  21877. /**
  21878. * @language zh_CN
  21879. * 垂直两端对齐
  21880. * 注意:TextFiled不支持此对齐方式。
  21881. * @version Egret 2.4
  21882. * @platform Web,Native
  21883. */
  21884. VerticalAlign.JUSTIFY = "justify";
  21885. /**
  21886. * @language en_US
  21887. * Align the content of the child items, relative to the container. This operation will adjust uniformly the size of all the child items to be the Content Height \" of the container \".
  21888. * The Content Height \" of the container \" is the size of the max. child item. If the size of all child items are less than the height of the container, they will be adjusted to the height of the container.
  21889. * Note: TextFiled does not support this alignment method.
  21890. * @version Egret 2.4
  21891. * @platform Web,Native
  21892. */
  21893. /**
  21894. * @language zh_CN
  21895. * 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的"内容高度"。
  21896. * 容器的"内容高度"是最大子项的大小,如果所有子项都小于容器的高度,则会将所有子项的大小调整为容器的高度。
  21897. * 注意:TextFiled不支持此对齐方式。
  21898. * @version Egret 2.4
  21899. * @platform Web,Native
  21900. */
  21901. VerticalAlign.CONTENT_JUSTIFY = "contentJustify";
  21902. egret.VerticalAlign = VerticalAlign;
  21903. __reflect(VerticalAlign.prototype, "egret.VerticalAlign");
  21904. })(egret || (egret = {}));
  21905. //////////////////////////////////////////////////////////////////////////////////////
  21906. //
  21907. // Copyright (c) 2014-present, Egret Technology.
  21908. // All rights reserved.
  21909. // Redistribution and use in source and binary forms, with or without
  21910. // modification, are permitted provided that the following conditions are met:
  21911. //
  21912. // * Redistributions of source code must retain the above copyright
  21913. // notice, this list of conditions and the following disclaimer.
  21914. // * Redistributions in binary form must reproduce the above copyright
  21915. // notice, this list of conditions and the following disclaimer in the
  21916. // documentation and/or other materials provided with the distribution.
  21917. // * Neither the name of the Egret nor the
  21918. // names of its contributors may be used to endorse or promote products
  21919. // derived from this software without specific prior written permission.
  21920. //
  21921. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  21922. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  21923. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  21924. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  21925. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  21926. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  21927. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  21928. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  21929. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  21930. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21931. //
  21932. //////////////////////////////////////////////////////////////////////////////////////
  21933. var egret;
  21934. (function (egret) {
  21935. /**
  21936. * @language en_US
  21937. * The Endian class contains values that denote the byte order used to represent multibyte numbers.
  21938. * The byte order is either bigEndian (most significant byte first) or littleEndian (least significant byte first).
  21939. * @version Egret 2.4
  21940. * @platform Web,Native
  21941. */
  21942. /**
  21943. * @language zh_CN
  21944. * Endian 类中包含一些值,它们表示用于表示多字节数字的字节顺序。
  21945. * 字节顺序为 bigEndian(最高有效字节位于最前)或 littleEndian(最低有效字节位于最前)。
  21946. * @version Egret 2.4
  21947. * @platform Web,Native
  21948. */
  21949. var Endian = (function () {
  21950. function Endian() {
  21951. }
  21952. return Endian;
  21953. }());
  21954. /**
  21955. * @language en_US
  21956. * Indicates the least significant byte of the multibyte number appears first in the sequence of bytes.
  21957. * The hexadecimal number 0x12345678 has 4 bytes (2 hexadecimal digits per byte). The most significant byte is 0x12. The least significant byte is 0x78. (For the equivalent decimal number, 305419896, the most significant digit is 3, and the least significant digit is 6).
  21958. * @version Egret 2.4
  21959. * @platform Web,Native
  21960. */
  21961. /**
  21962. * @language zh_CN
  21963. * 表示多字节数字的最低有效字节位于字节序列的最前面。
  21964. * 十六进制数字 0x12345678 包含 4 个字节(每个字节包含 2 个十六进制数字)。最高有效字节为 0x12。最低有效字节为 0x78。(对于等效的十进制数字 305419896,最高有效数字是 3,最低有效数字是 6)。
  21965. * @version Egret 2.4
  21966. * @platform Web,Native
  21967. */
  21968. Endian.LITTLE_ENDIAN = "littleEndian";
  21969. /**
  21970. * @language en_US
  21971. * Indicates the most significant byte of the multibyte number appears first in the sequence of bytes.
  21972. * The hexadecimal number 0x12345678 has 4 bytes (2 hexadecimal digits per byte). The most significant byte is 0x12. The least significant byte is 0x78. (For the equivalent decimal number, 305419896, the most significant digit is 3, and the least significant digit is 6).
  21973. * @version Egret 2.4
  21974. * @platform Web,Native
  21975. */
  21976. /**
  21977. * @language zh_CN
  21978. * 表示多字节数字的最高有效字节位于字节序列的最前面。
  21979. * 十六进制数字 0x12345678 包含 4 个字节(每个字节包含 2 个十六进制数字)。最高有效字节为 0x12。最低有效字节为 0x78。(对于等效的十进制数字 305419896,最高有效数字是 3,最低有效数字是 6)。
  21980. * @version Egret 2.4
  21981. * @platform Web,Native
  21982. */
  21983. Endian.BIG_ENDIAN = "bigEndian";
  21984. egret.Endian = Endian;
  21985. __reflect(Endian.prototype, "egret.Endian");
  21986. /**
  21987. * @language en_US
  21988. * The ByteArray class provides methods and attributes for optimized reading and writing as well as dealing with binary data.
  21989. * Note: The ByteArray class is applied to the advanced developers who need to access data at the byte layer.
  21990. * @version Egret 2.4
  21991. * @platform Web,Native
  21992. * @includeExample egret/utils/ByteArray.ts
  21993. */
  21994. /**
  21995. * @language zh_CN
  21996. * ByteArray 类提供用于优化读取、写入以及处理二进制数据的方法和属性。
  21997. * 注意:ByteArray 类适用于需要在字节层访问数据的高级开发人员。
  21998. * @version Egret 2.4
  21999. * @platform Web,Native
  22000. * @includeExample egret/utils/ByteArray.ts
  22001. */
  22002. var ByteArray = (function () {
  22003. /**
  22004. * @version Egret 2.4
  22005. * @platform Web,Native
  22006. */
  22007. function ByteArray(buffer) {
  22008. /**
  22009. * @private
  22010. */
  22011. this.BUFFER_EXT_SIZE = 0; //Buffer expansion size
  22012. /**
  22013. * @private
  22014. */
  22015. this.EOF_byte = -1;
  22016. /**
  22017. * @private
  22018. */
  22019. this.EOF_code_point = -1;
  22020. this._setArrayBuffer(buffer || new ArrayBuffer(this.BUFFER_EXT_SIZE));
  22021. this.endian = Endian.BIG_ENDIAN;
  22022. }
  22023. /**
  22024. * @private
  22025. * @param buffer
  22026. */
  22027. ByteArray.prototype._setArrayBuffer = function (buffer) {
  22028. this.write_position = buffer.byteLength;
  22029. this.data = new DataView(buffer);
  22030. this._position = 0;
  22031. };
  22032. /**
  22033. * @deprecated
  22034. * @version Egret 2.4
  22035. * @platform Web,Native
  22036. */
  22037. ByteArray.prototype.setArrayBuffer = function (buffer) {
  22038. };
  22039. Object.defineProperty(ByteArray.prototype, "buffer", {
  22040. get: function () {
  22041. return this.data.buffer;
  22042. },
  22043. /**
  22044. * @private
  22045. */
  22046. set: function (value) {
  22047. this.data = new DataView(value);
  22048. },
  22049. enumerable: true,
  22050. configurable: true
  22051. });
  22052. Object.defineProperty(ByteArray.prototype, "dataView", {
  22053. /**
  22054. * @private
  22055. * @version Egret 2.4
  22056. * @platform Web,Native
  22057. */
  22058. get: function () {
  22059. return this.data;
  22060. },
  22061. /**
  22062. * @private
  22063. */
  22064. set: function (value) {
  22065. this.data = value;
  22066. this.write_position = value.byteLength;
  22067. },
  22068. enumerable: true,
  22069. configurable: true
  22070. });
  22071. Object.defineProperty(ByteArray.prototype, "bufferOffset", {
  22072. /**
  22073. * @private
  22074. */
  22075. get: function () {
  22076. return this.data.byteOffset;
  22077. },
  22078. enumerable: true,
  22079. configurable: true
  22080. });
  22081. Object.defineProperty(ByteArray.prototype, "position", {
  22082. /**
  22083. * @language en_US
  22084. * The current position of the file pointer (in bytes) to move or return to the ByteArray object. The next time you start reading reading method call in this position, or will start writing in this position next time call a write method.
  22085. * @version Egret 2.4
  22086. * @platform Web,Native
  22087. */
  22088. /**
  22089. * @language zh_CN
  22090. * 将文件指针的当前位置(以字节为单位)移动或返回到 ByteArray 对象中。下一次调用读取方法时将在此位置开始读取,或者下一次调用写入方法时将在此位置开始写入。
  22091. * @version Egret 2.4
  22092. * @platform Web,Native
  22093. */
  22094. get: function () {
  22095. return this._position;
  22096. },
  22097. set: function (value) {
  22098. //if (this._position < value) {
  22099. // if (!this.validate(value - this._position)) {
  22100. // return;
  22101. // }
  22102. //}
  22103. this._position = value;
  22104. this.write_position = value > this.write_position ? value : this.write_position;
  22105. },
  22106. enumerable: true,
  22107. configurable: true
  22108. });
  22109. Object.defineProperty(ByteArray.prototype, "length", {
  22110. /**
  22111. * @language en_US
  22112. * The length of the ByteArray object (in bytes).
  22113. * If the length is set to be larger than the current length, the right-side zero padding byte array.
  22114. * If the length is set smaller than the current length, the byte array is truncated.
  22115. * @version Egret 2.4
  22116. * @platform Web,Native
  22117. */
  22118. /**
  22119. * @language zh_CN
  22120. * ByteArray 对象的长度(以字节为单位)。
  22121. * 如果将长度设置为大于当前长度的值,则用零填充字节数组的右侧。
  22122. * 如果将长度设置为小于当前长度的值,将会截断该字节数组。
  22123. * @version Egret 2.4
  22124. * @platform Web,Native
  22125. */
  22126. get: function () {
  22127. return this.write_position;
  22128. },
  22129. set: function (value) {
  22130. this.write_position = value;
  22131. var tmp = new Uint8Array(new ArrayBuffer(value));
  22132. var byteLength = this.data.buffer.byteLength;
  22133. if (byteLength > value) {
  22134. this._position = value;
  22135. }
  22136. var length = Math.min(byteLength, value);
  22137. tmp.set(new Uint8Array(this.data.buffer, 0, length));
  22138. this.buffer = tmp.buffer;
  22139. },
  22140. enumerable: true,
  22141. configurable: true
  22142. });
  22143. Object.defineProperty(ByteArray.prototype, "bytesAvailable", {
  22144. /**
  22145. * @language en_US
  22146. * The number of bytes that can be read from the current position of the byte array to the end of the array data.
  22147. * When you access a ByteArray object, the bytesAvailable property in conjunction with the read methods each use to make sure you are reading valid data.
  22148. * @version Egret 2.4
  22149. * @platform Web,Native
  22150. */
  22151. /**
  22152. * @language zh_CN
  22153. * 可从字节数组的当前位置到数组末尾读取的数据的字节数。
  22154. * 每次访问 ByteArray 对象时,将 bytesAvailable 属性与读取方法结合使用,以确保读取有效的数据。
  22155. * @version Egret 2.4
  22156. * @platform Web,Native
  22157. */
  22158. get: function () {
  22159. return this.data.byteLength - this._position;
  22160. },
  22161. enumerable: true,
  22162. configurable: true
  22163. });
  22164. /**
  22165. * @language en_US
  22166. * Clears the contents of the byte array and resets the length and position properties to 0.
  22167. * @version Egret 2.4
  22168. * @platform Web,Native
  22169. */
  22170. /**
  22171. * @language zh_CN
  22172. * 清除字节数组的内容,并将 length 和 position 属性重置为 0。
  22173. * @version Egret 2.4
  22174. * @platform Web,Native
  22175. */
  22176. ByteArray.prototype.clear = function () {
  22177. this._setArrayBuffer(new ArrayBuffer(this.BUFFER_EXT_SIZE));
  22178. };
  22179. /**
  22180. * @language en_US
  22181. * Read a Boolean value from the byte stream. Read a simple byte. If the byte is non-zero, it returns true; otherwise, it returns false.
  22182. * @return If the byte is non-zero, it returns true; otherwise, it returns false.
  22183. * @version Egret 2.4
  22184. * @platform Web,Native
  22185. */
  22186. /**
  22187. * @language zh_CN
  22188. * 从字节流中读取布尔值。读取单个字节,如果字节非零,则返回 true,否则返回 false
  22189. * @return 如果字节不为零,则返回 true,否则返回 false
  22190. * @version Egret 2.4
  22191. * @platform Web,Native
  22192. */
  22193. ByteArray.prototype.readBoolean = function () {
  22194. if (!this.validate(ByteArray.SIZE_OF_BOOLEAN))
  22195. return null;
  22196. return this.data.getUint8(this.position++) != 0;
  22197. };
  22198. /**
  22199. * @language en_US
  22200. * Read signed bytes from the byte stream.
  22201. * @return An integer ranging from -128 to 127
  22202. * @version Egret 2.4
  22203. * @platform Web,Native
  22204. */
  22205. /**
  22206. * @language zh_CN
  22207. * 从字节流中读取带符号的字节
  22208. * @return 介于 -128 和 127 之间的整数
  22209. * @version Egret 2.4
  22210. * @platform Web,Native
  22211. */
  22212. ByteArray.prototype.readByte = function () {
  22213. if (!this.validate(ByteArray.SIZE_OF_INT8))
  22214. return null;
  22215. return this.data.getInt8(this.position++);
  22216. };
  22217. /**
  22218. * @language en_US
  22219. * Read data byte number specified by the length parameter from the byte stream. Starting from the position specified by offset, read bytes into the ByteArray object specified by the bytes parameter, and write bytes into the target ByteArray
  22220. * @param bytes ByteArray object that data is read into
  22221. * @param offset Offset (position) in bytes. Read data should be written from this position
  22222. * @param length Byte number to be read Default value 0 indicates reading all available data
  22223. * @version Egret 2.4
  22224. * @platform Web,Native
  22225. */
  22226. /**
  22227. * @language zh_CN
  22228. * 从字节流中读取 length 参数指定的数据字节数。从 offset 指定的位置开始,将字节读入 bytes 参数指定的 ByteArray 对象中,并将字节写入目标 ByteArray 中
  22229. * @param bytes 要将数据读入的 ByteArray 对象
  22230. * @param offset bytes 中的偏移(位置),应从该位置写入读取的数据
  22231. * @param length 要读取的字节数。默认值 0 导致读取所有可用的数据
  22232. * @version Egret 2.4
  22233. * @platform Web,Native
  22234. */
  22235. ByteArray.prototype.readBytes = function (bytes, offset, length) {
  22236. if (offset === void 0) { offset = 0; }
  22237. if (length === void 0) { length = 0; }
  22238. if (length == 0) {
  22239. length = this.bytesAvailable;
  22240. }
  22241. else if (!this.validate(length)) {
  22242. return null;
  22243. }
  22244. if (bytes) {
  22245. bytes.validateBuffer(offset + length);
  22246. }
  22247. else {
  22248. bytes = new ByteArray(new ArrayBuffer(offset + length));
  22249. }
  22250. //This method is expensive
  22251. for (var i = 0; i < length; i++) {
  22252. bytes.data.setUint8(i + offset, this.data.getUint8(this.position++));
  22253. }
  22254. };
  22255. /**
  22256. * @language en_US
  22257. * Read an IEEE 754 double-precision (64 bit) floating point number from the byte stream
  22258. * @return Double-precision (64 bit) floating point number
  22259. * @version Egret 2.4
  22260. * @platform Web,Native
  22261. */
  22262. /**
  22263. * @language zh_CN
  22264. * 从字节流中读取一个 IEEE 754 双精度(64 位)浮点数
  22265. * @return 双精度(64 位)浮点数
  22266. * @version Egret 2.4
  22267. * @platform Web,Native
  22268. */
  22269. ByteArray.prototype.readDouble = function () {
  22270. if (!this.validate(ByteArray.SIZE_OF_FLOAT64))
  22271. return null;
  22272. var value = this.data.getFloat64(this.position, this.endian == Endian.LITTLE_ENDIAN);
  22273. this.position += ByteArray.SIZE_OF_FLOAT64;
  22274. return value;
  22275. };
  22276. /**
  22277. * @language en_US
  22278. * Read an IEEE 754 single-precision (32 bit) floating point number from the byte stream
  22279. * @return Single-precision (32 bit) floating point number
  22280. * @version Egret 2.4
  22281. * @platform Web,Native
  22282. */
  22283. /**
  22284. * @language zh_CN
  22285. * 从字节流中读取一个 IEEE 754 单精度(32 位)浮点数
  22286. * @return 单精度(32 位)浮点数
  22287. * @version Egret 2.4
  22288. * @platform Web,Native
  22289. */
  22290. ByteArray.prototype.readFloat = function () {
  22291. if (!this.validate(ByteArray.SIZE_OF_FLOAT32))
  22292. return null;
  22293. var value = this.data.getFloat32(this.position, this.endian == Endian.LITTLE_ENDIAN);
  22294. this.position += ByteArray.SIZE_OF_FLOAT32;
  22295. return value;
  22296. };
  22297. /**
  22298. * @language en_US
  22299. * Read a 32-bit signed integer from the byte stream.
  22300. * @return A 32-bit signed integer ranging from -2147483648 to 2147483647
  22301. * @version Egret 2.4
  22302. * @platform Web,Native
  22303. */
  22304. /**
  22305. * @language zh_CN
  22306. * 从字节流中读取一个带符号的 32 位整数
  22307. * @return 介于 -2147483648 和 2147483647 之间的 32 位带符号整数
  22308. * @version Egret 2.4
  22309. * @platform Web,Native
  22310. */
  22311. ByteArray.prototype.readInt = function () {
  22312. if (!this.validate(ByteArray.SIZE_OF_INT32))
  22313. return null;
  22314. var value = this.data.getInt32(this.position, this.endian == Endian.LITTLE_ENDIAN);
  22315. this.position += ByteArray.SIZE_OF_INT32;
  22316. return value;
  22317. };
  22318. ///**
  22319. // * 使用指定的字符集从字节流中读取指定长度的多字节字符串
  22320. // * @param length 要从字节流中读取的字节数
  22321. // * @param charSet 表示用于解释字节的字符集的字符串。可能的字符集字符串包括 "shift-jis"、"cn-gb"、"iso-8859-1"”等
  22322. // * @return UTF-8 编码的字符串
  22323. // * @method egret.ByteArray#readMultiByte
  22324. // */
  22325. //public readMultiByte(length:number, charSet?:string):string {
  22326. // if (!this.validate(length)) return null;
  22327. //
  22328. // return "";
  22329. //}
  22330. /**
  22331. * @language en_US
  22332. * Read a 16-bit signed integer from the byte stream.
  22333. * @return A 16-bit signed integer ranging from -32768 to 32767
  22334. * @version Egret 2.4
  22335. * @platform Web,Native
  22336. */
  22337. /**
  22338. * @language zh_CN
  22339. * 从字节流中读取一个带符号的 16 位整数
  22340. * @return 介于 -32768 和 32767 之间的 16 位带符号整数
  22341. * @version Egret 2.4
  22342. * @platform Web,Native
  22343. */
  22344. ByteArray.prototype.readShort = function () {
  22345. if (!this.validate(ByteArray.SIZE_OF_INT16))
  22346. return null;
  22347. var value = this.data.getInt16(this.position, this.endian == Endian.LITTLE_ENDIAN);
  22348. this.position += ByteArray.SIZE_OF_INT16;
  22349. return value;
  22350. };
  22351. /**
  22352. * @language en_US
  22353. * Read unsigned bytes from the byte stream.
  22354. * @return A 32-bit unsigned integer ranging from 0 to 255
  22355. * @version Egret 2.4
  22356. * @platform Web,Native
  22357. */
  22358. /**
  22359. * @language zh_CN
  22360. * 从字节流中读取无符号的字节
  22361. * @return 介于 0 和 255 之间的 32 位无符号整数
  22362. * @version Egret 2.4
  22363. * @platform Web,Native
  22364. */
  22365. ByteArray.prototype.readUnsignedByte = function () {
  22366. if (!this.validate(ByteArray.SIZE_OF_UINT8))
  22367. return null;
  22368. return this.data.getUint8(this.position++);
  22369. };
  22370. /**
  22371. * @language en_US
  22372. * Read a 32-bit unsigned integer from the byte stream.
  22373. * @return A 32-bit unsigned integer ranging from 0 to 4294967295
  22374. * @version Egret 2.4
  22375. * @platform Web,Native
  22376. */
  22377. /**
  22378. * @language zh_CN
  22379. * 从字节流中读取一个无符号的 32 位整数
  22380. * @return 介于 0 和 4294967295 之间的 32 位无符号整数
  22381. * @version Egret 2.4
  22382. * @platform Web,Native
  22383. */
  22384. ByteArray.prototype.readUnsignedInt = function () {
  22385. if (!this.validate(ByteArray.SIZE_OF_UINT32))
  22386. return null;
  22387. var value = this.data.getUint32(this.position, this.endian == Endian.LITTLE_ENDIAN);
  22388. this.position += ByteArray.SIZE_OF_UINT32;
  22389. return value;
  22390. };
  22391. /**
  22392. * @language en_US
  22393. * Read a 16-bit unsigned integer from the byte stream.
  22394. * @return A 16-bit unsigned integer ranging from 0 to 65535
  22395. * @version Egret 2.4
  22396. * @platform Web,Native
  22397. */
  22398. /**
  22399. * @language zh_CN
  22400. * 从字节流中读取一个无符号的 16 位整数
  22401. * @return 介于 0 和 65535 之间的 16 位无符号整数
  22402. * @version Egret 2.4
  22403. * @platform Web,Native
  22404. */
  22405. ByteArray.prototype.readUnsignedShort = function () {
  22406. if (!this.validate(ByteArray.SIZE_OF_UINT16))
  22407. return null;
  22408. var value = this.data.getUint16(this.position, this.endian == Endian.LITTLE_ENDIAN);
  22409. this.position += ByteArray.SIZE_OF_UINT16;
  22410. return value;
  22411. };
  22412. /**
  22413. * @language en_US
  22414. * Read a UTF-8 character string from the byte stream Assume that the prefix of the character string is a short unsigned integer (use byte to express length)
  22415. * @return UTF-8 character string
  22416. * @version Egret 2.4
  22417. * @platform Web,Native
  22418. */
  22419. /**
  22420. * @language zh_CN
  22421. * 从字节流中读取一个 UTF-8 字符串。假定字符串的前缀是无符号的短整型(以字节表示长度)
  22422. * @return UTF-8 编码的字符串
  22423. * @version Egret 2.4
  22424. * @platform Web,Native
  22425. */
  22426. ByteArray.prototype.readUTF = function () {
  22427. if (!this.validate(ByteArray.SIZE_OF_UINT16))
  22428. return null;
  22429. var length = this.data.getUint16(this.position, this.endian == Endian.LITTLE_ENDIAN);
  22430. this.position += ByteArray.SIZE_OF_UINT16;
  22431. if (length > 0) {
  22432. return this.readUTFBytes(length);
  22433. }
  22434. else {
  22435. return "";
  22436. }
  22437. };
  22438. /**
  22439. * @language en_US
  22440. * Read a UTF-8 byte sequence specified by the length parameter from the byte stream, and then return a character string
  22441. * @param Specify a short unsigned integer of the UTF-8 byte length
  22442. * @return A character string consists of UTF-8 bytes of the specified length
  22443. * @version Egret 2.4
  22444. * @platform Web,Native
  22445. */
  22446. /**
  22447. * @language zh_CN
  22448. * 从字节流中读取一个由 length 参数指定的 UTF-8 字节序列,并返回一个字符串
  22449. * @param length 指明 UTF-8 字节长度的无符号短整型数
  22450. * @return 由指定长度的 UTF-8 字节组成的字符串
  22451. * @version Egret 2.4
  22452. * @platform Web,Native
  22453. */
  22454. ByteArray.prototype.readUTFBytes = function (length) {
  22455. if (!this.validate(length))
  22456. return null;
  22457. var bytes = new Uint8Array(this.buffer, this.bufferOffset + this.position, length);
  22458. this.position += length;
  22459. /*let bytes: Uint8Array = new Uint8Array(new ArrayBuffer(length));
  22460. for (let i = 0; i < length; i++) {
  22461. bytes[i] = this.data.getUint8(this.position++);
  22462. }*/
  22463. return this.decodeUTF8(bytes);
  22464. };
  22465. /**
  22466. * @language en_US
  22467. * Write a Boolean value. A single byte is written according to the value parameter. If the value is true, write 1; if the value is false, write 0.
  22468. * @param value A Boolean value determining which byte is written. If the value is true, write 1; if the value is false, write 0.
  22469. * @version Egret 2.4
  22470. * @platform Web,Native
  22471. */
  22472. /**
  22473. * @language zh_CN
  22474. * 写入布尔值。根据 value 参数写入单个字节。如果为 true,则写入 1,如果为 false,则写入 0
  22475. * @param value 确定写入哪个字节的布尔值。如果该参数为 true,则该方法写入 1;如果该参数为 false,则该方法写入 0
  22476. * @version Egret 2.4
  22477. * @platform Web,Native
  22478. */
  22479. ByteArray.prototype.writeBoolean = function (value) {
  22480. this.validateBuffer(ByteArray.SIZE_OF_BOOLEAN);
  22481. this.data.setUint8(this.position++, value ? 1 : 0);
  22482. };
  22483. /**
  22484. * @language en_US
  22485. * Write a byte into the byte stream
  22486. * The low 8 bits of the parameter are used. The high 24 bits are ignored.
  22487. * @param value A 32-bit integer. The low 8 bits will be written into the byte stream
  22488. * @version Egret 2.4
  22489. * @platform Web,Native
  22490. */
  22491. /**
  22492. * @language zh_CN
  22493. * 在字节流中写入一个字节
  22494. * 使用参数的低 8 位。忽略高 24 位
  22495. * @param value 一个 32 位整数。低 8 位将被写入字节流
  22496. * @version Egret 2.4
  22497. * @platform Web,Native
  22498. */
  22499. ByteArray.prototype.writeByte = function (value) {
  22500. this.validateBuffer(ByteArray.SIZE_OF_INT8);
  22501. this.data.setInt8(this.position++, value);
  22502. };
  22503. /**
  22504. * @language en_US
  22505. * Write the byte sequence that includes length bytes in the specified byte array, bytes, (starting at the byte specified by offset, using a zero-based index), into the byte stream
  22506. * If the length parameter is omitted, the default length value 0 is used and the entire buffer starting at offset is written. If the offset parameter is also omitted, the entire buffer is written
  22507. * If the offset or length parameter is out of range, they are clamped to the beginning and end of the bytes array.
  22508. * @param bytes ByteArray Object
  22509. * @param offset A zero-based index specifying the position into the array to begin writing
  22510. * @param length An unsigned integer specifying how far into the buffer to write
  22511. * @version Egret 2.4
  22512. * @platform Web,Native
  22513. */
  22514. /**
  22515. * @language zh_CN
  22516. * 将指定字节数组 bytes(起始偏移量为 offset,从零开始的索引)中包含 length 个字节的字节序列写入字节流
  22517. * 如果省略 length 参数,则使用默认长度 0;该方法将从 offset 开始写入整个缓冲区。如果还省略了 offset 参数,则写入整个缓冲区
  22518. * 如果 offset 或 length 超出范围,它们将被锁定到 bytes 数组的开头和结尾
  22519. * @param bytes ByteArray 对象
  22520. * @param offset 从 0 开始的索引,表示在数组中开始写入的位置
  22521. * @param length 一个无符号整数,表示在缓冲区中的写入范围
  22522. * @version Egret 2.4
  22523. * @platform Web,Native
  22524. */
  22525. ByteArray.prototype.writeBytes = function (bytes, offset, length) {
  22526. if (offset === void 0) { offset = 0; }
  22527. if (length === void 0) { length = 0; }
  22528. var writeLength;
  22529. if (offset < 0) {
  22530. return;
  22531. }
  22532. if (length < 0) {
  22533. return;
  22534. }
  22535. else if (length == 0) {
  22536. writeLength = bytes.length - offset;
  22537. }
  22538. else {
  22539. writeLength = Math.min(bytes.length - offset, length);
  22540. }
  22541. if (writeLength > 0) {
  22542. this.validateBuffer(writeLength);
  22543. var tmp_data = new DataView(bytes.buffer);
  22544. var length_12 = writeLength;
  22545. var BYTES_OF_UINT32 = 4;
  22546. for (; length_12 > BYTES_OF_UINT32; length_12 -= BYTES_OF_UINT32) {
  22547. this.data.setUint32(this._position, tmp_data.getUint32(offset));
  22548. this.position += BYTES_OF_UINT32;
  22549. offset += BYTES_OF_UINT32;
  22550. }
  22551. for (; length_12 > 0; length_12--) {
  22552. this.data.setUint8(this.position++, tmp_data.getUint8(offset++));
  22553. }
  22554. }
  22555. };
  22556. /**
  22557. * @language en_US
  22558. * Write an IEEE 754 double-precision (64 bit) floating point number into the byte stream
  22559. * @param value Double-precision (64 bit) floating point number
  22560. * @version Egret 2.4
  22561. * @platform Web,Native
  22562. */
  22563. /**
  22564. * @language zh_CN
  22565. * 在字节流中写入一个 IEEE 754 双精度(64 位)浮点数
  22566. * @param value 双精度(64 位)浮点数
  22567. * @version Egret 2.4
  22568. * @platform Web,Native
  22569. */
  22570. ByteArray.prototype.writeDouble = function (value) {
  22571. this.validateBuffer(ByteArray.SIZE_OF_FLOAT64);
  22572. this.data.setFloat64(this.position, value, this.endian == Endian.LITTLE_ENDIAN);
  22573. this.position += ByteArray.SIZE_OF_FLOAT64;
  22574. };
  22575. /**
  22576. * @language en_US
  22577. * Write an IEEE 754 single-precision (32 bit) floating point number into the byte stream
  22578. * @param value Single-precision (32 bit) floating point number
  22579. * @version Egret 2.4
  22580. * @platform Web,Native
  22581. */
  22582. /**
  22583. * @language zh_CN
  22584. * 在字节流中写入一个 IEEE 754 单精度(32 位)浮点数
  22585. * @param value 单精度(32 位)浮点数
  22586. * @version Egret 2.4
  22587. * @platform Web,Native
  22588. */
  22589. ByteArray.prototype.writeFloat = function (value) {
  22590. this.validateBuffer(ByteArray.SIZE_OF_FLOAT32);
  22591. this.data.setFloat32(this.position, value, this.endian == Endian.LITTLE_ENDIAN);
  22592. this.position += ByteArray.SIZE_OF_FLOAT32;
  22593. };
  22594. /**
  22595. * @language en_US
  22596. * Write a 32-bit signed integer into the byte stream
  22597. * @param value An integer to be written into the byte stream
  22598. * @version Egret 2.4
  22599. * @platform Web,Native
  22600. */
  22601. /**
  22602. * @language zh_CN
  22603. * 在字节流中写入一个带符号的 32 位整数
  22604. * @param value 要写入字节流的整数
  22605. * @version Egret 2.4
  22606. * @platform Web,Native
  22607. */
  22608. ByteArray.prototype.writeInt = function (value) {
  22609. this.validateBuffer(ByteArray.SIZE_OF_INT32);
  22610. this.data.setInt32(this.position, value, this.endian == Endian.LITTLE_ENDIAN);
  22611. this.position += ByteArray.SIZE_OF_INT32;
  22612. };
  22613. /**
  22614. * @language en_US
  22615. * Write a 16-bit integer into the byte stream. The low 16 bits of the parameter are used. The high 16 bits are ignored.
  22616. * @param value A 32-bit integer. Its low 16 bits will be written into the byte stream
  22617. * @version Egret 2.4
  22618. * @platform Web,Native
  22619. */
  22620. /**
  22621. * @language zh_CN
  22622. * 在字节流中写入一个 16 位整数。使用参数的低 16 位。忽略高 16 位
  22623. * @param value 32 位整数,该整数的低 16 位将被写入字节流
  22624. * @version Egret 2.4
  22625. * @platform Web,Native
  22626. */
  22627. ByteArray.prototype.writeShort = function (value) {
  22628. this.validateBuffer(ByteArray.SIZE_OF_INT16);
  22629. this.data.setInt16(this.position, value, this.endian == Endian.LITTLE_ENDIAN);
  22630. this.position += ByteArray.SIZE_OF_INT16;
  22631. };
  22632. /**
  22633. * @language en_US
  22634. * Write a 32-bit unsigned integer into the byte stream
  22635. * @param value An unsigned integer to be written into the byte stream
  22636. * @version Egret 2.4
  22637. * @platform Web,Native
  22638. */
  22639. /**
  22640. * @language zh_CN
  22641. * 在字节流中写入一个无符号的 32 位整数
  22642. * @param value 要写入字节流的无符号整数
  22643. * @version Egret 2.4
  22644. * @platform Web,Native
  22645. */
  22646. ByteArray.prototype.writeUnsignedInt = function (value) {
  22647. this.validateBuffer(ByteArray.SIZE_OF_UINT32);
  22648. this.data.setUint32(this.position, value, this.endian == Endian.LITTLE_ENDIAN);
  22649. this.position += ByteArray.SIZE_OF_UINT32;
  22650. };
  22651. /**
  22652. * @language en_US
  22653. * Write a 16-bit unsigned integer into the byte stream
  22654. * @param value An unsigned integer to be written into the byte stream
  22655. * @version Egret 2.5
  22656. * @platform Web,Native
  22657. */
  22658. /**
  22659. * @language zh_CN
  22660. * 在字节流中写入一个无符号的 16 位整数
  22661. * @param value 要写入字节流的无符号整数
  22662. * @version Egret 2.5
  22663. * @platform Web,Native
  22664. */
  22665. ByteArray.prototype.writeUnsignedShort = function (value) {
  22666. this.validateBuffer(ByteArray.SIZE_OF_UINT16);
  22667. this.data.setUint16(this.position, value, this.endian == Endian.LITTLE_ENDIAN);
  22668. this.position += ByteArray.SIZE_OF_UINT16;
  22669. };
  22670. /**
  22671. * @language en_US
  22672. * Write a UTF-8 string into the byte stream. The length of the UTF-8 string in bytes is written first, as a 16-bit integer, followed by the bytes representing the characters of the string
  22673. * @param value Character string value to be written
  22674. * @version Egret 2.4
  22675. * @platform Web,Native
  22676. */
  22677. /**
  22678. * @language zh_CN
  22679. * 将 UTF-8 字符串写入字节流。先写入以字节表示的 UTF-8 字符串长度(作为 16 位整数),然后写入表示字符串字符的字节
  22680. * @param value 要写入的字符串值
  22681. * @version Egret 2.4
  22682. * @platform Web,Native
  22683. */
  22684. ByteArray.prototype.writeUTF = function (value) {
  22685. var utf8bytes = this.encodeUTF8(value);
  22686. var length = utf8bytes.length;
  22687. this.validateBuffer(ByteArray.SIZE_OF_UINT16 + length);
  22688. this.data.setUint16(this.position, length, this.endian == Endian.LITTLE_ENDIAN);
  22689. this.position += ByteArray.SIZE_OF_UINT16;
  22690. this._writeUint8Array(utf8bytes, false);
  22691. };
  22692. /**
  22693. * @language en_US
  22694. * Write a UTF-8 string into the byte stream. Similar to the writeUTF() method, but the writeUTFBytes() method does not prefix the string with a 16-bit length word
  22695. * @param value Character string value to be written
  22696. * @version Egret 2.4
  22697. * @platform Web,Native
  22698. */
  22699. /**
  22700. * @language zh_CN
  22701. * 将 UTF-8 字符串写入字节流。类似于 writeUTF() 方法,但 writeUTFBytes() 不使用 16 位长度的词为字符串添加前缀
  22702. * @param value 要写入的字符串值
  22703. * @version Egret 2.4
  22704. * @platform Web,Native
  22705. */
  22706. ByteArray.prototype.writeUTFBytes = function (value) {
  22707. this._writeUint8Array(this.encodeUTF8(value));
  22708. };
  22709. /**
  22710. *
  22711. * @returns
  22712. * @version Egret 2.4
  22713. * @platform Web,Native
  22714. */
  22715. ByteArray.prototype.toString = function () {
  22716. return "[ByteArray] length:" + this.length + ", bytesAvailable:" + this.bytesAvailable;
  22717. };
  22718. /**
  22719. * @private
  22720. * 将 Uint8Array 写入字节流
  22721. * @param bytes 要写入的Uint8Array
  22722. * @param validateBuffer
  22723. */
  22724. ByteArray.prototype._writeUint8Array = function (bytes, validateBuffer) {
  22725. if (validateBuffer === void 0) { validateBuffer = true; }
  22726. if (validateBuffer) {
  22727. this.validateBuffer(this.position + bytes.length);
  22728. }
  22729. for (var i = 0; i < bytes.length; i++) {
  22730. this.data.setUint8(this.position++, bytes[i]);
  22731. }
  22732. };
  22733. /**
  22734. * @param len
  22735. * @returns
  22736. * @version Egret 2.4
  22737. * @platform Web,Native
  22738. * @private
  22739. */
  22740. ByteArray.prototype.validate = function (len) {
  22741. //len += this.data.byteOffset;
  22742. if (this.data.byteLength > 0 && this._position + len <= this.data.byteLength) {
  22743. return true;
  22744. }
  22745. else {
  22746. egret.$error(1025);
  22747. }
  22748. };
  22749. /**********************/
  22750. /* PRIVATE METHODS */
  22751. /**********************/
  22752. /**
  22753. * @private
  22754. * @param len
  22755. * @param needReplace
  22756. */
  22757. ByteArray.prototype.validateBuffer = function (len, needReplace) {
  22758. if (needReplace === void 0) { needReplace = false; }
  22759. this.write_position = len > this.write_position ? len : this.write_position;
  22760. len += this._position;
  22761. if (this.data.byteLength < len || needReplace) {
  22762. var tmp = new Uint8Array(new ArrayBuffer(len + this.BUFFER_EXT_SIZE));
  22763. var length_13 = Math.min(this.data.buffer.byteLength, len + this.BUFFER_EXT_SIZE);
  22764. tmp.set(new Uint8Array(this.data.buffer, 0, length_13));
  22765. this.buffer = tmp.buffer;
  22766. }
  22767. };
  22768. /**
  22769. * @private
  22770. * UTF-8 Encoding/Decoding
  22771. */
  22772. ByteArray.prototype.encodeUTF8 = function (str) {
  22773. var pos = 0;
  22774. var codePoints = this.stringToCodePoints(str);
  22775. var outputBytes = [];
  22776. while (codePoints.length > pos) {
  22777. var code_point = codePoints[pos++];
  22778. if (this.inRange(code_point, 0xD800, 0xDFFF)) {
  22779. this.encoderError(code_point);
  22780. }
  22781. else if (this.inRange(code_point, 0x0000, 0x007f)) {
  22782. outputBytes.push(code_point);
  22783. }
  22784. else {
  22785. var count = void 0, offset = void 0;
  22786. if (this.inRange(code_point, 0x0080, 0x07FF)) {
  22787. count = 1;
  22788. offset = 0xC0;
  22789. }
  22790. else if (this.inRange(code_point, 0x0800, 0xFFFF)) {
  22791. count = 2;
  22792. offset = 0xE0;
  22793. }
  22794. else if (this.inRange(code_point, 0x10000, 0x10FFFF)) {
  22795. count = 3;
  22796. offset = 0xF0;
  22797. }
  22798. outputBytes.push(this.div(code_point, Math.pow(64, count)) + offset);
  22799. while (count > 0) {
  22800. var temp = this.div(code_point, Math.pow(64, count - 1));
  22801. outputBytes.push(0x80 + (temp % 64));
  22802. count -= 1;
  22803. }
  22804. }
  22805. }
  22806. return new Uint8Array(outputBytes);
  22807. };
  22808. /**
  22809. * @private
  22810. *
  22811. * @param data
  22812. * @returns
  22813. */
  22814. ByteArray.prototype.decodeUTF8 = function (data) {
  22815. var fatal = false;
  22816. var pos = 0;
  22817. var result = "";
  22818. var code_point;
  22819. var utf8_code_point = 0;
  22820. var utf8_bytes_needed = 0;
  22821. var utf8_bytes_seen = 0;
  22822. var utf8_lower_boundary = 0;
  22823. while (data.length > pos) {
  22824. var _byte = data[pos++];
  22825. if (_byte == this.EOF_byte) {
  22826. if (utf8_bytes_needed != 0) {
  22827. code_point = this.decoderError(fatal);
  22828. }
  22829. else {
  22830. code_point = this.EOF_code_point;
  22831. }
  22832. }
  22833. else {
  22834. if (utf8_bytes_needed == 0) {
  22835. if (this.inRange(_byte, 0x00, 0x7F)) {
  22836. code_point = _byte;
  22837. }
  22838. else {
  22839. if (this.inRange(_byte, 0xC2, 0xDF)) {
  22840. utf8_bytes_needed = 1;
  22841. utf8_lower_boundary = 0x80;
  22842. utf8_code_point = _byte - 0xC0;
  22843. }
  22844. else if (this.inRange(_byte, 0xE0, 0xEF)) {
  22845. utf8_bytes_needed = 2;
  22846. utf8_lower_boundary = 0x800;
  22847. utf8_code_point = _byte - 0xE0;
  22848. }
  22849. else if (this.inRange(_byte, 0xF0, 0xF4)) {
  22850. utf8_bytes_needed = 3;
  22851. utf8_lower_boundary = 0x10000;
  22852. utf8_code_point = _byte - 0xF0;
  22853. }
  22854. else {
  22855. this.decoderError(fatal);
  22856. }
  22857. utf8_code_point = utf8_code_point * Math.pow(64, utf8_bytes_needed);
  22858. code_point = null;
  22859. }
  22860. }
  22861. else if (!this.inRange(_byte, 0x80, 0xBF)) {
  22862. utf8_code_point = 0;
  22863. utf8_bytes_needed = 0;
  22864. utf8_bytes_seen = 0;
  22865. utf8_lower_boundary = 0;
  22866. pos--;
  22867. code_point = this.decoderError(fatal, _byte);
  22868. }
  22869. else {
  22870. utf8_bytes_seen += 1;
  22871. utf8_code_point = utf8_code_point + (_byte - 0x80) * Math.pow(64, utf8_bytes_needed - utf8_bytes_seen);
  22872. if (utf8_bytes_seen !== utf8_bytes_needed) {
  22873. code_point = null;
  22874. }
  22875. else {
  22876. var cp = utf8_code_point;
  22877. var lower_boundary = utf8_lower_boundary;
  22878. utf8_code_point = 0;
  22879. utf8_bytes_needed = 0;
  22880. utf8_bytes_seen = 0;
  22881. utf8_lower_boundary = 0;
  22882. if (this.inRange(cp, lower_boundary, 0x10FFFF) && !this.inRange(cp, 0xD800, 0xDFFF)) {
  22883. code_point = cp;
  22884. }
  22885. else {
  22886. code_point = this.decoderError(fatal, _byte);
  22887. }
  22888. }
  22889. }
  22890. }
  22891. //Decode string
  22892. if (code_point !== null && code_point !== this.EOF_code_point) {
  22893. if (code_point <= 0xFFFF) {
  22894. if (code_point > 0)
  22895. result += String.fromCharCode(code_point);
  22896. }
  22897. else {
  22898. code_point -= 0x10000;
  22899. result += String.fromCharCode(0xD800 + ((code_point >> 10) & 0x3ff));
  22900. result += String.fromCharCode(0xDC00 + (code_point & 0x3ff));
  22901. }
  22902. }
  22903. }
  22904. return result;
  22905. };
  22906. /**
  22907. * @private
  22908. *
  22909. * @param code_point
  22910. */
  22911. ByteArray.prototype.encoderError = function (code_point) {
  22912. egret.$error(1026, code_point);
  22913. };
  22914. /**
  22915. * @private
  22916. *
  22917. * @param fatal
  22918. * @param opt_code_point
  22919. * @returns
  22920. */
  22921. ByteArray.prototype.decoderError = function (fatal, opt_code_point) {
  22922. if (fatal) {
  22923. egret.$error(1027);
  22924. }
  22925. return opt_code_point || 0xFFFD;
  22926. };
  22927. /**
  22928. * @private
  22929. *
  22930. * @param a
  22931. * @param min
  22932. * @param max
  22933. */
  22934. ByteArray.prototype.inRange = function (a, min, max) {
  22935. return min <= a && a <= max;
  22936. };
  22937. /**
  22938. * @private
  22939. *
  22940. * @param n
  22941. * @param d
  22942. */
  22943. ByteArray.prototype.div = function (n, d) {
  22944. return Math.floor(n / d);
  22945. };
  22946. /**
  22947. * @private
  22948. *
  22949. * @param string
  22950. */
  22951. ByteArray.prototype.stringToCodePoints = function (string) {
  22952. /** @type {Array.<number>} */
  22953. var cps = [];
  22954. // Based on http://www.w3.org/TR/WebIDL/#idl-DOMString
  22955. var i = 0, n = string.length;
  22956. while (i < string.length) {
  22957. var c = string.charCodeAt(i);
  22958. if (!this.inRange(c, 0xD800, 0xDFFF)) {
  22959. cps.push(c);
  22960. }
  22961. else if (this.inRange(c, 0xDC00, 0xDFFF)) {
  22962. cps.push(0xFFFD);
  22963. }
  22964. else {
  22965. if (i == n - 1) {
  22966. cps.push(0xFFFD);
  22967. }
  22968. else {
  22969. var d = string.charCodeAt(i + 1);
  22970. if (this.inRange(d, 0xDC00, 0xDFFF)) {
  22971. var a = c & 0x3FF;
  22972. var b = d & 0x3FF;
  22973. i += 1;
  22974. cps.push(0x10000 + (a << 10) + b);
  22975. }
  22976. else {
  22977. cps.push(0xFFFD);
  22978. }
  22979. }
  22980. }
  22981. i += 1;
  22982. }
  22983. return cps;
  22984. };
  22985. return ByteArray;
  22986. }());
  22987. /**
  22988. * @private
  22989. */
  22990. ByteArray.SIZE_OF_BOOLEAN = 1;
  22991. /**
  22992. * @private
  22993. */
  22994. ByteArray.SIZE_OF_INT8 = 1;
  22995. /**
  22996. * @private
  22997. */
  22998. ByteArray.SIZE_OF_INT16 = 2;
  22999. /**
  23000. * @private
  23001. */
  23002. ByteArray.SIZE_OF_INT32 = 4;
  23003. /**
  23004. * @private
  23005. */
  23006. ByteArray.SIZE_OF_UINT8 = 1;
  23007. /**
  23008. * @private
  23009. */
  23010. ByteArray.SIZE_OF_UINT16 = 2;
  23011. /**
  23012. * @private
  23013. */
  23014. ByteArray.SIZE_OF_UINT32 = 4;
  23015. /**
  23016. * @private
  23017. */
  23018. ByteArray.SIZE_OF_FLOAT32 = 4;
  23019. /**
  23020. * @private
  23021. */
  23022. ByteArray.SIZE_OF_FLOAT64 = 8;
  23023. egret.ByteArray = ByteArray;
  23024. __reflect(ByteArray.prototype, "egret.ByteArray");
  23025. })(egret || (egret = {}));
  23026. //////////////////////////////////////////////////////////////////////////////////////
  23027. //
  23028. // Copyright (c) 2014-present, Egret Technology.
  23029. // All rights reserved.
  23030. // Redistribution and use in source and binary forms, with or without
  23031. // modification, are permitted provided that the following conditions are met:
  23032. //
  23033. // * Redistributions of source code must retain the above copyright
  23034. // notice, this list of conditions and the following disclaimer.
  23035. // * Redistributions in binary form must reproduce the above copyright
  23036. // notice, this list of conditions and the following disclaimer in the
  23037. // documentation and/or other materials provided with the distribution.
  23038. // * Neither the name of the Egret nor the
  23039. // names of its contributors may be used to endorse or promote products
  23040. // derived from this software without specific prior written permission.
  23041. //
  23042. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  23043. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  23044. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  23045. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  23046. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  23047. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  23048. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  23049. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  23050. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  23051. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23052. //
  23053. //////////////////////////////////////////////////////////////////////////////////////
  23054. var egret;
  23055. (function (egret) {
  23056. //混合模式在Web端只有部分被支持,在 Native 中全部都支持。
  23057. //目前所有平台的浏览器都支持的有:Layer,Alpha,Normal,Add,ERASE。
  23058. //IOS中的所有浏览器以及Android内的部分浏览器还支持:Multiply,Screen,Lighten,Darken,Difference,Overlay,HardLight。
  23059. //仅在 Native 端支持的有:Subtract,Invert。
  23060. /**
  23061. * @language en_US
  23062. * A class that provides constant values for visual blend mode effects. These constants are used in the blendMode
  23063. * property of the DisplayObject class.
  23064. * @see egret.DisplayObject#blendMode
  23065. * @version Egret 2.4
  23066. * @platform Web,Native
  23067. * @includeExample egret/display/BlendMode.ts
  23068. * @see http://edn.egret.com/cn/docs/page/108 显示容器的概念与实现
  23069. */
  23070. /**
  23071. * @language zh_CN
  23072. * 提供混合模式可视效果的常量值的类,通常用于 DisplayObject 的 blendMode 属性上。
  23073. * @see egret.DisplayObject#blendMode
  23074. * @version Egret 2.4
  23075. * @platform Web,Native
  23076. * @includeExample egret/display/BlendMode.ts
  23077. * @see http://edn.egret.com/cn/docs/page/108 显示容器的概念与实现
  23078. */
  23079. var BlendMode = (function () {
  23080. function BlendMode() {
  23081. }
  23082. return BlendMode;
  23083. }());
  23084. /**
  23085. * @language en_US
  23086. * The display object appears in front of the background. Pixel values of the display object override the pixel
  23087. * values of the background. Where the display object is transparent, the background is visible.
  23088. * @version Egret 2.4
  23089. * @platform Web,Native
  23090. */
  23091. /**
  23092. * @language zh_CN
  23093. * 该显示对象出现在背景前面。显示对象的像素值会覆盖背景的像素值。在显示对象为透明的区域,背景是可见的。
  23094. * @version Egret 2.4
  23095. * @platform Web,Native
  23096. */
  23097. BlendMode.NORMAL = "normal";
  23098. /**
  23099. * @language en_US
  23100. * Adds the values of the constituent colors of the display object to the colors of its background, applying a
  23101. * ceiling of 0xFF. This setting is commonly used for animating a lightening dissolve between two objects.<br/>
  23102. * For example, if the display object has a pixel with an RGB value of 0xAAA633, and the background pixel has an
  23103. * RGB value of 0xDD2200, the resulting RGB value for the displayed pixel is 0xFFC833 (because 0xAA + 0xDD > 0xFF,
  23104. * 0xA6 + 0x22 = 0xC8, and 0x33 + 0x00 = 0x33).
  23105. * @version Egret 2.4
  23106. * @platform Web,Native
  23107. */
  23108. /**
  23109. * @language zh_CN
  23110. * 将显示对象的原色值添加到它的背景颜色中,上限值为 0xFF。此设置通常用于使两个对象间的加亮溶解产生动画效果。<br/>
  23111. * 例如,如果显示对象的某个像素的 RGB 值为 0xAAA633,背景像素的 RGB 值为 0xDD2200,则显示像素的结果 RGB 值为 0xFFC833
  23112. * (因为 0xAA + 0xDD > 0xFF,0xA6 + 0x22 = 0xC8,且 0x33 + 0x00 = 0x33)。
  23113. * @version Egret 2.4
  23114. * @platform Web,Native
  23115. */
  23116. BlendMode.ADD = "add";
  23117. /**
  23118. * @language en_US
  23119. * Erases the background based on the alpha value of the display object.
  23120. * @version Egret 2.4
  23121. * @platform Web,Native
  23122. */
  23123. /**
  23124. * @language zh_CN
  23125. * 根据显示对象的 Alpha 值擦除背景。Alpha 值不为0的区域将被擦除。
  23126. * @version Egret 2.4
  23127. * @platform Web,Native
  23128. */
  23129. BlendMode.ERASE = "erase";
  23130. egret.BlendMode = BlendMode;
  23131. __reflect(BlendMode.prototype, "egret.BlendMode");
  23132. })(egret || (egret = {}));
  23133. (function (egret) {
  23134. var sys;
  23135. (function (sys) {
  23136. var blendModeString = ["normal", "add", "erase"];
  23137. var blendModeNumber = {};
  23138. var length = blendModeString.length;
  23139. for (var i = 0; i < length; i++) {
  23140. var str = blendModeString[i];
  23141. blendModeNumber[str] = i;
  23142. }
  23143. /**
  23144. * @private
  23145. * 转换 blendMode 字符串为数字。
  23146. */
  23147. function blendModeToNumber(blendMode) {
  23148. var num = blendModeNumber[blendMode];
  23149. return num === undefined ? 0 : num;
  23150. }
  23151. sys.blendModeToNumber = blendModeToNumber;
  23152. /**
  23153. * @private
  23154. * 转换数字为 blendMode 字符串。
  23155. */
  23156. function numberToBlendMode(blendMode) {
  23157. var str = blendModeString[blendMode];
  23158. return str === undefined ? "normal" : str;
  23159. }
  23160. sys.numberToBlendMode = numberToBlendMode;
  23161. })(sys = egret.sys || (egret.sys = {}));
  23162. })(egret || (egret = {}));
  23163. var egret;
  23164. (function (egret) {
  23165. /**
  23166. * @private
  23167. */
  23168. egret.fontMapping = {};
  23169. /**
  23170. * 兼容旧版本不使用 fontMapping 的情况
  23171. * @private
  23172. */
  23173. egret.useFontMapping = false;
  23174. /**
  23175. * @language en_US
  23176. * Register font mapping.
  23177. * @param fontFamily The font family name to register.
  23178. * @param value The font value.
  23179. * @version Egret 3.2.3
  23180. * @platform Native
  23181. */
  23182. /**
  23183. * @language zh_CN
  23184. * 注册字体映射
  23185. * @param fontFamily 要注册的字体名称
  23186. * @param value 注册的字体值
  23187. * @version Egret 3.2.3
  23188. * @platform Native
  23189. */
  23190. function registerFontMapping(fontFamily, value) {
  23191. egret.useFontMapping = true;
  23192. egret.fontMapping[fontFamily] = value;
  23193. }
  23194. egret.registerFontMapping = registerFontMapping;
  23195. })(egret || (egret = {}));
  23196. //////////////////////////////////////////////////////////////////////////////////////
  23197. //
  23198. // Copyright (c) 2014-present, Egret Technology.
  23199. // All rights reserved.
  23200. // Redistribution and use in source and binary forms, with or without
  23201. // modification, are permitted provided that the following conditions are met:
  23202. //
  23203. // * Redistributions of source code must retain the above copyright
  23204. // notice, this list of conditions and the following disclaimer.
  23205. // * Redistributions in binary form must reproduce the above copyright
  23206. // notice, this list of conditions and the following disclaimer in the
  23207. // documentation and/or other materials provided with the distribution.
  23208. // * Neither the name of the Egret nor the
  23209. // names of its contributors may be used to endorse or promote products
  23210. // derived from this software without specific prior written permission.
  23211. //
  23212. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  23213. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  23214. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  23215. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  23216. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  23217. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  23218. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  23219. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  23220. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  23221. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23222. //
  23223. //////////////////////////////////////////////////////////////////////////////////////
  23224. var egret;
  23225. (function (egret) {
  23226. /**
  23227. * @language en_US
  23228. * The Stage class represents the main drawing area.The Stage object is not globally accessible. You need to access
  23229. * it through the stage property of a DisplayObject instance.<br/>
  23230. * The Stage class has several ancestor classes — Sprite, DisplayObject, and EventDispatcher — from which it inherits
  23231. * properties and methods. Many of these properties and methods are inapplicable to Stage objects.
  23232. * @event egret.Event.RESIZE Dispatched when the stageWidth or stageHeight property of the Stage object is changed.
  23233. * @version Egret 2.4
  23234. * @platform Web,Native
  23235. * @includeExample egret/display/Stage.ts
  23236. */
  23237. /**
  23238. * @language zh_CN
  23239. * Stage 类代表主绘图区。
  23240. * 可以利用 DisplayObject 实例的 stage 属性进行访问。<br/>
  23241. * Stage 类具有多个祖代类: Sprite、DisplayObject 和 EventDispatcher,属性和方法便是从这些类继承而来的。
  23242. * 从这些继承的许多属性和方法不适用于 Stage 对象。
  23243. * @event egret.Event.RESIZE 当stageWidth或stageHeight属性发生改变时调度
  23244. * @event egret.Event.DEACTIVATE 当stage失去焦点后调度
  23245. * @event egret.Event.ACTIVATE 当stage获得焦点后调度
  23246. *
  23247. * @version Egret 2.4
  23248. * @platform Web,Native
  23249. * @includeExample egret/display/Stage.ts
  23250. */
  23251. var Stage = (function (_super) {
  23252. __extends(Stage, _super);
  23253. /**
  23254. * @private
  23255. * Stage不许允许自行实例化
  23256. * @version Egret 2.4
  23257. * @platform Web,Native
  23258. */
  23259. function Stage() {
  23260. var _this = _super.call(this) || this;
  23261. /**
  23262. * @private
  23263. */
  23264. _this.$stageWidth = 0;
  23265. /**
  23266. * @private
  23267. */
  23268. _this.$stageHeight = 0;
  23269. _this.$scaleMode = egret.StageScaleMode.SHOW_ALL;
  23270. _this.$orientation = egret.OrientationMode.AUTO;
  23271. _this.$maxTouches = 99;
  23272. _this.$dirtyRegionPolicy = egret.DirtyRegionPolicy.ON;
  23273. _this.$stage = _this;
  23274. _this.$nestLevel = 1;
  23275. return _this;
  23276. }
  23277. Object.defineProperty(Stage.prototype, "frameRate", {
  23278. /**
  23279. * @language en_US
  23280. * Gets and sets the frame rate of the stage. The frame rate is defined as frames per second. Valid range for the
  23281. * frame rate is from 0.01 to 1000 frames per second.<br/>
  23282. * Note: setting the frameRate property of one Stage object changes the frame rate for all Stage objects
  23283. * @default 30
  23284. * @version Egret 2.4
  23285. * @platform Web,Native
  23286. */
  23287. /**
  23288. * @language zh_CN
  23289. * 获取并设置舞台的帧速率。帧速率是指每秒显示的帧数。帧速率的有效范围为每秒 0.01 到 60 个帧。<br/>
  23290. * 注意: 修改任何一个Stage的frameRate属性都会同步修改其他Stage的帧率。
  23291. * @default 30
  23292. * @version Egret 2.4
  23293. * @platform Web,Native
  23294. */
  23295. get: function () {
  23296. return egret.sys.$ticker.$frameRate;
  23297. },
  23298. set: function (value) {
  23299. egret.sys.$ticker.$setFrameRate(value);
  23300. },
  23301. enumerable: true,
  23302. configurable: true
  23303. });
  23304. Object.defineProperty(Stage.prototype, "stageWidth", {
  23305. /**
  23306. * @language en_US
  23307. * Indicates the width of the stage, in pixels.
  23308. * @version Egret 2.4
  23309. * @platform Web,Native
  23310. */
  23311. /**
  23312. * @language zh_CN
  23313. * 舞台的当前宽度(以像素为单位)。
  23314. * @version Egret 2.4
  23315. * @platform Web,Native
  23316. */
  23317. get: function () {
  23318. return this.$stageWidth;
  23319. },
  23320. enumerable: true,
  23321. configurable: true
  23322. });
  23323. Object.defineProperty(Stage.prototype, "stageHeight", {
  23324. /**
  23325. * @language en_US
  23326. * Indicates the height of the stage, in pixels.
  23327. * @version Egret 2.4
  23328. * @platform Web,Native
  23329. */
  23330. /**
  23331. * @language zh_CN
  23332. * 舞台的当前高度(以像素为单位)。
  23333. * @version Egret 2.4
  23334. * @platform Web,Native
  23335. */
  23336. get: function () {
  23337. return this.$stageHeight;
  23338. },
  23339. enumerable: true,
  23340. configurable: true
  23341. });
  23342. /**
  23343. * @language en_US
  23344. * After you call the invalidate() method, when the display list is next rendered, the Egret runtime sends a render
  23345. * event to each display object that has registered to listen for the render event. You must call the invalidate()
  23346. * method each time you want the Egret runtime to send render events.
  23347. * @version Egret 2.4
  23348. * @platform Web,Native
  23349. */
  23350. /**
  23351. * @language zh_CN
  23352. * 调用 invalidate() 方法后,在显示列表下次呈现时,Egret 会向每个已注册侦听 Event.RENDER 事件的显示对象发送一个 Event.RENDER 事件。
  23353. * 每次您希望 Egret 发送 Event.RENDER 事件时,都必须调用 invalidate() 方法。
  23354. * @version Egret 2.4
  23355. * @platform Web,Native
  23356. */
  23357. Stage.prototype.invalidate = function () {
  23358. egret.sys.$invalidateRenderFlag = true;
  23359. };
  23360. /**
  23361. * @deprecated
  23362. */
  23363. Stage.prototype.registerImplementation = function (interfaceName, instance) {
  23364. egret.registerImplementation(interfaceName, instance);
  23365. };
  23366. /**
  23367. * @deprecated
  23368. */
  23369. Stage.prototype.getImplementation = function (interfaceName) {
  23370. return egret.getImplementation(interfaceName);
  23371. };
  23372. Object.defineProperty(Stage.prototype, "scaleMode", {
  23373. /**
  23374. * @language en_US
  23375. * A StageScaleMode class that specifies which scale mode to use. The following are valid values:<br/>
  23376. * <ul>
  23377. * <li>StageScaleMode.EXACT_FIT -- The entire application be visible in the specified area without trying to preserve the original aspect ratio. Distortion can occur, the application may be stretched or compressed.</li>
  23378. * <li>StageScaleMode.SHOW_ALL -- The entire application is visible in the specified area without distortion while maintaining the application of the original aspect ratio. Applications may display border.</li>
  23379. * <li>StageScaleMode.NO_SCALE -- The size of the entire application is fixed, so that even if the size of the player window changes, it remains unchanged. If the player window is smaller than the content, it may do some trimming.</li>
  23380. * <li>StageScaleMode.NO_BORDER -- Keep the original aspect ratio scaling application content, after scaling a narrow direction of application content to fill the viewport players on both sides in the other direction may exceed the viewport and the player is cut.</li>
  23381. * <li>StageScaleMode.FIXED_WIDTH -- Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant width, height may change.</li>
  23382. * <li>StageScaleMode.FIXED_HEIGHT -- Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant height, width may change.</li>
  23383. * </ul>
  23384. * @default egret.StageScaleMode.SHOW_ALL
  23385. */
  23386. /**
  23387. * @language zh_CN
  23388. * 一个 StageScaleMode 类中指定要使用哪种缩放模式的值。以下是有效值:<br/>
  23389. * <ul>
  23390. * <li>StageScaleMode.EXACT_FIT -- 整个应用程序在指定区域中可见,但不尝试保持原始高宽比。可能会发生扭曲,应用程序可能会拉伸或压缩显示。</li>
  23391. * <li>StageScaleMode.SHOW_ALL -- 整个应用程序在指定区域中可见,且不发生扭曲,同时保持应用程序的原始高宽比。应用程序的可能会显示边框。</li>
  23392. * <li>StageScaleMode.NO_SCALE -- 整个应用程序的大小固定,因此,即使播放器窗口的大小更改,它也会保持不变。如果播放器窗口比内容小,则可能进行一些裁切。</li>
  23393. * <li>StageScaleMode.NO_BORDER -- 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较窄方向填满播放器视口,另一个方向的两侧可能会超出播放器视口而被裁切。</li>
  23394. * <li>StageScaleMode.FIXED_WIDTH -- 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始宽度不变,高度可能会改变。</li>
  23395. * <li>StageScaleMode.FIXED_HEIGHT -- 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始高度不变,宽度可能会改变。</li>
  23396. * </ul>
  23397. * @default egret.StageScaleMode.SHOW_ALL
  23398. */
  23399. get: function () {
  23400. return this.$scaleMode;
  23401. },
  23402. set: function (value) {
  23403. if (this.$scaleMode == value) {
  23404. return;
  23405. }
  23406. this.$scaleMode = value;
  23407. this.$screen.updateScreenSize();
  23408. },
  23409. enumerable: true,
  23410. configurable: true
  23411. });
  23412. Object.defineProperty(Stage.prototype, "orientation", {
  23413. /**
  23414. * @language en_US
  23415. * Horizontal and vertical screen display screen, can only be set under the current Native in the configuration file. A egret.OrientationMode class that specifies which display mode to use. The following are valid values:<br/>
  23416. * <ul>
  23417. * <li>egret.OrientationMode.AUTO -- Always follow the direction of application display screen, always guaranteed by the look down.</li>
  23418. * <li>egret.OrientationMode.PORTRAIT -- Applications remain portrait mode, namely horizontal screen look, the screen from left to right.</li>
  23419. * <li>egret.OrientationMode.LANDSCAPE -- Applications remain horizontal screen mode, namely vertical screen, the screen from right to left.</li>
  23420. * <li>egret.OrientationMode.LANDSCAPE_FLIPPED -- Applications remain horizontal screen mode, namely vertical screen, the screen from left to right.</li>
  23421. * </ul>
  23422. * @platform Web
  23423. * @version 2.4
  23424. */
  23425. /**
  23426. * @language zh_CN
  23427. * 屏幕横竖屏显示方式,目前 Native 下只能在配置文件里设置。一个 egret.OrientationMode 类中指定要使用哪种显示方式。以下是有效值:<br/>
  23428. * <ul>
  23429. * <li>egret.OrientationMode.AUTO -- 应用始终跟随屏幕的方向显示,始终保证由上往下看。</li>
  23430. * <li>egret.OrientationMode.PORTRAIT -- 应用始终保持竖屏模式,即横屏看时,屏幕由左往右看。</li>
  23431. * <li>egret.OrientationMode.LANDSCAPE -- 应用始终保持横屏模式,即竖屏看时,屏幕显示由右往左。</li>
  23432. * <li>egret.OrientationMode.LANDSCAPE_FLIPPED -- 应用始终保持横屏模式,即竖屏看时,屏幕显示由左往右。</li>
  23433. * </ul>
  23434. * @platform Web
  23435. * @version 2.4
  23436. */
  23437. get: function () {
  23438. return this.$orientation;
  23439. },
  23440. set: function (value) {
  23441. if (this.$orientation == value) {
  23442. return;
  23443. }
  23444. this.$orientation = value;
  23445. this.$screen.updateScreenSize();
  23446. },
  23447. enumerable: true,
  23448. configurable: true
  23449. });
  23450. Object.defineProperty(Stage.prototype, "textureScaleFactor", {
  23451. /**
  23452. * @language en_US
  23453. * Draw texture zoom ratio
  23454. * @default 1
  23455. */
  23456. /**
  23457. * @language zh_CN
  23458. * 绘制纹理的缩放比率,默认值为1
  23459. * @default 1
  23460. */
  23461. get: function () {
  23462. return egret.$TextureScaleFactor;
  23463. },
  23464. set: function (value) {
  23465. egret.$TextureScaleFactor = value;
  23466. },
  23467. enumerable: true,
  23468. configurable: true
  23469. });
  23470. Object.defineProperty(Stage.prototype, "maxTouches", {
  23471. /**
  23472. * @language en_US
  23473. * Set the number of screens can simultaneously touch. Above this amount will not be triggered in response.
  23474. * @default 99
  23475. */
  23476. /**
  23477. * @language zh_CN
  23478. * 设置屏幕同时可以触摸的数量。高于这个数量将不会被触发响应。
  23479. * @default 99
  23480. */
  23481. get: function () {
  23482. return this.$maxTouches;
  23483. },
  23484. set: function (value) {
  23485. if (this.$maxTouches == value) {
  23486. return;
  23487. }
  23488. this.$maxTouches = value;
  23489. this.$screen.updateMaxTouches();
  23490. },
  23491. enumerable: true,
  23492. configurable: true
  23493. });
  23494. Object.defineProperty(Stage.prototype, "dirtyRegionPolicy", {
  23495. get: function () {
  23496. return this.$dirtyRegionPolicy;
  23497. },
  23498. /**
  23499. * @language en_US
  23500. * Set dirty region policy
  23501. * One of the constants defined by egret.DirtyRegionPolicy
  23502. * @version Egret 2.5.5
  23503. * @platform Web,Native
  23504. */
  23505. /**
  23506. * @language zh_CN
  23507. * 设置脏矩形策略
  23508. * egret.DirtyRegionPolicy 定义的常量之一
  23509. * @version Egret 2.5.5
  23510. * @platform Web,Native
  23511. */
  23512. set: function (policy) {
  23513. if (this.$dirtyRegionPolicy != policy) {
  23514. this.$dirtyRegionPolicy = policy;
  23515. this.$displayList.setDirtyRegionPolicy(policy);
  23516. }
  23517. },
  23518. enumerable: true,
  23519. configurable: true
  23520. });
  23521. /**
  23522. * @language en_US
  23523. * Set resolution size
  23524. * @param width width
  23525. * @param height height
  23526. * @version Egret 2.5.5
  23527. * @platform Web,Native
  23528. */
  23529. /**
  23530. * @language zh_CN
  23531. * 设置分辨率尺寸
  23532. * @param width 宽度
  23533. * @param height 高度
  23534. * @version Egret 2.5.5
  23535. * @platform Web,Native
  23536. */
  23537. Stage.prototype.setContentSize = function (width, height) {
  23538. this.$screen.setContentSize(width, height);
  23539. };
  23540. return Stage;
  23541. }(egret.DisplayObjectContainer));
  23542. egret.Stage = Stage;
  23543. __reflect(Stage.prototype, "egret.Stage");
  23544. if (true) {
  23545. egret.$markCannotUse(Stage, "alpha", 1);
  23546. egret.$markCannotUse(Stage, "visible", true);
  23547. egret.$markCannotUse(Stage, "x", 0);
  23548. egret.$markCannotUse(Stage, "y", 0);
  23549. egret.$markCannotUse(Stage, "scaleX", 1);
  23550. egret.$markCannotUse(Stage, "scaleY", 1);
  23551. egret.$markCannotUse(Stage, "rotation", 0);
  23552. egret.$markCannotUse(Stage, "cacheAsBitmap", false);
  23553. egret.$markCannotUse(Stage, "scrollRect", null);
  23554. egret.$markCannotUse(Stage, "filters", null);
  23555. egret.$markCannotUse(Stage, "blendMode", null);
  23556. egret.$markCannotUse(Stage, "touchEnabled", true);
  23557. egret.$markCannotUse(Stage, "matrix", null);
  23558. }
  23559. if (true) {
  23560. egret.$markReadOnly(Stage, "stageWidth");
  23561. egret.$markReadOnly(Stage, "stageHeight");
  23562. }
  23563. })(egret || (egret = {}));
  23564. //////////////////////////////////////////////////////////////////////////////////////
  23565. //
  23566. // Copyright (c) 2014-present, Egret Technology.
  23567. // All rights reserved.
  23568. // Redistribution and use in source and binary forms, with or without
  23569. // modification, are permitted provided that the following conditions are met:
  23570. //
  23571. // * Redistributions of source code must retain the above copyright
  23572. // notice, this list of conditions and the following disclaimer.
  23573. // * Redistributions in binary form must reproduce the above copyright
  23574. // notice, this list of conditions and the following disclaimer in the
  23575. // documentation and/or other materials provided with the distribution.
  23576. // * Neither the name of the Egret nor the
  23577. // names of its contributors may be used to endorse or promote products
  23578. // derived from this software without specific prior written permission.
  23579. //
  23580. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  23581. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  23582. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  23583. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  23584. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  23585. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  23586. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  23587. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  23588. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  23589. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23590. //
  23591. //////////////////////////////////////////////////////////////////////////////////////
  23592. var egret;
  23593. (function (egret) {
  23594. /**
  23595. * @language en_US
  23596. * Logger is an entrance for the log processing namespace of the engine
  23597. * @version Egret 2.4
  23598. * @platform Web,Native
  23599. */
  23600. /**
  23601. * @language zh_CN
  23602. * Logger是引擎的日志处理模块入口
  23603. * @version Egret 2.4
  23604. * @platform Web,Native
  23605. */
  23606. var Logger = (function () {
  23607. function Logger() {
  23608. }
  23609. Object.defineProperty(Logger, "logLevel", {
  23610. /**
  23611. * @language en_US
  23612. * Set the current need to open the log level. Grade level are: ALL <DEBUG <INFO <WARN <ERROR <OFF<br/>
  23613. * This feature is only in DEBUG mode to take effect. <br/>
  23614. * <Ul>
  23615. * <Li> Logger.ALL - all levels of log can be printed out. </ li>
  23616. * <Li> Logger.DEBUG - print debug, info, log, warn, error. </ li>
  23617. * <Li> Logger.INFO - print info, log, warn, error. </ li>
  23618. * <Li> Logger.WARN - can print warn, error. </ li>
  23619. * <Li> Logger.ERROR - You can print error. </ li>
  23620. * <Li> Logger.OFF - all closed. </ li>
  23621. * </ Ul>
  23622. *param LogType from this level to start printing.
  23623. * @version Egret 2.4
  23624. * @platform Web,Native
  23625. */
  23626. /**
  23627. * @language zh_CN
  23628. * 设置当前需要开启的log级别。级别等级分别为:ALL < DEBUG < INFO < WARN < ERROR < OFF<br/>
  23629. * 此功能只在 DEBUG 模式下才生效。<br/>
  23630. * <ul>
  23631. * <li>Logger.ALL -- 所有等级的log都可以打印出来。</li>
  23632. * <li>Logger.DEBUG -- 可以打印debug、info、log、warn、error。</li>
  23633. * <li>Logger.INFO -- 可以打印info、log、warn、error。</li>
  23634. * <li>Logger.WARN -- 可以打印warn、error。</li>
  23635. * <li>Logger.ERROR -- 可以打印error。</li>
  23636. * <li>Logger.OFF -- 全部关闭。</li>
  23637. * </ul>
  23638. * @param logType 从这个等级开始打印。
  23639. * @version Egret 2.4
  23640. * @platform Web,Native
  23641. */
  23642. set: function (logType) {
  23643. },
  23644. enumerable: true,
  23645. configurable: true
  23646. });
  23647. return Logger;
  23648. }());
  23649. /**
  23650. * @language en_US
  23651. * open all
  23652. * @version Egret 2.4
  23653. * @platform Web,Native
  23654. */
  23655. /**
  23656. * @language zh_CN
  23657. * 全开
  23658. * @version Egret 2.4
  23659. * @platform Web,Native
  23660. */
  23661. Logger.ALL = "all";
  23662. /**
  23663. * @language en_US
  23664. * level: DEBUG
  23665. * @version Egret 2.4
  23666. * @platform Web,Native
  23667. */
  23668. /**
  23669. * @language zh_CN
  23670. * 等级为 DEBUG
  23671. * @version Egret 2.4
  23672. * @platform Web,Native
  23673. */
  23674. Logger.true = "debug";
  23675. /**
  23676. * @language en_US
  23677. * level: INFO
  23678. * @version Egret 2.4
  23679. * @platform Web,Native
  23680. */
  23681. /**
  23682. * @language zh_CN
  23683. * 等级为 INFO
  23684. * @version Egret 2.4
  23685. * @platform Web,Native
  23686. */
  23687. Logger.INFO = "info";
  23688. /**
  23689. * @language en_US
  23690. * level: WARN
  23691. * @version Egret 2.4
  23692. * @platform Web,Native
  23693. */
  23694. /**
  23695. * @language zh_CN
  23696. * 等级为 WARN
  23697. * @version Egret 2.4
  23698. * @platform Web,Native
  23699. */
  23700. Logger.WARN = "warn";
  23701. /**
  23702. * @language en_US
  23703. * level: ERROR
  23704. * @version Egret 2.4
  23705. * @platform Web,Native
  23706. */
  23707. /**
  23708. * @language zh_CN
  23709. * 等级为 ERROR
  23710. * @version Egret 2.4
  23711. * @platform Web,Native
  23712. */
  23713. Logger.ERROR = "error";
  23714. /**
  23715. * @language en_US
  23716. * close all
  23717. * @version Egret 2.4
  23718. * @platform Web,Native
  23719. */
  23720. /**
  23721. * @language zh_CN
  23722. * 全关
  23723. * @version Egret 2.4
  23724. * @platform Web,Native
  23725. */
  23726. Logger.OFF = "off";
  23727. egret.Logger = Logger;
  23728. __reflect(Logger.prototype, "egret.Logger");
  23729. })(egret || (egret = {}));
  23730. //////////////////////////////////////////////////////////////////////////////////////
  23731. //
  23732. // Copyright (c) 2014-present, Egret Technology.
  23733. // All rights reserved.
  23734. // Redistribution and use in source and binary forms, with or without
  23735. // modification, are permitted provided that the following conditions are met:
  23736. //
  23737. // * Redistributions of source code must retain the above copyright
  23738. // notice, this list of conditions and the following disclaimer.
  23739. // * Redistributions in binary form must reproduce the above copyright
  23740. // notice, this list of conditions and the following disclaimer in the
  23741. // documentation and/or other materials provided with the distribution.
  23742. // * Neither the name of the Egret nor the
  23743. // names of its contributors may be used to endorse or promote products
  23744. // derived from this software without specific prior written permission.
  23745. //
  23746. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  23747. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  23748. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  23749. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  23750. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  23751. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  23752. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  23753. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  23754. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  23755. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23756. //
  23757. //////////////////////////////////////////////////////////////////////////////////////
  23758. var egret;
  23759. (function (egret) {
  23760. /**
  23761. * @version Egret 2.4
  23762. * @platform Web,Native
  23763. */
  23764. var NumberUtils = (function () {
  23765. function NumberUtils() {
  23766. }
  23767. /**
  23768. * @language en_US
  23769. * Judge whether it is a numerical value
  23770. * @param value Parameter that needs to be judged
  23771. * @returns
  23772. * @version Egret 2.4
  23773. * @platform Web,Native
  23774. */
  23775. /**
  23776. * @language zh_CN
  23777. * 判断是否是数值
  23778. * @param value 需要判断的参数
  23779. * @returns
  23780. * @version Egret 2.4
  23781. * @platform Web,Native
  23782. */
  23783. NumberUtils.isNumber = function (value) {
  23784. return typeof (value) === "number" && !isNaN(value);
  23785. };
  23786. /**
  23787. * @language en_US
  23788. * Obtain the approximate sin value of the corresponding angle value
  23789. * @param value {number} Angle value
  23790. * @returns {number} sin value
  23791. * @version Egret 2.4
  23792. * @platform Web,Native
  23793. */
  23794. /**
  23795. * @language zh_CN
  23796. * 得到对应角度值的sin近似值
  23797. * @param value {number} 角度值
  23798. * @returns {number} sin值
  23799. * @version Egret 2.4
  23800. * @platform Web,Native
  23801. */
  23802. NumberUtils.sin = function (value) {
  23803. var valueFloor = Math.floor(value);
  23804. var valueCeil = valueFloor + 1;
  23805. var resultFloor = NumberUtils.sinInt(valueFloor);
  23806. if (valueFloor == value) {
  23807. return resultFloor;
  23808. }
  23809. var resultCeil = NumberUtils.sinInt(valueCeil);
  23810. return (value - valueFloor) * resultCeil + (valueCeil - value) * resultFloor;
  23811. };
  23812. /**
  23813. * @private
  23814. *
  23815. * @param value
  23816. * @returns
  23817. */
  23818. NumberUtils.sinInt = function (value) {
  23819. value = value % 360;
  23820. if (value < 0) {
  23821. value += 360;
  23822. }
  23823. return egret_sin_map[value];
  23824. };
  23825. /**
  23826. * @language en_US
  23827. * Obtain the approximate cos value of the corresponding angle value
  23828. * @param value {number} Angle value
  23829. * @returns {number} cos value
  23830. * @version Egret 2.4
  23831. * @platform Web,Native
  23832. */
  23833. /**
  23834. * @language zh_CN
  23835. * 得到对应角度值的cos近似值
  23836. * @param value {number} 角度值
  23837. * @returns {number} cos值
  23838. * @version Egret 2.4
  23839. * @platform Web,Native
  23840. */
  23841. NumberUtils.cos = function (value) {
  23842. var valueFloor = Math.floor(value);
  23843. var valueCeil = valueFloor + 1;
  23844. var resultFloor = NumberUtils.cosInt(valueFloor);
  23845. if (valueFloor == value) {
  23846. return resultFloor;
  23847. }
  23848. var resultCeil = NumberUtils.cosInt(valueCeil);
  23849. return (value - valueFloor) * resultCeil + (valueCeil - value) * resultFloor;
  23850. };
  23851. /**
  23852. * @private
  23853. *
  23854. * @param value
  23855. * @returns
  23856. */
  23857. NumberUtils.cosInt = function (value) {
  23858. value = value % 360;
  23859. if (value < 0) {
  23860. value += 360;
  23861. }
  23862. return egret_cos_map[value];
  23863. };
  23864. return NumberUtils;
  23865. }());
  23866. egret.NumberUtils = NumberUtils;
  23867. __reflect(NumberUtils.prototype, "egret.NumberUtils");
  23868. })(egret || (egret = {}));
  23869. /**
  23870. * @private
  23871. */
  23872. var egret_sin_map = {};
  23873. /**
  23874. * @private
  23875. */
  23876. var egret_cos_map = {};
  23877. /**
  23878. * @private
  23879. */
  23880. var DEG_TO_RAD = Math.PI / 180;
  23881. for (var NumberUtils_i = 0; NumberUtils_i < 360; NumberUtils_i++) {
  23882. egret_sin_map[NumberUtils_i] = Math.sin(NumberUtils_i * DEG_TO_RAD);
  23883. egret_cos_map[NumberUtils_i] = Math.cos(NumberUtils_i * DEG_TO_RAD);
  23884. }
  23885. egret_sin_map[90] = 1;
  23886. egret_cos_map[90] = 0;
  23887. egret_sin_map[180] = 0;
  23888. egret_cos_map[180] = -1;
  23889. egret_sin_map[270] = -1;
  23890. egret_cos_map[270] = 0;
  23891. //对未提供bind的浏览器实现bind机制
  23892. if (!Function.prototype.bind) {
  23893. Function.prototype.bind = function (oThis) {
  23894. if (typeof this !== "function") {
  23895. // closest thing possible to the ECMAScript 5 internal IsCallable function
  23896. egret.$error(1029);
  23897. }
  23898. var aArgs = Array.prototype.slice.call(arguments, 1), fToBind = this, fNOP = function () {
  23899. }, fBound = function () {
  23900. return fToBind.apply(this instanceof fNOP && oThis
  23901. ? this
  23902. : oThis, aArgs.concat(Array.prototype.slice.call(arguments)));
  23903. };
  23904. fNOP.prototype = this.prototype;
  23905. fBound.prototype = new fNOP();
  23906. return fBound;
  23907. };
  23908. }
  23909. //////////////////////////////////////////////////////////////////////////////////////
  23910. //
  23911. // Copyright (c) 2014-present, Egret Technology.
  23912. // All rights reserved.
  23913. // Redistribution and use in source and binary forms, with or without
  23914. // modification, are permitted provided that the following conditions are met:
  23915. //
  23916. // * Redistributions of source code must retain the above copyright
  23917. // notice, this list of conditions and the following disclaimer.
  23918. // * Redistributions in binary form must reproduce the above copyright
  23919. // notice, this list of conditions and the following disclaimer in the
  23920. // documentation and/or other materials provided with the distribution.
  23921. // * Neither the name of the Egret nor the
  23922. // names of its contributors may be used to endorse or promote products
  23923. // derived from this software without specific prior written permission.
  23924. //
  23925. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  23926. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  23927. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  23928. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  23929. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  23930. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  23931. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  23932. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  23933. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  23934. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23935. //
  23936. //////////////////////////////////////////////////////////////////////////////////////
  23937. var egret;
  23938. (function (egret) {
  23939. /**
  23940. * @language en_US
  23941. * The Timer class is the interface to timers, which let you run code on a specified time sequence. Use the start()
  23942. * method to start a timer. Add an event listener for the timer event to set up code to be run on the timer interval.<br/>
  23943. * You can create Timer objects to run once or repeat at specified intervals to execute code on a schedule. Depending
  23944. * on the framerate or the runtime environment (available memory and other factors), the runtime may dispatchEvent events at
  23945. * slightly offset intervals.
  23946. * @see egret.TimerEvent
  23947. * @version Egret 2.4
  23948. * @platform Web,Native
  23949. * @includeExample egret/utils/Timer.ts
  23950. */
  23951. /**
  23952. * @language zh_CN
  23953. * Timer 类是计时器的接口,它使您能按指定的时间序列运行代码。
  23954. * 使用 start() 方法来启动计时器。为 timer 事件添加事件侦听器,以便将代码设置为按计时器间隔运行。
  23955. * 可以创建 Timer 对象以运行一次或按指定间隔重复运行,从而按计划执行代码。
  23956. * 根据 Egret 的帧速率或运行时环境(可用内存和其他因素),运行时调度事件的间隔可能稍有不同。
  23957. * @see egret.TimerEvent
  23958. * @version Egret 2.4
  23959. * @platform Web,Native
  23960. * @includeExample egret/utils/Timer.ts
  23961. */
  23962. var Timer = (function (_super) {
  23963. __extends(Timer, _super);
  23964. /**
  23965. * @language en_US
  23966. * Constructs a new Timer object with the specified delay and repeatCount states.
  23967. * @param delay The delay between timer events, in milliseconds. A delay lower than 20 milliseconds is not recommended.
  23968. * Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems.
  23969. * @param repeatCount Specifies the number of repetitions. If zero, the timer repeats indefinitely.If nonzero,
  23970. * the timer runs the specified number of times and then stops.
  23971. * @version Egret 2.4
  23972. * @platform Web,Native
  23973. */
  23974. /**
  23975. * @language zh_CN
  23976. * 使用指定的 delay 和 repeatCount 状态构造新的 Timer 对象。
  23977. * @param delay 计时器事件间的延迟(以毫秒为单位)。建议 delay 不要低于 20 毫秒。计时器频率不得超过 60 帧/秒,这意味着低于 16.6 毫秒的延迟可导致出现运行时问题。
  23978. * @param repeatCount 指定重复次数。如果为零,则计时器将持续不断重复运行。如果不为 0,则将运行计时器,运行次数为指定的次数,然后停止。
  23979. * @version Egret 2.4
  23980. * @platform Web,Native
  23981. */
  23982. function Timer(delay, repeatCount) {
  23983. if (repeatCount === void 0) { repeatCount = 0; }
  23984. var _this = _super.call(this) || this;
  23985. /**
  23986. * @private
  23987. */
  23988. _this._delay = 0;
  23989. /**
  23990. * @private
  23991. */
  23992. _this._currentCount = 0;
  23993. /**
  23994. * @private
  23995. */
  23996. _this._running = false;
  23997. /**
  23998. * @private
  23999. */
  24000. _this.updateInterval = 1000;
  24001. /**
  24002. * @private
  24003. */
  24004. _this.lastCount = 1000;
  24005. /**
  24006. * @private
  24007. */
  24008. _this.lastTimeStamp = 0;
  24009. _this.delay = delay;
  24010. _this.repeatCount = +repeatCount | 0;
  24011. return _this;
  24012. }
  24013. Object.defineProperty(Timer.prototype, "delay", {
  24014. /**
  24015. * @language en_US
  24016. * The delay between timer events, in milliseconds. A delay lower than 20 milliseconds is not recommended.<br/>
  24017. * Note: Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems.
  24018. * @version Egret 2.4
  24019. * @platform Web,Native
  24020. */
  24021. /**
  24022. * @language zh_CN
  24023. * 计时器事件间的延迟(以毫秒为单位)。如果在计时器正在运行时设置延迟间隔,则计时器将按相同的 repeatCount 迭代重新启动。<br/>
  24024. * 注意:建议 delay 不要低于 20 毫秒。计时器频率不得超过 60 帧/秒,这意味着低于 16.6 毫秒的延迟可导致出现运行时问题。
  24025. * @version Egret 2.4
  24026. * @platform Web,Native
  24027. */
  24028. get: function () {
  24029. return this._delay;
  24030. },
  24031. set: function (value) {
  24032. //value = +value||0;
  24033. if (value < 1) {
  24034. value = 1;
  24035. }
  24036. if (this._delay == value) {
  24037. return;
  24038. }
  24039. this._delay = value;
  24040. this.lastCount = this.updateInterval = Math.round(60 * value);
  24041. },
  24042. enumerable: true,
  24043. configurable: true
  24044. });
  24045. Object.defineProperty(Timer.prototype, "currentCount", {
  24046. /**
  24047. * @language en_US
  24048. * The total number of times the timer has fired since it started at zero. If the timer has been reset, only the fires since the reset are counted.
  24049. * @version Egret 2.4
  24050. * @platform Web,Native
  24051. */
  24052. /**
  24053. * @language zh_CN
  24054. * 计时器从 0 开始后触发的总次数。如果已重置了计时器,则只会计入重置后的触发次数。
  24055. * @version Egret 2.4
  24056. * @platform Web,Native
  24057. */
  24058. get: function () {
  24059. return this._currentCount;
  24060. },
  24061. enumerable: true,
  24062. configurable: true
  24063. });
  24064. Object.defineProperty(Timer.prototype, "running", {
  24065. /**
  24066. * @language en_US
  24067. * The timer's current state; true if the timer is running, otherwise false.
  24068. * @version Egret 2.4
  24069. * @platform Web,Native
  24070. */
  24071. /**
  24072. * @language zh_CN
  24073. * 计时器的当前状态;如果计时器正在运行,则为 true,否则为 false。
  24074. * @version Egret 2.4
  24075. * @platform Web,Native
  24076. */
  24077. get: function () {
  24078. return this._running;
  24079. },
  24080. enumerable: true,
  24081. configurable: true
  24082. });
  24083. /**
  24084. * @language en_US
  24085. * Stops the timer, if it is running, and sets the currentCount property back to 0, like the reset button of a stopwatch.
  24086. * Then, when start() is called, the timer instance runs for the specified number of repetitions, as set by the repeatCount value.
  24087. * @version Egret 2.4
  24088. * @platform Web,Native
  24089. */
  24090. /**
  24091. * @language zh_CN
  24092. * 如果计时器正在运行,则停止计时器,并将 currentCount 属性设回为 0,这类似于秒表的重置按钮。然后,在调用 start() 后,将运行计时器实例,运行次数为指定的重复次数(由 repeatCount 值设置)。
  24093. * @version Egret 2.4
  24094. * @platform Web,Native
  24095. */
  24096. Timer.prototype.reset = function () {
  24097. this.stop();
  24098. this._currentCount = 0;
  24099. };
  24100. /**
  24101. * @language en_US
  24102. * Starts the timer, if it is not already running.
  24103. * @version Egret 2.4
  24104. * @platform Web,Native
  24105. */
  24106. /**
  24107. * @language zh_CN
  24108. * 如果计时器尚未运行,则启动计时器。
  24109. * @version Egret 2.4
  24110. * @platform Web,Native
  24111. */
  24112. Timer.prototype.start = function () {
  24113. if (this._running)
  24114. return;
  24115. this.lastCount = this.updateInterval;
  24116. this.lastTimeStamp = egret.getTimer();
  24117. egret.sys.$ticker.$startTick(this.$update, this);
  24118. this._running = true;
  24119. };
  24120. /**
  24121. * @language en_US
  24122. * Stops the timer. When start() is called after stop(), the timer instance runs for the remaining number of
  24123. * repetitions, as set by the repeatCount property.
  24124. * @version Egret 2.4
  24125. * @platform Web,Native
  24126. */
  24127. /**
  24128. * @language zh_CN
  24129. * 停止计时器。如果在调用 stop() 后调用 start(),则将继续运行计时器实例,运行次数为剩余的 重复次数(由 repeatCount 属性设置)。
  24130. * @version Egret 2.4
  24131. * @platform Web,Native
  24132. */
  24133. Timer.prototype.stop = function () {
  24134. if (!this._running)
  24135. return;
  24136. egret.stopTick(this.$update, this);
  24137. this._running = false;
  24138. };
  24139. /**
  24140. * @private
  24141. * Ticker以60FPS频率刷新此方法
  24142. */
  24143. Timer.prototype.$update = function (timeStamp) {
  24144. var deltaTime = timeStamp - this.lastTimeStamp;
  24145. if (deltaTime >= this._delay) {
  24146. this.lastCount = this.updateInterval;
  24147. }
  24148. else {
  24149. this.lastCount -= 1000;
  24150. if (this.lastCount > 0) {
  24151. return false;
  24152. }
  24153. this.lastCount += this.updateInterval;
  24154. }
  24155. this.lastTimeStamp = timeStamp;
  24156. this._currentCount++;
  24157. var complete = (this.repeatCount > 0 && this._currentCount >= this.repeatCount);
  24158. egret.TimerEvent.dispatchTimerEvent(this, egret.TimerEvent.TIMER);
  24159. if (complete) {
  24160. this.stop();
  24161. egret.TimerEvent.dispatchTimerEvent(this, egret.TimerEvent.TIMER_COMPLETE);
  24162. }
  24163. return false;
  24164. };
  24165. return Timer;
  24166. }(egret.EventDispatcher));
  24167. egret.Timer = Timer;
  24168. __reflect(Timer.prototype, "egret.Timer");
  24169. if (true) {
  24170. egret.$markReadOnly(Timer, "currentCount");
  24171. egret.$markReadOnly(Timer, "running");
  24172. }
  24173. })(egret || (egret = {}));
  24174. //////////////////////////////////////////////////////////////////////////////////////
  24175. //
  24176. // Copyright (c) 2014-present, Egret Technology.
  24177. // All rights reserved.
  24178. // Redistribution and use in source and binary forms, with or without
  24179. // modification, are permitted provided that the following conditions are met:
  24180. //
  24181. // * Redistributions of source code must retain the above copyright
  24182. // notice, this list of conditions and the following disclaimer.
  24183. // * Redistributions in binary form must reproduce the above copyright
  24184. // notice, this list of conditions and the following disclaimer in the
  24185. // documentation and/or other materials provided with the distribution.
  24186. // * Neither the name of the Egret nor the
  24187. // names of its contributors may be used to endorse or promote products
  24188. // derived from this software without specific prior written permission.
  24189. //
  24190. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  24191. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  24192. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24193. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24194. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24195. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  24196. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  24197. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24198. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  24199. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24200. //
  24201. //////////////////////////////////////////////////////////////////////////////////////
  24202. var egret;
  24203. (function (egret) {
  24204. })(egret || (egret = {}));
  24205. //////////////////////////////////////////////////////////////////////////////////////
  24206. //
  24207. // Copyright (c) 2014-present, Egret Technology.
  24208. // All rights reserved.
  24209. // Redistribution and use in source and binary forms, with or without
  24210. // modification, are permitted provided that the following conditions are met:
  24211. //
  24212. // * Redistributions of source code must retain the above copyright
  24213. // notice, this list of conditions and the following disclaimer.
  24214. // * Redistributions in binary form must reproduce the above copyright
  24215. // notice, this list of conditions and the following disclaimer in the
  24216. // documentation and/or other materials provided with the distribution.
  24217. // * Neither the name of the Egret nor the
  24218. // names of its contributors may be used to endorse or promote products
  24219. // derived from this software without specific prior written permission.
  24220. //
  24221. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  24222. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  24223. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24224. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24225. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24226. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  24227. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  24228. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24229. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  24230. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24231. //
  24232. //////////////////////////////////////////////////////////////////////////////////////
  24233. var egret;
  24234. (function (egret) {
  24235. /**
  24236. * @private
  24237. */
  24238. egret.$callLaterFunctionList = [];
  24239. /**
  24240. * @private
  24241. */
  24242. egret.$callLaterThisList = [];
  24243. /**
  24244. * @private
  24245. */
  24246. egret.$callLaterArgsList = [];
  24247. /**
  24248. * @language en_US
  24249. * Delay the function to run unless screen is redrawn.
  24250. * @param method {Function} The function to be delayed to run
  24251. * @param thisObject {any} this reference of callback function
  24252. * @param ...args {any} Function parameter list
  24253. * @version Egret 2.4
  24254. * @platform Web,Native
  24255. * @includeExample egret/utils/callLater.ts
  24256. */
  24257. /**
  24258. * @language zh_CN
  24259. * 延迟函数到屏幕重绘前执行。
  24260. * @param method {Function} 要延迟执行的函数
  24261. * @param thisObject {any} 回调函数的this引用
  24262. * @param ...args {any} 函数参数列表
  24263. * @version Egret 2.4
  24264. * @platform Web,Native
  24265. * @includeExample egret/utils/callLater.ts
  24266. */
  24267. function callLater(method, thisObject) {
  24268. var args = [];
  24269. for (var _i = 2; _i < arguments.length; _i++) {
  24270. args[_i - 2] = arguments[_i];
  24271. }
  24272. egret.$callLaterFunctionList.push(method);
  24273. egret.$callLaterThisList.push(thisObject);
  24274. egret.$callLaterArgsList.push(args);
  24275. }
  24276. egret.callLater = callLater;
  24277. /**
  24278. * @private
  24279. */
  24280. egret.$callAsyncFunctionList = [];
  24281. /**
  24282. * @private
  24283. */
  24284. egret.$callAsyncThisList = [];
  24285. /**
  24286. * @private
  24287. */
  24288. egret.$callAsyncArgsList = [];
  24289. /**
  24290. * 异步调用函数
  24291. * @param method {Function} 要异步调用的函数
  24292. * @param thisObject {any} 函数的this引用
  24293. * @param ...args {any} 函数参数列表
  24294. * @private
  24295. */
  24296. function $callAsync(method, thisObject) {
  24297. var args = [];
  24298. for (var _i = 2; _i < arguments.length; _i++) {
  24299. args[_i - 2] = arguments[_i];
  24300. }
  24301. egret.$callAsyncFunctionList.push(method);
  24302. egret.$callAsyncThisList.push(thisObject);
  24303. egret.$callAsyncArgsList.push(args);
  24304. }
  24305. egret.$callAsync = $callAsync;
  24306. })(egret || (egret = {}));
  24307. //////////////////////////////////////////////////////////////////////////////////////
  24308. //
  24309. // Copyright (c) 2014-present, Egret Technology.
  24310. // All rights reserved.
  24311. // Redistribution and use in source and binary forms, with or without
  24312. // modification, are permitted provided that the following conditions are met:
  24313. //
  24314. // * Redistributions of source code must retain the above copyright
  24315. // notice, this list of conditions and the following disclaimer.
  24316. // * Redistributions in binary form must reproduce the above copyright
  24317. // notice, this list of conditions and the following disclaimer in the
  24318. // documentation and/or other materials provided with the distribution.
  24319. // * Neither the name of the Egret nor the
  24320. // names of its contributors may be used to endorse or promote products
  24321. // derived from this software without specific prior written permission.
  24322. //
  24323. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  24324. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  24325. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24326. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24327. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24328. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  24329. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  24330. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24331. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  24332. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24333. //
  24334. //////////////////////////////////////////////////////////////////////////////////////
  24335. //function __extends(d, b) {
  24336. // for (let p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  24337. // function __() {
  24338. // this.constructor = d;
  24339. // }
  24340. //
  24341. // __.prototype = b.prototype;
  24342. // d.prototype = new __();
  24343. //}
  24344. var egret;
  24345. (function (egret) {
  24346. /**
  24347. * @language en_US
  24348. * Call setter properties of the parent class, instead of the other writing languages, such as super.alpha = 1;
  24349. * @param currentClass The current class class name, non-string
  24350. * @param thisObj The current object. Always this
  24351. * @param type Setter property names need to call
  24352. * @param values Value passed to the parent class
  24353. *
  24354. * @exmaple egret.superSetter(egret.Sprite, this, "alpha", 1);
  24355. */
  24356. /**
  24357. * @language zh_CN
  24358. * 调用父类的setter属性,代替其他语言的写法,如 super.alpha = 1;
  24359. * @param thisObj 当前对象。永远都this
  24360. * @param currentClass 当前 class 类名,非字符串
  24361. * @param type 需要调用的setter属性名称
  24362. * @param values 传给父类的值
  24363. *
  24364. * @exmaple egret.superSetter(egret.Sprite, this, "alpha", 1);
  24365. */
  24366. function superSetter(currentClass, thisObj, type) {
  24367. var values = [];
  24368. for (var _i = 3; _i < arguments.length; _i++) {
  24369. values[_i - 3] = arguments[_i];
  24370. }
  24371. var cla = currentClass.prototype;
  24372. var seters;
  24373. if (!currentClass.hasOwnProperty("__sets__")) {
  24374. Object.defineProperty(currentClass, "__sets__", { "value": {} });
  24375. }
  24376. seters = currentClass["__sets__"];
  24377. var setF = seters[type];
  24378. if (setF) {
  24379. return setF.apply(thisObj, values);
  24380. }
  24381. var d = Object.getPrototypeOf(cla);
  24382. if (d == null) {
  24383. return;
  24384. }
  24385. while (!d.hasOwnProperty(type)) {
  24386. d = Object.getPrototypeOf(d);
  24387. if (d == null) {
  24388. return;
  24389. }
  24390. }
  24391. setF = Object.getOwnPropertyDescriptor(d, type).set;
  24392. seters[type] = setF;
  24393. setF.apply(thisObj, values);
  24394. }
  24395. egret.superSetter = superSetter;
  24396. /**
  24397. * @language en_US
  24398. * Get getter property value of the parent class. Instead of writing in other languages, such as super.alpha;
  24399. * @param currentClass The current class class name, non-string
  24400. * @param thisObj The current object. Always this
  24401. * @param type Setter property names need to call
  24402. * @returns {any} The value returned by the parent
  24403. *
  24404. * @exmaple egret.superGetter(egret.Sprite, this, "alpha");
  24405. */
  24406. /**
  24407. * @language zh_CN
  24408. * 获取父类的getter属性值。代替其他语言的写法,如 super.alpha;
  24409. * @param thisObj 当前对象。永远都this
  24410. * @param currentClass 当前 class 类名,非字符串
  24411. * @param type 需要调用的setter属性名称
  24412. * @returns {any} 父类返回的值
  24413. *
  24414. * @exmaple egret.superGetter(egret.Sprite, this, "alpha");
  24415. */
  24416. function superGetter(currentClass, thisObj, type) {
  24417. var cla = currentClass.prototype;
  24418. var geters;
  24419. if (!currentClass.hasOwnProperty("__gets__")) {
  24420. Object.defineProperty(currentClass, "__gets__", { "value": {} });
  24421. }
  24422. geters = currentClass["__gets__"];
  24423. var getF = geters[type];
  24424. if (getF) {
  24425. return getF.call(thisObj);
  24426. }
  24427. var d = Object.getPrototypeOf(cla);
  24428. if (d == null) {
  24429. return;
  24430. }
  24431. while (!d.hasOwnProperty(type)) {
  24432. d = Object.getPrototypeOf(d);
  24433. if (d == null) {
  24434. return;
  24435. }
  24436. }
  24437. getF = Object.getOwnPropertyDescriptor(d, type).get;
  24438. geters[type] = getF;
  24439. return getF.call(thisObj);
  24440. }
  24441. egret.superGetter = superGetter;
  24442. })(egret || (egret = {}));
  24443. //////////////////////////////////////////////////////////////////////////////////////
  24444. //
  24445. // Copyright (c) 2014-present, Egret Technology.
  24446. // All rights reserved.
  24447. // Redistribution and use in source and binary forms, with or without
  24448. // modification, are permitted provided that the following conditions are met:
  24449. //
  24450. // * Redistributions of source code must retain the above copyright
  24451. // notice, this list of conditions and the following disclaimer.
  24452. // * Redistributions in binary form must reproduce the above copyright
  24453. // notice, this list of conditions and the following disclaimer in the
  24454. // documentation and/or other materials provided with the distribution.
  24455. // * Neither the name of the Egret nor the
  24456. // names of its contributors may be used to endorse or promote products
  24457. // derived from this software without specific prior written permission.
  24458. //
  24459. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  24460. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  24461. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24462. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24463. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24464. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  24465. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  24466. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24467. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  24468. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24469. //
  24470. //////////////////////////////////////////////////////////////////////////////////////
  24471. var egret;
  24472. (function (egret) {
  24473. /**
  24474. * @private
  24475. */
  24476. var getDefinitionByNameCache = {};
  24477. /**
  24478. * @language en_US
  24479. * Returns a reference to the class object of the class specified by the name parameter.
  24480. * @param name The name of a class.
  24481. * @version Egret 2.4
  24482. * @platform Web,Native
  24483. * @includeExample egret/utils/getDefinitionByName.ts
  24484. */
  24485. /**
  24486. * @language zh_CN
  24487. * 返回 name 参数指定的类的类对象引用。
  24488. * @param name 类的名称。
  24489. * @version Egret 2.4
  24490. * @platform Web,Native
  24491. * @includeExample egret/utils/getDefinitionByName.ts
  24492. */
  24493. function getDefinitionByName(name) {
  24494. if (!name)
  24495. return null;
  24496. var definition = getDefinitionByNameCache[name];
  24497. if (definition) {
  24498. return definition;
  24499. }
  24500. var paths = name.split(".");
  24501. var length = paths.length;
  24502. definition = __global;
  24503. for (var i = 0; i < length; i++) {
  24504. var path = paths[i];
  24505. definition = definition[path];
  24506. if (!definition) {
  24507. return null;
  24508. }
  24509. }
  24510. getDefinitionByNameCache[name] = definition;
  24511. return definition;
  24512. }
  24513. egret.getDefinitionByName = getDefinitionByName;
  24514. if (true) {
  24515. egret["cleanCache"] = function () {
  24516. getDefinitionByNameCache = {};
  24517. };
  24518. }
  24519. })(egret || (egret = {}));
  24520. var __global = this.__global || this;
  24521. //////////////////////////////////////////////////////////////////////////////////////
  24522. //
  24523. // Copyright (c) 2014-present, Egret Technology.
  24524. // All rights reserved.
  24525. // Redistribution and use in source and binary forms, with or without
  24526. // modification, are permitted provided that the following conditions are met:
  24527. //
  24528. // * Redistributions of source code must retain the above copyright
  24529. // notice, this list of conditions and the following disclaimer.
  24530. // * Redistributions in binary form must reproduce the above copyright
  24531. // notice, this list of conditions and the following disclaimer in the
  24532. // documentation and/or other materials provided with the distribution.
  24533. // * Neither the name of the Egret nor the
  24534. // names of its contributors may be used to endorse or promote products
  24535. // derived from this software without specific prior written permission.
  24536. //
  24537. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  24538. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  24539. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24540. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24541. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24542. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  24543. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  24544. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24545. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  24546. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24547. //
  24548. //////////////////////////////////////////////////////////////////////////////////////
  24549. var egret;
  24550. (function (egret) {
  24551. })(egret || (egret = {}));
  24552. //////////////////////////////////////////////////////////////////////////////////////
  24553. //
  24554. // Copyright (c) 2014-present, Egret Technology.
  24555. // All rights reserved.
  24556. // Redistribution and use in source and binary forms, with or without
  24557. // modification, are permitted provided that the following conditions are met:
  24558. //
  24559. // * Redistributions of source code must retain the above copyright
  24560. // notice, this list of conditions and the following disclaimer.
  24561. // * Redistributions in binary form must reproduce the above copyright
  24562. // notice, this list of conditions and the following disclaimer in the
  24563. // documentation and/or other materials provided with the distribution.
  24564. // * Neither the name of the Egret nor the
  24565. // names of its contributors may be used to endorse or promote products
  24566. // derived from this software without specific prior written permission.
  24567. //
  24568. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  24569. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  24570. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24571. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24572. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24573. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  24574. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  24575. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24576. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  24577. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24578. //
  24579. //////////////////////////////////////////////////////////////////////////////////////
  24580. var egret;
  24581. (function (egret) {
  24582. /**
  24583. * @language en_US
  24584. * Return the fully qualified class name of an object
  24585. * @param value The object for which a fully qualified class name is desired. Any JavaScript value may be passed to
  24586. * this method including all available JavaScript types, object instances, primitive types such as number, and class objects.
  24587. * @returns A string containing the fully qualified class name.
  24588. * @example
  24589. * <pre>
  24590. * egret.getQualifiedClassName(egret.DisplayObject) //return "egret.DisplayObject"
  24591. * </pre>
  24592. * @version Egret 2.4
  24593. * @platform Web,Native
  24594. * @includeExample egret/utils/getQualifiedClassName.ts
  24595. */
  24596. /**
  24597. * @language zh_CN
  24598. * 返回对象的完全限定类名。
  24599. * @param value 需要完全限定类名称的对象,可以将任何 JavaScript 值传递给此方法,包括所有可用的 JavaScript 类型、对象实例、原始类型
  24600. * (如number)和类对象
  24601. * @returns 包含完全限定类名称的字符串。
  24602. * @example
  24603. * <pre>
  24604. * egret.getQualifiedClassName(egret.DisplayObject) //返回 "egret.DisplayObject"
  24605. * </pre>
  24606. * @version Egret 2.4
  24607. * @platform Web,Native
  24608. * @includeExample egret/utils/getQualifiedClassName.ts
  24609. */
  24610. function getQualifiedClassName(value) {
  24611. var type = typeof value;
  24612. if (!value || (type != "object" && !value.prototype)) {
  24613. return type;
  24614. }
  24615. var prototype = value.prototype ? value.prototype : Object.getPrototypeOf(value);
  24616. if (prototype.hasOwnProperty("__class__")) {
  24617. return prototype["__class__"];
  24618. }
  24619. var constructorString = prototype.constructor.toString().trim();
  24620. var index = constructorString.indexOf("(");
  24621. var className = constructorString.substring(9, index);
  24622. Object.defineProperty(prototype, "__class__", {
  24623. value: className,
  24624. enumerable: false,
  24625. writable: true
  24626. });
  24627. return className;
  24628. }
  24629. egret.getQualifiedClassName = getQualifiedClassName;
  24630. })(egret || (egret = {}));
  24631. //////////////////////////////////////////////////////////////////////////////////////
  24632. //
  24633. // Copyright (c) 2014-present, Egret Technology.
  24634. // All rights reserved.
  24635. // Redistribution and use in source and binary forms, with or without
  24636. // modification, are permitted provided that the following conditions are met:
  24637. //
  24638. // * Redistributions of source code must retain the above copyright
  24639. // notice, this list of conditions and the following disclaimer.
  24640. // * Redistributions in binary form must reproduce the above copyright
  24641. // notice, this list of conditions and the following disclaimer in the
  24642. // documentation and/or other materials provided with the distribution.
  24643. // * Neither the name of the Egret nor the
  24644. // names of its contributors may be used to endorse or promote products
  24645. // derived from this software without specific prior written permission.
  24646. //
  24647. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  24648. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  24649. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24650. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24651. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24652. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  24653. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  24654. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24655. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  24656. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24657. //
  24658. //////////////////////////////////////////////////////////////////////////////////////
  24659. var egret;
  24660. (function (egret) {
  24661. /** @language en_US
  24662. * Returns the fully qualified class name of the base class of the object specified by the value parameter.
  24663. * @param value The object for which a parent class is desired. Any JavaScript value may be passed to this method including
  24664. * all available JavaScript types, object instances, primitive types such as number, and class objects.
  24665. * @returns A fully qualified base class name, or null if none exists.
  24666. * @example
  24667. * <pre>
  24668. * egret.getQualifiedSuperclassName(egret.Bitmap) //return "egret.DisplayObject"
  24669. * </pre>
  24670. * @version Egret 2.4
  24671. * @platform Web,Native
  24672. * @includeExample egret/utils/getQualifiedSuperclassName.ts
  24673. */
  24674. /**
  24675. * @language zh_CN
  24676. * 返回 value 参数指定的对象的基类的完全限定类名。
  24677. * @param value 需要取得父类的对象,可以将任何 JavaScript 值传递给此方法,包括所有可用的 JavaScript 类型、对象实例、原始类型(如number)和类对象
  24678. * @returns 完全限定的基类名称,或 null(如果不存在基类名称)。
  24679. * @example
  24680. * <pre>
  24681. * egret.getQualifiedSuperclassName(egret.Sprite) //返回 "egret.DisplayObject"
  24682. * </pre>
  24683. * @version Egret 2.4
  24684. * @platform Web,Native
  24685. * @includeExample egret/utils/getQualifiedSuperclassName.ts
  24686. */
  24687. function getQualifiedSuperclassName(value) {
  24688. if (!value || (typeof value != "object" && !value.prototype)) {
  24689. return null;
  24690. }
  24691. var prototype = value.prototype ? value.prototype : Object.getPrototypeOf(value);
  24692. var superProto = Object.getPrototypeOf(prototype);
  24693. if (!superProto) {
  24694. return null;
  24695. }
  24696. var superClass = egret.getQualifiedClassName(superProto.constructor);
  24697. if (!superClass) {
  24698. return null;
  24699. }
  24700. return superClass;
  24701. }
  24702. egret.getQualifiedSuperclassName = getQualifiedSuperclassName;
  24703. })(egret || (egret = {}));
  24704. //////////////////////////////////////////////////////////////////////////////////////
  24705. //
  24706. // Copyright (c) 2014-present, Egret Technology.
  24707. // All rights reserved.
  24708. // Redistribution and use in source and binary forms, with or without
  24709. // modification, are permitted provided that the following conditions are met:
  24710. //
  24711. // * Redistributions of source code must retain the above copyright
  24712. // notice, this list of conditions and the following disclaimer.
  24713. // * Redistributions in binary form must reproduce the above copyright
  24714. // notice, this list of conditions and the following disclaimer in the
  24715. // documentation and/or other materials provided with the distribution.
  24716. // * Neither the name of the Egret nor the
  24717. // names of its contributors may be used to endorse or promote products
  24718. // derived from this software without specific prior written permission.
  24719. //
  24720. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  24721. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  24722. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24723. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24724. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24725. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  24726. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  24727. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24728. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  24729. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24730. //
  24731. //////////////////////////////////////////////////////////////////////////////////////
  24732. var egret;
  24733. (function (egret) {
  24734. /**
  24735. * @language en_US
  24736. * Used to compute relative time.this method returns the number of milliseconds since the Egret framework was initialized
  24737. * @returns The number of milliseconds since the Egret framework was initialized
  24738. * @version Egret 2.4
  24739. * @platform Web,Native
  24740. * @includeExample egret/utils/getTimer.ts
  24741. */
  24742. /**
  24743. * @language zh_CN
  24744. * 用于计算相对时间。此方法返回自启动 Egret 框架以来经过的毫秒数。
  24745. * @returns 启动 Egret 框架以来经过的毫秒数。
  24746. * @version Egret 2.4
  24747. * @platform Web,Native
  24748. * @includeExample egret/utils/getTimer.ts
  24749. */
  24750. function getTimer() {
  24751. return Date.now() - egret.sys.$START_TIME;
  24752. }
  24753. egret.getTimer = getTimer;
  24754. })(egret || (egret = {}));
  24755. //////////////////////////////////////////////////////////////////////////////////////
  24756. //
  24757. // Copyright (c) 2014-present, Egret Technology.
  24758. // All rights reserved.
  24759. // Redistribution and use in source and binary forms, with or without
  24760. // modification, are permitted provided that the following conditions are met:
  24761. //
  24762. // * Redistributions of source code must retain the above copyright
  24763. // notice, this list of conditions and the following disclaimer.
  24764. // * Redistributions in binary form must reproduce the above copyright
  24765. // notice, this list of conditions and the following disclaimer in the
  24766. // documentation and/or other materials provided with the distribution.
  24767. // * Neither the name of the Egret nor the
  24768. // names of its contributors may be used to endorse or promote products
  24769. // derived from this software without specific prior written permission.
  24770. //
  24771. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  24772. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  24773. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24774. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24775. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24776. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  24777. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  24778. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24779. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  24780. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24781. //
  24782. //////////////////////////////////////////////////////////////////////////////////////
  24783. var egret;
  24784. (function (egret) {
  24785. /**
  24786. * @language en_US
  24787. * Check whether a public definition exists in the specified application domain. The definition can be that of a class, a naming space or a function.
  24788. * @param name {string} Name of the definition.
  24789. * @returns {boolean} Whether the public definition exists
  24790. * @example
  24791. * egret.hasDefinition("egret.DisplayObject") //return true
  24792. * @version Egret 2.4
  24793. * @platform Web,Native
  24794. * @includeExample egret/utils/hasDefinition.ts
  24795. */
  24796. /**
  24797. * @language zh_CN
  24798. * 检查指定的应用程序域之内是否存在一个公共定义。该定义可以是一个类、一个命名空间或一个函数的定义。
  24799. * @param name {string} 定义的名称。
  24800. * @returns {boolean} 公共定义是否存在
  24801. * @example
  24802. * egret.hasDefinition("egret.DisplayObject") //返回 true
  24803. * @version Egret 2.4
  24804. * @platform Web,Native
  24805. * @includeExample egret/utils/hasDefinition.ts
  24806. */
  24807. function hasDefinition(name) {
  24808. var definition = egret.getDefinitionByName(name);
  24809. return definition ? true : false;
  24810. }
  24811. egret.hasDefinition = hasDefinition;
  24812. })(egret || (egret = {}));
  24813. //////////////////////////////////////////////////////////////////////////////////////
  24814. //
  24815. // Copyright (c) 2014-present, Egret Technology.
  24816. // All rights reserved.
  24817. // Redistribution and use in source and binary forms, with or without
  24818. // modification, are permitted provided that the following conditions are met:
  24819. //
  24820. // * Redistributions of source code must retain the above copyright
  24821. // notice, this list of conditions and the following disclaimer.
  24822. // * Redistributions in binary form must reproduce the above copyright
  24823. // notice, this list of conditions and the following disclaimer in the
  24824. // documentation and/or other materials provided with the distribution.
  24825. // * Neither the name of the Egret nor the
  24826. // names of its contributors may be used to endorse or promote products
  24827. // derived from this software without specific prior written permission.
  24828. //
  24829. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  24830. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  24831. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24832. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24833. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24834. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  24835. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  24836. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24837. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  24838. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24839. //
  24840. //////////////////////////////////////////////////////////////////////////////////////
  24841. var egret;
  24842. (function (egret) {
  24843. /**
  24844. * @language en_US
  24845. * Indicates whether an object is a instance of the class or interface specified as the parameter.This method has better performance
  24846. * compared width the instanceOf operator,and it can indicate whether an object is a instance of the specific interface.
  24847. * @param instance the instance to be checked.
  24848. * @param typeName the string value representing a specific class or interface.
  24849. * @returns A value of true if the object is a instance of the class or interface specified as the parameter.
  24850. * @example
  24851. * <pre>
  24852. * let instance = new egret.Sprite();
  24853. * egret.log(egret.is(instance,"egret.Sprite")) //true
  24854. * egret.log(egret.is(instance,"egret.DisplayObjectContainer")) //true
  24855. * egret.log(egret.is(instance,"egret.Bitmap")) //false
  24856. * </pre>
  24857. * @see egret.registerClass()
  24858. * @version Egret 2.4
  24859. * @platform Web,Native
  24860. */
  24861. /**
  24862. * @language zh_CN
  24863. * 检查指定对象是否为 Egret 框架内指定接口或类或其子类的实例。此方法与使用 instanceOf 关键字相比具有更高的性能,并且能判断接口的实现。
  24864. * @param instance 要判断的实例。
  24865. * @param typeName 类或接口的完全名称.
  24866. * @returns 返回true表示当前对象是指定类或接口的实例。
  24867. * @example
  24868. * <pre>
  24869. * let instance = new egret.Sprite();
  24870. * egret.log(egret.is(instance,"egret.Sprite")) //true
  24871. * egret.log(egret.is(instance,"egret.DisplayObjectContainer")) //true
  24872. * egret.log(egret.is(instance,"egret.Bitmap")) //false
  24873. * </pre>
  24874. * @see egret.registerClass()
  24875. * @version Egret 2.4
  24876. * @platform Web,Native
  24877. */
  24878. function is(instance, typeName) {
  24879. if (!instance || typeof instance != "object") {
  24880. return false;
  24881. }
  24882. var prototype = Object.getPrototypeOf(instance);
  24883. var types = prototype ? prototype.__types__ : null;
  24884. if (!types) {
  24885. return false;
  24886. }
  24887. return (types.indexOf(typeName) !== -1);
  24888. }
  24889. egret.is = is;
  24890. })(egret || (egret = {}));
  24891. //////////////////////////////////////////////////////////////////////////////////////
  24892. //
  24893. // Copyright (c) 2014-present, Egret Technology.
  24894. // All rights reserved.
  24895. // Redistribution and use in source and binary forms, with or without
  24896. // modification, are permitted provided that the following conditions are met:
  24897. //
  24898. // * Redistributions of source code must retain the above copyright
  24899. // notice, this list of conditions and the following disclaimer.
  24900. // * Redistributions in binary form must reproduce the above copyright
  24901. // notice, this list of conditions and the following disclaimer in the
  24902. // documentation and/or other materials provided with the distribution.
  24903. // * Neither the name of the Egret nor the
  24904. // names of its contributors may be used to endorse or promote products
  24905. // derived from this software without specific prior written permission.
  24906. //
  24907. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  24908. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  24909. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24910. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24911. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24912. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  24913. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  24914. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24915. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  24916. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24917. //
  24918. //////////////////////////////////////////////////////////////////////////////////////
  24919. var egret;
  24920. (function (egret) {
  24921. /**
  24922. * @language en_US
  24923. * Register and start a timer,which will notify the callback method at a rate of 60 FPS ,and pass the current time stamp as parameters.<br/>
  24924. * Note: After the registration,it will notify the callback method continuously,you can call the stopTick () method to stop it.
  24925. * @param callBack the call back method. the timeStamp parameter of this method represents the number of milliseconds
  24926. * since the Egret framework was initialized. If the return value of this method is true, it will force Egret runtime
  24927. * to render after processing of this method completes.
  24928. * @param thisObject the call back method's "this"
  24929. * @version Egret 2.4
  24930. * @platform Web,Native
  24931. */
  24932. /**
  24933. * @language zh_CN
  24934. * 注册并启动一个计时器,通常会以60FPS的速率触发回调方法,并传入当前时间戳。注意:注册后将会持续触发回调方法,若要停止回调,需要手动调用stopTick()方法。
  24935. * @param callBack 要执行的回调方法。参数 timeStamp 表示从启动Egret框架开始经过的时间(毫秒)。
  24936. * 若回调方法返回值为true,其作用与TimerEvent.updateAfterEvent()类似,将会忽略帧频限制,在此方法处理完成后立即重绘屏幕。
  24937. * @param thisObject 回调方法的this对象引用。
  24938. * @version Egret 2.4
  24939. * @platform Web,Native
  24940. */
  24941. function startTick(callBack, thisObject) {
  24942. if (true && !callBack) {
  24943. egret.$error(1003, "callBack");
  24944. }
  24945. egret.sys.$ticker.$startTick(callBack, thisObject);
  24946. }
  24947. egret.startTick = startTick;
  24948. })(egret || (egret = {}));
  24949. //////////////////////////////////////////////////////////////////////////////////////
  24950. //
  24951. // Copyright (c) 2014-present, Egret Technology.
  24952. // All rights reserved.
  24953. // Redistribution and use in source and binary forms, with or without
  24954. // modification, are permitted provided that the following conditions are met:
  24955. //
  24956. // * Redistributions of source code must retain the above copyright
  24957. // notice, this list of conditions and the following disclaimer.
  24958. // * Redistributions in binary form must reproduce the above copyright
  24959. // notice, this list of conditions and the following disclaimer in the
  24960. // documentation and/or other materials provided with the distribution.
  24961. // * Neither the name of the Egret nor the
  24962. // names of its contributors may be used to endorse or promote products
  24963. // derived from this software without specific prior written permission.
  24964. //
  24965. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  24966. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  24967. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24968. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24969. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24970. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  24971. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  24972. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24973. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  24974. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24975. //
  24976. //////////////////////////////////////////////////////////////////////////////////////
  24977. var egret;
  24978. (function (egret) {
  24979. /**
  24980. * @language en_US
  24981. * Stops the timer started by the egret.startTick() method.
  24982. * @param callBack the call back method. the timeStamp parameter of this method represents the number of milliseconds
  24983. * since the Egret framework was initialized. If the return value of this method is true, it will force Egret runtime
  24984. * to render after processing of this method completes.
  24985. * @param thisObject the call back method's "this"
  24986. * @version Egret 2.4
  24987. * @platform Web,Native
  24988. */
  24989. /**
  24990. * @language zh_CN
  24991. * 停止之前用 startTick() 方法启动的计时器。
  24992. * @param callBack 要执行的回调方法。参数 timeStamp 表示从启动Egret框架开始经过的时间(毫秒)。
  24993. * 若回调方法返回值为true,其作用与TimerEvent.updateAfterEvent()类似,将会忽略帧频限制,在此方法处理完成后立即重绘屏幕。
  24994. * @param thisObject 回调方法的this对象引用。
  24995. * @version Egret 2.4
  24996. * @platform Web,Native
  24997. */
  24998. function stopTick(callBack, thisObject) {
  24999. if (true && !callBack) {
  25000. egret.$error(1003, "callBack");
  25001. }
  25002. egret.sys.$ticker.$stopTick(callBack, thisObject);
  25003. }
  25004. egret.stopTick = stopTick;
  25005. })(egret || (egret = {}));
  25006. //////////////////////////////////////////////////////////////////////////////////////
  25007. //
  25008. // Copyright (c) 2014-present, Egret Technology.
  25009. // All rights reserved.
  25010. // Redistribution and use in source and binary forms, with or without
  25011. // modification, are permitted provided that the following conditions are met:
  25012. //
  25013. // * Redistributions of source code must retain the above copyright
  25014. // notice, this list of conditions and the following disclaimer.
  25015. // * Redistributions in binary form must reproduce the above copyright
  25016. // notice, this list of conditions and the following disclaimer in the
  25017. // documentation and/or other materials provided with the distribution.
  25018. // * Neither the name of the Egret nor the
  25019. // names of its contributors may be used to endorse or promote products
  25020. // derived from this software without specific prior written permission.
  25021. //
  25022. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  25023. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  25024. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  25025. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  25026. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25027. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  25028. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  25029. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  25030. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  25031. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25032. //
  25033. //////////////////////////////////////////////////////////////////////////////////////
  25034. var egret;
  25035. (function (egret) {
  25036. /**
  25037. * @language en_US
  25038. * Transfer number to color character string
  25039. * @param value {number} color value ,such as 0xffffff
  25040. * @returns {string} Color character string, for example, #ffffff.
  25041. * @version Egret 2.4
  25042. * @platform Web,Native
  25043. * @includeExample egret/utils/toColorString.ts
  25044. */
  25045. /**
  25046. * @language zh_CN
  25047. * 转换数字为颜色字符串
  25048. * @param value {number} 颜色值,例如 0xffffff
  25049. * @returns {string} 颜色字符串,例如"#ffffff"。
  25050. * @version Egret 2.4
  25051. * @platform Web,Native
  25052. * @includeExample egret/utils/toColorString.ts
  25053. */
  25054. function toColorString(value) {
  25055. if (value < 0)
  25056. value = 0;
  25057. if (value > 16777215)
  25058. value = 16777215;
  25059. var color = value.toString(16).toUpperCase();
  25060. while (color.length > 6) {
  25061. color = color.slice(1, color.length);
  25062. }
  25063. while (color.length < 6) {
  25064. color = "0" + color;
  25065. }
  25066. return "#" + color;
  25067. }
  25068. egret.toColorString = toColorString;
  25069. })(egret || (egret = {}));
  25070. //////////////////////////////////////////////////////////////////////////////////////
  25071. //
  25072. // Copyright (c) 2014-present, Egret Technology.
  25073. // All rights reserved.
  25074. // Redistribution and use in source and binary forms, with or without
  25075. // modification, are permitted provided that the following conditions are met:
  25076. //
  25077. // * Redistributions of source code must retain the above copyright
  25078. // notice, this list of conditions and the following disclaimer.
  25079. // * Redistributions in binary form must reproduce the above copyright
  25080. // notice, this list of conditions and the following disclaimer in the
  25081. // documentation and/or other materials provided with the distribution.
  25082. // * Neither the name of the Egret nor the
  25083. // names of its contributors may be used to endorse or promote products
  25084. // derived from this software without specific prior written permission.
  25085. //
  25086. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  25087. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  25088. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  25089. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  25090. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25091. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  25092. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  25093. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  25094. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  25095. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25096. //
  25097. //////////////////////////////////////////////////////////////////////////////////////