1; GIMP - The GNU Image Manipulation Program 2; Copyright (C) 1995 Spencer Kimball and Peter Mattis 3; 4; Lava effect 5; Copyright (c) 1997 Adrian Likins 6; aklikins@eos.ncsu.edu 7; 8; based on a idea by Sven Riedel <lynx@heim8.tu-clausthal.de> 9; tweaked a bit by Sven Neumann <neumanns@uni-duesseldorf.de> 10; 11; This program is free software: you can redistribute it and/or modify 12; it under the terms of the GNU General Public License as published by 13; the Free Software Foundation; either version 3 of the License, or 14; (at your option) any later version. 15; 16; This program is distributed in the hope that it will be useful, 17; but WITHOUT ANY WARRANTY; without even the implied warranty of 18; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19; GNU General Public License for more details. 20; 21; You should have received a copy of the GNU General Public License 22; along with this program. If not, see <https://www.gnu.org/licenses/>. 23 24 25(define (script-fu-lava image 26 drawable 27 seed 28 tile_size 29 mask_size 30 gradient 31 keep-selection 32 separate-layer 33 current-grad) 34 (let* ( 35 (type (car (gimp-drawable-type-with-alpha drawable))) 36 (image-width (car (gimp-image-width image))) 37 (image-height (car (gimp-image-height image))) 38 (active-selection 0) 39 (selection-bounds 0) 40 (select-offset-x 0) 41 (select-offset-y 0) 42 (select-width 0) 43 (select-height 0) 44 (lava-layer 0) 45 (active-layer 0) 46 ) 47 48 (gimp-context-push) 49 (gimp-context-set-defaults) 50 (gimp-image-undo-group-start image) 51 52 (if (= (car (gimp-drawable-has-alpha drawable)) FALSE) 53 (gimp-layer-add-alpha drawable) 54 ) 55 56 (if (= (car (gimp-selection-is-empty image)) TRUE) 57 (gimp-image-select-item image CHANNEL-OP-REPLACE drawable) 58 ) 59 60 (set! active-selection (car (gimp-selection-save image))) 61 (gimp-image-set-active-layer image drawable) 62 63 (set! selection-bounds (gimp-selection-bounds image)) 64 (set! select-offset-x (cadr selection-bounds)) 65 (set! select-offset-y (caddr selection-bounds)) 66 (set! select-width (- (cadr (cddr selection-bounds)) select-offset-x)) 67 (set! select-height (- (caddr (cddr selection-bounds)) select-offset-y)) 68 69 (if (= separate-layer TRUE) 70 (begin 71 (set! lava-layer (car (gimp-layer-new image 72 select-width 73 select-height 74 type 75 "Lava Layer" 76 100 77 LAYER-MODE-NORMAL-LEGACY))) 78 79 (gimp-image-insert-layer image lava-layer 0 -1) 80 (gimp-layer-set-offsets lava-layer select-offset-x select-offset-y) 81 (gimp-selection-none image) 82 (gimp-drawable-edit-clear lava-layer) 83 84 (gimp-image-select-item image CHANNEL-OP-REPLACE drawable) 85 (gimp-image-set-active-layer image lava-layer) 86 ) 87 ) 88 89 (set! active-layer (car (gimp-image-get-active-layer image))) 90 91 (if (= current-grad FALSE) 92 (gimp-context-set-gradient gradient) 93 ) 94 95 (plug-in-solid-noise RUN-NONINTERACTIVE image active-layer FALSE TRUE seed 2 2 2) 96 (plug-in-cubism RUN-NONINTERACTIVE image active-layer tile_size 2.5 0) 97 (plug-in-oilify RUN-NONINTERACTIVE image active-layer mask_size 0) 98 (plug-in-edge RUN-NONINTERACTIVE image active-layer 2 0 0) 99 (plug-in-gauss-rle RUN-NONINTERACTIVE image active-layer 2 TRUE TRUE) 100 (plug-in-gradmap RUN-NONINTERACTIVE image active-layer) 101 102 (if (= keep-selection FALSE) 103 (gimp-selection-none image) 104 ) 105 106 (gimp-image-set-active-layer image drawable) 107 (gimp-image-remove-channel image active-selection) 108 109 (gimp-image-undo-group-end image) 110 (gimp-context-pop) 111 112 (gimp-displays-flush) 113 ) 114) 115 116(script-fu-register "script-fu-lava" 117 _"_Lava..." 118 _"Fill the current selection with lava" 119 "Adrian Likins <adrian@gimp.org>" 120 "Adrian Likins" 121 "10/12/97" 122 "RGB* GRAY*" 123 SF-IMAGE "Image" 0 124 SF-DRAWABLE "Drawable" 0 125 SF-ADJUSTMENT _"Seed" '(10 1 30000 1 10 0 1) 126 SF-ADJUSTMENT _"Size" '(10 0 100 1 10 0 1) 127 SF-ADJUSTMENT _"Roughness" '(7 3 50 1 10 0 0) 128 SF-GRADIENT _"Gradient" "German flag smooth" 129 SF-TOGGLE _"Keep selection" TRUE 130 SF-TOGGLE _"Separate layer" TRUE 131 SF-TOGGLE _"Use current gradient" FALSE 132) 133 134(script-fu-menu-register "script-fu-lava" 135 "<Image>/Filters/Render") 136