Section 1.2: Drawing a UFO (continued). Writing a program to draw UFOs Remember that the header includes: define program’s name(let’s call it UFO-draw)

Slides:



Advertisements
Similar presentations
Page 6 As we can see, the formula is really the same as the formula. So, Furthermore, if an equation of the tangent line at (a, f(a)) can be written as:
Advertisements


Drawing In One-Point Perspective
Flipping Across the Axis
Problem of the Day Problem of the Day next Geometry - Connect the Dots
How to Draw a Face FRONT VIEW.
Image Maps and Graphics Internet Basics and Far Beyond! Mrs. Wilson.
Section 1.1: Flying a UFO (continued). Conversion recipe 1)Expand abbreviations 2)Parenthesize all subexpressions that have an operator. Should end up.
Section 1.2: Drawing a UFO (conclusion). Last time… ● Using figure 1, we can now find a UFO’s location (using the X and Y functions). ● And, we can now.
16 MULTIPLE INTEGRALS.
CSC 160 Computer Programming for Non-Majors Section 1.3: Animating the UFOs Flight Prof. Adam M. Wittenstein
Exercise A) Find out how tock in that figure works manually. Enter expression expressions such as (tock 0) and (tock 1) into DrScheme's Interactions.
MULTIPLE INTEGRALS Double Integrals over General Regions MULTIPLE INTEGRALS In this section, we will learn: How to use double integrals to.
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.
CSC 160 Computer Programming for Non-Majors Section 1.2: Drawing a UFO Prof. Adam M. Wittenstein
CSC 160 Computer Programming for Non-Majors Chapter 3: Programs are Functions Plus Variable Definitions Prof. Adam M. Wittenstein
Copyright © Cengage Learning. All rights reserved.
Creating Tessellations With Paint. Open Microsoft Paint. Go to: Start, Programs, Accessories, Paint.
Program State and Program Execution CSE 1310 – Introduction to Computers and Programming 1.
College Algebra Fifth Edition James Stewart Lothar Redlin Saleem Watson.
Tutorial for Arrays and Lists By Ruthie Tucker. Description This presentation will cover the basics of using Arrays and Lists in an Alice world This presentation.
In.  This presentation will only make sense if you view it in presentation mode (hit F5). If you don’t do that there will be multiple slides that are.
Getting Started With Alice By Ruthie Tucker under the direction of Prof. Susan Rodger Duke University, July
Creating your own form from scratch.. To create a custom form, you can modify an existing form or design and create a form from scratch. In either case,
INTEGRALS Areas and Distances INTEGRALS In this section, we will learn that: We get the same special type of limit in trying to find the area under.
Introduction to Flash. Topics What is Flash? What can you do with it? Simple animation Complex interactive web application, such as an online store. Starting.
Graphics Concepts CS 2302, Fall /3/20142 Drawing Paths.
1.2 Points, Lines and Planes Wherein we define the fundamental concepts of geometry – point, line, plane, on, between and distance. This is our basic set.
SOLIDWORKS: Lesson II – Revolutions, Fillets, & Chamfers UCF Engineering.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
Sketchup For 3D Design Part 2: 3D Text.
Using the paper provided for this activity, fold your paper so that it is divided into 14 boxes. The bottom 2 boxes should be wider than the others. In.
Graphic Basics in C ATS 315. The Graphics Window Will look something like this.
Loops & Graphics IP 10 Mr. Mellesmoen Recall Earlier we wrote a program listing numbers from 1 – 24 i=1 start: TextWindow.WriteLine(i) i=i+1 If.
1 Building Java Programs Supplement 3G: Graphics These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may not be rehosted, sold,
Data Representation The storage of Text Numbers Graphics.
Abstract Classes and Interfaces 5-Dec-15. Abstract methods You can declare an object without defining it: Person p; Similarly, you can declare a method.
Relations And Functions. A relation is a set of ordered pairs {(2,3), (-1,5), (4,-2), (9,9), (0,-6)} This is a relation The domain is the set of all x.
Multiplying Decimals © Math As A Second Language All Rights Reserved next #8 Taking the Fear out of Math 8.25 × 3.5.
FLIPPING ACROSS THE AXIS REFLECTION. WHAT IS REFLECTION? A Reflection is an exact copy of the same image or picture that is flipped across an axis.
1 A Simple Applet. 2 Applets and applications An applet is a Java program that runs on a web page Applets can be run within any modern browser To run.
Hyperstudio: A Beginner’s Tutorial By Judy Swaim.
“FEATURES OF THE PROGRAM” MICROSOFT PAINT TUTORIAL.
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.
Prime and Composite Numbers Factors What is a prime number? Is this number prime?
Processing Variables. Variables Processing gives us several variables to play with These variables are always being updated and you can assume they have.
Warm Up What algebraic equation shows the sentence four plus a number divided by six is equal to the product of twelve and the same number?
Stylizing a Navigational Menu Web Design Section 6-3 Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development.
Relations And Functions © 2002 by Shawna Haider. A relation is a set of ordered pairs. {(2,3), (-1,5), (4,-2), (9,9), (0,-6)} This is a relation The domain.
Leonardo da Vinci, Facial Proportion, and the Self-Portrait
Graphical Output Basic Images.
Pixels, Colors and Shapes
Multiply using the Distributive Property
8.4 Volume and Areas of Similar Figures
Building Java Programs
Lesson One: The Beginning Chapter 1: Pixels Learning Processing Daniel Shiffman Presentation by Donald W. Smith Graphics from
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
Flipping Across the Axis
Basic Graphics Drawing Shapes 1.
How to Draw Cones & Cylinders
College Algebra Fifth Edition
Los Angeles Mission College
Let’s start at where we left out just now
Realistic Self-portrait time….
CSE 142 Lecture Notes Graphics with DrawingPanel Chapter 3
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
Relations And Functions © 2002 by Shawna Haider.
Relations And Functions.
Relations And Functions.
Presentation transcript:

Section 1.2: Drawing a UFO (continued)

Writing a program to draw UFOs Remember that the header includes: define program’s name(let’s call it UFO-draw) program’s variables (t, for the time) (define (ufo-draw t)... will fill in later …)

Writing a program to draw UFOs (define (ufo-draw t) (and (draw-solid-disk ) (draw-solid-rect ))) Since we drew a disk and a rectangle to draw the UFO, the function says that to draw a UFO first draw a disk and then a rectangle.

Writing a program to draw UFOs (define (ufo-draw t) (and (draw-solid-disk 'green) (draw-solid-rect 'green))) To keep the program relatively simple, we will assume that all UFO’s are green and exactly the same size.

Writing a program to draw UFOs Of course, the (…) tells us that the function is still incomplete. More precisely, the dots in draw-solid-disk0 (and draw-solid- rect0) say we don't know the X and Y coordinates of the UFO. Recall that the UFO’s location is expressed by X and Y. So if we know t, we can use the X and Y programs that we wrote in Section 1.1: (define (X t) (+ (* 10 t) 20)) [We used the + and * functions (define (Y t)to write X (and Y).] (+ (* 20 t) 60))

Writing a program to draw UFOs For draw-solid-disk0, the location is the center: (X, Y). (define (ufo-draw t) (and (draw-solid-disk0 (X t) (Y t) 10 'green) (draw-solid-rect0 … 40 3 'green)))

Writing a program to draw UFOs However, for draw-solid-rect0, the location is the top- left corner: (X – 20, Y). (define (ufo-draw t) (and (draw-solid-disk0 (X t) (Y t) 10 'green) (draw-solid-rect0 (- (X t) 20) (Y t) 40 3 'green))) [We used the draw-solid-disk0, draw-solid-rect0, X, and Y functions to write ufo-draw.]

Writing a program to erase UFOs Notice that the screen is (almost) white. To make it appear that we are erasing the UFO, we simply draw a white one. Let’s call this function erase-UFO. All we need to do is make 2 small changes to draw-UFO: -change the program’s name -change each of the colors to white

Writing a program to erase UFOs (define (ufo-draw t) (and (draw-solid-disk0 (X t) (Y t) 10 'green) (draw-solid-rect0 (- (X t) 20) (Y t) 40 3 'green))) BECOMES (define (ufo-erase t) (and (draw-solid-disk0 (X t) (Y t) 10 ‘white) (draw-solid-rect0 (- (X t) 20) (Y t) 40 3 ‘white)))

In summary… Using figure 1, we can now find a UFO’s location (using the X and Y functions. And, we can now draw and erase the UFO on the screen (using the UFO-draw and UFO-erase functions). Next time… In programming, one should not have two functions that both have similar code. We will see another way to write UFO-draw and UFO-erase. Then, finally on to the ANIMATION!