;;; transparent-text.scm --- gives text a transparent effect ;; Copyright (C) 2004 Ivan Zenkov ;; Maintainer: Ivan Zenkov ;; Keywords: logos ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program; if not, write to the Free Software ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ;;; Commentary: ;; Based on Transparent Objects tutorial written by Ron Scott ;;; Code: (define (script-fu-transparent-text string font-name font-size light-set shadow) (let* ((text-ext (gimp-text-get-extents-fontname string font-size PIXELS font-name)) (wid (+ (car text-ext) 30)) (hig (+ (cadr text-ext) 30)) (img (car (gimp-image-new wid hig RGB))) (bg-layer (car (gimp-layer-new img wid hig RGB-IMAGE "Background" 100 NORMAL-MODE))) (text-layer (car (gimp-layer-new img wid hig RGBA-IMAGE "Text" 100 NORMAL-MODE))) (text-channel (car (gimp-channel-new img wid hig "Text channel" 50 '(0 0 0)))) (old-fg (car (gimp-palette-get-foreground))) (old-bg (car (gimp-palette-get-background)))) (define (percent a) (/ (caddr text-ext) (* (/ (/ (caddr text-ext) a) (caddr text-ext)) 100))) (define (spline) (let* ((a (cons-array 4 'byte))) (set-pt a 0 0 0) (set-pt a 1 255 60) a)) (gimp-image-undo-disable img) (gimp-image-add-layer img bg-layer 0) (gimp-image-add-layer img text-layer -1) (gimp-image-add-channel img text-channel 0) (gimp-palette-set-background '(255 255 255)) (gimp-edit-clear bg-layer) (gimp-edit-clear text-layer) (gimp-palette-set-background '(0 0 0)) (gimp-edit-clear text-channel) (gimp-palette-set-foreground '(132 106 79)) (gimp-floating-sel-anchor (car (gimp-text-fontname img text-layer 10 10 string 0 TRUE font-size PIXELS font-name))) ;;; volumetric text (gimp-selection-layer-alpha text-layer) (gimp-edit-fill text-channel WHITE-FILL) (gimp-selection-none img) (plug-in-gauss-rle2 1 img text-channel (percent 5) (percent 5)) (gimp-drawable-set-visible text-channel 0) (plug-in-bump-map 1 img text-layer text-channel 135 45 4 0 0 0 0 0 0 GRADIENT-LINEAR) ;;; transparent effect (gimp-selection-layer-alpha text-layer) (gimp-selection-shrink img (percent 3)) (gimp-selection-feather img (percent 2)) (gimp-curves-spline text-layer 4 HISTOGRAM-ALPHA (spline)) (gimp-selection-none img) (gimp-invert text-layer) ;;; drop shadow (if (= shadow TRUE) (script-fu-drop-shadow img text-layer (percent 12) (percent 12) (percent 10) '(0 0 0) 50 0)) (gimp-hue-saturation text-layer ALL-HUES 0 light-set 0) (gimp-palette-set-foreground old-fg) (gimp-palette-set-background old-bg) (gimp-image-undo-enable img) (gimp-display-new img))) (script-fu-register "script-fu-transparent-text" _"/Xtns/Script-Fu/Logos/Transparent..." "Gives text a transparent effect" "Ivan Zenkov" "Ivan Zenkov" "September 23, 2004" "" SF-STRING _"Text" "Bugs" SF-FONT _"Font" "Broken74" SF-ADJUSTMENT _"Font Size (pixels)" '(100 2 1000 1 10 0 1) SF-ADJUSTMENT _"Lightness" '(50 -100 100 1 1 0 0) SF-TOGGLE _"Shadow" TRUE) ;;; transparent-text.scm ends here