Loading [MathJax]/jax/input/TeX/config.js

2010年6月10日木曜日

Script-Fu

(define (script-fu-duplicate-layer img layer)
(let ((copy-layer (car (gimp-layer-copy layer TRUE))))
(gimp-image-add-layer img copy-layer -1)
(gimp-displays-flush)))
(script-fu-register
"script-fu-duplicate-layer"
"Duplicate Layer..."
"description"
"name"
"copyright"
"date"
"RGB*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0)
(script-fu-menu-register "script-fu-duplicate-layer"
"<Image>/Filters/Test")
view raw duplicate.scm hosted with ❤ by GitHub

(define (script-fu-create-new-image bg-color width height)
(let ((img (car (gimp-image-new width height RGB))))
(let ((layer (car (gimp-layer-new img width height RGB-IMAGE
"Background" 100 NORMAL-MODE))))
(gimp-context-push)
(gimp-deawable-fill layer BG-IMAGE-FILL)
(gimp-image-add-layer img layer -1)
(gimp-context-pop)
(gimp-display-new img)
(gimp-displays-flush))))
(script-fu-register
"script-fu-create-new-image"
"New Image..."
"description"
"name"
"copyright"
"date"
""
SF-COLOR "Background color" '(255 255 255)
SF-ADJUSTMENT "Width" '(256 1 1024 1 10 0 1)
SF-ADJUSTMENT "Height" '(256 1 1024 1 10 0 1))
(script-fu-menu-register "script-fu-create-new-image"
"<Image>/Filters/Test")

;; ドロップシャドウを作るスクリプト
(define (script-fu-drop-shadow-text text size font bg-color text-color)
(let ((img (car (gimp-image-new 256 256 RGB))))
;; 前処理
(gimp-image-undo-disable img)
(gimp-context-push)
;; テキストレイヤー作り
(gimp-context-set-foreground text-color)
(let ((text-layer (car (gimp-text-fontname img -1 0 0 text 20
TRUE size PIXELS font))))
;; 背景レイヤー作り
(let ((width (car (gimp-drawable-width text-layer)))
(height (car (gimp-drawable-height text-layer))))
(gimp-image-resize img width height 0 0)
(let ((bg-layer (car (gimp-layer-new img width height RGB-IMAGE
"Background" 100 NORMAL-MODE))))
(gimp-image-add-layer img bg-layer 1)
(gimp-context-set-background bg-color)
(gimp-edit-clear bg-layer)
;; ドロップシャドウの作成
(gimp-context0set-foreground '(0 0 0))
(let ((shadow-layer (car (gimp-text-fontname img -1 0 0 text 20
TRUE xize PIXELS font))))
(gimp-channel-ops-offset shadow-layer FALSE OFFSET-TRANSPARENT 5 5)
(gimp-channel-ops-offset text-layer FALSE OFFSET-TRANSPARENT -5 -5)
(plug-in-gauss-iir2 1 img shadow-layer 20 20)
(gimp-layer-set-opacity shadow-layer 75)
;; 後処理
(gimp-context-pop)
(gimp-image-undo-enable img)
(gimp-display-new img)
(gimp-displays-flush)))))))
;; スクリプトの登録
(script-fu-register
"script-fu-drop-shadow-text"
"Drop Shadow Text..."
"Create the drop shadow text"
"Iccii <iccii@hotmail.com>"
"iccii"
"Jun, 2001/May, 2009"
""
SF-STRING "Text" "Script-Fu!"
SF-ADJUSTMENT "Font size (pixels)" '(100 2 1000 1 10 0 1)
SF-FONT "Font" "Dragonwick"
SF-COLOR "Background color" '(255 255 255)
SF-COLOR "Text color" '(223 8 8))
(script-fu-menu-register "script-fu-drop-shadow-text"
"<Image>/Filters/Test")

(define (script-fu-all-inputs-box
image drawable layer channel vectors color
toggle value string filename dirname
adjustment0 adjustment1 font pattern brush
gradient option palette text enum display)
;; (gimp-message "This is the input box test script!")
(gimp-message (string-append
"Image is " (number->string image) "\n"
"Drawable is " (number->string drawable) "\n"
"Layer is " (number->string layer) "\n"
"Channel is " (number->string channel) "\n"
"Vectors is " (number->string vectors) "\n"
"Color is " "'(" (number->string (car color)) " "
(number->string (cadr color)) " "
(number->string (caddr color)) ")\n"
"Toggle is " (if (equal? toggle TRUE) "TRUE\n" "FALSE\n")
"Value is " (number->string value) "\"\n"
"String is " "\"" string "\"\n"
"Filename is " "\"" filename "\"\n"
"Dirname is " "\"" dirname "\"\n"
"Adjust0 is " (number->string adjustment0) "\n"
"Adjust1 is " (number->string adjustment1) "\n"
"Font is " "\"" font "\"\n"
"Pattern is " "\"" pattern "\"\n"
"Brush is " "'(" "\"" (list-ref brush 0) "\" "
(number->string (list-ref brush 1)) " "
(number->string (list-ref brush 2)) " "
(number->string (list-ref brush 3)) ")\n"
"Gradient is " "\"" gradient "\"\n"
"Option is " (number->string option) "\n"
"Palette is " "\"" palette "\"\n"
"Text is " "\"" text "\"\n"
"Enmu is " (number->string enum) "\n"
"Display is " (number->string display)))
)
(script-fu-register
"script-fu-all-inputs-box"
"All Inputs Box..."
"Show all inputs box"
"Iccii <iccii@hotmail.com>"
"Iccii"
"Jun, 2001/May, 2009"
""
SF-IMAGE "SF-IMAGE" 0
SF-DRAWABLE "SF-DRAWABLE" 0
SF-LAYER "SF-LAYER" 0
SF-CHANNEL "SF-CHANNEL" 0
SF-VECTORS "SF-VECTORS" 0
SF-COLOR "SF-COLOR" '(255 255 255)
SF-TOGGLE "SF-TOGGLE" FALSE
SF-VALUE "SF-VALUE" "10"
SF-STRING "SF-STRING" "The Gimp"
SF-FILENAME "SF-FILENAME" "/FILENAME"
SF-DIRNAME "SF-DIRNAME" ""
SF-ADJUSTMENT "SF-ADJUSTMENT 0" '(256 1 1024 1 10 0 0)
SF-ADJUSTMENT "SF-ADJUSTMENT 1" '(256 1 1024 1 10 0 1)
SF-FONT "SF-FONT" "Sans"
SF-PATTERN "SF-PATTERN" "Leopard"
SF-BRUSH "SF-BRUSH" '("Circle (15)" 1.0 20 0)
SF-GRADIENT "SF-GRADIENT" "Blue Green"
SF-OPTION "SF-OPTION" '("Option1" "Option2" "Option3")
SF-PALETTE "SF-PALETTE" "Blues"
SF-TEXT "SF-TEXT" "Try input \n any texts"
SF-ENUM "SF-ENUM" '("GimpGradientType" "linear")
SF-DISPLAY "SF-DISPLAY" 0
)
(script-fu-menu-register "script-fu-all-inputs-box"
"<Image>/Filters/Test")

;; ドロップシャドウを追加するスクリプト
(define (script-fu-layer-effect-drop-shadow
img ; 画像
layer ; ドロアブル (レイヤー)
shadow-color ; 影の色
blur-radius ; 影のぼかし半径
opacity ; 影の不透明度
x-offset ; 影の X オフセット
y-offset ; 影の Y オフセット
)
(let ((width (car gimp-drawable-width layer))
(height (car (gimp-drawable-height layer))))
(let ((shadow-layer (car (gimp-layer-new img width height RGBA-IMAGE
"Drop Shadow" opacity MULTIPLY-MODE))))
(let ((shadow-mask (car (gimp-layer-create-mask shadow-layer BLACK-MASK))))
;; 処理準備
(gimp-image-undo-group-start img)
(gimp-context-push)
(gimp-image-add-layer img shadow-layer -1)
(gimp-image-add-layer-mask img shadow-layer shadow-mask)
;; シャドウレイヤーマスクの作成
(gimp-context-set-background shadow-color)
(gimp-drawabla-fill shadow-layer BG-IMAGE-FILL)
(gimp-selection-layer-alpha layer)
(gimp-edit-fill shadow-mask WHITE-IMAGE-FILL)
(gimp-selection-none img)
;; シャドウレイヤーマスクへの変更
(gimp-context-set-background '(0 0 0))
(gimp-channel-ops-offset shadow-mask FALSE OFFSET-BACKGROUND x-offset y-offset)
(plug-in-gauss-iir2 1 img shadow-mask blur-radius blur-radius)
;; 後処理
(gimp-image-lower-layer img shadow-layer)
(gimp-context-pop)
(gimp-image-undo-group-end img)
(gimp-displays-flush)))))
(script-fu-register
"script-fu-layer-effect-drop-shadow"
"Drop Shadow..."
"Create drop shadow on the layer with alpha"
"iccii <iccii@hotmail.com"
"iccii"
"Aug, 2001/May, 2009"
"RGBA"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
SF-COLOR "Shadow color" '(0 0 0)
SF-ADJUSTMENT "Shadow blur radius" '(10 1 100 1 10 0 0)
SF-ADJUSTMENT "Drop shadow opacity" '(75 0 100 1 10 0 0)
SF-ADJUSTMENT "Shadow X offset" '(5 -100 100 1 10 0 1)
SF-ADJUSTMENT "Shadow Y offset" '(5 -100 100 1 10 0 1))
(script-fu-menu-register "script-fu-layer-effect-drop-shadow"
"<Image>/Filters/Layer Effect")

;; レイヤー光彩 (内側) スクリプト
(define (script-fu-layer-effect-inner-glow
img ; 画像
layer ; ドロアブル (レイヤー)
glow-color ; 光彩の色
blur-radius ; 光彩のぼかし半径
glow-radius ; 光彩の半径
opacity ; 光彩の不透明度
glow-type ; 光彩のタイプ (縁 or 内部)
)
(let ((width (car (gimp-drawable-width layer)))
(height (car (gimp-drawable-height layer))))
(let ((glow-layer (car (gimp-layer-new img width height RGBA-IMAGE
"Inner Glow" opacity SCREEN-MODE))))
(let ((glow-mask (car (gimp-layer-create-mask glow-layer WHITE-MASK))))
;; 処理準備
(gimp-image-undo-group-start img)
(gimp-context-push)
(gimp-image-add-layer img glow-layer -1)
(gimp-image-add-layer-mask img glow-layer glow-mask)
;; 光彩レイヤーマスクの作成
(gimp-context-set-background glow-color)
(gimp-drawable-fill glow-layer BG-IMAGE-FILL)
(gimp-selection-layer-alpha layer)
(gimp-selection-invert img)
(gimp-selection-grow img glow-radius)
(gimp-selection-invert img)
(gimp-context-set-background '(0 0 0))
(gimp-edit-fill glow-mask BG-IMAGE-FILL)
(gimp-selection-none img)
;; 光彩レイヤーマスクへの変更
(plug-in-gauss-iir2 1 img glow-mask blur-radius blur-radius)
(and (eqv? glow-type 1)
(gimp-invert glow-mask))
;; もう一度レイヤーマスクを作る
(gimp-image-remove-layer-mask img glow-layer APPLY)
(let ((glow-mask2 (car (gimp-layer-create-mask glow-layer BLACK-MASK))))
(gimp-image-add-layer-mask img glow-layer glow-mask2)
(gimp-selection-layer-alpha layer)
(gimp-edit-fill glow-mask2 WHITE-IMAGE-FILL)
(gimp-selection-none img)
;; 後処理
(gimp-context-pop)
(gimp-image-undo-group-end img)
(gimp-displays-flush))))))
(script-fu-register
"script-fu-layer-effect-inner-glow"
"Inside Glow..."
"Create inner glow on the layer with alpha"
"Iccii <iccii@hotmail.com>"
"Iccii"
"Aug, 2001/May, 2009"
"RGBA"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
SF-COLOR "Glow color" '(255 255 191)
SF-ADJUSTMENT "Blur radius" '(10 1 100 1 10 0 0)
SF-ADJUSTMENT "Glow radius" '(2 1 100 1 10 0 0)
SF-ADJUSTMENT "Opacity" '(75 0 100 1 10 0 0)
SF-OPTION "Glow type" '("Edge" "Inner")
)
(script-fu-menu-register "script-fu-layer-effect-inner-glow"
"<Image>/Filters/Layer Effect")

;; レイヤー光彩 (外側) スクリプト
(define (script-fu-layer-effect-outer-glow
img ; 画像
layer ; ドロアブル (レイヤー)
glow-color ; 光彩の色
blur-radius ; 光彩のぼかし半径
glow-radius ; 光彩の半径
opacity ; 光彩の不透明度
)
(let ((width (car (gimp-drawable-width layer)))
(height (car (gimp-drawable-height layer))))
(let ((glow-layer (car (gimp-layer-new img width height RGBA-IMAGE
"Outer Glow" opacity SCREEN-MODE))))
(let ((glow-mask (car (gimp-layer-create-mask glow-layer BLACK-MASK))))
;; 処理準備
(gimp-image-undo-group-start img)
(gimp-context-push)
(gimp-image-add-layer img glow-layer -1)
(gimp-image-add-layer-mask img glow-layer glow-mask)
;; 光彩レイヤーマスクの作成
(gimp-context-set-background glow-color)
(gimp-drawable-fill glow-layer BG-IMAGE-FILL)
(gimp-selection-layer-alpha layer)
(gimp-selection-grow img glow-radius)
(gimp-edit-fill glow-mask WHITE-IMAGE-FILL)
(gimp-selection-none img)
;; 光彩レイヤーマスクへの変更
(gimp-context-set-background '(0 0 0))
(plug-in-gauss-iir2 1 img glow-mask blur-radius blur-radius)
;; 後処理
(gimp-image-lower-layer img glow-layer)
(gimp-context-pop)
(gimp-image-undo-group-end img)
(gimp-displays-flush)))))
(script-fu-register
"script-fu-layer-effect-outer-glow"
"Outer Glow..."
"Create outer glow on the layer with alpha"
"Iccii <iccii@hotmail.com>"
"Iccii"
"Aug, 2001/May, 2009"
"RGBA"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
SF-COLOR "Glow color" '(255 255 191)
SF-ADJUSTMENT "Blur radius" '(10 1 100 1 10 0 0)
SF-ADJUSTMENT "Glow radius" '(2 1 100 1 10 0 0)
SF-ADJUSTMENT "Opacity" '(75 0 100 1 10 0 0)
)
(script-fu-menu-register "script-fu-layer-effect-outer-glow"
"<Image>/Filters/Layer Effect")

;; レイヤー光彩 (内側) スクリプト
(define (script-fu-layer-effect-inner-glow
img ; 画像
layer ; ドロアブル (レイヤー)
glow-color ; 光彩の色
blur-radius ; 光彩のぼかし半径
glow-radius ; 光彩の半径
opacity ; 光彩の不透明度
glow-type ; 光彩のタイプ (縁 or 内部)
)
(let ((width (car (gimp-drawable-width layer)))
(height (car (gimp-drawable-height layer))))
(let ((glow-layer (car (gimp-layer-new img width height RGBA-IMAGE
"Inner Glow" opacity SCREEN-MODE))))
(let ((glow-mask (car (gimp-layer-create-mask glow-layer WHITE-MASK))))
;; 処理準備
(gimp-image-undo-group-start img)
(gimp-context-push)
(gimp-image-add-layer img glow-layer -1)
(gimp-image-add-layer-mask img glow-layer glow-mask)
;; 光彩レイヤーマスクの作成
(gimp-context-set-background glow-color)
(gimp-drawable-fill glow-layer BG-IMAGE-FILL)
(gimp-selection-layer-alpha layer)
(gimp-selection-invert img)
(gimp-selection-grow img glow-radius)
(gimp-selection-invert img)
(gimp-context-set-background '(0 0 0))
(gimp-edit-fill glow-mask BG-IMAGE-FILL)
(gimp-selection-none img)
;; 光彩レイヤーマスクへの変更
(plug-in-gauss-iir2 1 img glow-mask blur-radius blur-radius)
(and (eqv? glow-type 1)
(gimp-invert glow-mask))
;; もう一度レイヤーマスクを作る
(gimp-image-remove-layer-mask img glow-layer APPLY)
(let ((glow-mask2 (car (gimp-layer-create-mask glow-layer BLACK-MASK))))
(gimp-image-add-layer-mask img glow-layer glow-mask2)
(gimp-selection-layer-alpha layer)
(gimp-edit-fill glow-mask2 WHITE-IMAGE-FILL)
(gimp-selection-none img)
;; 後処理
(gimp-context-pop)
(gimp-image-undo-group-end img)
(gimp-displays-flush))))))
(script-fu-register
"script-fu-layer-effect-inner-glow"
"Inside Glow..."
"Create inner glow on the layer with alpha"
"Iccii <iccii@hotmail.com>"
"Iccii"
"Aug, 2001/May, 2009"
"RGBA"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
SF-COLOR "Glow color" '(255 255 191)
SF-ADJUSTMENT "Blur radius" '(10 1 100 1 10 0 0)
SF-ADJUSTMENT "Glow radius" '(2 1 100 1 10 0 0)
SF-ADJUSTMENT "Opacity" '(75 0 100 1 10 0 0)
SF-OPTION "Glow type" '("Edge" "Inner")
)
(script-fu-menu-register "script-fu-layer-effect-inner-glow"
"<Image>/Filters/Layer Effect")

0 件のコメント:

コメントを投稿