80 likes | 87 Views
Learn to create shapes and work with images in programming using predefined functions. Practice drawing rectangles, circles, and triangles, and manipulate images with overlay function.
E N D
CSC 160Computer Programmingfor Non-MajorsLecture #3c: Working with Pictures (continued) Prof. Adam M. Wittenstein Wittenstein@adelphi.edu http://www.adelphi.edu/~wittensa/csc160/
A preview of today… • As a review of our first language rule (calling functions), we will look at some predefined functions from the “world.ss” teachpack. • Then we will learn our second language rule, which is defining a variable.
Some “world.ss” functions Here are some functions to create shapes. --Wherever a function takes in a "mode", you may use either the symbol 'solid or the symbol 'outline. --Wherever a function takes in an “image-color”, you can enter a color with a string or a symbol. For example, ‘blue or ‘Blue or “blue” or “Blue”. • 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.)
Exercise 1: Creating shapes Using the function rectangle. • Have DrScheme draw a solid red rectangle that is 50 by 100. Using the function circle. • Have DrScheme draw a solid red circle with a radius of 5. Using the function triangle. • Have DrScheme draw an outline of an green equilateral triangle with sides of 50 pixels each.
More “world.ss” functions • image-width: image -> number • image-height: image -> number • overlay: image image ... -> image
Exercise 2: More Image Functions • Find the width and height of one of the shapes from Exercise 1. • Find the width and height of a picture from your computer or a website. • Put a solid red circle with a radius of 5 on top of this picture.
In summary… We have called (predefined) functions involving each of these data types: • Mathematical: numbers, booleans • Linguistic: words (a.k.a. symbols), sentences (a.k.a. strings) • Images: pictures, shapes -- Next class, we will see how to define variables and functions.