Files
gimp/plug-ins/script-fu/scripts/grid-system.scm
Kevin Cozens 6239dddda3 With this commit we finally say goodbye to SIOD. This large set of changes
2006-10-15  Kevin Cozens  <kcozens@cvs.gnome.org>

	With this commit we finally say goodbye to SIOD. This large set of
	changes updates the Script-Fu plug-in to use the TinyScheme Scheme
	interpreter. These changes originated with changes originally made
	to Script-Fu which created Tiny-Fu (aka. the gimp-tiny-fu module).

	* plug-ins/script-fu/Makefile.am
	* plug-ins/script-fu/script-fu-console.c
	* plug-ins/script-fu/script-fu-interface.c
	* plug-ins/script-fu/script-fu-scripts.c
	* plug-ins/script-fu/script-fu-scripts.h
	* plug-ins/script-fu/script-fu-server.c
	* plug-ins/script-fu/script-fu-text-console.c
	* plug-ins/script-fu/script-fu.c: Updated with the changes made to
	these files as part of the work on the Tiny-Fu project.

	* plug-ins/script-fu/scheme-wrapper.c
	* plug-ins/script-fu/scheme-wrapper.h: Renamed from siod-wrapper.[ch]
	and updated based on differences to ts-wrapper.[ch] from gimp-tiny-fu.

	* plug-ins/script-fu/ftx/*
	* plug-ins/script-fu/re/*
	* plug-ins/script-fu/tinyscheme/*
	* plug-ins/script-fu/scripts/script-fu.init
	* plug-ins/script-fu/scripts/script-fu-compat.init
	* plug-ins/script-fu/scripts/contactsheet.scm
	* plug-ins/script-fu/scripts/script-fu-set-cmap.scm
	* plug-ins/script-fu/scripts/script-fu-util-setpt.scm
	* plug-ins/script-fu/scripts/ts-helloworld.scm: Added all of these
	files and directories from Tiny-Fu. Updated the Makefile.am files
	of ftx, re, and tinyscheme now they are in the GIMP source tree.

	* plug-ins/script-fu/scripts/*.scm: All scripts have been updated as
	needed to ensure they will work with the TinyScheme interpreter. Most
	of the files have been reformatted making it easier to see the syntax
	of Scheme and making them easier to read.

	* plug-ins/script-fu/scripts/Makefile.am: Updated script file lists.

	* plug-ins/script-fu/siod-wrapper.c
	* plug-ins/script-fu/siod-wrapper.h
	* plug-ins/script-fu/siod/*: Removed obsolete files.

	* configure.in: Updated list of files in AC_CONFIG_FILES. Changed
	--disable-script-fu to --without-script-fu which it should have
	been when originally added.

	* INSTALL: Updated to show change to --without-script-fu.
2006-10-16 01:08:54 +00:00

99 lines
3.4 KiB
Scheme

;;; grid-system.scm -*-scheme-*-
;;; Time-stamp: <1998/01/20 23:22:02 narazaki@InetQ.or.jp>
;;; This file is a part of:
;;; The GIMP (Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis)
;;; Author: Shuji Narazaki (narazaki@InetQ.or.jp)
;;; Version 0.6
;;; Code:
(if (not (symbol-bound? 'script-fu-grid-system-x-divides (current-environment)))
(define script-fu-grid-system-x-divides "'(1 g 1)"))
(if (not (symbol-bound? 'script-fu-grid-system-y-divides (current-environment)))
(define script-fu-grid-system-y-divides "'(1 g 1)"))
(define (script-fu-grid-system img drw x-divides-orig y-divides-orig)
(define (update-segment! s x0 y0 x1 y1)
(aset s 0 x0)
(aset s 1 y0)
(aset s 2 x1)
(aset s 3 y1))
(define (map proc seq)
(if (null? seq)
'()
(cons (proc (car seq))
(map proc (cdr seq)))))
(define (convert-g l)
(cond ((null? l) '())
((eq? (car l) 'g) (cons 1.618 (convert-g (cdr l))))
((eq? (car l) '1/g) (cons 0.618 (convert-g (cdr l))))
('else (cons (car l) (convert-g (cdr l))))))
(define (wrap-list l)
(define (wrap-object obj)
(cond ((number? obj) (string-append (number->string obj) " "))
((eq? obj 'g) "g ")
(eq? obj '1/g) "1/g "))
(string-append "'(" (apply string-append (map wrap-object l)) ")"))
(let* ((drw-width (car (gimp-drawable-width drw)))
(drw-height (car (gimp-drawable-height drw)))
(drw-offset-x (nth 0 (gimp-drawable-offsets drw)))
(drw-offset-y (nth 1 (gimp-drawable-offsets drw)))
(grid-layer #f)
(segment (cons-array 4 'double))
(stepped-x 0)
(stepped-y 0)
(temp 0)
(total-step-x 0)
(total-step-y 0)
(x-divides (convert-g x-divides-orig))
(y-divides (convert-g y-divides-orig))
(total-step-x (apply + x-divides))
(total-step-y (apply + y-divides)))
(gimp-context-push)
(gimp-image-undo-group-start img)
(set! grid-layer (car (gimp-layer-copy drw TRUE)))
(gimp-image-add-layer img grid-layer 0)
(gimp-edit-clear grid-layer)
(gimp-drawable-set-name grid-layer "Grid Layer")
(while (not (null? (cdr x-divides)))
(set! stepped-x (+ stepped-x (car x-divides)))
(set! temp (* drw-width (/ stepped-x total-step-x)))
(set! x-divides (cdr x-divides))
(update-segment! segment
(+ drw-offset-x temp) drw-offset-y
(+ drw-offset-x temp) (+ drw-offset-y drw-height))
(gimp-pencil grid-layer 4 segment))
(while (not (null? (cdr y-divides)))
(set! stepped-y (+ stepped-y (car y-divides)))
(set! temp (* drw-height (/ stepped-y total-step-y)))
(set! y-divides (cdr y-divides))
(update-segment! segment
drw-offset-x (+ drw-offset-y temp)
(+ drw-offset-x drw-width) (+ drw-offset-y temp))
(gimp-pencil grid-layer 4 segment))
(gimp-image-undo-group-end img)
(gimp-context-pop)
(gimp-displays-flush)))
(script-fu-register "script-fu-grid-system"
_"_Grid..."
_"Draw a grid as specified by the lists of X and Y locations using the current brush"
"Shuji Narazaki <narazaki@InetQ.or.jp>"
"Shuji Narazaki"
"1997"
"RGB*, INDEXED*, GRAY*"
SF-IMAGE "Image to use" 0
SF-DRAWABLE "Drawable to draw grid" 0
SF-VALUE _"X divisions" "'(1 g 1)"
SF-VALUE _"Y divisions" "'(1 g 1)"
)
;;; grid-system.scm ends here
(script-fu-menu-register "script-fu-grid-system"
"<Image>/Filters/Render/Pattern")