Announcements Assignment 9 is due Project 2 is due 7/27/04 We will be skipping chapter 22 Test 3 (chapters 18-21) will be on 7/29/04 Tip of the Day : Functions.

Slides:



Advertisements
Similar presentations
Chapter 20 Iteration Principles. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Learning Objectives Trace the execution.
Advertisements

Chapter 20 Iteration Principles. Learning Objectives Trace the execution of a given for loop Write a World-Famous Iteration for loop Discuss the structure.
The Web Warrior Guide to Web Design Technologies
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Iteration Principles Once is Not Enough lawrence snyder c h a p t e r 21.
© The McGraw-Hill Companies, 2006 Chapter 5 Arrays.
Web-based Application Development Lecture 18 March 21, 2006 Anita Raja.
Lecture 3 IAT 800. Sept 15, Fall 2006IAT 8002 Suggestions on learning to program  Spend a lot of time fiddling around with code –Programming is something.
JavaScript, Third Edition
Chapter 9 Introduction to the Document Object Model (DOM) JavaScript, Third Edition.
FLASH Introduction to Animation. Review: Intro to Computer Operation Information Technology Vocabulary Computer Hardware Motherboard CPU and Memory Peripheral.
Excel Services II: Requirements, recommendations, and permissions What you need for Excel Services As explained in the first course in the series, “Excel.
Taking Pictures Sec 9-9 Web Design. Objectives The student will: Know how command the scribbler robot to take a picture. Know how to display the picture.
Programming Games Computer science big ideas. Computer Science jargon. Show virtual dog Homework: [Catch up: dice game, credit card or other form.] Plan.
JS Arrays, Functions, Events Week 5 INFM 603. Agenda Arrays Functions Event-Driven Programming.
Test 2 Part a You have 20 minutes Don’t forget to put your name on the test Closed book No computers Do your own work.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
G RAPHICS P ROGRAMMING Lecture 3 - Simple Animation - Simple 3D Drawing.
Unit 8.2 / Lesson 1 / presentation1a Web Elements.
Chapter 20 Iteration Principles. Learning Objectives Trace the execution of a given for loop Write a World-Famous Iteration for loop Discuss the structure.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
11 A First Game Program Session Session Overview  Begin the creation of an arcade game  Learn software design techniques that apply to any form.
Lecture # 3 HTML and Arrays. Today Questions: From notes/reading/life? From Lab # 2 – Preview of Lab # 2 1.Introduce: How do you make a Web Page?: HTML.
Processing.js.
Chapter 10 Fireworks: Part II The Web Warrior Guide to Web Design Technologies.
Unit 2 — The Exciting World of JavaScript Lesson 6 — Using Images with JavaScript.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
VB Games: Preparing for Memory Brainstorm controls & events Parallel structures (again), Visibility, LoadPicture, User-defined procedures, Do While/Loop,busy.
Microsoft ® Office SharePoint ® Server 2007 Training Excel Services II: Requirements, recommendations, and permissions [Your company name] presents:
CSC1401 Classes - 1. Learning Goals Computing concepts Identifying objects and classes Declaring a class Declaring fields Default field values.
Topic 7 Temporal Control. 2Chapter 25 - Temporal ControlOutline Goals and Objectives Goals and Objectives Introduction Introduction Timeline Animation.
Modified from Moseley ’s sli desWeb Applications Development. Lecture 3 Slide 1 Lecture 3: Dynamic Web Pages – Introduction to JavaScript Instructor: Dr.
Chapter 22 The Smooth Motion: Case Study in Algorithmic Solving.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Fluency with Information Technology Third Edition by Lawrence Snyder Chapter.
Learning Objectives State and apply the Decomposition Principle
CIS 3.5 Lecture 2.2 More programming with "Processing"
Today’s Announcements Assignment 8 is due Project 2 is due 7/27/04 We will be skipping chapter 22 Test 3 (chapters 18-21) will be on 7/29/04 Tip of the.
A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University ©2011 Pearson Prentice Hall ISBN Chapter 17 JavaScript.
Creating Web Documents catch-up JavaScript slide show tools redirection.
Chapter 7 P 1 Lists and Loops List boxes and combo boxes List box - list of items - useful for a list which does not change Combo box - list of items -
JavaScript, Fourth Edition Chapter 4 Manipulating the Browser Object Model.
Animation is a group of moving pictures to make an object or a character to look like it is moving for example a stickman walking along a road. Animation.
JavaScript Introduction. Slide 2 Lecture Overview JavaScript background The purpose of JavaScript A first JavaScript example Introduction to getElementById.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Computer Science I Share plans for virtual something. Text. Show my virtual dog. Classwork: Plans for your virtual something. Homework: start implementation.
Introduction to JavaScript CSc 2320 Fall 2014 Disclaimer: All words, pictures are adopted from “Simple JavaScript”by Kevin Yank and Cameron Adams and also.
Event Handling (the right way). A Simple Web Page Events - Summary The web page looks like this:
Review of HTML and CSS A (very) brief review of some key fundamentals to be aware of in IT-238.
Invitation to Computer Science 6 th Edition Chapter 10 The Tower of Babel.
This shows CIS17 and the first day introduction..
Today’s Announcements` If you have problems with the assignments, don’t be afraid to ask for help Assignment 6 is due and will be graded before the end.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
Introduction to Arrays. Learning Objectives By the end of this lecture, you should be able to: – Understand what an array is – Know how to create an array.
JavaScript, Sixth Edition
JavaScript Wrap Up JavaScript is a versatile programming language … if you know it, you can learn others © 2004, Lawrence Snyder.
Loops and Arrays Chapter 19 and Material Adapted from Fluency Text book.
COM621: Advanced Interactive Web Development Lecture 6 – JavaScript (cont.)
CPT 450 Computer Graphics 12th Lecture – Animation.
Fluency with Information Technology
Fluency with Information Technology
Chapter 4: Scalable Vector Graphics (SVG)
Retrieving information from forms
JavaScript Selection Statement Creating Array
GIF Animation.
The Web Wizard’s Guide To JavaScript
More programming with "Processing"
For this assignment, copy and past the XHTML to a notepad file with the .html extension. Then add the code I ask for to complete the problems.
The Smooth Motion: Case Study in Algorithmic Solving
Web Programming and Design
Web Programming and Design
Retrieving information from forms
Presentation transcript:

Announcements Assignment 9 is due Project 2 is due 7/27/04 We will be skipping chapter 22 Test 3 (chapters 18-21) will be on 7/29/04 Tip of the Day : Functions are not intuitive. Review Tuesday’s lecture, textbook and Memory Bank code

Animation JavaScript can be used for animating images on a web page © 2004, Lawrence Snyder

The Plan An animation is the rapid display of a series of still images … like cartoons There are three steps to animation 1) Place first still image(s) on web page 2) Prefech the series of images and store them 3) Setup a timer to cycle through the images Smooth motion requires 30 times/sec display busy0.gifbusy1.gifbusy2.gifbusy3.gifbusy4.gifbusy5.gifbusy6.gifbusy7.gif

Creating GIFs GIF files for animation are progressively different … make them w/Photoshop The series should all have the same size Begin with an initial GIF and build all others from it Getting the motion to be smooth may take a bit of fiddling Animated GIFs -- GIFs that automatically cycle use a special format and software

1. Place Still Image(s) Placing the image uses a standard tag Test Page Code here Test Page Code here

The document.images When HTML draws a page, the images go in an array: document.images Recall, arrays are names w/ indexes, like A[1] Each element of document.images array holds one image Pictures are put into document.images in the order encountered on page build … so for Test Page, document.images[0]  busy0.gif Changing the.src property of the array changes the picture But the images must be prefetched first

2. Prefetch Images I “Prefetch” means to get the images and save them in (our own) array so they are handy to assign to doc.im We must declare an array (and probably an index variable, too): var i, pref = new Array(4); Then we set it up to hold images: for (i=0; i<4; i++) { pref[i] = new Image; }

Prefetch Images II Once the array is declared and setup, get the images and assign them to the.src field of the array: for (i=0; i<4; i++) { pref[i].src = “Animation/busy" + i + “.gif"; } Notice that the names of the images, busy0.gif, busy1.gif, busy2.gif, etc. are constructed using the index variable

Test It var i, pref = new Array(4); for (i=0; i<4; i++){ pref[i] = new Image; } for (i=0; i<4; i++){ pref[i].src=“Animation/busy"+i+".gif"; } document.images[0].src=pref[1].src; var i, pref = new Array(4); for (i=0; i<4; i++){ pref[i] = new Image; } for (i=0; i<4; i++){ pref[i].src=“Animation/busy"+i+".gif"; } document.images[0].src=pref[1].src; Place two “0” pix then change the first to “1”

3. Change Image Once Web page is drawn, nothing happens unless you cause an event To animate a series of stills you must cause the computer to “wake-up” and change to the next image 30 times a second Set a timer to cause the wake-up timerID=setTimeout("animate()",30); Milliseconds to wait Function to change picture JS Timer Setting Function Handle holder -- to be explained

Animate Function animate() must advance the frame counter, update the image and schedule the next timer … var frame=0, timeID; function animate(){ frame=(frame+1)%8; //advance document.images[0].src = prefetch[frame].src; //update timerID=setTimeout("animate()",30); }

Watch It Go My var i, pref = new Array(4); var frame=0, timerID; for (i=0; i<8; i++){ pref[i] = new Image; } for (i=0; i<8; i++){ pref[i].src=“Animation/busy" + i + ".gif"; } timerID=setTimeout("animate()",2000); function animate(){ frame = (frame+1)%4; document.images[0].src=pref[frame].src; timerID = setTimeout("animate()",30); } Page Start action

Changes … Suppose we want “busy” to revolve once ever 2 seconds … animate() sets timer for two different times When animating, 30 ms When waiting, 2000ms Use an if -statement if (frame == 0) setTimeout("animate()",2000); else setTimeout("animate()",30); It’s a little more subtle

Watch It Go My var i, pref = new Array(4); var frame=0, timerID; for (i=0; i<8; i++){ pref[i] = new Image; } for (i=0; i<8; i++){ pref[i].src=“Animate/busy" + i + ".gif"; } timerID=setTimeout("animate()",2000); function animate(){ frame = (frame+1)%8; document.images[0].src=pref[frame].src; if (frame == 0) timeID = setTimeout("animate()",2000); else timerID = setTimeout("animate()",30); } Page

Summary Animation requires a 3 step process 1) Place the initial image(s) 2) Prefetch the series of images that will be the animation 3) Setup the animation function to draw the next item in the series When creating your own GIFs make sure that the sizes are all the same