Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on May 22nd, 2012  |  syntax: None  |  size: 1.40 KB  |  views: 40  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. (define (create-sprite-sheet img drawable)
  2.         (let *
  3.                 (
  4.                         (anImage 0)
  5.                         (numlayers 0)
  6.                         (layers 0)
  7.                         (imgw 0)
  8.                         (imgh 0)
  9.                         (nimgw 0)
  10.                         (idx 0)
  11.                         (layr 0)
  12.                         (xoff 0)
  13.                 )
  14.  
  15.                 (set! anImage   (car (gimp-image-duplicate img)))
  16.                 (set! numlayers (car (gimp-image-get-layers anImage)))
  17.                 (set! layers    (cadr(gimp-image-get-layers anImage)))
  18.                 (set! imgw      (car (gimp-image-width anImage)))
  19.                 (set! imgh      (car (gimp-image-height anImage)))
  20.                 (set! nimgw                     (* 2 2))        ;I don't work!
  21.                 ;(set! nimgw            (+ 2 2))  ;but I work!
  22.                 ;(set! nimgw 4)                                         ;and I work too!
  23.                
  24.                 (while (< idx numlayers)
  25.                         (set! layr (aref layers (- (- numlayers 1) idx)))
  26.                         (gimp-layer-translate layr xoff 0)
  27.                         (set! xoff (+ imgw xoff))
  28.                         (set! idx (+ idx 1))
  29.                 )
  30.                
  31.                 (gimp-image-resize anImage 1000 1000 0 0)
  32.                 ;(gimp-image-resize anImage nimgw imgh 0 0)
  33.                 (gimp-image-merge-visible-layers anImage EXPAND-AS-NECESSARY)
  34.                 (gimp-display-new anImage)
  35.         )
  36.        
  37. )              
  38.                
  39. (script-fu-register "create-sprite-sheet"
  40.         _"<Toolbox>/Xtns/Sprite-Sheet/Create From Layers..."
  41.     "Creates a new image from current image, then offsets each layer of new image, and finally merges all visible layers to create a spritesheet"
  42.     "Brian.Schultheiss@airegear.com"
  43.     "Brian.Schultheiss@airegear.com"
  44.     "2009"
  45.     "INDEXED* RGB* GRAY*"
  46.     SF-IMAGE        "Image to use"          0
  47.     SF-DRAWABLE     "Layer to use"          0
  48. )
clone this paste RAW Paste Data