t-o-p-logo.scm 5.2 KB
Newer Older
Elliot Lee's avatar
Elliot Lee committed
1 2 3 4 5
;;  Trace of Particles Effect
;; Shuji Narazaki (narazaki@InetQ.or.jp)
;; Time-stamp: <97/03/15 17:27:33 narazaki@InetQ.or.jp>
;; Version 0.2

6 7 8 9 10 11 12 13 14 15
(define (apply-t-o-p-logo-effect img
				 logo-layer
				 b-size
				 hit-rate
				 edge-size
				 edge-only
				 base-color
				 bg-color)
  (let* ((width (car (gimp-drawable-width logo-layer)))
	 (height (car (gimp-drawable-height logo-layer)))
16 17 18 19
	 (logo-layer-mask (car (gimp-layer-create-mask logo-layer ADD-BLACK-MASK)))
	 (sparkle-layer (car (gimp-layer-new img width height RGBA-IMAGE "Sparkle" 100 NORMAL-MODE)))
	 (shadow-layer (car (gimp-layer-new img width height RGBA-IMAGE "Shadow" 90 ADDITION-MODE)))
	 (bg-layer (car (gimp-layer-new img width height RGB-IMAGE "Background" 100 NORMAL-MODE)))
Elliot Lee's avatar
Elliot Lee committed
20
	 (selection 0)
21 22 23 24
	 (white '(255 255 255)))

    (gimp-context-push)

25
    (script-fu-util-image-resize-from-layer img logo-layer)
Elliot Lee's avatar
Elliot Lee committed
26 27 28 29
    (gimp-image-add-layer img sparkle-layer 2)
    (gimp-image-add-layer img shadow-layer 3)
    (gimp-image-add-layer img bg-layer 4)
    (gimp-selection-none img)
30 31
    (gimp-edit-clear shadow-layer)
    (gimp-edit-clear sparkle-layer)
32
    (gimp-context-set-background base-color)
33
    (gimp-edit-fill sparkle-layer BACKGROUND-FILL)
34
    (gimp-selection-layer-alpha logo-layer)
Elliot Lee's avatar
Elliot Lee committed
35 36 37 38 39 40 41
    (set! selection (car (gimp-selection-save img)))
    (gimp-selection-grow img edge-size)
    '(plug-in-noisify 1 img sparkle-layer FALSE
		     (* 0.1 hit-rate) (* 0.1 hit-rate) (* 0.1 hit-rate) 0.0)
    (gimp-selection-border img edge-size)
    (plug-in-noisify 1 img sparkle-layer FALSE hit-rate hit-rate hit-rate 0.0)
    (gimp-selection-none img)
42
    (plug-in-sparkle 1 img sparkle-layer 0.03 0.49 width 6 15 1.0 0.0 0.0 0.0 FALSE FALSE FALSE 0)
43
    (gimp-selection-load selection)
Elliot Lee's avatar
Elliot Lee committed
44
    (gimp-selection-shrink img edge-size)
45 46
    (gimp-levels sparkle-layer 0 0 255 1.2 0 255)
    (gimp-selection-load selection)
Elliot Lee's avatar
Elliot Lee committed
47
    (gimp-selection-border img edge-size)
48 49
    (gimp-levels sparkle-layer 0 0 255 0.5 0 255)
    (gimp-selection-load selection)
Elliot Lee's avatar
Elliot Lee committed
50 51
    (gimp-selection-grow img (/ edge-size 2.0))
    (gimp-selection-invert img)
52
    (gimp-edit-clear sparkle-layer)
53
    (if (= edge-only TRUE)
Elliot Lee's avatar
Elliot Lee committed
54
	(begin
55
	  (gimp-selection-load selection)
Elliot Lee's avatar
Elliot Lee committed
56
	  (gimp-selection-shrink img (/ edge-size 2.0))
57 58
	  (gimp-edit-clear sparkle-layer)
	  (gimp-selection-load selection)
Elliot Lee's avatar
Elliot Lee committed
59 60
	  (gimp-selection-grow img (/ edge-size 2.0))
	  (gimp-selection-invert img)))
61 62
    (gimp-context-set-foreground '(0 0 0))
    (gimp-context-set-background '(255 255 255))
63
    (gimp-context-set-brush "Circle Fuzzy (11)")
64
    (gimp-selection-feather img b-size)
65
    (gimp-edit-fill shadow-layer BACKGROUND-FILL)
Elliot Lee's avatar
Elliot Lee committed
66
    (gimp-selection-none img)
67
    (gimp-context-set-background base-color)
68
    (gimp-edit-fill bg-layer BACKGROUND-FILL)
69
    (gimp-selection-load selection)
70
    (gimp-context-set-brush "Circle Fuzzy (07)")
71
    (gimp-context-set-foreground '(255 255 255))
Elliot Lee's avatar
Elliot Lee committed
72
    (gimp-selection-none img)
73
    (gimp-drawable-set-visible logo-layer 0)
74 75 76
    (gimp-image-set-active-layer img sparkle-layer)

    (gimp-context-pop)))
77 78 79 80 81 82 83 84 85 86 87


(define (script-fu-t-o-p-logo-alpha img
				    logo-layer
				    b-size
				    hit-rate
				    edge-size
				    edge-only
				    base-color
				    bg-color)
  (begin
88
    (gimp-image-undo-group-start img)
89 90
    (apply-t-o-p-logo-effect img logo-layer b-size hit-rate
			     edge-size edge-only base-color bg-color)
91
    (gimp-image-undo-group-end img)
92 93 94
    (gimp-displays-flush)))

(script-fu-register "script-fu-t-o-p-logo-alpha"
95
		    _"<Image>/Script-Fu/Alpha to Logo/_Particle Trace..."
96 97 98 99 100 101 102
		    "Trace of Particles Effect"
		    "Shuji Narazaki (narazaki@InetQ.or.jp)"
		    "Shuji Narazaki"
		    "1997"
		    "RGBA"
                    SF-IMAGE      "Image" 0
                    SF-DRAWABLE   "Drawable" 0
103 104 105 106 107 108
		    SF-ADJUSTMENT _"Border size (pixels)" '(20 1 200 1 10 0 1)
                    SF-ADJUSTMENT _"Hit rate" '(0.2 0 1 .01 .01 2 0)
                    SF-ADJUSTMENT _"Edge width" '(2 0 128 1 1 0 0)
		    SF-TOGGLE     _"Edge only" FALSE
		    SF-COLOR      _"Base color" '(0 40 0)
		    SF-COLOR      _"Background color" '(255 255 255)
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
		    )


(define (script-fu-t-o-p-logo text
			      size
			      fontname
			      hit-rate
			      edge-size
			      edge-only
			      base-color
			      bg-color)
  (let* ((img (car (gimp-image-new 256 256 RGB)))
	 (border (/ size 5))
	 (text-layer (car (gimp-text-fontname img -1 0 0 text (* border 2) TRUE size PIXELS fontname))))
    (gimp-image-undo-disable img)
124
    (gimp-drawable-set-name text-layer text)
125 126
    (apply-t-o-p-logo-effect img text-layer border hit-rate
			     edge-size edge-only base-color bg-color)
Marc Lehmann's avatar
Marc Lehmann committed
127
    (gimp-image-undo-enable img)
Elliot Lee's avatar
Elliot Lee committed
128 129 130
    (gimp-display-new img)))

(script-fu-register "script-fu-t-o-p-logo"
131
		    _"<Toolbox>/Xtns/Script-Fu/Logos/_Particle Trace..."
Elliot Lee's avatar
Elliot Lee committed
132 133 134 135 136
		    "Trace of Particles Effect"
		    "Shuji Narazaki (narazaki@InetQ.or.jp)"
		    "Shuji Narazaki"
		    "1997"
		    ""
137
		    SF-STRING     _"Text" "The GIMP"
138
		    SF-ADJUSTMENT _"Font size (pixels)" '(100 1 1000 1 10 0 1)
139
		    SF-FONT       _"Font" "Becker"
140 141 142 143 144
            SF-ADJUSTMENT _"Hit rate" '(0.2 0 1 .01 .01 2 0)
            SF-ADJUSTMENT _"Edge width" '(2 0 128 1 1 0 0)
		    SF-TOGGLE     _"Edge only" FALSE
		    SF-COLOR      _"Base color" '(0 40 0)
		    SF-COLOR      _"Background color" '(255 255 255)
145
		    )
Elliot Lee's avatar
Elliot Lee committed
146 147

; end of t-o-p.scm