宽度和高度将更改图层,但不会更改图像,GIMP计划

问题描述 投票:0回答:1

我最近开始学习GIMP方案,并编写了“创建心脏”脚本。我想学习如何创建SF调整以使心脏尺寸不同?我创建了调整高度和宽度。当我运行脚本时,可以在对话框上更改“宽度和高度”,并更改图层的大小,但心脏的图像却没有。我在做什么错?

(define (script-fu-create-heart imgWidth imgHeight foreground-color heart-color)
    (let* (



        (img  (car (gimp-image-new imgWidth imgHeight RGB)))
        (layer (car (gimp-layer-new img imgWidth imgHeight RGB-IMAGE "Background" 100 LAYER-MODE-NORMAL)))
        (theheart (car (gimp-layer-new img imgWidth imgHeight RGB "Heart" 100 LAYER-MODE-NORMAL)))
        (heartcopy 0)
        (heart 0)
        (theshadow (car (gimp-layer-new img imgWidth imgHeight RGB "Inner shadow" 100 LAYER-MODE-NORMAL)))
        (thereflection (car (gimp-layer-new img imgWidth imgHeight RGB "Reflection" 100 LAYER-MODE-NORMAL)))

        )

        (gimp-context-push)
        (gimp-image-undo-group-start img)


        ;Create the Background
        (gimp-image-insert-layer img layer 0 0)
        (gimp-context-set-foreground foreground-color)
        (gimp-drawable-fill layer FILL-FOREGROUND)

        ;Create the heart layer
        (gimp-image-add-layer img theheart -1)
        (gimp-layer-add-alpha theheart)
        (gimp-drawable-fill theheart FILL-TRANSPARENT)

        ;Create the the first half of the heart
        (gimp-image-select-ellipse img  2 60 105 385 285)
        (gimp-image-select-rectangle img  1  0  0  500  250)
        (gimp-image-select-ellipse img  0 60 125 385  250)
        (gimp-context-set-foreground heart-color)
        (gimp-drawable-edit-fill theheart FILL-FOREGROUND)
        (gimp-selection-none img)
        (gimp-drawable-transform-rotate theheart 44.75 TRUE 250 250 0 2 TRUE 1 0)
        (gimp-layer-resize-to-image-size theheart)
        (gimp-image-select-rectangle img  2  250  0  250  500)
        (gimp-edit-cut theheart)
        (gimp-selection-none img)

        ;Create the second half of the heart
        (set! heartcopy (car (gimp-layer-copy theheart TRUE)))
        (gimp-image-add-layer img heartcopy -1)
        (gimp-item-transform-flip-simple heartcopy 0 1 0)
        (gimp-image-merge-down img heartcopy 1)

        ;Create a selection
        (set! heartcopy (car (gimp-image-get-active-drawable img)))
        (gimp-image-select-color img CHANNEL-OP-REPLACE  heartcopy heart-color)


        ;Create inner shadow layer
        (gimp-image-add-layer img theshadow -1)
        (gimp-layer-add-alpha theshadow)
        (gimp-drawable-fill theshadow FILL-TRANSPARENT)

        ;Shrink the selection and set the foreground color
        (gimp-selection-shrink img 8)
        (gimp-context-set-foreground '(0 0 0))

        ;Set the brush and the size apply 
        (gimp-context-set-brush "2. Hardness 100")
        (gimp-context-get-brush)
        (gimp-context-set-brush-size 8)

        ;Stroke selection and apply gaussian blur
        (gimp-edit-stroke theshadow)
        (gimp-selection-none img)
        (plug-in-gauss RUN-NONINTERACTIVE  img theshadow 48 48 1)

        ;Create the light reflection on the heart

        ;Create light reflection layer
        (gimp-image-add-layer img thereflection 0)
        (gimp-layer-add-alpha thereflection)
        (gimp-drawable-fill thereflection FILL-TRANSPARENT)

        ;Draw the dot on the left side and apply gaussian blur 
        (gimp-image-select-ellipse img  2 150 150 25 25)
        (gimp-edit-fill thereflection 2)
        (gimp-selection-none img)

        ;Merge the top two layer
        (plug-in-gauss RUN-NONINTERACTIVE img thereflection 18 18 1)
        (gimp-image-merge-down img thereflection 1)
        (set! theshadow (car (gimp-image-get-active-drawable img)))
        (gimp-image-merge-down img theshadow 1) 
        (gimp-image-undo-group-end img)
        (gimp-context-pop)
        (gimp-display-new img)
        (gimp-displays-flush)










    )
)




(script-fu-register
    "script-fu-create-heart"                        
    "Create a heart"
    "Creates a heart shape image"    
    "Pocholo"                            
    "Pocholo"
    "April 2020"                          
    ""



    SF-ADJUSTMENT "Width" '(500 50 1000 1 10 0 1)
    SF-ADJUSTMENT "Height" '(500 50 1000 1 10 0 1)
    SF-COLOR      "Foreground color"   "Black"
    SF-COLOR      "Heart color"   "Red"

)
(script-fu-menu-register "script-fu-create-heart" "<Image>/File/Create") 
scheme gimp
1个回答
0
投票

[脚本中的大多数显式数字应替换为imgWidthimgHeight或其中的某些计算(例如(/ imgWidth 2)(/ imgHeight 2)而不是250)。

© www.soinside.com 2019 - 2024. All rights reserved.