René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback
 

Script-fu example 03: Drawing a line

Creates a 250x250 picture and draws a line into it.
ex_03.scm
(define (ex_03)

  (let* (
          (my_image (car (gimp-image-new 250 250 RGB      )))

          (my_layer (car (gimp-layer-new my_image 250 250 RGB-IMAGE "my layer" 0 NORMAL)))

          (line_points (cons-array 4 'double)) ; line_points: Array of 4 doubles
        )

        (aset line_points 0  10) ; x1
        (aset line_points 1  10) ; y1
        (aset line_points 2 230) ; x2
        (aset line_points 3 230) ; y2

        (gimp-image-add-layer my_image my_layer 0)

        (gimp-context-set-background '(000 000 255))
        (gimp-context-set-foreground '(255 000 000))

        (gimp-drawable-fill my_layer BACKGROUND-FILL)

        (gimp-pencil my_layer 4 line_points)

        (gimp-file-save RUN-NONINTERACTIVE my_image my_layer "c:\\temp\\ex_03.jpg" "")
  )
)

c:\> start gimp-2.2.exe -d -i -b  "(ex_03)" "(gimp-quit 0)"
See also other examples