Search code examples
schemegimpscript-fu

How set layer transparent fill on gimp image with script-fu / scheme


I'm trying to learn Scheme / Script-Fu for making some Gimp-Scripts. When I create a new layer on opened image, it adds a black background color, even though I call (gimp-drawable-fill layer TRANSPARENT-FILL) and add afterwards the new layer to the image.

The new layer shows up in Gimp, but it is always filled with black.

(define (script-fu-grid-lines-debug image brush foreground)
  (gimp-context-push)
  (let* (
        (point (cons-array 4 'double))
        (imageWidth (car (gimp-image-width image)))
        (imageHeight (car (gimp-image-height image)))        
        (layer (car (gimp-layer-new image imageWidth imageHeight RGB-IMAGE "Gridline Layer" 100 NORMAL) ))
        (dash-length spacing)
      )

    (gimp-drawable-fill layer TRANSPARENT-FILL)
    (gimp-image-add-layer image layer -1)

    (gimp-context-set-foreground  foreground)
    (gimp-context-set-brush (car brush))

    ; ... unnecessary code removed

    (gimp-context-pop)
    ;(gimp-displays-flush)
    (list image layer)
  )
)

Can anyone point out what the problem here is or how I have to set the transparent background for the layer? I couldn't find a site with anything related to transparent layers.

Thanks.


Solution

  • Create your layer with type RGBA_IMAGE (A=alpha, aka opacity channel)

    This said, you can write your Gimp scripts in Python, which is a lot easier to learn and master.