Advertisement
kylergs

SomeVGuides.scm

Jun 9th, 2015
690
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. ; Spaced V-Guides
  2. ; This function creates a series of v-guides in the image at the user specified
  3. ; spacing
  4. (define (script-fu-n-spaced-vguides image spacing origin n)
  5.  
  6. (let*
  7. (
  8. (x 0) ; will be computed v-guide position.
  9. (width (car (gimp-image-width image)))
  10. (center (/ width 2))
  11. (i 0)
  12. )
  13.  
  14. (gimp-context-push) ; Initiates the temporary state.
  15.  
  16. ; Calculate starting point
  17. (set! x origin)
  18.  
  19. ; Iterate and create h-guides until y > height
  20. (while (< i n)
  21. (gimp-image-add-vguide image x)
  22. (set! x (+ x spacing))
  23. (set! i (+ i 1))
  24. )
  25.  
  26. ; DEBUG
  27. ;(gimp-message
  28. ; (string-append "Origin: " (number->string origin) " \nSpacing: " (number->string spacing)
  29. ; "\nCenter: " (number->string center) "\nMod: " y
  30. ; )
  31. ;)
  32. ; DEBUG
  33.  
  34. ; Deactivates the temporary state and resets the previous user defaults.
  35. (gimp-context-pop)
  36. (gimp-displays-flush)
  37. ) ; close let*
  38. ) ; close define
  39.  
  40.  
  41. (define (calc-offset origin center width spacing)
  42. (cond
  43. ((<= origin 0) spacing) ; Left
  44. ((<= origin 1) (modulo center spacing)) ; Center
  45. ((<= origin 2) (modulo width spacing)) ; Right
  46. )
  47. )
  48.  
  49.  
  50. ; Finally register our script with script-fu.
  51. (script-fu-register
  52. "script-fu-n-spaced-vguides" ;func name
  53. "N Spaced V-Guides" ;menu label
  54. ;description
  55. "Create a series of vertical guides at even spacing"
  56. "Jeffrey Boulais" ;author
  57. "copyright 2009, Jeffrey Boulais" ;copyright notice
  58. "February 2008" ;date created
  59. "RGB* GRAY* INDEXED*" ;image type that the script works on
  60. SF-IMAGE "Image" 0
  61. SF-VALUE "Vertical Guide Spacing (px)" "100"
  62. SF-VALUE "Start from" "0"
  63. SF-VALUE "Number" "24"
  64. )
  65. (script-fu-menu-register "script-fu-n-spaced-vguides" "<Image>/Image/Guides")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement