~ubuntu-branches/ubuntu/hoary/gimp/hoary

« back to all changes in this revision

Viewing changes to plug-ins/script-fu/scripts/guides-new-percent.scm

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2005-04-04 14:51:23 UTC
  • Revision ID: james.westby@ubuntu.com-20050404145123-9py049eeelfymur8
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
;; -*-scheme-*-
 
2
 
 
3
;; Alan Horkan 2004.  Copyright.  
 
4
;; I'll fix it and license it differntly later if anyone cares to ask
 
5
 
 
6
(define (script-fu-guide-new-percent image
 
7
                                     drawable
 
8
                                     direction
 
9
                                     position)
 
10
  (let* ((width (car (gimp-drawable-width drawable)))
 
11
         (height (car (gimp-drawable-height drawable))))
 
12
    (gimp-image-undo-group-start image)
 
13
 
 
14
    (if (= direction 0)
 
15
        (set! position (/ (* height position) 100))
 
16
        (set! position (/ (* width position) 100)))
 
17
 
 
18
    (if (= direction 0) 
 
19
        ;; convert position to pixel 
 
20
        (if (< position height) (gimp-image-add-hguide image position))
 
21
        (if (< position width) (gimp-image-add-vguide image position)))
 
22
 
 
23
    (gimp-image-undo-group-end image)
 
24
    (gimp-displays-flush)))
 
25
    
 
26
(script-fu-register "script-fu-guide-new-percent"
 
27
                    _"New Guide (by _Percent)..." 
 
28
                    "Add a single Line Guide with the specified postion. Position specified as a percent of the image size."
 
29
                    "Alan Horkan"
 
30
                    "Alan Horkan, 2004"
 
31
                    "April 2004"
 
32
                    ""
 
33
                    SF-IMAGE      "Input Image"      0 
 
34
                    SF-DRAWABLE   "Input Drawable"   0
 
35
                    SF-OPTION     _"Direction"       '(_"Horizontal" 
 
36
                                                       _"Vertical")
 
37
                    SF-ADJUSTMENT _"Position (in %)" '(50 0 100 1 10 0 1))
 
38
    
 
39
(script-fu-menu-register "script-fu-guide-new-percent"
 
40
                         "<Image>/Image/Guides")