*plugins/script-fu/scripts/grid-system.scm

*plugins/script-fu/scripts/hsv-graph.scm
        *plugins/script-fu/scripts/image-structure.scm
        *plugins/script-fu/scripts/line-nova.scm
        *plugins/script-fu/scripts/text-circle.scm
        *plugins/script-fu/scripts/unsharp-mask.scm:
        *data/palettes/Named_colors:
                script and palette updates from Shuji Narazaki

	also remved the duplicate circle-logo.scm

-adrian
This commit is contained in:
Adrian Likins 1998-04-08 23:15:24 +00:00
parent 4564203361
commit 14c1116468
7 changed files with 371 additions and 281 deletions

View File

@ -28,7 +28,6 @@ scriptdata_DATA = \
chip-away.scm \
chrome-it.scm \
chrome-logo.scm \
circle-logo.scm \
circuit.scm \
clothify.scm \
color-cycling.scm \
@ -77,6 +76,7 @@ scriptdata_DATA = \
title-header.scm \
trochoid.scm \
truchet.scm \
unsharp-mask.scm \
waves-anim.scm \
weave.scm \
xach-effect.scm

View File

@ -1,120 +0,0 @@
;; circle-logo -- a script for The GIMP 1.0
;; Author: Shuji Narazaki (narazaki@InetQ.or.jp)
;; Time-stamp: <1997/06/09 22:16:20 narazaki@InetQ.or.jp>
;; Version 1.3
(define modulo fmod) ; in R4RS way
(define (script-fu-circle-logo text radius start-angle fill-angle
font font-size slant antialias)
(let* ((drawable-size (* 2.0 (+ radius (* 2 font-size))))
(img (car (gimp-image-new drawable-size drawable-size RGB)))
(BG-layer (car (gimp-layer-new img drawable-size drawable-size
RGBA_IMAGE "background" 100 NORMAL)))
(merged-layer #f)
(char-num (string-length text))
(radian-step 0)
(rad-90 (/ *pi* 2))
(center-x (/ drawable-size 2))
(center-y center-x)
(fixed-pole " ]Ag") ; some fonts have no "]" "g" has desc.
(font-infos (gimp-text-get-extents fixed-pole font-size PIXELS
"*" font "*" slant "*" "*"))
(extra (max 0 (- (nth 0 font-infos) 5))) ; why 5? See text_tool.c.
(desc (nth 3 font-infos))
(angle-list #f)
(letter "")
(new-layer #f)
(index 0))
(gimp-image-disable-undo img)
(gimp-image-add-layer img BG-layer 0)
(gimp-edit-fill img BG-layer)
;; change units
(set! start-angle (* (/ (modulo start-angle 360) 360) 2 *pi*))
(set! fill-angle (* (/ fill-angle 360) 2 *pi*))
(set! radian-step (/ fill-angle char-num))
;; make width-list
(let ((temp-list '())
(temp-str #f)
(scale 0)
(temp #f))
(set! index 0)
(while (< index char-num)
(set! temp-str (substring text index (+ index 1)))
(if (equal? " " temp-str)
(set! temp-str "]"))
(set! temp (gimp-text-get-extents temp-str font-size PIXELS
"*" font "*" slant "*" "*"))
(set! temp-list (cons (nth 0 temp) temp-list))
(set! index (+ index 1)))
(set! angle-list (nreverse temp-list))
(set! temp 0)
(set! angle-list
(mapcar (lambda (angle)
(let ((tmp temp))
(set! temp (+ angle temp))
(+ tmp (/ angle 2))))
angle-list))
(set! scale (/ fill-angle temp))
(set! angle-list (mapcar (lambda (angle) (* scale angle)) angle-list)))
(set! index 0)
(while (< index char-num)
(set! letter (substring text index (+ index 1)))
(if (not (equal? " " letter))
;; Running gimp-text with " " causes an error!
(let* ((new-layer (car (gimp-text img -1 0 0
(string-append letter fixed-pole)
1 antialias
font-size PIXELS
"*" font "*" slant "*" "*")))
(width (car (gimp-drawable-width new-layer)))
(height (car (gimp-drawable-height new-layer)))
(rotate-radius (- (/ height 2) desc))
(angle (+ start-angle (- (nth index angle-list) rad-90))))
;; delete fixed-pole
(gimp-layer-resize new-layer (- width extra 1) height 0 0)
(set! width (car (gimp-drawable-width new-layer)))
(gimp-layer-translate new-layer
(+ center-x
(* radius (cos angle))
(* rotate-radius
(cos (if (< 0 fill-angle)
angle
(+ angle *pi*))))
(- (/ width 2)))
(+ center-y
(* radius (sin angle))
(* rotate-radius
(sin (if (< 0 fill-angle)
angle
(+ angle *pi*))))
(- (/ height 2))))
(gimp-rotate img new-layer 1
((if (< 0 fill-angle) + -) angle rad-90))))
(set! index (+ index 1)))
(gimp-layer-set-visible BG-layer 0)
(set! merged-layer (car (gimp-image-merge-visible-layers img CLIP-TO-IMAGE)))
(gimp-layer-set-name merged-layer "text circle")
(gimp-layer-set-visible BG-layer 1)
(gimp-image-enable-undo img)
(gimp-display-new img)
(gimp-displays-flush)))
(script-fu-register "script-fu-circle-logo"
"<Toolbox>/Xtns/Script-Fu/Logos/Text Circle"
"Render the specified text along the perimeter of a circle"
"Shuji Narazaki (narazaki@InetQ.or.jp)"
"Shuji Narazaki"
"1997"
""
SF-VALUE "Text" "\"Ring World again! Tiger! Tiger! Tiger! \""
SF-VALUE "Radius" "80"
SF-VALUE "Start-angle" "0"
SF-VALUE "Fill-angle" "360"
SF-VALUE "Family" "\"helvetica\""
SF-VALUE "Font Size (pixel)" "18"
SF-VALUE "Slant" "\"r\""
SF-TOGGLE "Antialias" TRUE
)
;; circle-logo.scm ends here

View File

@ -1,28 +1,54 @@
;;; grid-system.scm -*-scheme-*-
;;; Time-stamp: <1997/07/03 23:30:19 narazaki@InetQ.or.jp>
;;; Time-stamp: <1998/01/20 23:22:02 narazaki@InetQ.or.jp>
;;; This file is a part of:
;;; The GIMP (Copyright (C) 1995 Spencer Kimball and Peter Mattis)
;;; The GIMP (Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis)
;;; Author: Shuji Narazaki (narazaki@InetQ.or.jp)
;;; Version 0.2
;;; Version 0.6
;;; Code:
(define (script-fu-grid-system img drw x-divides y-divides)
(if (not (symbol-bound? 'script-fu-grid-system-x-divides (the-environment)))
(define script-fu-grid-system-x-divides "'(1 g 1)"))
(if (not (symbol-bound? 'script-fu-grid-system-y-divides (the-environment)))
(define script-fu-grid-system-y-divides "'(1 g 1)"))
(define (script-fu-grid-system img drw x-divides-orig y-divides-orig)
(define (update-segment! s x0 y0 x1 y1)
(aset s 0 x0)
(aset s 1 y0)
(aset s 2 x1)
(aset s 3 y1))
(define (convert-g l)
(cond ((null? l) '())
((eq? (car l) 'g) (cons 1.618 (convert-g (cdr l))))
((eq? (car l) '1/g) (cons 0.618 (convert-g (cdr l))))
('else (cons (car l) (convert-g (cdr l))))))
(define (wrap-list l)
(define (wrap-object obj)
(cond ((number? obj) (string-append (number->string obj) " "))
((eq? obj 'g) "g ")
(eq? ojb '1/g) "1/g "))
(string-append "'("
(apply string-append (map wrap-object l))
")"))
(let* ((drw-width (car (gimp-drawable-width drw)))
(drw-height (car (gimp-drawable-height drw)))
(drw-offset-x (nth 0 (gimp-drawable-offsets drw)))
(drw-offset-y (nth 1 (gimp-drawable-offsets drw)))
(grid-layer #f)
(segment (cons-array 4 'double))
(stepped-x 0)
(stepped-y 0)
(temp 0)
(total-step-x (apply + x-divides))
(total-step-y (apply + y-divides)))
(gimp-image-disable-undo img)
(total-step-x 0)
(total-step-y 0))
(set! x-divides (convert-g x-divides-orig))
(set! y-divides (convert-g y-divides-orig))
(set! total-step-x (apply + x-divides))
(set! total-step-y (apply + y-divides))
;(gimp-undo-push-group-start img)
(set! grid-layer (car (gimp-layer-copy drw TRUE)))
(gimp-edit-clear img grid-layer)
(gimp-layer-set-name grid-layer "grid layer")
(while (not (null? (cdr x-divides)))
(set! stepped-x (+ stepped-x (car x-divides)))
(set! temp (* drw-width (/ stepped-x total-step-x)))
@ -30,7 +56,7 @@
(update-segment! segment
(+ drw-offset-x temp) drw-offset-y
(+ drw-offset-x temp) (+ drw-offset-y drw-height))
(gimp-pencil img drw 4 segment))
(gimp-pencil img grid-layer 4 segment))
(while (not (null? (cdr y-divides)))
(set! stepped-y (+ stepped-y (car y-divides)))
(set! temp (* drw-height (/ stepped-y total-step-y)))
@ -38,8 +64,11 @@
(update-segment! segment
drw-offset-x (+ drw-offset-y temp)
(+ drw-offset-x drw-width) (+ drw-offset-y temp))
(gimp-pencil img drw 4 segment))
(gimp-image-enable-undo img)
(gimp-pencil img grid-layer 4 segment))
(gimp-image-add-layer img grid-layer 0)
;(gimp-undo-push-group-end img)
(set! script-fu-grid-system-x-divides (wrap-list x-divides-orig))
(set! script-fu-grid-system-y-divides (wrap-list y-divides-orig))
(gimp-displays-flush)))
(script-fu-register "script-fu-grid-system"
@ -51,8 +80,8 @@
"RGB*, INDEXED*, GRAY*"
SF-IMAGE "Image to use" 0
SF-DRAWABLE "Drawable to draw grid" 0
SF-VALUE "Grids: X" "'(1 5 1 5 1)"
SF-VALUE "Grids: Y" "'(1 5 1 5 1)"
SF-VALUE "Grids: X" script-fu-grid-system-x-divides
SF-VALUE "Grids: Y" script-fu-grid-system-y-divides
)
;;; grid-system.scm ends here
;;; grid-system.scm ends here

View File

@ -1,16 +1,33 @@
;;; hsv-graph.scm -*-scheme-*-
;;; Author: Shuji Narazaki <narazaki@InetQ.or.jp>
;;; Time-stamp: <1997/07/31 21:10:53 narazaki@InetQ.or.jp>
;;; Version: 0.7
;;; Time-stamp: <1998/01/18 05:25:03 narazaki@InetQ.or.jp>
;;; Version: 1.2
;;; Code:
(if (not (symbol-bound? 'script-fu-hsv-graph-scale (the-environment)))
(define script-fu-hsv-graph-scale 1))
(if (not (symbol-bound? 'script-fu-hsv-graph-opacity (the-environment)))
(define script-fu-hsv-graph-opacity 100))
(if (not (symbol-bound? 'script-fu-hsv-graph-bounds? (the-environment)))
(define script-fu-hsv-graph-bounds? TRUE))
(if (not (symbol-bound? 'script-fu-hsv-graph-left2right? (the-environment)))
(define script-fu-hsv-graph-left2right? FALSE))
(if (not (symbol-bound? 'script-fu-hsv-graph-beg-x (the-environment)))
(define script-fu-hsv-graph-beg-x 0))
(if (not (symbol-bound? 'script-fu-hsv-graph-beg-y (the-environment)))
(define script-fu-hsv-graph-beg-y 0))
(if (not (symbol-bound? 'script-fu-hsv-graph-end-x (the-environment)))
(define script-fu-hsv-graph-end-x 1))
(if (not (symbol-bound? 'script-fu-hsv-graph-end-y (the-environment)))
(define script-fu-hsv-graph-end-y 1))
(define (script-fu-hsv-graph img drawable scale opacity bounds?
left2right? beg-x beg-y end-x end-y)
(define (floor x) (- x (fmod x 1)))
(define *pos* #f)
(define (set-point fvec index x y)
(aset! fvec (* 2 index) x)
(aset! fvec (+ (* 2 index) 1) y)
(define (set-point! fvec index x y)
(aset fvec (* 2 index) x)
(aset fvec (+ (* 2 index) 1) y)
fvec)
(define (plot-dot img drawable x y)
@ -172,20 +189,34 @@
(set! beg-y (nth 2 results))
(set! end-x (nth (if (= TRUE left2right?) 3 1) results))
(set! end-y (nth 4 results)))
(begin
(let ((offsets (gimp-drawable-offsets drawable)))
(set! beg-x (if (= TRUE left2right?)
0
(- (car (gimp-drawable-width drawable)) 1)))
(set! beg-y 0)
(nth 0 offsets)
(- (+ (nth 0 offsets)
(car (gimp-drawable-width drawable)))
1)))
(set! beg-y (nth 1 offsets))
(set! end-x (if (= TRUE left2right?)
(- (car (gimp-drawable-width drawable)) 1)
0))
(set! end-y (- (car (gimp-drawable-height drawable)) 1))))
(begin
(set! beg-x (clamp-value beg-x 0 (gimp-drawable-width drawable)))
(set! end-x (clamp-value end-x 0 (gimp-drawable-width drawable)))
(set! beg-y (clamp-value beg-y 0 (gimp-drawable-height drawable)))
(set! end-y (clamp-value beg-y 0 (gimp-drawable-heigth drawable)))))
(- (+ (nth 0 offsets)
(car (gimp-drawable-width drawable)))
1)
(nth 0 offsets)))
(set! end-y (- (+ (nth 1 offsets)
(car (gimp-drawable-height drawable)))
1))))
(let ((offsets (gimp-drawable-offsets drawable)))
(set! beg-x (clamp-value beg-x 0
(+ (nth 0 offsets)
(gimp-drawable-width drawable))))
(set! end-x (clamp-value end-x 0
(+ (nth 0 offsets)
(gimp-drawable-width drawable))))
(set! beg-y (clamp-value beg-y 0
(+ (nth 1 offsets)
(gimp-drawable-height drawable))))
(set! end-y (clamp-value beg-y 0
(+ (nth 1 offsets)
(gimp-drawable-height drawable))))))
(set! opacity (clamp-value opacity 0 100))
(let* ((x-len (- end-x beg-x))
(y-len (- end-y beg-y))
@ -197,7 +228,7 @@
(bglayer (car (gimp-layer-new gimg
(+ (* 2 border-size) gimg-width)
(+ (* 2 border-size) gimg-height)
RGB_IMAGE "Background" 100 NORMAL)))
1 "Background" 100 NORMAL)))
(hsv-layer (car (gimp-layer-new gimg
(+ (* 2 border-size) gimg-width)
(+ (* 2 border-size) gimg-height)
@ -280,6 +311,7 @@
(gimp-layer-translate clayer 0 offset-y)
(gimp-layer-translate text-layer border-size (+ offset-y 15)))
(gimp-image-set-active-layer gimg bglayer)
(gimp-image-clean-all gimg)
;; return back the state
(gimp-palette-set-foreground old-foreground)
(gimp-palette-set-foreground old-background)
@ -287,25 +319,34 @@
(gimp-brushes-set-paint-mode old-paint-mode)
(gimp-brushes-set-opacity old-opacity)
(gimp-image-enable-undo gimg)
(set! script-fu-hsv-graph-scale scale)
(set! script-fu-hsv-graph-opacity opacity)
(set! script-fu-hsv-graph-bounds? bounds?)
(set! script-fu-hsv-graph-left2right? left2right?)
(set! script-fu-hsv-graph-beg-x beg-x)
(set! script-fu-hsv-graph-beg-y beg-y)
(set! script-fu-hsv-graph-end-x end-x)
(set! script-fu-hsv-graph-end-y end-y)
(gimp-displays-flush)))
(script-fu-register "script-fu-hsv-graph"
"<Image>/Script-Fu/Utils/Draw HSV Graph"
"Draph the graph of H/S/V values on the drawable"
"Shuji Narazaki (narazaki@InetQ.or.jp)"
"Shuji Narazaki"
"1997"
"RGB*"
SF-IMAGE "Image to analyze" 0
SF-DRAWABLE "Drawable to analyze" 0
SF-VALUE "Graph Scale" "1"
SF-VALUE "BG Opacity" "50"
SF-TOGGLE "Use Selection Bounds instead of belows" TRUE
SF-TOGGLE "from Top-Left to Bottom-Right" TRUE
SF-VALUE "Start X" "0"
SF-VALUE "Start Y" "0"
SF-VALUE "End X" "100"
SF-VALUE "End Y" "100"
(script-fu-register
"script-fu-hsv-graph"
"<Image>/Script-Fu/Utils/Draw HSV Graph"
"Draph the graph of H/S/V values on the drawable"
"Shuji Narazaki <narazaki@InetQ.or.jp>"
"Shuji Narazaki"
"1997"
"RGB*"
SF-IMAGE "Image to analyze" 0
SF-DRAWABLE "Drawable to analyze" 0
SF-VALUE "Graph Scale" (number->string script-fu-hsv-graph-scale)
SF-VALUE "BG Opacity" (number->string script-fu-hsv-graph-opacity)
SF-TOGGLE "Use Selection Bounds instead of belows" script-fu-hsv-graph-bounds?
SF-TOGGLE "from Top-Left to Bottom-Right" script-fu-hsv-graph-left2right?
SF-VALUE "Start X" (number->string script-fu-hsv-graph-beg-x)
SF-VALUE "Start Y" (number->string script-fu-hsv-graph-beg-y)
SF-VALUE "End X" (number->string script-fu-hsv-graph-end-x)
SF-VALUE "End Y" (number->string script-fu-hsv-graph-end-y)
)
;;; hsv-graph.scm ends here

View File

@ -1,13 +1,51 @@
;;; image-structure.scm -*-scheme-*-
;;; Time-stamp: <1997/06/30 00:21:41 narazaki@InetQ.or.jp>
;;; Time-stamp: <1998/03/28 02:46:26 narazaki@InetQ.or.jp>
;;; Author: Shuji Narazaki <narazaki@InetQ.or.jp>
;;; Version 0.3
;;; Version 0.7
;;; Code:
(define (script-fu-show-image-structure img drawable space shear-length border
apply-layer-mask? with-layer-name?
with-pad? padding-color padding-opacity
with-background? background-color)
(if (not (symbol-bound? 'script-fu-show-image-structure-new-image?
(the-environment)))
(define script-fu-show-image-structure-new-image? TRUE))
(if (not (symbol-bound? 'script-fu-show-image-structure-space
(the-environment)))
(define script-fu-show-image-structure-space 50))
(if (not (symbol-bound? 'script-fu-show-image-structure-shear-length
(the-environment)))
(define script-fu-show-image-structure-shear-length 50))
(if (not (symbol-bound? 'script-fu-show-image-structure-border
(the-environment)))
(define script-fu-show-image-structure-border 10))
(if (not (symbol-bound? 'script-fu-show-image-structure-apply-layer-mask?
(the-environment)))
(define script-fu-show-image-structure-apply-layer-mask? TRUE))
(if (not (symbol-bound? 'script-fu-show-image-structure-with-layer-name?
(the-environment)))
(define script-fu-show-image-structure-with-layer-name? TRUE))
(if (not (symbol-bound? 'script-fu-show-image-structure-with-pad?
(the-environment)))
(define script-fu-show-image-structure-with-pad? TRUE))
(if (not (symbol-bound? 'script-fu-show-image-structure-padding-color
(the-environment)))
(define script-fu-show-image-structure-padding-color '(255 255 255)))
(if (not (symbol-bound? 'script-fu-show-image-structure-padding-opacity
(the-environment)))
(define script-fu-show-image-structure-padding-opacity 25))
(if (not (symbol-bound? 'script-fu-show-image-structure-with-background?
(the-environment)))
(define script-fu-show-image-structure-with-background? TRUE))
(if (not (symbol-bound? 'script-fu-show-image-structure-background-color
(the-environment)))
(define script-fu-show-image-structure-background-color '(0 0 0)))
(define (script-fu-show-image-structure img drawable new-image? space
shear-length border apply-layer-mask?
with-layer-name? with-pad? padding-color
padding-opacity with-background?
background-color)
(if (eq? new-image? TRUE)
(begin (set! img (car (gimp-channel-ops-duplicate img)))
(gimp-display-new img)))
(let* ((layers (gimp-image-get-layers img))
(num-of-layers (car layers))
(old-width (car (gimp-image-width img)))
@ -67,7 +105,7 @@
(set! layer-names (nreverse layer-names))
(while (< index num-of-layers)
(set! text-layer (car (gimp-text img -1 (/ border 2)
(+ (* space index) old-width)
(+ (* space index) old-height)
(car layer-names)
0 TRUE 14 PIXELS "*" "helvetica"
"*" "*" "*" "*")))
@ -77,27 +115,40 @@
(gimp-image-set-active-layer img new-bg)
(gimp-palette-set-background old-background)
(gimp-palette-set-foreground old-foreground)
(set! script-fu-show-image-structure-new-image? new-image?)
(set! script-fu-show-image-structure-space space)
(set! script-fu-show-image-structure-shear-length shear-length)
(set! script-fu-show-image-structure-border border)
(set! script-fu-show-image-structure-apply-layer-mask? apply-layer-mask?)
(set! script-fu-show-image-structure-with-layer-name? with-layer-name?)
(set! script-fu-show-image-structure-with-pad? with-pad?)
(set! script-fu-show-image-structure-padding-color padding-color)
(set! script-fu-show-image-structure-padding-opacity padding-opacity)
(set! script-fu-show-image-structure-with-background? with-background?)
(set! script-fu-show-image-structure-background-color background-color)
(gimp-displays-flush)))
(script-fu-register "script-fu-show-image-structure"
"<Image>/Script-Fu/Utils/Show Image Structure Destructively"
"Show the layer structure of the image DESTRACTIVELY(the original image was modified)"
"Shuji Narazaki (narazaki@InetQ.or.jp)"
"Shuji Narazaki"
"1997"
"RGB*, GRAY*"
SF-IMAGE "image" 0
SF-DRAWABLE "Drawable (unused)" 0
SF-VALUE "Space between layers" "50"
SF-VALUE "Shear length (> 0)" "50"
SF-VALUE "Outer Border (>= 0)" "10"
SF-TOGGLE "Apply layer mask (otherwise discard)" TRUE
SF-TOGGLE "Insert layer names" TRUE
SF-TOGGLE "Padding for transparent regions" TRUE
SF-COLOR "Pad Color" '(255 255 255)
SF-VALUE "Pad Opacity [0:100]" "25"
SF-TOGGLE "Make New Background" TRUE
SF-COLOR "Background Color" '(0 0 0)
(script-fu-register
"script-fu-show-image-structure"
"<Image>/Script-Fu/Utils/Show Image Structure"
"Show the layer structure of the image"
"Shuji Narazaki <narazaki@InetQ.or.jp>"
"Shuji Narazaki"
"1997"
"RGB*, GRAY*"
SF-IMAGE "image" 0
SF-DRAWABLE "Drawable (unused)" 0
SF-TOGGLE "Make new image" script-fu-show-image-structure-new-image?
SF-VALUE "Space between layers" (number->string script-fu-show-image-structure-space)
SF-VALUE "Shear length (> 0)" (number->string script-fu-show-image-structure-shear-length)
SF-VALUE "Outer Border (>= 0)" (number->string script-fu-show-image-structure-border)
SF-TOGGLE "Apply layer mask (or discard)" script-fu-show-image-structure-apply-layer-mask?
SF-TOGGLE "Insert layer names" script-fu-show-image-structure-with-layer-name?
SF-TOGGLE "Padding for transparent regions" script-fu-show-image-structure-with-pad?
SF-COLOR "Pad Color" script-fu-show-image-structure-padding-color
SF-VALUE "Pad Opacity [0:100]" (number->string script-fu-show-image-structure-padding-opacity)
SF-TOGGLE "Make New Background" script-fu-show-image-structure-with-background?
SF-COLOR "Background Color" script-fu-show-image-structure-background-color
)
;;; image-structure.scm ends here

View File

@ -1,10 +1,20 @@
;;; line-nova.scm -*-scheme-*-
;;;
;;; Time-stamp: <1997/09/11 00:19:32 narazaki@InetQ.or.jp>
;;; Version 0.1
;;; Time-stamp: <1998/01/17 21:15:38 narazaki@InetQ.or.jp>
;;; Author Shuji Narazaki <narazaki@inetq.or.jp>
;;; Version 0.6
(if (not (symbol-bound? 'script-fu-line-nova-num-of-lines (the-environment)))
(define script-fu-line-nova-num-of-lines 200))
(if (not (symbol-bound? 'script-fu-line-nova-corn-deg (the-environment)))
(define script-fu-line-nova-corn-deg 1.0))
(if (not (symbol-bound? 'script-fu-line-nova-offset (the-environment)))
(define script-fu-line-nova-offset 100))
(if (not (symbol-bound? 'script-fu-line-nova-variation (the-environment)))
(define script-fu-line-nova-variation 30))
(define (script-fu-line-nova img drw num-of-lines corn-deg offset variation)
(let* ((*points* (cons-array (* 3 2) 'double))
(modulo fmod) ; in R4RS way
(pi/2 (/ *pi* 2))
(pi/4 (/ *pi* 4))
(pi3/4 (* 3 pi/4))
@ -14,12 +24,13 @@
(2pi (* 2 *pi*))
(rad/deg (/ 2pi 360))
(variation/2 (/ variation 2))
(drw-width (car (gimp-drawable-width drw)))
(drw-height (car (gimp-drawable-height drw)))
(old-selection (car (gimp-selection-save img)))
(radius (max drw-height drw-width))
(index 0)
(dir-deg/line (/ 360 num-of-lines)))
(drw-width (car (gimp-drawable-width drw)))
(drw-height (car (gimp-drawable-height drw)))
(drw-offsets (gimp-drawable-offsets drw))
(old-selection (car (gimp-selection-save img)))
(radius (max drw-height drw-width))
(index 0)
(dir-deg/line (/ 360 num-of-lines)))
(define (draw-vector beg-x beg-y direction)
(define (set-point! index x y)
(aset *points* (* 2 index) x)
@ -45,36 +56,41 @@
TRUE ; antialias
FALSE ; feather
0 ; feather radius
)
))
)))
(gimp-image-disable-undo img)
(gimp-undo-push-group-start img)
(gimp-selection-none img)
(srand (realtime))
(while (< index num-of-lines)
(draw-vector (/ drw-width 2)
(/ drw-height 2)
(draw-vector (+ (nth 0 drw-offsets) (/ drw-width 2))
(+ (nth 1 drw-offsets) (/ drw-height 2))
(* index dir-deg/line))
(set! index (+ index 1)))
(gimp-bucket-fill img drw FG-BUCKET-FILL NORMAL 100 0 FALSE 0 0)
(gimp-selection-load img old-selection)
(gimp-image-set-active-layer img drw)
;; (gimp-channel-delete old-selection) core dumped!!
(gimp-displays-flush)
(gimp-image-enable-undo img)))
(script-fu-register "script-fu-line-nova"
"<Image>/Script-Fu/Render/Line Nova (destructively)"
"Line Nova. You can't undo the output."
"Shuji Narazaki <narazaki@InetQ.or.jp>"
"Shuji Narazaki"
"1997"
"RGB*, INDEXED*, GRAY*"
SF-IMAGE "Image to use" 0
SF-DRAWABLE "Drawable to draw line" 0
SF-VALUE "Number of lines" "200"
SF-VALUE "Sharpness (deg.)" "1"
SF-VALUE "Offset" "100"
SF-VALUE "- randomness" "30")
;; (gimp-image-set-active-layer img drw)
;; delete extra channel by Sven Neumann <neumanns@uni-duesseldorf.de>
(gimp-image-remove-channel img old-selection)
(gimp-undo-push-group-end img)
(set! script-fu-line-nova-num-of-lines num-of-lines)
(set! script-fu-line-nova-corn-deg corn-deg)
(set! script-fu-line-nova-offset offset)
(set! script-fu-line-nova-variation variation)
(gimp-displays-flush)))
(script-fu-register
"script-fu-line-nova"
"<Image>/Script-Fu/Render/Line Nova"
"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."
"Shuji Narazaki <narazaki@InetQ.or.jp>"
"Shuji Narazaki"
"1997"
"RGB*, INDEXED*, GRAY*"
SF-IMAGE "Image to use" 0
SF-DRAWABLE "Drawable to draw line" 0
SF-VALUE "Number of lines" (number->string script-fu-line-nova-num-of-lines)
SF-VALUE "Sharpness (deg.)" (number->string script-fu-line-nova-corn-deg)
SF-VALUE "Offset radius" (number->string script-fu-line-nova-offset)
SF-VALUE "- randomness" (number->string script-fu-line-nova-variation)
)
;;; line-nova.scm ends here

View File

@ -1,58 +1,99 @@
;; text-circle -- a scheme script for The GIMP
;; Shuji Narazaki (narazaki@InetQ.or.jp)
;; Time-stamp: <1997/05/16 23:44:21 narazaki@InetQ.or.jp>
;; Version 1.0
;; 1.0 official release with the following modifications:
;; 0.7 implement reverse fill mode (try minus fill-angle)
;; 0.6 handle proportional font correctly
;; 0.5 fix the bug in angle calculation
;; 0.4 add start/fill angle parameters
;; 0.3 included in 0.99.8
;; text-circle.scm -- a script for The GIMP 1.0
;; Author: Shuji Narazaki <narazaki@InetQ.or.jp>
;; Time-stamp: <1998/01/28 22:09:41 narazaki@InetQ.or.jp>
;; Version 2.3
;; Thanks:
;; jseymour@jimsun.LinxNet.com (Jim Seymour)
(define modulo fmod) ; in R4RS way
(if (not (symbol-bound? 'script-fu-text-circle-text (the-environment)))
(define script-fu-text-circle-text
"\"The GNU Image Manipulation Program Version 1.0 \""))
(if (not (symbol-bound? 'script-fu-text-circle-radius (the-environment)))
(define script-fu-text-circle-radius 80))
(if (not (symbol-bound? 'script-fu-text-circle-start-angle (the-environment)))
(define script-fu-text-circle-start-angle 0))
(if (not (symbol-bound? 'script-fu-text-circle-fill-angle (the-environment)))
(define script-fu-text-circle-fill-angle 360))
(if (not (symbol-bound? 'script-fu-text-circle-font-size (the-environment)))
(define script-fu-text-circle-font-size 18))
(if (not (symbol-bound? 'script-fu-text-circle-antialias (the-environment)))
(define script-fu-text-circle-antialias TRUE))
(if (not (symbol-bound? 'script-fu-text-circle-font-foundry (the-environment)))
(define script-fu-text-circle-font-foundry "\"*\""))
(if (not (symbol-bound? 'script-fu-text-circle-font-family (the-environment)))
(define script-fu-text-circle-font-family "\"helvetica\""))
(if (not (symbol-bound? 'script-fu-text-circle-font-weight (the-environment)))
(define script-fu-text-circle-font-weight "\"*\""))
(if (not (symbol-bound? 'script-fu-text-circle-font-slant (the-environment)))
(define script-fu-text-circle-font-slant "\"r\""))
(if (not (symbol-bound? 'script-fu-text-circle-font-width (the-environment)))
(define script-fu-text-circle-font-width "\"*\""))
(if (not (symbol-bound? 'script-fu-text-circle-font-spacing (the-environment)))
(define script-fu-text-circle-font-spacing "\"*\""))
(define (text-circle text radius start-angle fill-angle
font font-size slant antialias)
(let* ((width (* radius 2.5))
(height (* radius 2.5))
(img (car (gimp-image-new width height RGB)))
(drawable (car (gimp-layer-new img width height RGBA_IMAGE
"text-circle" 100 NORMAL)))
(define (script-fu-text-circle text radius start-angle fill-angle
font-size antialias
foundry family weight slant width spacing)
(define modulo fmod) ; in R4RS way
(define (wrap-string str) (string-append "\"" str "\""))
(define (white-space-string? str)
(or (equal? " " str) (equal? " " str)))
(let* ((drawable-size (* 2.0 (+ radius (* 2 font-size))))
(img (car (gimp-image-new drawable-size drawable-size RGB)))
(BG-layer (car (gimp-layer-new img drawable-size drawable-size
RGBA_IMAGE "background" 100 NORMAL)))
(merged-layer #f)
(char-num (string-length text))
(radian-step 0)
(rad-90 (/ *pi* 2))
(center-x (/ width 2))
(center-y (/ height 2))
(center-x (/ drawable-size 2))
(center-y center-x)
(fixed-pole " ]Ag") ; some fonts have no "]" "g" has desc.
(font-infos (gimp-text-get-extents fixed-pole font-size PIXELS
"*" font "*" slant "*" "*"))
(extra (max 0 (- (nth 0 font-infos) 5))) ; why 5? See text_tool.c.
"*" family "*" slant "*" "*"))
(desc (nth 3 font-infos))
(extra 0) ; extra is calculated from real layer
(angle-list #f)
(letter "")
(new-layer #f)
(index 0))
(gimp-image-disable-undo img)
;(gimp-display-new img)
(gimp-image-add-layer img drawable 0)
(gimp-edit-fill img drawable)
;; change unit
(set! start-angle (* (/ (modulo start-angle 360) 360) 2 *pi*))
(set! fill-angle (* (/ fill-angle 360) 2 *pi*))
(set! radian-step (/ fill-angle char-num))
(gimp-image-add-layer img BG-layer 0)
(gimp-edit-fill img BG-layer)
;; change units
(set! start-angle-rad (* (/ (modulo start-angle 360) 360) 2 *pi*))
(set! fill-angle-rad (* (/ fill-angle 360) 2 *pi*))
(set! radian-step (/ fill-angle-rad char-num))
;; set extra
(let ((temp-pole-layer (car (gimp-text img -1 0 0
fixed-pole
1 antialias
font-size PIXELS
"*" family "*" slant "*" "*"))))
(set! extra (car (gimp-drawable-width temp-pole-layer)))
(gimp-image-remove-layer img temp-pole-layer))
;; make width-list
;; In a situation,
;; (car (gimp-drawable-width (car (gimp-text ...)))
;; != (car (gimp-text-get_extent ...))
;; Thus, I changed to gimp-text from gimp-text-get-extent at 2.2 !!
(let ((temp-list '())
(temp-str #f)
(temp-layer #f)
(scale 0)
(temp #f))
(set! index 0)
(while (< index char-num)
(set! temp-str (substring text index (+ index 1)))
(if (equal? " " temp-str)
(if (white-space-string? temp-str)
(set! temp-str "]"))
(set! temp (gimp-text-get-extents temp-str font-size PIXELS
"*" font "*" slant "*" "*"))
(set! temp-list (cons (nth 0 temp) temp-list))
(set! temp-layer (car (gimp-text img -1 0 0
temp-str
1 antialias
font-size PIXELS
"*" family "*" slant "*" "*")))
(set! temp-list (cons (car (gimp-drawable-width temp-layer)) temp-list))
(gimp-image-remove-layer img temp-layer)
(set! index (+ index 1)))
(set! angle-list (nreverse temp-list))
(set! temp 0)
@ -62,57 +103,89 @@
(set! temp (+ angle temp))
(+ tmp (/ angle 2))))
angle-list))
(set! scale (/ fill-angle temp))
(set! scale (/ fill-angle-rad temp))
(set! angle-list (mapcar (lambda (angle) (* scale angle)) angle-list)))
(set! index 0)
(while (< index char-num)
(set! letter (substring text index (+ index 1)))
(if (not (equal? " " letter))
(if (not (white-space-string? letter))
;; Running gimp-text with " " causes an error!
(let* ((new-layer (car (gimp-text img -1 0 0
(string-append letter fixed-pole)
1 antialias
1 antialias
font-size PIXELS
"*" font "*" slant "*" "*")))
"*" family "*" slant "*" "*")))
(width (car (gimp-drawable-width new-layer)))
(height (car (gimp-drawable-height new-layer)))
(rotate-radius (- (/ height 2) desc))
(angle (+ start-angle (- (nth index angle-list) rad-90))))
(new-width (- width extra 1))
(angle (+ start-angle-rad (- (nth index angle-list) rad-90))))
;; delete fixed-pole
(gimp-layer-resize new-layer (- width extra 1) height 0 0)
(gimp-layer-resize new-layer new-width height 0 0)
(set! width (car (gimp-drawable-width new-layer)))
(gimp-layer-translate new-layer
(+ center-x
(* radius (cos angle))
(* rotate-radius
(cos (if (< 0 fill-angle)
(cos (if (< 0 fill-angle-rad)
angle
(+ angle *pi*))))
(- (/ width 2)))
(+ center-y
(* radius (sin angle))
(* rotate-radius
(sin (if (< 0 fill-angle)
(sin (if (< 0 fill-angle-rad)
angle
(+ angle *pi*))))
(- (/ height 2))))
(gimp-rotate img new-layer 1
((if (< 0 fill-angle) + -) angle rad-90))))
((if (< 0 fill-angle-rad) + -) angle rad-90))))
(set! index (+ index 1)))
(gimp-image-merge-visible-layers img CLIP-TO-IMAGE)
(gimp-layer-set-visible BG-layer 0)
(set! merged-layer
(car (gimp-image-merge-visible-layers img CLIP-TO-IMAGE)))
(gimp-layer-set-name merged-layer
(if (< (length text) 16)
(wrap-string text)
"Circle Logo"))
(gimp-layer-set-visible BG-layer 1)
(gimp-image-enable-undo img)
(gimp-display-new img)))
(gimp-image-clean-all img)
(gimp-display-new img)
(set! script-fu-text-circle-text (wrap-string text))
(set! script-fu-text-circle-radius radius)
(set! script-fu-text-circle-start-angle start-angle)
(set! script-fu-text-circle-fill-angle fill-angle)
(set! script-fu-text-circle-font-size font-size)
(set! script-fu-text-circle-antialias antialias)
(set! script-fu-text-circle-font-foundry (wrap-string foundry))
(set! script-fu-text-circle-font-family (wrap-string family))
(set! script-fu-text-circle-font-weight (wrap-string weight))
(set! script-fu-text-circle-font-slant (wrap-string slant))
(set! script-fu-text-circle-font-width (wrap-string width))
(set! script-fu-text-circle-font-spacing (wrap-string spacing))
(gimp-displays-flush)))
(script-fu-register "text-circle" "Text Circle"
SF-VALUE "Text" "\"Ring World again! Tiger! Tiger! Tiger! \""
SF-VALUE "Radius" "80"
SF-VALUE "Start-angle" "0"
SF-VALUE "Fill-angle" "360"
SF-VALUE "Family" "\"helvetica\""
SF-VALUE "Font Size (pixel)" "18"
SF-VALUE "Slant" "\"r\""
SF-VALUE "Antialias [0/1]" "1"
(script-fu-register
"script-fu-text-circle"
"<Toolbox>/Xtns/Script-Fu/Logos/Text Circle"
"Render the specified text along the perimeter of a circle"
"Shuji Narazaki <narazaki@InetQ.or.jp>"
"Shuji Narazaki"
"1997-1998"
""
SF-VALUE "Text" script-fu-text-circle-text
SF-VALUE "Radius" (number->string script-fu-text-circle-radius)
SF-VALUE "Start-angle[-180:180]" (number->string script-fu-text-circle-start-angle)
SF-VALUE "Fill-angle [-360:360]" (number->string script-fu-text-circle-fill-angle)
SF-VALUE "Font Size (pixel)" (number->string script-fu-text-circle-font-size)
SF-TOGGLE "Antialias" script-fu-text-circle-antialias
SF-VALUE "Font Foundry" script-fu-text-circle-font-foundry
SF-VALUE " - Family" script-fu-text-circle-font-family
SF-VALUE " - Weight" script-fu-text-circle-font-weight
SF-VALUE " - Slant" script-fu-text-circle-font-slant
SF-VALUE " - Width" script-fu-text-circle-font-width
SF-VALUE " - Spacing" script-fu-text-circle-font-spacing
)
;; text-circle.scm ends here