CSC151 2007S, Class 05: Tools for Scripting the Gimp Admin: * Are there final questions on Assignment 2? * I spent too long on it! THEN STOP! (And tell me you spent 3 hours) * I've forgotten every bit of math I ever learned * Partner with someone who does * Ask a professional mathematician * Ask someone * Describe what you want to do approximately * Suppose f(x) is a function that determines whether x is in a circle. ... * Reading for Wednesday: Turtle Graphics. * No office hours this morning. Sorry. I will be around this afternoon. * A few printed labs available, for those who like dead trees. * Quiz: What stairway will they close next? Overview: * A model of images, extended. * Coding algorithms for drawing. * Lab Computer Science is ... the study of algorithms AND data structures * There are many ways to represent the same kind of information * ANd to think about generating info * We will play with lots of image models as a way to think about ways to structure and organize information * And a way to describe algorithms [Sam draws a really bad looking face on the whiteboard and asks how we might describe it] * (1) As a lot of dots, most of which are white * (2) As four shapes * A circle * Two big dots * A slightly-tilted half-circle * (3) In terms of the GIMP commands someone might use to create it * Choose the ellipse tool * Click at (0,0) and drag to (100,100) * Select "Stroke Selection" from the "Edit" menu * ... * (4) In terms of the turtle commands someone might use to create it * And in many other ways. Let's focus on GIMP commands * Focus is on building the image, not on what the result is * Imperative - Sequence of orders to do something These commands are simple enough that we can represent them as procedures that tell the computer to do the same thing * CHoose the ellipse tool and then select the region from 0,0 to 50,80 + (image-select-ellipse! ... 0 0 50 80) * Stroke that selection + (image-stroke! ...) An example (done live) canvas > (image-show canvas) (1) > (image-select-ellipse! canvas selection.replace 150 150 200 200) Error: eval: unbound variable: selection.replace > (image-select-ellipse! canvas selection-replace 150 150 200 200) 1 > (image-stroke! canvas) (#t) > (context-set-fgcolor! "red") #t > (image-fill! canvas) 1 > (context-set-fgcolor! "blue") #t > (context-set-brush! "Circle Fuzzy (09)") "Circle Fuzzy (09)" > (image-stroke! canvas) (#t) > (context-update-displays!) (#t) == Some Notes == * It's okay to make mistakes. (Note that Sam made mistakes in the code above.) * You often won't see the results of your commands until either (a) you click in the drawing window or (b) you type the wonderful (context-update-displays!) * No one (except Sam) knows everything. Observe how often Max says "I'm not sure". * Whoops ... I guess Sam doesn't know everything (image-select-ellipse! image selection left top WIDTH HEIGHT) * If DrFu starts saying "Success" in response to every command, it is very confused. Except when you load a file, "Success" means "I'm broken". SAVE, quit, and restart. * Sometimes it's useful to sketch things on paper * Why are images numbers? GIMP stores them in a table