Thanks for responding Kevin & saulgoode, but oddly it doesn't seem to be working. I'm usually very tired when I make these posts, because I truly make the Google rounds looking for answers, checking scripts, etc. I try to make this my last resort. I'm going to post the full script and maybe that will help.
Basically, I'm trying to draw random lines but at the same time adjust the brush angle so that all the lines look thin, as if they were drawn on an exact horizontal line set at 0 degrees. I chose the 2. Block 03 brush because it is easy to see when the degrees are off. When the degrees change perfectly, it's a thin line. But when the degrees are off it's a thick line.
But, as I said before it crashes. The error I get is:
Error: ( : 1) Procedure execution of gimp-context-set-brush-angle failed on invalid input arguments: Procedure 'gimp-context-set-brush-angle' has been called with value '270.610000' for argument 'angle' (#1, type gdouble). This value is out of range.
The value is always different.
Additionally, It'll draw a few lines. They start off thin, then quickly become thick, then the script crashes with that error. The results are different every time I run it, I guess that's the random portion at work.
(define (script-fu-angle-test image drawable lines)
(let*
(
(image-width (car (gimp-image-width image)))
(image-height (car (gimp-image-height image)))
(size-x image-width)
(size-y image-height)
(vector-array (make-vector 4 'double))
(count 0)
(slope)
(angle)
(x1)
(x2)
(y1)
(y2)
)
;start undo
(gimp-image-undo-group-start image)
;Set drawable color, brush and brush size
(gimp-context-set-foreground '(0 0 0))
(gimp-context-set-brush "2. Block 03")
(gimp-context-set-brush-size 20)
;Starting drawing random lines
(while (< count lines)
(set! count (+ count 1))
;Setting xy coordinates
(vector-set! vector-array 0 (random size-x))
(vector-set! vector-array 1 (random size-y))
(vector-set! vector-array 2 (random size-x))
(vector-set! vector-array 3 (random size-y))
;Recalling xy coordinates for slope equation
(set! x1 (aref vector-array 0))
(set! y1 (aref vector-array 1))
(set! x2 (aref vector-array 2))
(set! y2 (aref vector-array 3))
;Calculating angle
(set! slope (/ (- y2 y1)(- x2 x1)))
(set! angle (/ (* slope 180) *pi*))
;Problem somewhat corrected here. Discussed in prior replies in this thread.
;Setting angle & creating drawable
(gimp-context-set-brush-angle angle)
(gimp-paintbrush-default drawable 4 vector-array)
(gimp-displays-flush)
)
;Finish Undo & Refresh
(gimp-image-undo-group-end image)
(gimp-displays-flush)
)
)
(script-fu-register "script-fu-angle-test"
"<Image>/Filters/Angle Test"
"Angle Test"
"PD"
"PD"
"2012"
""
SF-IMAGE "image" 0
SF-DRAWABLE "drawable" 0
SF-ADJUSTMENT "Number of random lines created" '(24 2 100 2 10 0 0)
)
Thank you for your help!