~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to plug-ins/script-fu/scripts/grid-system.scm

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
;;; Version 0.6
7
7
 
8
8
;;; Code:
9
 
(if (not (symbol-bound? 'script-fu-grid-system-x-divides (the-environment)))
 
9
(if (not (symbol-bound? 'script-fu-grid-system-x-divides (current-environment)))
10
10
    (define script-fu-grid-system-x-divides "'(1 g 1)"))
11
 
(if (not (symbol-bound? 'script-fu-grid-system-y-divides (the-environment)))
 
11
(if (not (symbol-bound? 'script-fu-grid-system-y-divides (current-environment)))
12
12
    (define script-fu-grid-system-y-divides "'(1 g 1)"))
13
13
 
14
14
(define (script-fu-grid-system img drw x-divides-orig y-divides-orig)
24
24
              (map proc (cdr seq)))))
25
25
  (define (convert-g l)
26
26
    (cond ((null? l) '())
27
 
          ((eq? (car l) 'g) (cons 1.618 (convert-g (cdr l))))
28
 
          ((eq? (car l) '1/g) (cons 0.618 (convert-g (cdr l))))
29
 
          ('else (cons (car l) (convert-g (cdr l))))))
 
27
    ((eq? (car l) 'g) (cons 1.618 (convert-g (cdr l))))
 
28
    ((eq? (car l) '1/g) (cons 0.618 (convert-g (cdr l))))
 
29
    ('else (cons (car l) (convert-g (cdr l))))))
30
30
  (define (wrap-list l)
31
31
    (define (wrap-object obj)
32
32
      (cond ((number? obj) (string-append (number->string obj) " "))
33
 
            ((eq? obj 'g) "g ")
34
 
            (eq? obj '1/g) "1/g "))
35
 
    (string-append "'("
36
 
                   (apply string-append (map wrap-object l))
37
 
                   ")"))
 
33
      ((eq? obj 'g) "g ")
 
34
      (eq? obj '1/g) "1/g "))
 
35
    (string-append "'(" (apply string-append (map wrap-object l)) ")"))
38
36
  (let* ((drw-width (car (gimp-drawable-width drw)))
39
 
         (drw-height (car (gimp-drawable-height drw)))
40
 
         (drw-offset-x (nth 0 (gimp-drawable-offsets drw)))
41
 
         (drw-offset-y (nth 1 (gimp-drawable-offsets drw)))
42
 
         (grid-layer #f)
43
 
         (segment (cons-array 4 'double))
44
 
         (stepped-x 0)
45
 
         (stepped-y 0)
46
 
         (temp 0)
47
 
         (total-step-x 0)
48
 
         (total-step-y 0))
49
 
    (set! x-divides (convert-g x-divides-orig))
50
 
    (set! y-divides (convert-g y-divides-orig))
51
 
    (set! total-step-x (apply + x-divides))
52
 
    (set! total-step-y (apply + y-divides))
 
37
   (drw-height (car (gimp-drawable-height drw)))
 
38
   (drw-offset-x (nth 0 (gimp-drawable-offsets drw)))
 
39
   (drw-offset-y (nth 1 (gimp-drawable-offsets drw)))
 
40
   (grid-layer #f)
 
41
   (segment (cons-array 4 'double))
 
42
   (stepped-x 0)
 
43
   (stepped-y 0)
 
44
   (temp 0)
 
45
   (total-step-x 0)
 
46
   (total-step-y 0)
 
47
   (x-divides (convert-g x-divides-orig))
 
48
   (y-divides (convert-g y-divides-orig))
 
49
   (total-step-x (apply + x-divides))
 
50
   (total-step-y (apply + y-divides)))
53
51
 
54
52
    (gimp-image-undo-group-start img)
55
53
 
63
61
      (set! temp (* drw-width (/ stepped-x total-step-x)))
64
62
      (set! x-divides (cdr x-divides))
65
63
      (update-segment! segment
66
 
                       (+ drw-offset-x temp) drw-offset-y
67
 
                       (+ drw-offset-x temp) (+ drw-offset-y drw-height))
 
64
           (+ drw-offset-x temp) drw-offset-y
 
65
           (+ drw-offset-x temp) (+ drw-offset-y drw-height))
68
66
      (gimp-pencil grid-layer 4 segment))
69
67
 
70
68
    (while (not (null? (cdr y-divides)))
72
70
      (set! temp (* drw-height (/ stepped-y total-step-y)))
73
71
      (set! y-divides (cdr y-divides))
74
72
      (update-segment! segment
75
 
                       drw-offset-x (+ drw-offset-y temp)
76
 
                       (+ drw-offset-x drw-width) (+ drw-offset-y temp))
 
73
           drw-offset-x (+ drw-offset-y temp)
 
74
           (+ drw-offset-x drw-width) (+ drw-offset-y temp))
77
75
      (gimp-pencil grid-layer 4 segment))
78
76
 
79
77
    (gimp-image-undo-group-end img)
83
81
    (gimp-displays-flush)))
84
82
 
85
83
(script-fu-register "script-fu-grid-system"
86
 
                    _"_Grid..."
87
 
                    "Draw grid as specified by X-DIVIDES (list of propotions relative to the drawable) and Y-DIVIDES. The color and width of grid is detemined by the current settings of brush."
88
 
                    "Shuji Narazaki <narazaki@InetQ.or.jp>"
89
 
                    "Shuji Narazaki"
90
 
                    "1997"
91
 
                    "RGB*, INDEXED*, GRAY*"
92
 
                    SF-IMAGE     "Image to use"          0
93
 
                    SF-DRAWABLE  "Drawable to draw grid" 0
94
 
                    SF-VALUE    _"X divisions" script-fu-grid-system-x-divides
95
 
                    SF-VALUE    _"Y divisions" script-fu-grid-system-y-divides)
 
84
  _"_Grid..."
 
85
  _"Draw a grid as specified by the lists of X and Y locations using the current brush"
 
86
  "Shuji Narazaki <narazaki@InetQ.or.jp>"
 
87
  "Shuji Narazaki"
 
88
  "1997"
 
89
  "RGB*, INDEXED*, GRAY*"
 
90
  SF-IMAGE     "Image to use"          0
 
91
  SF-DRAWABLE  "Drawable to draw grid" 0
 
92
  SF-VALUE    _"X divisions"           script-fu-grid-system-x-divides
 
93
  SF-VALUE    _"Y divisions"           script-fu-grid-system-y-divides
 
94
)
96
95
 
97
 
(script-fu-menu-register "script-fu-grid-system"
98
 
                         _"<Image>/Script-Fu/Render")