CPSC1301 Computer Science 1 Chapter 14 Creating and Modifying Movies part 2.

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

Copyright 2006 by Pearson Education 1 Building Java Programs Supplement 3G: Graphics.
Laboratory Study II October, Java Programming Assignment  Write a program to calculate and output the distance traveled by a car on a tank of.
Graphics You draw on a Graphics object The Graphics object cannot directly be created by your code, instead one is generated when the method paintComponent.
Topic 9 more graphics Based on slides bu Marty Stepp and Stuart Reges from
Building Java Programs Supplement 3G Graphics Copyright (c) Pearson All rights reserved.
Building Java Programs Supplement 3G Graphics Copyright (c) Pearson All rights reserved.
Georgia Institute of Technology Movies part 3 Barb Ericson Georgia Institute of Technology April 2006.
1 A Simple Applet. 2 Applets and applications An application is an “ordinary” program Examples: Notepad, MS Word, Firefox, Halo, etc. An applet is a Java.
Copyright 2008 by Pearson Education Building Java Programs Graphics Reading: Supplement 3G.
Copyright 2006 by Pearson Education 1 Building Java Programs Supplement 3G: Graphics.
Copyright 2008 by Pearson Education Building Java Programs Graphics reading: Supplement 3G videos: Ch. 3G #1-2.
Copyright 2008 by Pearson Education Building Java Programs Graphics reading: Supplement 3G videos: Ch. 3G #1-2.
A Simple Applet. Applets and applications An applet is a Java program that runs on a web page –Applets can be run from: Internet Explorer Netscape Navigator.
Copyright 2006 by Pearson Education 1 Building Java Programs Supplement 3G: Graphics.
Java Review Structure of a graphics program. Computer Graphics and User Interfaces Java is Object-Oriented A program uses objects to model the solution.
1 Graphical objects We will draw graphics in Java using 3 kinds of objects: DrawingPanel : A window on the screen. Not part of Java; provided by the authors.
Java Concepts Chapter 2 – Graphical Applications Mr. Smith AP Computer Science A.
Georgia Institute of Technology Speed part 3 Barb Ericson Georgia Institute of Technology May 2006.
Introducing Graphics There are generally two types of graphics facilities in Java –Drawing –GUIs We concentrate on drawing here We will draw on a Graphics.
Learn about the types of Graphics that are available Develop a basic Graphics applet Develop a basic Graphics application Review the Java API and use.
Copyright 2010 by Pearson Education Building Java Programs Graphics reading: Supplement 3G.
Georgia Institute of Technology Movies part 5 Barb Ericson Georgia Institute of Technology April 2006.
Lecture 15: Intro to Graphics Yoni Fridman 7/25/01 7/25/01.
Chapter 15Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 15 l Basic Figures l Colors l Fonts and Other Text Details.
Georgia Institute of Technology Movies part 2 Barb Ericson Georgia Institute of Technology April 2006.
1 A Simple Applet. 2 Applets and applications An application is an “ordinary” program Examples: Notepad, MS Word, Firefox, Halo, etc. An applet is a Java.
Mixing integer and floating point numbers in an arithmetic operation.
CSC1401 Classes - 2. Learning Goals Computing concepts Adding a method To show the pictures in the slide show Creating accessors and modifiers That protect.
Georgia Institute of Technology Movies Barb Ericson Georgia Institute of Technology April 2006.
1 Building Java Programs Supplement 3G: Graphics These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may not be rehosted, sold,
Building Java Programs Supplement 3G Graphics Copyright (c) Pearson All rights reserved.
Georgia Institute of Technology Movies part 4 Barb Ericson Georgia Institute of Technology April 2006.
Video in Macromedia Flash (Optional) – Lesson 121 Video in Macromedia Flash (Optional) Lesson 12.
CIS 205—Web Design & Development Flash Chapter 3 Appendix on Using Buttons.
Building Java Programs Graphics Reading: Supplement 3G.
CS305j Introduction to Computing Simple Graphics 1 Topic 11 Simple Graphics "What makes the situation worse is that the highest level CS course I've ever.
Introduction to Graphics. Graphical objects To draw pictures, we will use three classes of objects: –DrawingPanel : A window on the screen. –Graphics.
Animating Objects in PowerPoint XP/2003 Using Motion Paths and Custom Animations to add interest to your classroom presentations.
Copyright 2008 by Pearson Education Building Java Programs Graphics reading: Supplement 3G videos: Ch. 3G #1-2.
CompSci 4 Java 4 Apr 14, 2009 Prof. Susan Rodger.
Contacts: Intro to game programming in Java (with almost-drawingpanel)
using System; namespace Demo01 { class Program
Building Java Programs
Building Java Programs
Basic Graphics Chapter 5 3/19/15 Thursday Section Only
Building Java Programs
Building Java Programs
A note on Programming Assignment
Building Java Programs
Basic Graphics Drawing Shapes 1.
Media Computation Questions
Topic 8 graphics "What makes the situation worse is that the highest level CS course I've ever taken is cs4, and quotes from the graphics group startup.
Building Java Programs
Building Java Programs
Barb Ericson Georgia Institute of Technology April 2006
CSE 142 Lecture Notes Graphics with DrawingPanel Chapter 3
class PrintOnetoTen { public static void main(String args[]) {
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Topic 9 More Graphics Based on slides bu Marty Stepp and Stuart Reges from
Building Java Programs
Building Java Programs
Barb Ericson Georgia Institute of Technology April 2006
Building Java Programs
Graphics Reading: Supplement 3G
Building Java Programs
Barb Ericson Georgia Institute of Technology May 2006
Presentation transcript:

CPSC1301 Computer Science 1 Chapter 14 Creating and Modifying Movies part 2

Learning Goals Media Goals  Generate a tickertape text movie  How to move more than one drawn object in a movie Computer Science Goal  Use a loop  Modify and extend an existing method

Generating a Tickertape Movie You can animate text by using drawString  At different locations over time on a blank picture  drawString("text to draw",baseX,baseY); The method drawString will automatically clip the string if it goes off the edge of the picture Click in the rectangle to see the tickertape movie

Code for Tickertape Movie public void makeTickerTapeMovie(String directory, String message) { int framesPerSec = 30; Picture p = null; Graphics g = null; FrameSequencer frameSequencer = new FrameSequencer(directory); Font font = new Font("Arial",Font.BOLD,24); // loop for 2 seconds of animation for (int i = 0; i < framesPerSec * 2; i++) {

Code for Tickertape Movie - Cont // draw the string p = new Picture(300,100); g = p.getGraphics(); g.setColor(Color.BLACK); g.setFont(font); g.drawString(message,300 - (i * 10), 50); // add frame to sequencer frameSequencer.addFrame(p); } // play the movie frameSequencer.play(framesPerSec); }

Main for Testing public static void main(String[] args) { MovieMaker movieMaker = new MovieMaker(); String dir = "c:/intro-prog-java/movies/tickertape/"; movieMaker.makeTickerTapeMovie(dir, "Buy more widgets"); }

Exercise Create a new method in MovieMaker Show text starting at the bottom of a picture and moving to the top  You can even change the font size as it moves Or you can move the text from top left to bottom right

Moving Two Objects You can have more than one object moving in your movie  Just draw more than one object in a different location in each frame  Here we use the same red rectangle from the previous movie  But add a blue rectangle moving in a circular way

Code for Two Rectangle Movie public void makeTwoRectangleMovie(String directory) { int framesPerSec = 30; Picture p = null; Graphics g = null; FrameSequencer frameSequencer = new FrameSequencer(directory); // loop through the first second for (int i = 0; i < framesPerSec; i++) {

Code for Two Rectangle Movie - Cont // draw a filled rectangle p = new Picture(640,480); g = p.getGraphics(); g.setColor(Color.RED); g.fillRect(i * 10, i * 5, 50,50); g.setColor(Color.BLUE); g.fillRect(100 + (int) (10 * Math.sin(i)), 4 * i + (int) (10 * Math.cos(i)), 50,50); // add frame to sequencer frameSequencer.addFrame(p); } // play the movie frameSequencer.play(framesPerSec); }

Main for Testing public static void main(String[] args) { MovieMaker movieMaker = new MovieMaker(); String dir = "c:/intro-prog-java/movies/rectangle2/"; movieMaker.makeTwoRectangleMovie(dir); }

Exercise Create a new method in MovieMaker Move two filled rectangles some random amount in x and y (< 5 pixels) each step in the animation  Use a random number generator (java.util.Random) to generate the random amounts  Make sure that the rectangles don't leave the picture

Summary You can move from text from right to left  Start at the right side  Subtract an increasing amount each time through the loop g.drawString(message,300 - (i * 10), 50); You can move more than one object at the same time  Modify how you specify the current location of the object