Functional Problem Solving (CSC 151 2013F) : EBoards

CSC151.02 2013F, Class 09: An Introduction to the GIMP


Overview

Admin

Preparation for Quiz (and other discussion items)

I have a bit of code to show you that I hope resolves some recent questions. Then I'll give you ten minutes for additonal questions.

#lang racket
(require gigls/unsafe)

;;; File:
;;;   sample.rkt
;;; Author:
;;;   Samuel A. Rebelsky
;;; Summary:
;;    A quick sample to illustrate a variety of points about drawings.

;;; Procedure:
;;;   bigred
;;; Parameters:
;;;   drawing, a drawing
;;; Purpose:
;;;   To confuse students
;;; Produces:
;;;   A drawing
;;; Props:
;;;   Taken from a clicker question designed by SR and JD
(define bigred
  (lambda (drawing)
    (drawing-recolor drawing "red")
    (drawing-scale drawing 10)))

;;; Procedure:
;;;   preview
;;; Parameters:
;;;   d, a drawing
;;; Purpose:
;;;   preview the drawing in a new window
;;; Produces:
;;;   img, the id of the preview image
;;; Preconditions:
;;;   (drawing-right d) >= 1
;;;   (drawing-bottom d) >= 1
;;; Postconditions:
;;;   img contains a rendering of d
(define preview
  (lambda (d)
    (image-show (drawing->image d (drawing-right d) (drawing-bottom d)))))

;;; Value
;;;   d1, a sample drawing
;;; Type:
;;;   drawing
;;; Contents:
;;;   A black, 50x50 circle centered at (25,25)
(define d1
  (drawing-hshift 
   (drawing-vshift
    (drawing-scale drawing-unit-circle 50)
    25)
   25))

;;; Value:
;;;   d2
;;; Type:
;;;   drawing
;;; Contents:
;;;   A purple 50x50 circle, centered at (75,75)
(define d2
  (drawing-hshift 
   (drawing-vshift
    (drawing-scale 
     (drawing-recolor drawing-unit-circle "purple")
     50)
    75)
   75))

;;; Value:
;;;   d3
;;; Type:
;;;   drawing
;;; Contents:
;;;   A green rectangle
(define d3
  (drawing-hshift
   (drawing-vshift
    (drawing-scale
     (drawing-recolor
      drawing-unit-square
      "green")
     30)
    20)
   80))

;;; Value:
;;;   scene
;;; Type:
;;;   drawing
;;; Summary:
;;;   A simple scene
(define scene
  (drawing-group d1 d2 d3))

;;; Procedure:
;;;   drawing-munge
;;; Parameters:
;;;   drawing, a drawing
;;; Purpose:
;;;   Create a new drawing, based on the original drawing
;;; Produces:
;;;   new-drawing, a drawing
(define drawing-munge
  (lambda (d)
    (drawing-recolor (drawing-scale d 1.1) "blue")))

Quiz

Lab


Samuel A. Rebelsky, rebelsky@grinnell.edu

Copyright (c) 2007-2013 Janet Davis, Samuel A. Rebelsky, and Jerod Weinman. (Selected materials are copyright by John David Stone or Henry Walker and are used with permission.)

Creative Commons License

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/3.0/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.