60 likes | 83 Views
CSC 160 Computer Programming for Non-Majors Images: Another Form of Symbolic Data. Prof. Adam M. Wittenstein Wittenstein@adelphi.edu http://www.adelphi.edu/~wittensa/csc160/. Data Type: Image (Shapes or Pictures). A third type of symbolic data. Fun to process images.
E N D
CSC 160Computer Programmingfor Non-MajorsImages: Another Form of Symbolic Data Prof. Adam M. Wittenstein Wittenstein@adelphi.edu http://www.adelphi.edu/~wittensa/csc160/
Data Type: Image (Shapes or Pictures) • A third type of symbolic data. Fun to process images. • Images are values like numbers, symbols, or strings – they can be used inside expressions. • Usually given names, since the same image can be used with several different functions. • Like symbols, images don't have any specific meaning, but we tend to connect them easily with the intended information.
Inserting Images • 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.
Another teachpack: “world.ss” This teachpack has some functions to create shapes. --Wherever a function takes in a "mode", you may use either the string “solid” or the symbol “outline”. --Wherever a function takes in an “image-color”, enter the color as a string. For example, “blue” or “Blue” or “red”. • rectangle : num num mode image-color -> image • circle : num mode image-color -> image • triangle : num mode image-color -> image (NOTE: The triangle function is only for equilateral triangles.)
Other “world.ss” functions • image-width : image -> number --to obtain an image's width in pixels • image-height : image -> number --to obtain an image's height in pixels • overlay : image image image ... -> image --to add the pixels of the second image onto the first image, lining up the pinholes (centers)
Next time… • The “tiles.ss” teachpack --Download it from the website: http://www.adelphi.edu/sbloch/class/171/tiles.plt --In DrScheme, Language->Add Teachpack-> Right-click on “tiles”. This extracts another “tiles” file. Install this file. • Writing our own image functions