Results 1 to 10 of 19

Thread: Goblin Lair

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Guild Apprentice
    Join Date
    Sep 2008
    Posts
    38

    Post

    Quote Originally Posted by RobA View Post
    I guess the question would be, is each object on its own layer? That would be simple enough to script. If, however there are multiple objects all flattened onto the same layer it would be more difficult...

    -Rob A>
    I usually rotate them as I'm putting them down, so they'd be on that temporary floating layer at the time.

  2. #2

    Post

    OK - Try this:

    Code:
    ; random_rotate.scm
    ; by Rob Antonishen
    ; http://ffaat.pointclark.net
    
    ; Version 1.0 (20080931)
    
    ; Description
    ;
    ; Script to randomly rotate the  floating layer
    ;
    
    ; License:
    ;
    ; This program is free software; you can redistribute it and/or modify
    ; it under the terms of the GNU General Public License as published by
    ; the Free Software Foundation; either version 2 of the License, or
    ; (at your option) any later version.
    ;
    ; This program is distributed in the hope that it will be useful,
    ; but WITHOUT ANY WARRANTY; without even the implied warranty of
    ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    ; GNU General Public License for more details.
    ;
    ; The GNU Public License is available at
    ; http://www.gnu.org/copyleft/gpl.html
    
    (define (script-fu-random-rotate img inLayer)
      (let* 
        (
    	  (varAngle (/ (* 2 *pi* (rand 360)) 360))   ;random angle to rotate
    	  (varLayer (car (gimp-image-get-floating-sel img)))         ;get floating selection ID
    	)
    	
    	; it begins here 
    	(gimp-image-undo-group-start img)
    	
        (if (<> varLayer -1)  ;if here is a floating selection
    	  (begin
            (set! varLayer (car (gimp-drawable-transform-rotate varLayer varAngle TRUE 0 0 TRANSFORM-FORWARD INTERPOLATION-LANCZOS TRUE 3 TRANSFORM-RESIZE-ADJUST)))
            (gimp-floating-sel-anchor varLayer)  ;anchor
    		(gimp-displays-flush)
           )
    	)
    	
    	;done
    	(gimp-image-undo-group-end img)
      )
    )
    
    (script-fu-register "script-fu-random-rotate"
            		    "<Image>/Filters/Random Rotate"
                        "Randomly rotate then anchor the floating selection."
                        "Rob Antonishen"
                        "Rob Antonishen"
                        "Sept 2008"
                        ""
                        SF-IMAGE      "image"      0
                        SF-DRAWABLE   "drawable"   0	
    )
    Just bind it to a key press. When you have a floating selection, just kit the defined key and it will randomly rotate the floating selection and then anchor it.

    -Rob A>

  3. #3
    Guild Apprentice
    Join Date
    Sep 2008
    Posts
    38

    Post

    I think I... I think I'm in love!

    This is exactly what I wanted... I'd like to learn to write script-fu, but I'm not very good with painting programs in general, and figure I should learn how to do things by hand before I start trying to automate them.

    Thank you so very much.

  4. #4

    Default

    No problem, xv43!

    Knocking out little helpers like this is only a few minutes work once you know a bit of Tiny Scheme, and how the script-fu has to be structured. Certainly not as simple as recording a macro, but still, not to bad.

    -Rob A>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •