Advertisement
MiKeMiTchi

FU_spr_outline_mitchi

Feb 6th, 2012
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 3.01 KB | None | 0 0
  1. ;==============================================================================
  2. ;  MITCHI Sprite Outliner
  3. ;------------------------------------------------------------------------------
  4. ;  FU_spr_outline_mitchi.scm
  5. ;  Script-FU version: 1.0b
  6. ;  By: //mitchi.exe    
  7. ;  Site: azurecosmos.wordpress.com                 
  8. ;  Last modified on: Feb. 7, 2012
  9. ;  Tested on GIMP-2.6+
  10. ;------------------------------------------------------------------------------
  11. ;  Description:
  12. ;  This gimp script creates a black outline to the sprite easily. The current
  13. ;  version does not work well with bounded sprites as well as autotiles.
  14. ;------------------------------------------------------------------------------
  15.  
  16. (define (FU-spr-outline-mitchi image drawable trans-check mode outline)
  17.  
  18.     ; start an undo group
  19.     (gimp-context-push)
  20.     (gimp-image-undo-group-start image)
  21.    
  22.     ; if background is transparent, copy layer
  23.     (let ((bg-layer (car (gimp-layer-copy drawable 1))))
  24.     (gimp-drawable-set-name bg-layer "Background")
  25.     (gimp-image-add-layer image bg-layer -1)
  26.    
  27.     ; fill bg-layer with foreground
  28.     (gimp-context-set-foreground '(0 222 156))
  29.     (gimp-edit-fill bg-layer 0)
  30.    
  31.     ;place layer at bottom, then merge down
  32.     (gimp-image-lower-layer-to-bottom image bg-layer)
  33.     (gimp-image-merge-visible-layers image 2)  
  34.     (define new-bg-layer (car (gimp-image-merge-visible-layers image 2)))
  35.    
  36.     ; create a layer
  37.     (define out-layer (car (gimp-layer-copy new-bg-layer 1)))
  38.     (gimp-drawable-set-name out-layer "OUTLINE")
  39.     (gimp-image-add-layer image out-layer -1)
  40.     (cond ((= mode TRUE) (begin (gimp-layer-set-mode out-layer 5))))
  41.    
  42.     ; remove background
  43.         (gimp-by-color-select out-layer
  44.             (car (gimp-image-pick-color image out-layer 1 1 FALSE FALSE 1)) 0 0 FALSE FALSE 0 FALSE  )
  45.         (gimp-edit-fill out-layer 3)
  46.         (gimp-edit-clear out-layer)
  47.         (cond ((= trans-check TRUE) (begin (gimp-edit-clear new-bg-layer))))
  48.         (gimp-selection-invert image)
  49.      
  50.     ;process outline layer
  51.     (gimp-edit-fill out-layer 2)
  52.     (gimp-invert out-layer)
  53.     (gimp-selection-shrink image 1)
  54.     (gimp-edit-clear out-layer)
  55.     (gimp-layer-set-opacity out-layer outline)
  56.    
  57.     ; select none
  58.     (gimp-selection-none image)
  59.    
  60.     ;copy visible then paste as layer  
  61.     (gimp-edit-copy-visible image)
  62.     (let* ((copy-layer (car (gimp-image-get-active-drawable image))))
  63.     (gimp-floating-sel-to-layer (car (gimp-edit-paste copy-layer 1))))
  64.    
  65.     ;remove processed layers
  66.     (gimp-image-remove-layer image out-layer)
  67.     (gimp-image-remove-layer image new-bg-layer)
  68.  
  69.     ;finish the undo group
  70.     (gimp-image-undo-group-end image)
  71.  
  72.     ;update image window
  73.     (gimp-context-pop)
  74.     (gimp-displays-flush)))
  75.  
  76.  
  77. (script-fu-register "FU-spr-outline-mitchi"
  78.         "<Image>/Script-Fu/Mitchi/Sprite Outliner v1.0..."
  79.         "Gives a black outline to the sprite"
  80.         "//mitchi.exe"
  81.         "AZURECOSMOS.wordpress.com"
  82.         "Feb. 8, 2012"
  83.         "RGB*"
  84.         SF-IMAGE "Image" 0
  85.         SF-DRAWABLE "Drawable" 0
  86.         SF-TOGGLE "Work with transparent image" FALSE
  87.         SF-TOGGLE "Overlay Mode" FALSE
  88.         SF-ADJUSTMENT "Outline opacity"    '(100  0  100   1   1   0   0)
  89. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement