;;; File: ;;; no-failure.scm ;;; Author: ;;; Samuel A. Rebelsky ;;; Version: ;;; 1.0 of April 2001 ;;; Summary: ;;; A simple Script-Fu program that provides a menu item that draws ;;; a log for the message "No Failure". Intented as a very simple ;;; illustration for CSC151. ;;; History: ;;; Tuesday, 2 April 2001 [Samuel A. Rebelsky] ;;; Wrote the code for the "No" sign while exploring the GIMP. ;;; Wednesday, 3 April 2001 [Samuel A. Rebelsky] ;;; Wrote the more general "No Failure" sign. ;;; Extended to take a parameter. ;;; Thursday, 4 April 2001 [Samuel A. Rebelsky] ;;; Copied to a new file. ;;; Added a command to add the procedure to the GIMP menus. ;;; Added the color parameter. ;;; Renamed the primary procedure. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Libraries (load "/home/rebelsky/Web/GIMP/Scripts/utils.ss") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Procedures ;;; Procedure: ;;; new-no-failure ;;; Parameters: ;;; side, an integer ;;; color, an RGB list ;;; Purpose: ;;; Creates a new image with the universal sign for "No Fs". ;;; The image has width side and height side. ;;; The F in the image has the specified color. ;;; Produces: ;;; Nothing. You call this only for the side effect of ;;; drawing a new image. ;;; Preconditions: ;;; Must be called from within Script-Fu. ;;; Postconditions: ;;; A new image appears on the screen. (define new-no-failure (lambda (side color) (let* ((image (car (gimp-image-new side side RGB))) (layer (car (gimp-layer-new image side side RGB_IMAGE "Layer" 100 0))) (unit (/ side 32))) ; Add the layer to the image (gimp-image-add-layer image layer 0) ; Clear everything (gimp-selection-all image) (gimp-edit-clear image layer) (gimp-selection-none image) ; Set default background (gimp-palette-set-background WHITE) ; Draw the silly letter F (gimp-palette-set-foreground color) (gimp-brushes-set-brush "Circle (11)") (samr-line image layer (* unit 12) (* unit 5) (* unit 20) (* unit 5)) (samr-line image layer (* unit 12) (* unit 5) (* unit 12) (* unit 27)) (samr-line image layer (* unit 12) (* unit 14) (* unit 18) (* unit 14)) ; Draw the nice red circle. (gimp-palette-set-foreground RED) (gimp-brushes-set-brush "Circle (07)") (gimp-ellipse-select image unit unit (- side unit unit) (- side unit unit) REPLACE 0 0 0) (gimp-edit-stroke image layer) (gimp-selection-none image) ; Now we're ready to draw the slash. Basic math tells us that ; the endpoints are offset by radius/(sqrt 2) from the center ; of the circle. ; direction). (let* ((center (/ side 2)) (radius (- center unit)) (offset (/ radius (sqrt 2)))) (samr-line image layer (- center offset) (- center offset) (+ center offset) (+ center offset))) ; And display the image (gimp-display-new image)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Fun Menu Stuff (script-fu-register "new-no-failure" "/Xtns/Script-Fu/Sample/No Failure" "Draws a \"No Failure\" logo" "Samuel A. Rebelsky" "Copyright (c) 2001 Samuel A. Rebelsky. All Rights Reserved" "Thursday, 5 April 2001" "RGB" SF-VALUE "Side Length" "256" SF-COLOR "Color" BLUE)