Files
gimp/plug-ins/script-fu/scripts/sphere.scm
Henrik Brix Andersen f36a63f68c removed function gimp_menu_path_strip_uline() ...
2003-08-09 Henrik Brix Andersen <brix@gimp.org>

* gimp/app/widgets/gimpwidgets-utils.[ch]: removed function
gimp_menu_path_strip_uline() ...

* gimp/libgimpbase/gimputils.[ch]: ... and added it here under the
name gimp_strip_uline()

* gimp/devel-docs/libgimpbase/libgimpbase-sections.txt: added
gimp_strip_uline to gimputils section

* gimp/app/plug-in/plug-in.c
* gimp/app/widgets/gimpitemfactory.c
* gimp/app/widgets/gimptoolbox.
* gimp/app/gui/plug-in-menus.c: changed accordingly

* gimp/plug-ins/script-fu/script-fu-scripts.c
(script_fu_interface): use gimp_strip_uline() to strip mnemonics
from script-fu menu paths

* gimp/app/gui/vectors-menu.c
* gimp/app/gui/templates-menu.c
* gimp/app/gui/qmask-menu.c
* gimp/app/gui/palettes-menu.c
* gimp/app/gui/palette-editor-menu.c
* gimp/app/gui/images-menu.c
* gimp/app/gui/gradients-menu.c
* gimp/app/gui/gradient-editor-menu.c
* gimp/app/gui/documents-menu.c
* gimp/app/gui/dialogs-menu.c
* gimp/app/gui/colormap-editor-menu.c
* gimp/app/gui/channels-menu.c
* gimp/app/gui/buffers-menu.c
* gimp/app/gui/brushes-menu.c
* gimp/app/gui/layers-menu.c
* gimp/plug-ins/pygimp/plug-ins/clothify.py
* gimp/plug-ins/pygimp/plug-ins/shadow_bevel.py
* gimp/plug-ins/pygimp/plug-ins/whirlpinch.py
* gimp/plug-ins/pygimp/plug-ins/foggify.py
* gimp/plug-ins/script-fu/scripts/*.scm
* gimp/plug-ins/script-fu/script-fu.c: added mnemonics fixing more
of bug #106991

* gimp/app/gui/error-console-menu.c (error_console_menu_update):
updated menu item names, added mnemonics

* gimp/plug-ins/common/animoptimize.c *
gimp/plug-ins/common/animationplay.c: don't prepend every menu
entry with "Animation"
2003-08-11 17:14:32 +00:00

79 lines
2.7 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)))
(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))
(old-fg (car (gimp-palette-get-foreground)))
(old-bg (car (gimp-palette-get-background))))
(gimp-image-undo-disable img)
(gimp-image-add-layer img drawable 0)
(gimp-palette-set-foreground sphere-color)
(gimp-palette-set-background bg-color)
(gimp-edit-fill drawable BG-IMAGE-FILL)
(gimp-palette-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)
(prog1 (set! shadow-x (+ cx shadow-w))
(set! shadow-w (- shadow-w))))
(gimp-ellipse-select img shadow-x shadow-y shadow-w shadow-h
REPLACE TRUE TRUE 7.5)
(gimp-bucket-fill drawable BG-BUCKET-FILL MULTIPLY 100 0 FALSE 0 0)))
(gimp-ellipse-select img (- cx radius) (- cy radius)
(* 2 radius) (* 2 radius) REPLACE TRUE FALSE 0)
(gimp-blend drawable FG-BG-RGB NORMAL
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-palette-set-background old-bg)
(gimp-palette-set-foreground old-fg)
(gimp-image-undo-enable img)
(gimp-display-new img)))
(script-fu-register "script-fu-sphere"
_"<Toolbox>/Xtns/Script-Fu/Misc/_Sphere..."
"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))