It is currently Sun May 19, 2013 11:29 am


Latest GIMP Scripts & Plug-ins

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: spinning-globe.scm
PostPosted: Tue Jul 12, 2011 1:33 pm  (#1) 
Offline
Administrator
User avatar

Joined: May 22, 2008
Posts: 5465
Location: Somewhere in GIMP
spinning-globe.scm is packaged with gimp and resides in the Program Files of gimp.

The filter Indexes the color and the resulting globe is rough around the edges because there is no antialiasing.

Can someone please fix it so that it ends up as RGB instead of Indexed?

Code:
;
; anim_sphere
;
;
; Chris Gutteridge (cjg@ecs.soton.ac.uk)
; At ECS Dept, University of Southampton, England.
; 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.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


; Define the function:

(define (script-fu-spinning-globe inImage
                                  inLayer
                                  inFrames
                                  inFromLeft
                                  inTransparent
                                  inIndex
                                  inCopy)
  (let* (
        (theImage (if (= inCopy TRUE)
                      (car (gimp-image-duplicate inImage))
                      inImage))
        (theLayer (car (gimp-image-get-active-layer theImage)))
        (n 0)
        (ang (* (/ 360 inFrames)
                (if (= inFromLeft TRUE) 1 -1) ))
        (theFrame 0)
        )

  (gimp-layer-add-alpha theLayer)

  (while (> inFrames n)
    (set! n (+ n 1))
    (set! theFrame (car (gimp-layer-copy theLayer FALSE)))
    (gimp-image-add-layer theImage theFrame 0)
    (gimp-drawable-set-name theFrame
                         (string-append "Anim Frame: "
                                        (number->string (- inFrames n) 10)
                                        " (replace)"))
    (plug-in-map-object RUN-NONINTERACTIVE
                        theImage theFrame    ; mapping
                        1                    ; viewpoint
                        0.5 0.5 2.0          ; object pos
                        0.5 0.5 0.0          ; first axis
                        1.0 0.0 0.0          ; 2nd axis
                        0.0 1.0 0.0          ; axis rotation
                        0.0 (* n ang) 0.0    ; light (type, color)
                        0 '(255 255 255)     ; light position
                        -0.5 -0.5 2.0        ; light direction
                        -1.0 -1.0 1.0  ; material (amb, diff, refl, spec, high)
                        0.3 1.0 0.5 0.0 27.0 ; antialias
                        TRUE                 ; tile
                        FALSE                ; new image
                        FALSE                ; transparency
                        inTransparent        ; radius
                        0.25                 ; unused parameters
                        1.0 1.0 1.0 1.0
                        -1 -1 -1 -1 -1 -1 -1 -1
    )
  )

  (gimp-image-remove-layer theImage theLayer)
  (plug-in-autocrop RUN-NONINTERACTIVE theImage theFrame)

  (if (= inIndex 0)
      ()
      (gimp-image-convert-indexed theImage FS-DITHER MAKE-PALETTE inIndex
                                  FALSE FALSE ""))

  (if (= inCopy TRUE)
    (begin
      (gimp-image-clean-all theImage)
      (gimp-display-new theImage)
    )
  )

  (gimp-displays-flush)
  )
)

(script-fu-register
  "script-fu-spinning-globe"
  _"_Spinning Globe..."
  _"Create an animation by mapping the current image onto a spinning sphere"
  "Chris Gutteridge"
  "1998, Chris Gutteridge / ECS dept, University of Southampton, England."
  "16th April 1998"
  "RGB* GRAY*"
  SF-IMAGE       "The Image"               0
  SF-DRAWABLE    "The Layer"               0
  SF-ADJUSTMENT _"Frames"                  '(10 1 360 1 10 0 1)
  SF-TOGGLE     _"Turn from left to right" FALSE
  SF-TOGGLE     _"Transparent background"  TRUE
  SF-ADJUSTMENT _"Index to n colors (0 = remain RGB)" '(63 0 256 1 10 0 1)
  SF-TOGGLE     _"Work on copy"            TRUE
)

(script-fu-menu-register "script-fu-spinning-globe"
                         "<Image>/Filters/Animation/Animators")

_________________
Image
Law of Gravity - Any tool, nut, bolt, screw, when dropped, will roll to the least accessible place.
Image


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Profile  
 

 Post subject: Re: spinning-globe.scm
PostPosted: Tue Jul 12, 2011 2:42 pm  (#2) 
Offline
GimpChat Member

Joined: Mar 29, 2011
Posts: 347
Location: Wisconsin
According to the script, setting the "Index to n colors" to 0 will leave it as an RGB image.
Code:
"Index to n colors (0 = remain RGB)"

Does that work?

_________________
Image


Top
 Profile  
 
 Post subject: Re: spinning-globe.scm
PostPosted: Tue Jul 12, 2011 2:53 pm  (#3) 
Offline
Administrator
User avatar

Joined: May 22, 2008
Posts: 5465
Location: Somewhere in GIMP
bkh1914 wrote:
According to the script, setting the "Index to n colors" to 0 will leave it as an RGB image.
Code:
"Index to n colors (0 = remain RGB)"

Does that work?


I'll give that a try but what about this?

Code:
(gimp-image-convert-indexed theImage FS-DITHER MAKE-PALETTE inIndex
                                  FALSE FALSE ""))


Also, what about the palette? Does it have a restricted palette?

_________________
Image
Law of Gravity - Any tool, nut, bolt, screw, when dropped, will roll to the least accessible place.
Image


Top
 Profile  
 
 Post subject: Re: spinning-globe.scm
PostPosted: Tue Jul 12, 2011 3:32 pm  (#4) 
Offline
GimpChat Member

Joined: Mar 29, 2011
Posts: 347
Location: Wisconsin
That snippet of code is part of this block:
Code:
  (if (= inIndex 0)
      ()
      (gimp-image-convert-indexed theImage FS-DITHER MAKE-PALETTE inIndex
                                  FALSE FALSE ""))

Which says:
If the number of colors (inIndex) is zero, do nothing ( "()" ),
- otherwise -
convert to an indexed image with the specified number of colors, creating a new palette using the "standard" (Floyd-Steinberg error diffusion) dithering technique to determine the colors.

So I think the answer to your question is:
The palette is not restricted and it will be optimized for the image.

_________________
Image


Top
 Profile  
 
 Post subject: Re: spinning-globe.scm
PostPosted: Tue Jul 12, 2011 3:37 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: Oct 29, 2010
Posts: 611
Location: Netherlands
I just tried what bkh1914 wrote and RGB remains intact.
Gerard.
Edit: To get a round globe your image should be square else it becomes egg shaped.

_________________
Gentoo Linux always up-to-date.
Kernel-3.8.4 Python-2.7.3-r3
Gimp-2.8.4

I use Linux only.


Top
 Profile  
 
 Post subject: Re: spinning-globe.scm
PostPosted: Tue Jul 12, 2011 4:39 pm  (#6) 
Offline
Administrator
User avatar

Joined: May 22, 2008
Posts: 5465
Location: Somewhere in GIMP
bkh1914 wrote:
According to the script, setting the "Index to n colors" to 0 will leave it as an RGB image.
Code:
"Index to n colors (0 = remain RGB)"

Does that work?


I changed it to this and my image still comes out Indexed.

Code:
"Index to 0 colors (0 = remain RGB)"

_________________
Image
Law of Gravity - Any tool, nut, bolt, screw, when dropped, will roll to the least accessible place.
Image


Top
 Profile  
 
 Post subject: Re: spinning-globe.scm
PostPosted: Tue Jul 12, 2011 5:05 pm  (#7) 
Offline
GimpChat Member

Joined: Mar 29, 2011
Posts: 347
Location: Wisconsin
Sorry, I was just trying to show the text of the dialog.
I should have posted this screen shot instead:
Image

Enter 0 and the image will remain RGB.

_________________
Image


Top
 Profile  
 

 Post subject: Re: spinning-globe.scm
PostPosted: Tue Jul 12, 2011 5:10 pm  (#8) 
Offline
Administrator
User avatar

Joined: May 22, 2008
Posts: 5465
Location: Somewhere in GIMP
Well, duhhhhhhh, now I feel totally inept. That works very nicely. Thank you

_________________
Image
Law of Gravity - Any tool, nut, bolt, screw, when dropped, will roll to the least accessible place.
Image


Top
 Profile  
 
 Post subject: Re: spinning-globe.scm
PostPosted: Tue Jul 12, 2011 6:43 pm  (#9) 
Offline
Global Moderator
User avatar

Joined: May 16, 2010
Posts: 8936
Location: "Looking for my eraser" =P
lol

_________________
Image
Gimp Rocks Blog
Simply Gimp Tutorials
"Once your in the cloud, you're in the net"
____________
OK, . . . . so what's the speed of dark?


Top
 Profile  
 
 Post subject: Re: spinning-globe.scm
PostPosted: Tue Jul 12, 2011 7:21 pm  (#10) 
Offline
Global Moderator
User avatar

Joined: Apr 07, 2010
Posts: 6943
Here is my little spinner but I can't get the line out of it. This only happens maybe in every other one.. grrr.
Image

_________________
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

* Login   * Subscribe to RSS Feed


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group