
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.
88 lines
3.1 KiB
Scheme
88 lines
3.1 KiB
Scheme
; Create a 3D sphere with optional shadow
|
|
; The sphere's principle color will be the foreground
|
|
; Parameters:
|
|
; bg-color: background color
|
|
; sphere-color: color of sphere
|
|
; radius: radius of the sphere in pixels
|
|
; light: angle of light source in degrees
|
|
; shadow: whather to create a shadow as well
|
|
|
|
(define (script-fu-sphere radius
|
|
light
|
|
shadow
|
|
bg-color
|
|
sphere-color)
|
|
(let* (
|
|
(width (* radius 3.75))
|
|
(height (* radius 2.5))
|
|
(img (car (gimp-image-new width height RGB)))
|
|
(drawable (car (gimp-layer-new img width height RGB-IMAGE
|
|
"Sphere Layer" 100 NORMAL-MODE)))
|
|
(*pi* (* 4 (atan 1.0)))
|
|
(radians (/ (* light *pi*) 180))
|
|
(cx (/ width 2))
|
|
(cy (/ height 2))
|
|
(light-x (+ cx (* radius (* 0.6 (cos radians)))))
|
|
(light-y (- cy (* radius (* 0.6 (sin radians)))))
|
|
(light-end-x (+ cx (* radius (cos (+ *pi* radians)))))
|
|
(light-end-y (- cy (* radius (sin (+ *pi* radians)))))
|
|
(offset (* radius 0.1))
|
|
)
|
|
|
|
(gimp-context-push)
|
|
|
|
(gimp-image-undo-disable img)
|
|
(gimp-image-add-layer img drawable 0)
|
|
(gimp-context-set-foreground sphere-color)
|
|
(gimp-context-set-background bg-color)
|
|
(gimp-edit-fill drawable BACKGROUND-FILL)
|
|
(gimp-context-set-background '(20 20 20))
|
|
(if (and
|
|
(or (and (>= light 45) (<= light 75))
|
|
(and (<= light 135) (>= light 105)))
|
|
(= shadow TRUE))
|
|
(let ((shadow-w (* (* radius 2.5) (cos (+ *pi* radians))))
|
|
(shadow-h (* radius 0.5))
|
|
(shadow-x cx)
|
|
(shadow-y (+ cy (* radius 0.65))))
|
|
(if (< shadow-w 0)
|
|
(begin (set! shadow-x (+ cx shadow-w))
|
|
(set! shadow-w (- shadow-w))))
|
|
|
|
(gimp-ellipse-select img shadow-x shadow-y shadow-w shadow-h
|
|
CHANNEL-OP-REPLACE TRUE TRUE 7.5)
|
|
(gimp-edit-bucket-fill drawable BG-BUCKET-FILL MULTIPLY-MODE 100 0 FALSE 0 0)))
|
|
|
|
(gimp-ellipse-select img (- cx radius) (- cy radius)
|
|
(* 2 radius) (* 2 radius) CHANNEL-OP-REPLACE TRUE FALSE 0)
|
|
|
|
(gimp-edit-blend drawable FG-BG-RGB-MODE NORMAL-MODE
|
|
GRADIENT-RADIAL 100 offset REPEAT-NONE FALSE
|
|
FALSE 0 0 TRUE
|
|
light-x light-y light-end-x light-end-y)
|
|
|
|
(gimp-selection-none img)
|
|
(gimp-image-undo-enable img)
|
|
(gimp-display-new img)
|
|
|
|
(gimp-context-pop)
|
|
)
|
|
)
|
|
|
|
(script-fu-register "script-fu-sphere"
|
|
_"_Sphere..."
|
|
_"Create a simple sphere with a drop shadow"
|
|
"Spencer Kimball"
|
|
"Spencer Kimball"
|
|
"1996"
|
|
""
|
|
SF-ADJUSTMENT _"Radius (pixels)" '(100 5 500 1 10 0 1)
|
|
SF-ADJUSTMENT _"Lighting (degrees)" '(45 0 360 1 10 0 0)
|
|
SF-TOGGLE _"Shadow" TRUE
|
|
SF-COLOR _"Background color" '(255 255 255)
|
|
SF-COLOR _"Sphere color" '(255 0 0)
|
|
)
|
|
|
|
(script-fu-menu-register "script-fu-sphere"
|
|
"<Toolbox>/Xtns/Misc")
|