It is currently Tue Jun 09, 2026 12:33 am


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 12:33 pm  (#1) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6946
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?

;
; anim_sphere
;
;
; Chris Gutteridge ([email protected])
; 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
World War IV will be fought with sticks and stones. - Albert Einstein


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: spinning-globe.scm
PostPosted: Tue Jul 12, 2011 1:42 pm  (#2) 
Offline
GimpChat Member

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

Does that work?

_________________
Image


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

Joined: May 22, 2008
Posts: 6946
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.
"Index to n colors (0 = remain RGB)"

Does that work?


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

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


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

_________________
Image
World War IV will be fought with sticks and stones. - Albert Einstein


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

Joined: Mar 29, 2011
Posts: 346
Location: Wisconsin
That snippet of code is part of this block:
  (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
 Post subject: Re: spinning-globe.scm
PostPosted: Tue Jul 12, 2011 2:37 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: Oct 29, 2010
Posts: 711
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.17.4 Python-2.7.8/3.3.5
Gimp-2.8.14

I use Linux only.
And Virtualbox with Win 7


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

Joined: May 22, 2008
Posts: 6946
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.
"Index to n colors (0 = remain RGB)"

Does that work?


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

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

_________________
Image
World War IV will be fought with sticks and stones. - Albert Einstein


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

Joined: Mar 29, 2011
Posts: 346
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
 Post subject: Re: spinning-globe.scm
PostPosted: Tue Jul 12, 2011 4:10 pm  (#8) 
Offline
Retired Staff
User avatar

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

_________________
Image
World War IV will be fought with sticks and stones. - Albert Einstein


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

Joined: May 16, 2010
Posts: 16021
lol

_________________
Image


Top
 Post subject: Re: spinning-globe.scm
PostPosted: Tue Jul 12, 2011 6:21 pm  (#10) 
Offline
GimpChat Member
User avatar

Joined: Apr 07, 2010
Posts: 14182
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
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group