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

Script-fu example 04: Drawing a thin line

Creates a 250x250 picture and draws a thin line into it. The thickness (or thinness) of the line is specified with gimp-brushes-set-brush.
ex_04.scm
(define (ex_04)

  (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 200 255))
        (gimp-context-set-foreground '(255 200 000))

        (gimp-drawable-fill my_layer BACKGROUND-FILL)
   
        (gimp-brushes-set-brush "Circle (01)")   
        (gimp-pencil my_layer 4 line_points)

        (gimp-file-save RUN-NONINTERACTIVE my_image my_layer "c:\\temp\\ex_04.jpg" "")
  )
)
c:\> start gimp-2.2.exe -d -i -b  "(ex_04)" "(gimp-quit 0)"
See also other examples