我昨天刚开始为我需要的脚本编写 GIMP script-fu 脚本,但我不知道如何自动在局部变量中添加图层并调用将图层添加到图像的函数。我尝试遍历列表但优雅地失败了。有人可以将我推向正确的方向吗?
(define (script-fu-gifslot inText inFont inFontSize inTextColor)
(let*
((theImageWidth 700) ; define our local variables
(theImageHeight 100) ; create a new image:
(theImage)
(layerX)
(inOffset)
(theImage (car (gimp-image-new theImageWidth theImageHeight RGB)))
(theText) ;a declaration for the text
(theLayer (car (gimp-layer-new theImage theImageWidth theImageHeight RGB-IMAGE "layer 1" 100 NORMAL)))
(theLayer2 (car (gimp-layer-new theImage theImageWidth theImageHeight RGB-IMAGE "layer 2" 100 NORMAL)))
(theLayer3 (car (gimp-layer-new theImage theImageWidth theImageHeight RGB-IMAGE "layer 3" 100 NORMAL)))
(theLayer4 (car (gimp-layer-new theImage theImageWidth theImageHeight RGB-IMAGE "layer 4" 100 NORMAL))))
(define (yannis-add-new-layer layerX inOffset)
(gimp-image-add-layer theImage layerX 0)
(gimp-context-set-background '(255 255 255))
(gimp-context-set-foreground inTextColor)
(gimp-drawable-fill layerX BACKGROUND-FILL)
(set! theText (car (gimp-text-fontname theImage layerX 0 0 inText 0 TRUE inFontSize PIXELS "Sans")))
(set! theImageHeight (car (gimp-drawable-height theText)))
(gimp-layer-resize layerX theImageWidth theImageHeight 0 0)
(gimp-layer-set-offsets theText 0 (- 0 inOffset)))
(yannis-add-new-layer theLayer 0)
(yannis-add-new-layer theLayer2 10)
(yannis-add-new-layer theLayer3 20)
(yannis-add-new-layer theLayer4 30)
(gimp-display-new theImage)
(list theImage layerX theText)))
(script-fu-register
"script-fu-gifslot"
"_GGGIF WORD Slotmachine..."
"Creates an image with a user specified text string."
"Yannis De Cleene <yannisdcl@gmail.com>"
"Yannis De Cleene"
"July, 2014"
""
SF-TEXT "Text" "PASTE\nMULTILINE TEXT\nIN HERE"
SF-FONT "Font" "Sans"
SF-ADJUSTMENT "Font size (pixels)" '(100 2 1000 1 10 0 1)
SF-COLOR "Color" '(0 0 0))
(script-fu-menu-register "script-fu-gifslot" "<Image>/File/Create")