




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
FluencywithInformationTechnology
ThirdEditionby
LawrenceSnyderChapter22:TheSmoothMotion:
CaseStudyinAlgorithmicProblemSolvingTheSmoothMotionApplicationTheSmoothMotionapplicationisacoordinationtestNotenamesofcomponentsHeadingGridKeysControlsInstructions23HowtheSmoothMotionApplicationShouldWorkStackofblocksmovingfromrighttoleftRandomstackgenerationuntiluserplacescursoroveroneofthebrownkeysBrownkeyscontrolstackheight(1-7)Goalistomovemouseacrossbrownkeysassmoothlyaspossibletocreateaperfectstaircaserisingtotheright4PlanningSmoothMotionApplytheDecompositionPrincipleDividealargetaskintosmallersubtasksthatcanbesolvedseparatelyandthencombinetheirsolutionstoproducetheoverallsolutionPrinciplecanbeappliedagaintoeachsubtask,ifnecessaryListtheTasks5PlanningSmoothMotion(cont'd)6PlanningSmoothMotion(cont'd)DecideonaProblem-SolvingStrategyStrategyonhowtosolveeachpartOrderinwhichwe'llsolvepartsBuildaBasicWebPageFirstDon'tspendtimeembellishingpageuntilothertasksaredone7PlanningSmoothMotion(cont'd)SolveIndependentTasksBeforeDependentTasksSometasksrelyonothertasksIndependenttasksshouldbedonefirstTasksthatdependontheindependenttasksaredonenext,andsoonPERT(ProgramEvaluationandReviewTechnique)ChartTaskdependencygraph89BuildtheBasicWebPageGUIFullGUIhastablewithheading,grid,keys,controls,instructionsBasicstructuralpage:TableHeadingInstructionsBackgroundcolor,fontstyleandcolorCenteringofapplicationonpage10BuildtheBasicWebPageGUI(cont'd)TheStructuralPageFive-row,one-columntableTextfortheSmoothMotionheadingandInstructionsinfirstandlastrowsTheStructuralPageHeading<h1>headingforheading,paragraphtagforinstructions(setfontcolorforinstructionstext)1112AnimatetheGridFirstAnalysisRecallthreebasicstepsofanimation:DefineandplaceinitialimagePrefetchframesforupdatingimageSettimerandbuildtimereventhandlertoupdateimage13AnimatetheGrid(cont'd)FramesfortheColumnsofBlocksDesignandorganizethecolumnframesIndexingColumnsfromLefttoRightOneachtimestep,givencolumnisreplacedbycolumntoitsrightIfcolumnsareindexedlefttoright,indexincolumniofgridatagivenstepisreplacedonnexttimestepbyimageincolumni+1Thelastcolumnneedstohaveanewimageassigned14AnimatetheGrid(cont'd)15AnimatetheGrid(cont'd)SecondAnalysisDefineandorganizetheeightcolumnarframesDefineandfetchtheinitialimages(0-19)PrefetchtheeightframesforuploadingtheimageSetatimerwithaneventhandlerthatshiftstheimagesincolumns1through19tocolumns0through18,andassignnewframeintocolumn1916AnimatetheGrid(cont'd)Subtask:DefineandOrganizetheFramesGuidelinesforcreatingframeimagesEnsureallimagesoverwritingoneanotherhavethesamedimensionsinpixelsEnsureallframesaresavedin.gifor.jpegformat,andthattheyareusedconsistently(onlyoverwrite.gifswith.gifs)1718AnimatetheGrid(cont'd)Subtask:DefineandPlaceInitialImagesUse<imgsrc="gifpix/Stack0.gif"/>tagtoplaceanimageonpageUsealooptocompleteimageinitializationof20images19AnimatetheGrid(cont'd)Subtask:PrefetchtheFrameImagesDeclaretheArrayintowhichtheimageswillbefetchedInitializethearrayelementstobeImageobjectsAssignthenamesofthefilestothesrcfieldsoftheImageobjects,causingbrowsertorecordthenamesandgetthefiles20AnimatetheGrid(cont'd)Subtask:SetTimerandBuildTimerEventHandlerEventhandleranimate()hasthreeoperations:Tomoveallimagesbutthefirst,onepositiontotheleftToassignanew(random)frametoimage19Toscheduleitselfforsometimeinthefuture212223TheBestLaidPlans…WefinditcumbersomenottobeabletostartandstopanimationondemandBuildControlstaskisscheduledforlaterMakesmoresensetosolveitnow,tosimplifyourwork24BuildControlsWhatshouldhappenwhenthecontrolisclicked?Gobuttonclick-eventStartanimationwithsetTimeout(),keepingtrackofthehandleStopbuttonclick-eventEndanimationbyclearingthetimerusingthehandleRadiobuttonclick-eventSetthetimerintervalbyassigningtodurationPlacethiscodeinthefourthrowofthestructuralpagetable25SensetheKeysAbilitytorecognizewhenmousehoversoveragivenkeyWeneedtolearnaboutmousemotiondetectionBrowserwithhelpoftheOSkeepstrackofwheremouseisatanygiventimeMouseOverandMouseOuteventsrecognizedinJavaScript26SensetheKeys(cont'd)Subtask:DefineandOrganizetheFramesSubtask:PlacetheInitialImagesPlacingtheimagescreatesthekeysPlacesevenimagesincenterofthirdrowofthestructuraltableusingaloop27SensetheKeys(cont'd)Subtask:PrefetchtheFramesAnalogoustoearlieranimationsSincethereareonlytwoframestoprefetchBrownBox.gifandOrangeBox.gif),it'snotworthwritingaloop28SensetheKeys(cont'd)Subtask:BuildtheEventHandlershere()forMouseOvergone()forMouseOutWhatshouldhappenwhenmousemovesoverakeyKeymustchangecolortogiveuserfeedbackMusttellGridAnimationeventhandlerwhichnewStackimagetodrawinthelastpositioninthegrid29SensetheKeys(cont'd)CombinetheSubtasksAddtheeventhandlerspecificationstothe<imgsrc="…"/>tags30StaircaseDetectionSubtask:RecognizingtheStaircaseHowdowerecognizethesevenconsecutiveframevalues?Keeppredictingthenextframevalue31StaircaseDetection(cont'd)Subtask:RecognizingContinuityModifytheanimate()functionatthepointwhereitisabouttosetthetimerforthenexttickIfthestaircaseisfound,thereshouldbenonexttick32AssembleOverallDesignBuildC
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- T/CIIA 026-2022農(nóng)業(yè)科學(xué)數(shù)據(jù)安全分級(jí)指南
- T/CIE 055-2018X射線脈沖星導(dǎo)航探測(cè)器試驗(yàn)安裝技術(shù)要求
- T/CHTS 20030-2023公路鋅鋁復(fù)合涂層鋼護(hù)欄
- T/CHTS 10074-2022智慧高速公路路側(cè)邊緣計(jì)算框架及要求
- T/CEMIA 023-2021半導(dǎo)體單晶硅生長(zhǎng)用石英坩堝
- T/CECS 10206-2022混凝土中氯離子和硫酸根離子的測(cè)定離子色譜法
- T/CCOA 45-2023氣膜鋼筋混凝土球形倉儲(chǔ)糧技術(shù)規(guī)程
- T/CCMA 0196-2024高原隧道純電動(dòng)鑿巖臺(tái)車
- T/CCMA 0186-2024非公路自卸車排氣污染物車載測(cè)量方法
- T/CCMA 0148-2023擦窗機(jī)使用手冊(cè)編制規(guī)則
- 2025年中國冷庫用叉車數(shù)據(jù)監(jiān)測(cè)研究報(bào)告
- 2025年高考第二次模擬考試物理(浙江卷)(參考答案)-20250416-113627
- 2025年化妝師職業(yè)技能考試試題及答案
- GA 1812.1-2024銀行系統(tǒng)反恐怖防范要求第1部分:人民幣發(fā)行庫
- 2025中信建投證券股份限公司校園招聘易考易錯(cuò)模擬試題(共500題)試卷后附參考答案
- 2025年山東省泰安市新泰市中考二模化學(xué)試題(原卷版+解析版)
- 2025年雞蛋市場(chǎng)調(diào)查報(bào)告
- 2025年職業(yè)技能競(jìng)賽(計(jì)算機(jī)程序員賽項(xiàng))參考試題(附答案)
- 合伙人商業(yè)保密協(xié)議書9篇
- 湖北省武漢市2025屆高中畢業(yè)生四月調(diào)研考試語文試卷及答案(武漢四調(diào))
- 2025年全國中小學(xué)生百科知識(shí)競(jìng)賽題庫及答案(480題)
評(píng)論
0/150
提交評(píng)論