; Various undocumented procedures (bad Sam!) written in CSC151 (load "/home/rebelsky/Web/Glimmer/ScriptFu/Code/gsfu.scm") ; Problem: Most people think about circles in terms of ; center and radius and not left/top/width/height (define circle (lambda (image layer x y r) (gimp-ellipse-select image (- x r) (- y r) (+ r r) (+ r r) REPLACE 0 0 0) (gimp-edit-stroke layer) (gimp-selection-none image))) (define select-random-brush (let ((num-brushes (car (gimp-brushes-list))) (brushes (cadr (gimp-brushes-list)))) (lambda () (gimp-brushes-set-brush (list-ref brushes (rand num-brushes)))))) (define random-circle (lambda (image layer) ; Choose a color with eqch component between 0 and 255 (gimp-palette-set-foreground (list (rand 256) (rand 256) (rand 256))) (select-random-brush) ; Radius should be less than starting point ; and more than 0 ; Choose random numbers (circle image layer (rand (car (gimp-image-width image))) (rand (car (gimp-image-height image))) (+ 10 (rand 80))) )) ;;; Procedure: ;;; Procedure: ;;; random-circles ;;; Parameters: ;;; image, the id of an image ;;; layer, the id of a layer ;;; num-circles, an integer ;;; Purpose: ;;; Draws num-circles circles. ;;; Produces: ;;; Nothing. ;;; Preconditions: ;;; image is the id of an open image ;;; layer is the id of a layer in that image ;;; num-circles >= 0 ;;; Postconditions: ;;; layer contains num-circles additional circles (define random-circles (lambda (image layer num-circles) (if (> num-circles 0) (begin (random-circle image layer) (random-circles image layer (- num-circles 1)))))) ;;; Procedure: ;;; trace ;;; Parameters: ;;; image, the id of an image ;;; layer, the id of a layer ;;; Purpose: ;;; Traces the image using the current color and brush ;;; Produces: ;;; Nothing ;;; Preconditions: ;;; image names a valid image ;;; layer names a valid layer on that image ;;; Postconditions: ;;; The non-background portion of the image is now traced. (define trace (lambda (image layer) (gimp-by-color-select layer (car (gimp-palette-get-background)) 0 ; threshold REPLACE ; operation 0 ; antialias 0 ; feather 0 ; feather_radius 0 ; sample_merged ) (gimp-selection-invert image) (gimp-edit-stroke layer) (gimp-selection-none image))) REPLACE ; operation