1998-11-26 05:18:26 +08:00
|
|
|
;;; line-nova.scm for gimp-1.1 -*-scheme-*-
|
|
|
|
;;; Time-stamp: <1998/11/25 13:26:44 narazaki@gimp.org>
|
|
|
|
;;; Author Shuji Narazaki <narazaki@gimp.org>
|
|
|
|
;;; Version 0.7
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
(define (script-fu-line-nova img drw num-of-lines corn-deg offset variation)
|
|
|
|
(let* ((*points* (cons-array (* 3 2) 'double))
|
1998-04-09 07:15:24 +08:00
|
|
|
(modulo fmod) ; in R4RS way
|
1997-11-25 06:05:25 +08:00
|
|
|
(pi/2 (/ *pi* 2))
|
|
|
|
(pi/4 (/ *pi* 4))
|
|
|
|
(pi3/4 (* 3 pi/4))
|
|
|
|
(pi5/4 (* 5 pi/4))
|
|
|
|
(pi3/2 (* 3 pi/2))
|
|
|
|
(pi7/4 (* 7 pi/4))
|
|
|
|
(2pi (* 2 *pi*))
|
|
|
|
(rad/deg (/ 2pi 360))
|
|
|
|
(variation/2 (/ variation 2))
|
1998-04-09 07:15:24 +08:00
|
|
|
(drw-width (car (gimp-drawable-width drw)))
|
|
|
|
(drw-height (car (gimp-drawable-height drw)))
|
|
|
|
(drw-offsets (gimp-drawable-offsets drw))
|
1998-11-26 05:18:26 +08:00
|
|
|
(old-selection (if (eq? (car (gimp-selection-is-empty img)) TRUE)
|
|
|
|
#f
|
|
|
|
(car (gimp-selection-save img))))
|
1998-04-09 07:15:24 +08:00
|
|
|
(radius (max drw-height drw-width))
|
|
|
|
(index 0)
|
|
|
|
(dir-deg/line (/ 360 num-of-lines)))
|
1997-11-25 06:05:25 +08:00
|
|
|
(define (draw-vector beg-x beg-y direction)
|
|
|
|
(define (set-point! index x y)
|
|
|
|
(aset *points* (* 2 index) x)
|
|
|
|
(aset *points* (+ (* 2 index) 1) y))
|
|
|
|
(define (deg->rad rad)
|
|
|
|
(* (modulo rad 360) rad/deg))
|
|
|
|
(define (set-marginal-point beg-x beg-y direction)
|
|
|
|
(let ((dir1 (deg->rad (+ direction corn-deg)))
|
|
|
|
(dir2 (deg->rad (- direction corn-deg))))
|
|
|
|
(define (aux dir index)
|
1998-11-15 04:46:25 +08:00
|
|
|
(set-point! index
|
1997-11-25 06:05:25 +08:00
|
|
|
(+ beg-x (* (cos dir) radius))
|
|
|
|
(+ beg-y (* (sin dir) radius))))
|
|
|
|
(aux dir1 1)
|
|
|
|
(aux dir2 2)))
|
|
|
|
(let ((dir0 (deg->rad direction))
|
1998-11-26 05:18:26 +08:00
|
|
|
(off (+ offset (- (modulo (rand) variation) variation/2))))
|
1998-11-15 04:46:25 +08:00
|
|
|
(set-point! 0
|
1998-11-26 05:18:26 +08:00
|
|
|
(+ beg-x (* off (cos dir0)))
|
|
|
|
(+ beg-y (* off (sin dir0))))
|
1997-11-25 06:05:25 +08:00
|
|
|
(set-marginal-point beg-x beg-y direction)
|
2004-02-03 19:46:27 +08:00
|
|
|
(gimp-free-select img 6 *points* CHANNEL-OP-ADD
|
1997-11-25 06:05:25 +08:00
|
|
|
TRUE ; antialias
|
|
|
|
FALSE ; feather
|
1998-11-26 05:18:26 +08:00
|
|
|
0 ; feather radius
|
1998-04-09 07:15:24 +08:00
|
|
|
)))
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-12-05 22:18:47 +08:00
|
|
|
(gimp-image-undo-group-start img)
|
1997-11-25 06:05:25 +08:00
|
|
|
(gimp-selection-none img)
|
|
|
|
(srand (realtime))
|
|
|
|
(while (< index num-of-lines)
|
1998-04-09 07:15:24 +08:00
|
|
|
(draw-vector (+ (nth 0 drw-offsets) (/ drw-width 2))
|
|
|
|
(+ (nth 1 drw-offsets) (/ drw-height 2))
|
1997-11-25 06:05:25 +08:00
|
|
|
(* index dir-deg/line))
|
|
|
|
(set! index (+ index 1)))
|
2004-01-07 21:25:00 +08:00
|
|
|
(gimp-edit-bucket-fill drw FG-BUCKET-FILL NORMAL-MODE 100 0 FALSE 0 0)
|
1998-11-26 05:18:26 +08:00
|
|
|
(if old-selection
|
|
|
|
(begin
|
|
|
|
(gimp-selection-load old-selection)
|
|
|
|
;; (gimp-image-set-active-layer img drw)
|
|
|
|
;; delete extra channel by Sven Neumann <neumanns@uni-duesseldorf.de>
|
|
|
|
(gimp-image-remove-channel img old-selection)))
|
2003-12-05 22:18:47 +08:00
|
|
|
(gimp-image-undo-group-end img)
|
1998-04-09 07:15:24 +08:00
|
|
|
(gimp-displays-flush)))
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-04-09 07:15:24 +08:00
|
|
|
(script-fu-register
|
|
|
|
"script-fu-line-nova"
|
2003-08-12 01:14:32 +08:00
|
|
|
_"<Image>/Script-Fu/Render/Line _Nova..."
|
1998-04-09 07:15:24 +08:00
|
|
|
"Line Nova. Draw lines with Foreground color from the center of image to the edges. 1st undo cancels bucket-fill. 2nd undo gets orignal selection."
|
1998-11-26 05:18:26 +08:00
|
|
|
"Shuji Narazaki <narazaki@gimp.org>"
|
1998-04-09 07:15:24 +08:00
|
|
|
"Shuji Narazaki"
|
1998-11-26 05:18:26 +08:00
|
|
|
"1997,1998"
|
|
|
|
""
|
2000-04-02 19:39:28 +08:00
|
|
|
SF-IMAGE "Image" 0
|
|
|
|
SF-DRAWABLE "Drawable" 0
|
2000-03-29 05:06:39 +08:00
|
|
|
SF-ADJUSTMENT _"Number of Lines" '(200 40 1000 1 1 0 1)
|
|
|
|
SF-ADJUSTMENT _"Sharpness (degrees)" '(1.0 0.0 10.0 0.1 1 1 1)
|
2000-04-02 19:39:28 +08:00
|
|
|
SF-ADJUSTMENT _"Offset Radius" '(100 0 2000 1 1 0 1)
|
2000-03-29 05:06:39 +08:00
|
|
|
SF-ADJUSTMENT _"Randomness" '(30 0 2000 1 1 0 1)
|
1998-04-09 07:15:24 +08:00
|
|
|
)
|
1997-11-25 06:05:25 +08:00
|
|
|
;;; line-nova.scm ends here
|