1 / 12

CSC 160 Computer Programming for Non-Majors Lecture #3b: Working with Pictures

CSC 160 Computer Programming for Non-Majors Lecture #3b: Working with Pictures. Prof. Adam M. Wittenstein Wittenstein@adelphi.edu http://www.adelphi.edu/~wittensa/csc160/. A preview of today…. So far we called pre-defined functions with numbers, words, and sentences.

cmarco
Download Presentation

CSC 160 Computer Programming for Non-Majors Lecture #3b: Working with Pictures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSC 160Computer Programmingfor Non-MajorsLecture #3b: Working with Pictures Prof. Adam M. Wittenstein Wittenstein@adelphi.edu http://www.adelphi.edu/~wittensa/csc160/

  2. A preview of today… • So far we called pre-defined functions with numbers, words, and sentences. • Today, we call pre-defined functions with images (pictures and shapes). • Then, we will see how to define variables in Scheme.

  3. Data Type: Image • Another type of data. Fun to process images. • Images are values like numbers, booleans, words, or sentences – they can be used inside expressions. • Usually given names, since the same image can be used with several different functions. • There are predefined functions to create shapes. Besides that, all other images (pictures) are inserted as follows:

  4. Inserting Images • You cannot type in images the way you type in a number or a word. • To insert an image into a program, move the blinking caret to the place in your program where you want the image, and select the Insert Image item from the Special menu. • DrScheme will then provide a dialog for selecting an image file. • After you have selected a file, the image will be inserted at the blinking caret.

  5. I. Calling Functions with Images

  6. Calling Functions involving Images • Once you have inserted the image (usually a picture), it is treated the same way as any other (simple) data type. • You can use image objects as arguments in a function. • Image objects can be the result of a function.

  7. Install two teachpacks • Open Internet Explorer and type in the website, http://www.adelphi.edu/~wittensa/csc160/tiles.plt • Save the file to the folder C:\ProgramFiles\PLT\Teachpack. • Then in DrScheme, go to “File >Install .plt File > File > tiles.plt”. • Now, as for any teachpack, choose “Language -> Add Teachpack -> tiles (bottom one)” and click Run. • Also, add the “world.ss” teachpack. Choose “Language -> Add Teachpack -> htdp -> world” and click Run.

  8. Some “tiles.ss” functions • reflect-horiz : image -> image • reflect-vert : image -> image • image-beside : image image -> image • image-above : image image -> image • rotate-cw : image -> image • rotate-ccw : image -> image • rotate-180 : image -> image

  9. Exercise 1: Calling Image Functions • Insert a picture into your DrScheme file either from your computer or a website. • Find the horizontal mirror image of the picture. • Put your picture next to itself. • Put your picture next to its horizontal mirror image.

  10. III. Preparing for Next Class

  11. In summary… • Pictures have to be inserted. They cannot simply be typed in like numbers, words, and sentences can. • However, after inserting them, they are treated like any other data type. Next time… • More practice with images • Defining variables

  12. Homework for next time… • No written assignments. • Readings: • Read the article on Pair Programming. • Read Sections 2.2-2.3 of How to Design Programs. • Read Chapter 4 of Simply Scheme.

More Related