CSC151 2007S, Class 40: Drawing with Script-Fu Admin: * Beware! Friday the 13th falls on Friday this month! * Due: HW 12 * Assigned: HW 13 * We'll go over your answers to homework 11. * Monday's reading will probably be ready late Saturday night. Sorry. * Cool news: Two Grinnellians are doing the Google Summer of Code * We may have prospectives today. What questions should we ask them? * "How does the snow on the ground feel?" * Alex from Virginia (near DC) - Earlham * Grinnell faculty sometimes give you an hour break between two subsequent Psychology tests * Grinnell CS faculty are deaf * "Cold" * "Scary" * Ravi from Des Moines - Already coming to Grinnell, so we can say whatver we want to him * "Grainy" * Jordan from Des Moines, Also - Already coming to Grinnell * "I don't know, I'm wearing shoes" Overview: * HW11 * Representing drawings. * Transforming drawings. * Lab.a /HW11 - Draw Something/ * Parameters - Three numbers, each 0..9 * Goal - Draw something different for each set of numbers * Why? * Potential to vary at least three things * 1000 different pictures, exactly * Clock * Tricky thing - Getting the lines right was a bit of trouble; we needed to learn the pythagorean theorem (which we were able to do through the benefits of a liberal arts education) * Something like the following (let* ((r-2-minute (* 175 175)) (x (* 17.5 val3)) (y (sqrt (- r-2-minute (* x x)))) (variable val3)) (cond ((> 2.5 variable) (line image 500 500 (+ x 500) (+ y 500))) ((> 5 variable) (line image 500 500 (- 500 x) (+ y 500)) * Cube * Make two squares * Offset of the second square based on position of the first square * Connect the corners of those squares (yay math) * Lessons * Choose good brushes * "Whoops ... select-all and then stroke is a bad idea" * Cuboid * Something like cube, but not necessarily with every side equal * Didn't think about using rectangles, so there were a lot of points to compute * Interesting behavior when one of the parameters was 0 * House Scene * Vary house color and ground color * Vary a few other things * Making the roof change color was difficult * A puzzle - How? * Lots of lets made life easier * Use her code as a model for variable naming and comments * draw-face * Sorta cartoony * Using a calligraphic brush gave us more interesting lips * Recommendation - add bunny ears * draw mark * A face with a bowtie * Hard part - drawing the bowtie * Solution: Recursive procedure that draws a lot of lines * draw-face-2 * Wanted a face that "looked cool" * Smile, but a different smile each time * Smile done by creating two ellipses and subtracting one from the other * Might consider adding the Jordan/Tommy lips * TA likes that it has a nose, but expects you could make significant improvements in the design * face-with-hair * Designing the hair was hard * Choosing the right brushes was important * draw-house * "sky blue" seems like a good idea for background * different height and width * higher houses get more windows * Windows were hard - Deciding when to add one in * One of the parameters (say val3) was height (cond ((< val3 3) ; don't draw any windows) ...) * egg * Simple is nice, too * draw-face-3 * Intricate facial expression that demonstrate a wide range of emotions, not just the pure joy or horror that my colleagues' images have presented /Key Ideas in Reading and Lab/ * Yet another way of thinking about programming and images * Think about a drawing simply as "connect the dots" * We might be able to get different effects by choosing different brushes and colors (but use the same points) * Three key point procedures * point * xcoord * ycoord * Global CS idea - You can transform these images by applying a procedure to each point in the drawing * Translate it vertically or horizontally * Scale it - Make the points closer together or further apart (enlarge or shrink) * "randomize" it - Move each of the points a little bit * We can also write procedures to generate the points * Spiral * Moving one point (define translate-point-horizontally (lambda (deltax pt) ; Add deltax to the x component of the point (point (+ deltax (xcoord pt)) (ycoord pt)))) * Moving lots of points - map applies a procedure to every element of a list (define translate-points-horizontally (lambda (deltax points) (map translate-point-horizontally points)))