;; generate sliders for reaktor (define (copy-drawable dest src fromx fromy tox toy) ; (gimp-message (string-append "copy-drawable " ; (number->string fromx) ; " " (number->string fromy) ; " " (number->string tox) ; " " (number->string toy))) (let ((orig-img (car (gimp-drawable-get-image src))) (height (car (gimp-drawable-height src)))) (if (and (> toy fromy) (> tox fromx)) (begin (gimp-selection-all orig-img) (gimp-rect-select orig-img fromx fromy (+ 1 (- tox fromx)) (+ 1 (- toy fromy)) ; (+ 1 (- tox fromx)) height CHANNEL-OP-INTERSECT FALSE FALSE)) (gimp-selection-none orig-img)) (gimp-edit-copy src) (car (gimp-edit-paste dest 0)))) (define (make-slider-step-v layer pos bar bar-active y-start y-end x-offset step steps) (let* ((pos-width (car (gimp-drawable-width pos))) (pos-height (car (gimp-drawable-height pos))) (bar-width (car (gimp-drawable-width bar))) (bar-height (car (gimp-drawable-height bar))) (slide-height (- (- bar-height y-end pos-height) y-start)) (inc (/ slide-height (- steps 1))) (height (max bar-height pos-height)) (width (max bar-width pos-width)) (mid-point (+ y-start (* inc step) (/ pos-height 2))) (ycoord (lambda (y) (- height y)))) (let ((new-bar (copy-drawable layer bar-active 0 (ycoord mid-point) bar-width (ycoord 0)))) (gimp-layer-set-offsets new-bar (* width step) (ycoord mid-point))) (let ((new-bar (copy-drawable layer bar 0 (ycoord bar-height) bar-width (ycoord mid-point)))) (gimp-layer-set-offsets new-bar (* width step) (ycoord bar-height))) (let ((new-pos (copy-drawable layer pos 0 0 pos-width pos-height))) (gimp-layer-set-offsets new-pos (+ x-offset (* width step)) (ycoord (+ y-start pos-height (* inc step))))))) (define (make-slider-step-h layer pos bar bar-active x-start x-end y-offset step steps) (let* ((pos-width (car (gimp-drawable-width pos))) (pos-height (car (gimp-drawable-height pos))) (bar-width (car (gimp-drawable-width bar))) (bar-height (car (gimp-drawable-height bar))) (slide-width (- (- bar-width x-end pos-width) x-start)) (inc (/ slide-width (- steps 1))) (height (max bar-height pos-height)) (mid-point (+ x-start (* inc step) (/ pos-width 2)))) (let ((new-bar (copy-drawable layer bar-active 0 0 mid-point bar-height))) (gimp-layer-set-offsets new-bar 0 (* height step))) (let ((new-bar (copy-drawable layer bar mid-point 0 bar-width bar-height))) (gimp-layer-set-offsets new-bar mid-point (* height step))) (let ((new-pos (copy-drawable layer pos 0 0 pos-width pos-height))) (gimp-layer-set-offsets new-pos (+ x-start (* inc step)) (+ y-offset (* height step)))))) (define (script-fu-reaktor-slider position bar-active bar vertical start end offset steps) (let* ((pos-width (car (gimp-drawable-width position))) (pos-height (car (gimp-drawable-height position))) (bar-width (car (gimp-drawable-width bar))) (bar-height (car (gimp-drawable-height bar))) (height (max bar-height pos-height)) (width (max bar-width pos-width)) (img (if (= vertical 1) (car (gimp-image-new (* width steps) height RGB)) (car (gimp-image-new width (* height steps) RGB)))) (animation-layer (if (= vertical 1) (car (gimp-layer-new img (* width steps) height RGBA-IMAGE "Animation Layer" 100 NORMAL-MODE)) (car (gimp-layer-new img width (* height steps) RGBA-IMAGE "Animation Layer" 100 NORMAL-MODE))))) (gimp-context-push) (gimp-image-undo-disable img) (gimp-image-add-layer img animation-layer 0) (let ((i 0)) (while (< i steps) (if (= vertical 1) (make-slider-step-v animation-layer position bar bar-active start end offset i steps) (make-slider-step-h animation-layer position bar bar-active start end offset i steps)) (set! i (+ i 1)))) (gimp-selection-none img) (gimp-image-undo-enable img) ; (gimp-image-flatten img) (gimp-display-new img) (gimp-context-pop))) (script-fu-register "script-fu-reaktor-slider" "/Xtns/Script-Fu/My Stuff/Reaktor Slider..." "Create a slider animation for reaktor" "das wesen" "das wesen" "Nov 2005" "" SF-DRAWABLE "Position Indicator" 0 SF-DRAWABLE "Sliderbar (active)" 0 SF-DRAWABLE "Sliderbar (inactive)" 0 SF-TOGGLE "Vertical" FALSE SF-VALUE "Start offset" "0" SF-VALUE "End offset" "0" SF-VALUE "Position offset" "0" SF-VALUE "Steps" "32")